定时生成任务订单
parent
b517f13cf3
commit
0131540f11
|
|
@ -46,6 +46,12 @@ public class BizCustomerRouteController extends BaseController
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/list2")
|
||||
public AjaxResult list2(BizCustomerRoute bizCustomerRoute)
|
||||
{
|
||||
return AjaxResult.success( bizCustomerRouteService.selectBizCustomerRouteList(bizCustomerRoute));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出路线列表
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,115 @@
|
|||
package com.cpxt.web.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cpxt.biz.domain.BizCustomerShop;
|
||||
import com.cpxt.biz.domain.BizCustomerWarehouse;
|
||||
import com.cpxt.biz.domain.BizOrder;
|
||||
import com.cpxt.biz.domain.BizOrderTask;
|
||||
import com.cpxt.biz.mapper.*;
|
||||
import com.cpxt.common.utils.Helper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component("orderTask")
|
||||
public class OrderTask {
|
||||
|
||||
private static OrderTask orderTask;
|
||||
|
||||
@Autowired
|
||||
private BizOrderMapper orderMapper;
|
||||
@Autowired
|
||||
private BizOrderTaskMapper orderTaskMapper;
|
||||
@Autowired
|
||||
private BizCustomerRouteShopMapper routeShopMapper;
|
||||
@Autowired
|
||||
private BizCustomerWarehouseMapper customerWarehouseMapper;
|
||||
@Autowired
|
||||
private BizCustomerShopMapper customerShopMapper;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
orderTask = this;
|
||||
|
||||
orderTask.orderMapper = this.orderMapper;
|
||||
orderTask.orderTaskMapper = this.orderTaskMapper;
|
||||
orderTask.routeShopMapper = this.routeShopMapper;
|
||||
orderTask.customerShopMapper = this.customerShopMapper;
|
||||
}
|
||||
|
||||
public void generateOrder(String code){
|
||||
LambdaQueryWrapper<BizOrderTask> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BizOrderTask::getCode, code);
|
||||
BizOrderTask task = orderTask.orderTaskMapper.selectOne(queryWrapper);
|
||||
|
||||
Long routeId = task.getRouteId();
|
||||
if (Helper.FInt(routeId)>0){
|
||||
List<Long> shopIds = orderTask.routeShopMapper.selectShopIdListByRouteId(routeId);
|
||||
|
||||
Long warehouseId = task.getWarehouseId();
|
||||
BizCustomerWarehouse warehouse = orderTask.customerWarehouseMapper.selectById(warehouseId);
|
||||
|
||||
for (Long shopId : shopIds ) {
|
||||
BizOrder order = new BizOrder();
|
||||
order.setOrderSn(getNewOrderSn());
|
||||
order.setCustomerId(task.getCustomerId());
|
||||
order.setCustomerName(task.getCustomerName());
|
||||
|
||||
order.setRouteId(routeId);
|
||||
order.setRouteName(task.getRouteName());
|
||||
|
||||
order.setWarehouseId(warehouse.getId());
|
||||
order.setWarehouseName(warehouse.getName());
|
||||
order.setSenderName(warehouse.getName());
|
||||
order.setSenderLinkman(warehouse.getLinkman());
|
||||
order.setSenderPhone(warehouse.getLinkphone());
|
||||
order.setSenderAddress(warehouse.getAddress());
|
||||
order.setSenderLat(warehouse.getLat());
|
||||
order.setSenderLng(warehouse.getLng());
|
||||
|
||||
BizCustomerShop shop = orderTask.customerShopMapper.selectById(shopId);
|
||||
order.setShopId(shopId);
|
||||
order.setShopName(shop.getName());
|
||||
order.setReceiverName(shop.getName());
|
||||
order.setReceiverLinkman(shop.getLinkman());
|
||||
order.setReceiverPhone(shop.getLinkphone());
|
||||
order.setReceiverAddress(shop.getAddress());
|
||||
order.setReceiverLat(shop.getLat());
|
||||
order.setReceiverLng(shop.getLng());
|
||||
|
||||
order.setDriverId(task.getDriverId());
|
||||
order.setDriverName(task.getDriverName());
|
||||
if (Helper.FInt(task.getCopilotId())>0) {
|
||||
order.setCopilotId(task.getCopilotId());
|
||||
order.setCopilotName(task.getCopilotName());
|
||||
}
|
||||
|
||||
order.setGoodsType("");
|
||||
order.setGoodsName("");
|
||||
orderTask.orderMapper.insert(order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 订单号生成规则
|
||||
private String getNewOrderSn() {
|
||||
String format = DateUtil.format(new Date(), "yyyyMMdd"); // 20241220
|
||||
String orderSn;
|
||||
BizOrder order = orderTask.orderMapper.selectLastestOrder();
|
||||
if (order == null || !order.getOrderSn().substring(1, 8).equals(format)){
|
||||
orderSn = "Y" + format + "1001";
|
||||
}else {
|
||||
String sn = order.getOrderSn();
|
||||
String substring = sn.substring(9); // 1001
|
||||
long aLong = Long.parseLong(substring);
|
||||
aLong += 1L;
|
||||
orderSn = "Y" + format + aLong;
|
||||
}
|
||||
return orderSn;
|
||||
}
|
||||
}
|
||||
|
|
@ -46,6 +46,14 @@ public class BizOrderTask
|
|||
@Excel(name = "路线名称")
|
||||
private String routeName;
|
||||
|
||||
/** 仓库ID */
|
||||
@Excel(name = "仓库ID")
|
||||
private Long warehouseId;
|
||||
|
||||
/** 仓库名称 */
|
||||
@Excel(name = "仓库名称")
|
||||
private String warehouseName;
|
||||
|
||||
/** 司机ID */
|
||||
@Excel(name = "司机ID")
|
||||
private Long driverId;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.cpxt.biz.service.impl;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.cpxt.biz.domain.BizCustomer;
|
||||
|
|
@ -56,6 +57,8 @@ public class BizCustomerRouteServiceImpl implements IBizCustomerRouteService
|
|||
public List<BizCustomerRoute> selectBizCustomerRouteList(BizCustomerRoute bizCustomerRoute)
|
||||
{
|
||||
LambdaQueryWrapper<BizCustomerRoute> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(bizCustomerRoute.getCustomerId()))
|
||||
queryWrapper.eq(BizCustomerRoute::getCustomerId, bizCustomerRoute.getCustomerId());
|
||||
queryWrapper.eq(BizCustomerRoute::getStatus,1);
|
||||
return bizCustomerRouteMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ public class BizCustomerWarehouseServiceImpl implements IBizCustomerWarehouseSer
|
|||
|
||||
private LambdaQueryWrapper<BizCustomerWarehouse> buildQueryWrapper(BizCustomerWarehouse bizCustomerWarehouse) {
|
||||
LambdaQueryWrapper<BizCustomerWarehouse> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(bizCustomerWarehouse.getCustomerId())){
|
||||
queryWrapper.eq(BizCustomerWarehouse::getCustomerId, bizCustomerWarehouse.getCustomerId());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(bizCustomerWarehouse.getCustomerName())){
|
||||
queryWrapper.like(BizCustomerWarehouse::getCustomerName, bizCustomerWarehouse.getCustomerName());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue