sunhz 3 سال پیش
والد
کامیت
ac6e0c39f6
16فایلهای تغییر یافته به همراه731 افزوده شده و 32 حذف شده
  1. 34 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/dto/OrderChangeDTO.java
  2. 7 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/Order.java
  3. 11 1
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/OrderAddress.java
  4. 80 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/OrderChange.java
  5. 3 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/OrderItem.java
  6. 36 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/vo/OrderChangeVO.java
  7. 2 2
      blade-service/blade-client/src/main/java/org/springblade/client/corps/controller/CorpsDescController.java
  8. 126 0
      blade-service/blade-land/src/main/java/org/springblade/land/controller/OrderChangeController.java
  9. 155 19
      blade-service/blade-land/src/main/java/org/springblade/land/controller/OrderController.java
  10. 73 2
      blade-service/blade-land/src/main/java/org/springblade/land/controller/OrderItemController.java
  11. 42 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/OrderChangeMapper.java
  12. 20 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/OrderChangeMapper.xml
  13. 41 0
      blade-service/blade-land/src/main/java/org/springblade/land/service/IOrderChangeService.java
  14. 41 0
      blade-service/blade-land/src/main/java/org/springblade/land/service/impl/OrderChangeServiceImpl.java
  15. 47 0
      blade-service/blade-land/src/main/java/org/springblade/land/service/impl/OrderItemServiceImpl.java
  16. 13 8
      blade-service/blade-land/src/main/java/org/springblade/land/service/impl/OrderServiceImpl.java

+ 34 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/dto/OrderChangeDTO.java

@@ -0,0 +1,34 @@
+/*
+ *      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.dto;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.land.entity.OrderChange;
+
+/**
+ * 陆运订单动态表数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2022-03-14
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class OrderChangeDTO extends OrderChange {
+	private static final long serialVersionUID = 1L;
+
+}

+ 7 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/Order.java

@@ -154,6 +154,12 @@ public class Order implements Serializable {
 	private String ctnDetail;
 
 	@TableField(exist = false)
+	private String dispatchCtnDetail;
+
+	@TableField(exist = false)
+	private String sendCtnDetail;
+
+	@TableField(exist = false)
 	private Integer itemStatus;
 
 	@TableField(exist = false)
@@ -173,4 +179,5 @@ public class Order implements Serializable {
 
 	@TableField(exist = false)
 	private String endCrateTime;
+
 }

+ 11 - 1
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/OrderAddress.java

@@ -52,12 +52,22 @@ public class OrderAddress implements Serializable {
 	@ApiModelProperty(value = "订单ID")
 	private Long orderId;
 	/**
+	 * 客户ID
+	 */
+	@ApiModelProperty(value = "客户ID")
+	private Long corpId;
+	/**
+	 * 客户名
+	 */
+	@ApiModelProperty(value = "客户名")
+	private String corpName;
+	/**
 	 * 排序
 	 */
 	@ApiModelProperty(value = "排序")
 	private Integer sort;
 	/**
-	 * 省
+	 * 省市区
 	 */
 	@ApiModelProperty(value = "省市区")
 	private String region;

+ 80 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/OrderChange.java

@@ -0,0 +1,80 @@
+/*
+ *      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.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 陆运订单动态表实体类
+ *
+ * @author BladeX
+ * @since 2022-03-14
+ */
+@Data
+@TableName("land_order_change")
+@ApiModel(value = "OrderChange对象", description = "陆运订单动态表")
+public class OrderChange implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 主键
+	 */
+	@ApiModelProperty(value = "主键")
+	private Long id;
+	/**
+	 * 订单ID
+	 */
+	@ApiModelProperty(value = "订单ID")
+	private Long orderId;
+	/**
+	 * 明细ID
+	 */
+	@ApiModelProperty(value = "明细ID")
+	private Long itemId;
+	/**
+	 * 状态
+	 */
+	@ApiModelProperty(value = "状态")
+	private Integer status;
+	/**
+	 * 租户
+	 */
+	@ApiModelProperty(value = "租户")
+	private String tenantId;
+	/**
+	 * 变更人
+	 */
+	@ApiModelProperty(value = "变更人")
+	private Long changeUser;
+	/**
+	 * 变更时间
+	 */
+	@ApiModelProperty(value = "变更时间")
+	private Date changeTime;
+
+
+}

+ 3 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/OrderItem.java

@@ -218,4 +218,7 @@ public class OrderItem implements Serializable {
 	@TableField(exist = false)
 	private String endCrateTime;
 
+	@TableField(exist = false)
+	private String addressDetail;
+
 }

+ 36 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/vo/OrderChangeVO.java

@@ -0,0 +1,36 @@
+/*
+ *      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.vo;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.land.entity.OrderChange;
+
+/**
+ * 陆运订单动态表视图实体类
+ *
+ * @author BladeX
+ * @since 2022-03-14
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "OrderChangeVO对象", description = "陆运订单动态表")
+public class OrderChangeVO extends OrderChange {
+	private static final long serialVersionUID = 1L;
+
+}

+ 2 - 2
blade-service/blade-client/src/main/java/org/springblade/client/corps/controller/CorpsDescController.java

@@ -289,7 +289,7 @@ public class CorpsDescController extends BladeController {
 	@GetMapping("/corpsDescList")
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "所有客户信息", notes = "corpType必填")
-	public R<List<CorpsDesc>> orderList(CorpsDescVO corpsDesc) {
+	public R<List<CorpsDescVO>> orderList(CorpsDescVO corpsDesc) {
 		if (StringUtils.isBlank(corpsDesc.getCorpType())) {
 			throw new SecurityException("缺少必要的参数,客户类型");
 		}
@@ -313,7 +313,7 @@ public class CorpsDescController extends BladeController {
 				desc.setBelongCompany(company.getCname());
 			}
 		});
-		return R.data(corpsDescList);
+		return R.data(voList);
 	}
 
 	/**

+ 126 - 0
blade-service/blade-land/src/main/java/org/springblade/land/controller/OrderChangeController.java

@@ -0,0 +1,126 @@
+/*
+ *      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.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.land.entity.OrderChange;
+import org.springblade.land.service.IOrderChangeService;
+import org.springblade.land.vo.OrderChangeVO;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+/**
+ * 陆运订单动态表 控制器
+ *
+ * @author BladeX
+ * @since 2022-03-14
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/orderchange")
+@Api(value = "陆运订单动态表", tags = "陆运订单动态表接口")
+public class OrderChangeController extends BladeController {
+
+	private final IOrderChangeService orderChangeService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入orderChange")
+	public R<OrderChange> detail(OrderChange orderChange) {
+		OrderChange detail = orderChangeService.getOne(Condition.getQueryWrapper(orderChange));
+		return R.data(detail);
+	}
+
+	/**
+	 * 分页 陆运订单动态表
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入orderChange")
+	public R<IPage<OrderChange>> list(OrderChange orderChange, Query query) {
+		IPage<OrderChange> pages = orderChangeService.page(Condition.getPage(query), Condition.getQueryWrapper(orderChange));
+		return R.data(pages);
+	}
+
+	/**
+	 * 自定义分页 陆运订单动态表
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入orderChange")
+	public R<IPage<OrderChangeVO>> page(OrderChangeVO orderChange, Query query) {
+		IPage<OrderChangeVO> pages = orderChangeService.selectOrderChangePage(Condition.getPage(query), orderChange);
+		return R.data(pages);
+	}
+
+	/**
+	 * 新增 陆运订单动态表
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入orderChange")
+	public R save(@Valid @RequestBody OrderChange orderChange) {
+		return R.status(orderChangeService.save(orderChange));
+	}
+
+	/**
+	 * 修改 陆运订单动态表
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入orderChange")
+	public R update(@Valid @RequestBody OrderChange orderChange) {
+		return R.status(orderChangeService.updateById(orderChange));
+	}
+
+	/**
+	 * 新增或修改 陆运订单动态表
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入orderChange")
+	public R submit(@Valid @RequestBody OrderChange orderChange) {
+		return R.status(orderChangeService.saveOrUpdate(orderChange));
+	}
+
+
+	/**
+	 * 删除 陆运订单动态表
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "删除", notes = "传入ids")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(orderChangeService.removeByIds(Func.toLongList(ids)));
+	}
+
+
+}

+ 155 - 19
blade-service/blade-land/src/main/java/org/springblade/land/controller/OrderController.java

@@ -53,7 +53,9 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -203,16 +205,17 @@ public class OrderController extends BladeController {
 			.between(StringUtil.isNotBlank(order.getBeginArrivalTime()) && StringUtil.isNotBlank(order.getEndArrivalTime()), Order::getArrivalTime, order.getBeginArrivalTime(), order.getEndArrivalTime())
 			.between(StringUtil.isNotBlank(order.getBeginCrateTime()) && StringUtil.isNotBlank(order.getEndCrateTime()), Order::getCreateTime, order.getBeginCrateTime(), order.getEndCrateTime())
 			.eq(Order::getIsDeleted, 0)
-			.eq(Order::getTenantId, AuthUtil.getTenantId())
-			.orderByDesc(Order::getCreateTime);
+			.eq(Order::getTenantId, AuthUtil.getTenantId());
 
 		if (order.getKind() == 1) {
+			orderQueryWrapper.orderByDesc(Order::getCreateTime);
 			if (role.contains(LandConstant.CORP_ROLE)) {
 				if (role.contains(LandConstant.LAND_OPERATOR)) {
 					orderQueryWrapper.eq(Order::getCreateUser, AuthUtil.getUserId());
 				}
 			}
-		} else if (order.getKind() == 2){
+		} else if (order.getKind() == 2) {
+			orderQueryWrapper.orderByDesc(Order::getUpdateTime);
 			orderQueryWrapper.eq(Order::getStatus, 1);
 			if (role.contains(LandConstant.LAND_OPERATOR)) {
 				orderQueryWrapper.like(Order::getAdminProfiles, AuthUtil.getUserId());
@@ -230,31 +233,164 @@ public class OrderController extends BladeController {
 				}
 			}
 
-			List<String> ctnTypeList = orderItemService.list(new LambdaQueryWrapper<OrderItem>()
-				.eq(OrderItem::getOrderId, record.getId())
-				.eq(OrderItem::getKind, 2)
-				.eq(OrderItem::getIsDeleted, 0)
-				.groupBy(OrderItem::getCtnType)
-			).stream().map(OrderItem::getCtnType).collect(Collectors.toList());
-
-			StringBuilder ctnDetail = new StringBuilder();
-			for (String ctnType : ctnTypeList) {
-				int ctnCount = orderItemService.count(new LambdaQueryWrapper<OrderItem>()
+			// 列表箱量显示处理
+			if (record.getStatus() == 0) {
+				List<OrderItem> itemList = orderItemService.list(new LambdaQueryWrapper<OrderItem>()
+					.eq(OrderItem::getOrderId, record.getId())
+					.eq(OrderItem::getKind, 1)
+					.eq(OrderItem::getIsDeleted, 0));
+
+				if (CollectionUtil.isNotEmpty(itemList)) {
+					StringBuilder ctnDetail = new StringBuilder();
+					for (OrderItem item : itemList) {
+						ctnDetail.append(item.getCtnType()).append("×").append(item.getCtnQuantity()).append(",");
+					}
+					if (ctnDetail.length() > 0) {
+						record.setCtnDetail(ctnDetail.deleteCharAt(ctnDetail.lastIndexOf(",")).toString());
+					}
+				}
+			} else {
+				List<OrderItem> itemList = orderItemService.list(new LambdaQueryWrapper<OrderItem>()
 					.eq(OrderItem::getOrderId, record.getId())
-					.eq(OrderItem::getCtnType, ctnType)
 					.eq(OrderItem::getKind, 2)
-					.eq(OrderItem::getIsDeleted, 0)
-				);
-				ctnDetail.append(ctnType).append("×").append(ctnCount).append(",");
+					.eq(OrderItem::getIsDeleted, 0));
+
+				if (CollectionUtil.isNotEmpty(itemList)) {
+					// 全部
+					Map<String, Long> ctnMap = itemList.stream().collect(Collectors.groupingBy(OrderItem::getCtnType, Collectors.counting()));
+					StringBuilder ctnDetail = new StringBuilder();
+					for (Map.Entry<String, Long> entry : ctnMap.entrySet()) {
+						ctnDetail.append(entry.getKey()).append("×").append(entry.getValue()).append(",");
+					}
+					if (ctnDetail.length() > 0) {
+						record.setCtnDetail(ctnDetail.deleteCharAt(ctnDetail.lastIndexOf(",")).toString());
+					}
+
+					// 已派
+					Map<String, Long> dispatchCtnMap = itemList.stream().filter(item -> item.getStatus() == 1).collect(Collectors.groupingBy(OrderItem::getCtnType, Collectors.counting()));
+					StringBuilder dispatchCtnDetail = new StringBuilder();
+					for (Map.Entry<String, Long> entry : dispatchCtnMap.entrySet()) {
+						dispatchCtnDetail.append(entry.getKey()).append("×").append(entry.getValue()).append(",");
+					}
+					if (dispatchCtnDetail.length() > 0) {
+						record.setDispatchCtnDetail(dispatchCtnDetail.deleteCharAt(dispatchCtnDetail.lastIndexOf(",")).toString());
+					}
+
+					// 受理
+					Map<String, Long> sendCtnMap = itemList.stream().filter(item -> item.getStatus() == 2).collect(Collectors.groupingBy(OrderItem::getCtnType, Collectors.counting()));
+					StringBuilder sendCtnDetail = new StringBuilder();
+					for (Map.Entry<String, Long> entry : sendCtnMap.entrySet()) {
+						sendCtnDetail.append(entry.getKey()).append("×").append(entry.getValue()).append(",");
+					}
+					if (sendCtnDetail.length() > 0) {
+						record.setSendCtnDetail(sendCtnDetail.deleteCharAt(sendCtnDetail.lastIndexOf(",")).toString());
+					}
+
+					// 拼接状态
+					long zero = itemList.stream().filter(item -> item.getStatus() == 0).count();
+					long one = itemList.stream().filter(item -> item.getStatus() == 1).count();
+					long two = itemList.stream().filter(item -> item.getStatus() == 2).count();
+					long three = itemList.stream().filter(item -> item.getStatus() == 3).count();
+					long four = itemList.stream().filter(item -> item.getStatus() == 4).count();
+					String statusDetail = "";
+					if (zero > 0) {
+						statusDetail += "未调度×" + zero + ";";
+					}
+					if (one > 0) {
+						statusDetail += "未派车×" + one + ";";
+					}
+					if (two > 0) {
+						statusDetail += "未受理×" + two + ";";
+					}
+					if (three > 0) {
+						statusDetail += "未完工×" + three + ";";
+					}
+					if (four > 0) {
+						statusDetail += "工单关闭×" + four + ";";
+					}
+					record.setItemStatusDetail(statusDetail.substring(0, statusDetail.lastIndexOf(";")));
+				}
+			}
+
+			// 拼接地址
+			List<OrderAddress> addressList = orderAddressService.list(new LambdaQueryWrapper<OrderAddress>()
+				.eq(OrderAddress::getOrderId, record.getId())
+				.eq(OrderAddress::getIsDeleted, 0)
+				.orderByAsc(OrderAddress::getSort)
+			);
+			StringBuilder addressDetail = new StringBuilder();
+			for (OrderAddress address : addressList) {
+				addressDetail.append(address.getSort()).append(":").append(address.getCorpName()).append("——").append(address.getAddress()).append(";\n");
 			}
-			if (ctnDetail.length() > 0) {
-				record.setCtnDetail(ctnDetail.deleteCharAt(ctnDetail.lastIndexOf(",")).toString());
+			if (addressDetail.length() > 0) {
+				record.setAddressDetail(addressDetail.deleteCharAt(addressDetail.lastIndexOf(";")).toString());
 			}
 		});
 		return R.data(pages);
 	}
 
 	/**
+	 * 统计
+	 */
+	@GetMapping("/count")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "统计", notes = "传入order")
+	public R count(Order order) {
+		long all = 0;
+		long zero = 0;
+		long one = 0;
+		long two = 0;
+		long three = 0;
+		long four = 0;
+
+		String role = AuthUtil.getUserRole();
+
+		List<Long> orderIdList;
+		LambdaQueryWrapper<Order> orderQueryWrapper = new LambdaQueryWrapper<>();
+		orderQueryWrapper.eq(Order::getStatus, 1)
+			.eq(Order::getTenantId, AuthUtil.getTenantId())
+			.eq(Order::getIsDeleted, 0);
+
+		if (order.getKind() == 1) {
+			if (role.contains(LandConstant.CORP_ROLE)) {
+				if (role.contains(LandConstant.LAND_OPERATOR)) {
+					orderQueryWrapper.eq(Order::getCreateUser, AuthUtil.getUserId());
+				}
+			}
+		} else if (order.getKind() == 2) {
+			if (role.contains(LandConstant.LAND_OPERATOR)) {
+				orderQueryWrapper.like(Order::getAdminProfiles, AuthUtil.getUserId());
+			}
+		} else {
+			return R.fail("参数异常");
+		}
+
+		orderIdList = orderService.list(orderQueryWrapper).stream().map(Order::getId).collect(Collectors.toList());
+		if (CollectionUtil.isNotEmpty(orderIdList)) {
+			List<OrderItem> itemList = orderItemService.list(new LambdaQueryWrapper<OrderItem>()
+				.in(OrderItem::getOrderId, orderIdList)
+				.eq(OrderItem::getKind, 2)
+				.eq(OrderItem::getIsDeleted, 0));
+
+			all = itemList.size();
+			zero = itemList.stream().filter(item -> item.getStatus() == 0).count();
+			one = itemList.stream().filter(item -> item.getStatus() == 1).count();
+			two = itemList.stream().filter(item -> item.getStatus() == 2).count();
+			three = itemList.stream().filter(item -> item.getStatus() == 3).count();
+			four = itemList.stream().filter(item -> item.getStatus() == 4).count();
+		}
+
+		Map<String, Object> data = new HashMap<>();
+		data.put("all", all);
+		data.put("zero", zero);
+		data.put("one", one);
+		data.put("two", two);
+		data.put("three", three);
+		data.put("four", four);
+		return R.data(data);
+	}
+
+	/**
 	 * 自定义分页 陆运订单表
 	 */
 	@GetMapping("/page")

+ 73 - 2
blade-service/blade-land/src/main/java/org/springblade/land/controller/OrderItemController.java

@@ -40,14 +40,18 @@ import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.land.entity.Order;
+import org.springblade.land.entity.OrderAddress;
 import org.springblade.land.entity.OrderItem;
+import org.springblade.land.service.IOrderAddressService;
 import org.springblade.land.service.IOrderItemService;
 import org.springblade.land.service.IOrderService;
 import org.springblade.land.vo.OrderItemVO;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -66,6 +70,8 @@ public class OrderItemController extends BladeController {
 
 	private final IOrderService orderService;
 
+	private final IOrderAddressService orderAddressService;
+
 	private final ICorpsDescClient corpsDescClient;
 
 	private final ILandDriverClient landDriverClient;
@@ -162,11 +168,74 @@ public class OrderItemController extends BladeController {
 				record.setDriverName(vehicle.getDriverName());
 				record.setTel(vehicle.getTel());
 			}
+
+			// 拼接地址
+			List<OrderAddress> addressList = orderAddressService.list(new LambdaQueryWrapper<OrderAddress>()
+				.eq(OrderAddress::getOrderId, order.getId())
+				.eq(OrderAddress::getIsDeleted, 0)
+				.orderByAsc(OrderAddress::getSort)
+			);
+			StringBuilder addressDetail = new StringBuilder();
+			for (OrderAddress address : addressList) {
+				addressDetail.append(address.getSort()).append(":").append(address.getCorpName()).append("-").append(address.getAddress()).append(";");
+			}
+			if (addressDetail.length() > 0) {
+				record.setAddressDetail(addressDetail.deleteCharAt(addressDetail.lastIndexOf(";")).toString());
+			}
 		});
 		return R.data(pages);
 	}
 
 	/**
+	 * 统计
+	 */
+	@GetMapping("/count")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "统计", notes = "传入orderItem")
+	public R count(OrderItem orderItem) {
+		String role = AuthUtil.getUserRole();
+
+		LambdaQueryWrapper<OrderItem> itemQueryWrapper = new LambdaQueryWrapper<>();
+		if (orderItem.getTag() == 4) {
+			itemQueryWrapper.notIn(OrderItem::getStatus, 0, 1);
+		} else if (orderItem.getTag() == 3) {
+			itemQueryWrapper.notIn(OrderItem::getStatus, 0);
+		} else {
+			return R.fail("参数异常");
+		}
+
+		if (role.contains(LandConstant.FLEET_ROLE)) {
+			if (role.contains(LandConstant.LAND_OPERATOR)) {
+				Long fleetId = corpsDescClient.getFleetId(AuthUtil.getUserId());
+				itemQueryWrapper.eq(OrderItem::getFleetId, fleetId);
+			}
+		}
+		if (role.contains(LandConstant.DRIVER_ROLE)) {
+			if (role.contains(LandConstant.LAND_OPERATOR)) {
+				Long driverId = landDriverClient.getDriverId(AuthUtil.getUserId());
+				itemQueryWrapper.eq(OrderItem::getDriverId, driverId);
+			}
+		}
+		itemQueryWrapper.eq(OrderItem::getKind, 2)
+			.eq(OrderItem::getTenantId, AuthUtil.getTenantId())
+			.eq(OrderItem::getIsDeleted, 0);
+		List<OrderItem> itemList = orderItemService.list(itemQueryWrapper);
+		long all = itemList.size();
+		long one = itemList.stream().filter(item -> item.getStatus() == 1).count();
+		long two = itemList.stream().filter(item -> item.getStatus() == 2).count();
+		long three = itemList.stream().filter(item -> item.getStatus() == 3).count();
+		long four = itemList.stream().filter(item -> item.getStatus() == 4).count();
+
+		Map<String, Object> data = new HashMap<>();
+		data.put("all", all);
+		data.put("one", one);
+		data.put("two", two);
+		data.put("three", three);
+		data.put("four", four);
+		return R.data(data);
+	}
+
+	/**
 	 * 自定义分页 陆运订单明细表
 	 */
 	@GetMapping("/page")
@@ -225,7 +294,8 @@ public class OrderItemController extends BladeController {
 	@ApiOperationSupport(order = 8)
 	@ApiOperation(value = "调度", notes = "传入orderItem")
 	public R dispatch(@RequestBody OrderItem orderItem) {
-		return R.status(orderItemService.dispatch(orderItem));
+		orderItemService.dispatch(orderItem);
+		return R.data(orderItemService.getById(orderItem.getId()));
 	}
 
 	/**
@@ -235,7 +305,8 @@ public class OrderItemController extends BladeController {
 	@ApiOperationSupport(order = 9)
 	@ApiOperation(value = "取消调度", notes = "传入id")
 	public R cancelDispatch(Long id) {
-		return R.status(orderItemService.cancelDispatch(id));
+		orderItemService.cancelDispatch(id);
+		return R.data(orderItemService.getById(id));
 	}
 
 	/**

+ 42 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/OrderChangeMapper.java

@@ -0,0 +1,42 @@
+/*
+ *      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.mapper;
+
+import org.springblade.land.entity.OrderChange;
+import org.springblade.land.vo.OrderChangeVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ * 陆运订单动态表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2022-03-14
+ */
+public interface OrderChangeMapper extends BaseMapper<OrderChange> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param orderChange
+	 * @return
+	 */
+	List<OrderChangeVO> selectOrderChangePage(IPage page, OrderChangeVO orderChange);
+
+}

+ 20 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/OrderChangeMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.land.mapper.OrderChangeMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="orderChangeResultMap" type="org.springblade.land.entity.OrderChange">
+        <id column="id" property="id"/>
+        <result column="order_id" property="orderId"/>
+        <result column="item_id" property="itemId"/>
+        <result column="status" property="status"/>
+        <result column="change_user" property="changeUser"/>
+        <result column="change_time" property="changeTime"/>
+    </resultMap>
+
+
+    <select id="selectOrderChangePage" resultMap="orderChangeResultMap">
+        select * from land_order_change where is_deleted = 0
+    </select>
+
+</mapper>

+ 41 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/IOrderChangeService.java

@@ -0,0 +1,41 @@
+/*
+ *      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.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.land.entity.OrderChange;
+import org.springblade.land.vo.OrderChangeVO;
+
+/**
+ * 陆运订单动态表 服务类
+ *
+ * @author BladeX
+ * @since 2022-03-14
+ */
+public interface IOrderChangeService extends IService<OrderChange> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param orderChange
+	 * @return
+	 */
+	IPage<OrderChangeVO> selectOrderChangePage(IPage<OrderChangeVO> page, OrderChangeVO orderChange);
+
+}

+ 41 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/OrderChangeServiceImpl.java

@@ -0,0 +1,41 @@
+/*
+ *      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.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.land.entity.OrderChange;
+import org.springblade.land.mapper.OrderChangeMapper;
+import org.springblade.land.service.IOrderChangeService;
+import org.springblade.land.vo.OrderChangeVO;
+import org.springframework.stereotype.Service;
+
+/**
+ * 陆运订单动态表 服务实现类
+ *
+ * @author BladeX
+ * @since 2022-03-14
+ */
+@Service
+public class OrderChangeServiceImpl extends ServiceImpl<OrderChangeMapper, OrderChange> implements IOrderChangeService {
+
+	@Override
+	public IPage<OrderChangeVO> selectOrderChangePage(IPage<OrderChangeVO> page, OrderChangeVO orderChange) {
+		return page.setRecords(baseMapper.selectOrderChangePage(page, orderChange));
+	}
+
+}

+ 47 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/OrderItemServiceImpl.java

@@ -16,15 +16,20 @@
  */
 package org.springblade.land.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.AllArgsConstructor;
 import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.land.entity.OrderChange;
 import org.springblade.land.entity.OrderItem;
+import org.springblade.land.mapper.OrderChangeMapper;
 import org.springblade.land.mapper.OrderItemMapper;
 import org.springblade.land.service.IOrderItemService;
 import org.springblade.land.vo.OrderItemVO;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
 import java.util.List;
@@ -36,8 +41,11 @@ import java.util.List;
  * @since 2022-03-07
  */
 @Service
+@AllArgsConstructor
 public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem> implements IOrderItemService {
 
+	private final OrderChangeMapper orderChangeMapper;
+
 	@Override
 	public IPage<OrderItemVO> selectOrderItemPage(IPage<OrderItemVO> page, OrderItemVO orderItem) {
 		return page.setRecords(baseMapper.selectOrderItemPage(page, orderItem));
@@ -55,6 +63,7 @@ public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public boolean dispatch(OrderItem orderItem) {
 		OrderItem item = new OrderItem();
 		item.setId(orderItem.getId());
@@ -63,10 +72,13 @@ public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem
 		item.setUpdateUser(AuthUtil.getUserId());
 		item.setUpdateTime(new Date());
 		baseMapper.updateById(item);
+
+		addChange(orderItem, 1);
 		return true;
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public boolean cancelDispatch(Long id) {
 		baseMapper.update(null, new LambdaUpdateWrapper<OrderItem>()
 			.set(OrderItem::getFleetId, null)
@@ -74,10 +86,13 @@ public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem
 			.set(OrderItem::getUpdateUser, AuthUtil.getUserId())
 			.set(OrderItem::getUpdateTime, new Date())
 			.eq(OrderItem::getId, id));
+
+		removeChange(id, 1);
 		return true;
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public boolean send(OrderItem orderItem) {
 		OrderItem item = new OrderItem();
 		item.setId(orderItem.getId());
@@ -88,10 +103,13 @@ public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem
 		item.setUpdateUser(AuthUtil.getUserId());
 		item.setUpdateTime(new Date());
 		baseMapper.updateById(item);
+
+		addChange(orderItem, 2);
 		return true;
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public boolean cancelSend(Long id) {
 		baseMapper.update(null, new LambdaUpdateWrapper<OrderItem>()
 			.set(OrderItem::getVehicleId, null)
@@ -101,10 +119,13 @@ public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem
 			.set(OrderItem::getUpdateUser, AuthUtil.getUserId())
 			.set(OrderItem::getUpdateTime, new Date())
 			.eq(OrderItem::getId, id));
+
+		removeChange(id, 2);
 		return true;
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public boolean accept(OrderItem orderItem) {
 		OrderItem item = new OrderItem();
 		item.setId(orderItem.getId());
@@ -114,10 +135,13 @@ public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem
 		item.setUpdateUser(AuthUtil.getUserId());
 		item.setUpdateTime(new Date());
 		baseMapper.updateById(item);
+
+		addChange(orderItem, 3);
 		return true;
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public boolean cancelAccept(Long id) {
 		baseMapper.update(null, new LambdaUpdateWrapper<OrderItem>()
 			.set(OrderItem::getCtnNo, null)
@@ -126,10 +150,13 @@ public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem
 			.set(OrderItem::getUpdateUser, AuthUtil.getUserId())
 			.set(OrderItem::getUpdateTime, new Date())
 			.eq(OrderItem::getId, id));
+
+		removeChange(id, 3);
 		return true;
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public boolean finished(Long id) {
 		OrderItem item = new OrderItem();
 		item.setId(id);
@@ -137,7 +164,27 @@ public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem
 		item.setUpdateUser(AuthUtil.getUserId());
 		item.setUpdateTime(new Date());
 		baseMapper.updateById(item);
+
+		addChange(baseMapper.selectById(id), 4);
 		return true;
 	}
 
+	private void addChange(OrderItem orderItem, Integer status) {
+		OrderChange change = new OrderChange();
+		change.setOrderId(orderItem.getOrderId());
+		change.setItemId(orderItem.getId());
+		change.setStatus(status);
+		change.setTenantId(AuthUtil.getTenantId());
+		change.setChangeUser(AuthUtil.getUserId());
+		change.setChangeTime(new Date());
+		orderChangeMapper.insert(change);
+	}
+
+	private void removeChange(Long id, Integer status) {
+		orderChangeMapper.delete(new LambdaQueryWrapper<OrderChange>()
+			.eq(OrderChange::getItemId, id)
+			.eq(OrderChange::getStatus, status)
+		);
+	}
+
 }

+ 13 - 8
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/OrderServiceImpl.java

@@ -26,14 +26,8 @@ import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.ObjectUtil;
-import org.springblade.land.entity.Order;
-import org.springblade.land.entity.OrderAddress;
-import org.springblade.land.entity.OrderFee;
-import org.springblade.land.entity.OrderItem;
-import org.springblade.land.mapper.OrderAddressMapper;
-import org.springblade.land.mapper.OrderFeeMapper;
-import org.springblade.land.mapper.OrderItemMapper;
-import org.springblade.land.mapper.OrderMapper;
+import org.springblade.land.entity.*;
+import org.springblade.land.mapper.*;
 import org.springblade.land.service.IOrderService;
 import org.springblade.land.vo.OrderVO;
 import org.springframework.stereotype.Service;
@@ -61,6 +55,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 
 	private final OrderFeeMapper orderFeeMapper;
 
+	private final OrderChangeMapper orderChangeMapper;
+
 	private final ICorpsDescClient corpsDescClient;
 
 	@Override
@@ -158,6 +154,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 				childItem.setCreateUser(AuthUtil.getUserId());
 				childItem.setCreateTime(new Date());
 				orderItemMapper.insert(childItem);
+
+				OrderChange change = new OrderChange();
+				change.setOrderId(childItem.getOrderId());
+				change.setItemId(childItem.getId());
+				change.setStatus(0);
+				change.setTenantId(AuthUtil.getTenantId());
+				change.setChangeUser(AuthUtil.getUserId());
+				change.setChangeTime(new Date());
+				orderChangeMapper.insert(change);
 			});
 		});