订单定时任务维护

master
luojian 2024-12-20 18:17:02 +08:00
parent ba2ba26334
commit b517f13cf3
18 changed files with 1397 additions and 112 deletions

View File

@ -4,7 +4,12 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cpxt.biz.domain.vo.BizOrderVo;
import com.cpxt.biz.domain.vo.BizOrderVoCustomer;
import com.cpxt.common.constant.HttpStatus; import com.cpxt.common.constant.HttpStatus;
import com.cpxt.common.core.domain.entity.SysUser;
import com.cpxt.common.utils.SecurityUtils;
import com.cpxt.system.service.ISysUserService;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -16,6 +21,7 @@ import com.cpxt.biz.domain.BizOrder;
import com.cpxt.biz.service.IBizOrderService; import com.cpxt.biz.service.IBizOrderService;
import com.cpxt.common.utils.poi.ExcelUtil; import com.cpxt.common.utils.poi.ExcelUtil;
import com.cpxt.common.core.page.TableDataInfo; import com.cpxt.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/** /**
* Controller * Controller
@ -25,11 +31,13 @@ import com.cpxt.common.core.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/biz/order") @RequestMapping("/biz/order")
public class BizOrderController extends BaseController public class BizOrderController extends BaseController {
{
@Autowired @Autowired
private IBizOrderService bizOrderService; private IBizOrderService bizOrderService;
@Autowired
private ISysUserService sysUserService;
/** /**
* *
*/ */
@ -37,9 +45,8 @@ public class BizOrderController extends BaseController
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(BizOrder bizOrder, public TableDataInfo list(BizOrder bizOrder,
@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "1") int pageNum,
@RequestParam(defaultValue = "10") int pageSize) @RequestParam(defaultValue = "10") int pageSize) {
{ Page<BizOrder> recordPage = bizOrderService.selectBizOrderPage(bizOrder, pageNum, pageSize);
Page<BizOrder> recordPage = bizOrderService.selectBizOrderPage(bizOrder,pageNum,pageSize);
TableDataInfo rspData = new TableDataInfo(); TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS); rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功"); rspData.setMsg("查询成功");
@ -53,19 +60,67 @@ public class BizOrderController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('biz:order:list')") @PreAuthorize("@ss.hasPermi('biz:order:list')")
@GetMapping("/list2") @GetMapping("/list2")
public AjaxResult list(BizOrder bizOrder) public AjaxResult list(BizOrder bizOrder) {
{
return AjaxResult.success(bizOrderService.selectBizOrderList(bizOrder)); return AjaxResult.success(bizOrderService.selectBizOrderList(bizOrder));
} }
/**
* -
*/
@PreAuthorize("@ss.hasPermi('biz:order:list')")
@GetMapping("/listByDriver")
public TableDataInfo list(String orderStatus,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(defaultValue = "10") int pageSize) {
Page<BizOrder> recordPage = bizOrderService.selectBizOrderPageByDriver(orderStatus, pageNum, pageSize);
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(recordPage.getRecords());
rspData.setTotal(recordPage.getTotal());
return rspData;
}
/**
*
*/
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) {
SysUser user = sysUserService.selectUserById(SecurityUtils.getLoginUser().getUserId());
if ("0".equals(user.getUserType())) {
ExcelUtil<BizOrderVo> util = new ExcelUtil<BizOrderVo>(BizOrderVo.class);
util.importTemplateExcel(response, "订单数据");
} else {
ExcelUtil<BizOrderVoCustomer> util = new ExcelUtil<BizOrderVoCustomer>(BizOrderVoCustomer.class);
util.importTemplateExcel(response, "订单数据");
}
}
@Log(title = "订单管理", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:user:import')")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
SysUser user = sysUserService.selectUserById(SecurityUtils.getLoginUser().getUserId());
String message;
if ("0".equals(user.getUserType())) {
ExcelUtil<BizOrderVo> util = new ExcelUtil<BizOrderVo>(BizOrderVo.class);
List<BizOrderVo> orderList = util.importExcel(file.getInputStream());
message = bizOrderService.importOrder(orderList, updateSupport);
} else {
ExcelUtil<BizOrderVoCustomer> util = new ExcelUtil<BizOrderVoCustomer>(BizOrderVoCustomer.class);
List<BizOrderVoCustomer> orderList = util.importExcel(file.getInputStream());
message = bizOrderService.importOrderCustomer(orderList, updateSupport);
}
return success(message);
}
/** /**
* *
*/ */
@PreAuthorize("@ss.hasPermi('biz:order:export')") @PreAuthorize("@ss.hasPermi('biz:order:export')")
@Log(title = "订单", businessType = BusinessType.EXPORT) @Log(title = "订单", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, BizOrder bizOrder) public void export(HttpServletResponse response, BizOrder bizOrder) {
{
List<BizOrder> list = bizOrderService.selectBizOrderList(bizOrder); List<BizOrder> list = bizOrderService.selectBizOrderList(bizOrder);
ExcelUtil<BizOrder> util = new ExcelUtil<BizOrder>(BizOrder.class); ExcelUtil<BizOrder> util = new ExcelUtil<BizOrder>(BizOrder.class);
util.exportExcel(response, list, "订单数据"); util.exportExcel(response, list, "订单数据");
@ -76,8 +131,7 @@ public class BizOrderController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('biz:order:query')") @PreAuthorize("@ss.hasPermi('biz:order:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id) {
{
return success(bizOrderService.selectBizOrderById(id)); return success(bizOrderService.selectBizOrderById(id));
} }
@ -87,8 +141,7 @@ public class BizOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('biz:order:add')") @PreAuthorize("@ss.hasPermi('biz:order:add')")
@Log(title = "订单", businessType = BusinessType.INSERT) @Log(title = "订单", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody BizOrder bizOrder) public AjaxResult add(@RequestBody BizOrder bizOrder) {
{
return toAjax(bizOrderService.insertBizOrder(bizOrder)); return toAjax(bizOrderService.insertBizOrder(bizOrder));
} }
@ -98,8 +151,7 @@ public class BizOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('biz:order:edit')") @PreAuthorize("@ss.hasPermi('biz:order:edit')")
@Log(title = "订单", businessType = BusinessType.UPDATE) @Log(title = "订单", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody BizOrder bizOrder) public AjaxResult edit(@RequestBody BizOrder bizOrder) {
{
return toAjax(bizOrderService.updateBizOrder(bizOrder)); return toAjax(bizOrderService.updateBizOrder(bizOrder));
} }
@ -108,9 +160,8 @@ public class BizOrderController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('biz:order:remove')") @PreAuthorize("@ss.hasPermi('biz:order:remove')")
@Log(title = "订单", businessType = BusinessType.DELETE) @Log(title = "订单", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids) {
{
return toAjax(bizOrderService.deleteBizOrderByIds(ids)); return toAjax(bizOrderService.deleteBizOrderByIds(ids));
} }
} }

View File

@ -0,0 +1,105 @@
package com.cpxt.web.controller.biz;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.cpxt.biz.domain.BizOrderTask;
import com.cpxt.biz.service.IBizOrderTaskService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cpxt.common.annotation.Log;
import com.cpxt.common.core.controller.BaseController;
import com.cpxt.common.core.domain.AjaxResult;
import com.cpxt.common.enums.BusinessType;
import com.cpxt.common.utils.poi.ExcelUtil;
import com.cpxt.common.core.page.TableDataInfo;
/**
* Controller
*
* @author ruoyi
* @date 2024-12-20
*/
@RestController
@RequestMapping("/system/task")
public class BizOrderTaskController extends BaseController
{
@Autowired
private IBizOrderTaskService bizOrderTaskService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:task:list')")
@GetMapping("/list")
public TableDataInfo list(BizOrderTask bizOrderTask)
{
startPage();
List<BizOrderTask> list = bizOrderTaskService.selectBizOrderTaskList(bizOrderTask);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:task:export')")
@Log(title = "订单任务", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BizOrderTask bizOrderTask)
{
List<BizOrderTask> list = bizOrderTaskService.selectBizOrderTaskList(bizOrderTask);
ExcelUtil<BizOrderTask> util = new ExcelUtil<BizOrderTask>(BizOrderTask.class);
util.exportExcel(response, list, "订单任务数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:task:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(bizOrderTaskService.selectBizOrderTaskById(id));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:task:add')")
@Log(title = "订单任务", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BizOrderTask bizOrderTask)
{
return toAjax(bizOrderTaskService.insertBizOrderTask(bizOrderTask));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:task:edit')")
@Log(title = "订单任务", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BizOrderTask bizOrderTask)
{
return toAjax(bizOrderTaskService.updateBizOrderTask(bizOrderTask));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:task:remove')")
@Log(title = "订单任务", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(bizOrderTaskService.deleteBizOrderTaskByIds(ids));
}
}

View File

@ -95,7 +95,7 @@ token:
# 令牌密钥 # 令牌密钥
secret: abcdefghijk secret: abcdefghijk
# 令牌有效期默认30分钟 # 令牌有效期默认30分钟
expireTime: 30 expireTime: 300
# MyBatis Plus配置 # MyBatis Plus配置
mybatis-plus: mybatis-plus:

View File

@ -22,12 +22,18 @@
<groupId>com.cpxt</groupId> <groupId>com.cpxt</groupId>
<artifactId>cpxt-common</artifactId> <artifactId>cpxt-common</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId> <artifactId>mybatis-plus-extension</artifactId>
<version>3.5.4</version> <version>3.5.4</version>
</dependency> </dependency>
<dependency>
<groupId>com.cpxt</groupId>
<artifactId>cpxt-quartz</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -1,5 +1,6 @@
package com.cpxt.biz.domain; package com.cpxt.biz.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
@ -8,6 +9,7 @@ import com.cpxt.common.annotation.Excel;
import com.cpxt.common.core.domain.BaseEntity; import com.cpxt.common.core.domain.BaseEntity;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 线 biz_customer_route * 线 biz_customer_route
@ -51,4 +53,7 @@ public class BizCustomerRoute
/** 备注 */ /** 备注 */
private String remark; private String remark;
@TableField(exist = false)
private List<Long> shops;
} }

View File

@ -0,0 +1,102 @@
package com.cpxt.biz.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.cpxt.common.annotation.Excel;
import com.cpxt.common.core.domain.BaseEntity;
import java.util.Date;
/**
* biz_order_task
*
* @author ruoyi
* @date 2024-12-20
*/
@Data
public class BizOrderTask
{
private static final long serialVersionUID = 1L;
/** ID */
private Integer id;
/** 任务code */
private String code;
/** 任务名称 */
@Excel(name = "任务名称")
private String name;
/** 客户ID */
@Excel(name = "客户ID")
private Long customerId;
/** 客户名称 */
@Excel(name = "客户名称")
private String customerName;
/** 路线ID */
@Excel(name = "路线ID")
private Long routeId;
/** 路线名称 */
@Excel(name = "路线名称")
private String routeName;
/** 司机ID */
@Excel(name = "司机ID")
private Long driverId;
/** 司机名称 */
@Excel(name = "司机名称")
private String driverName;
/** 副驾司机ID */
@Excel(name = "副驾司机ID")
private Long copilotId;
/** 副驾司机名称 */
@Excel(name = "副驾司机名称")
private String copilotName;
/** cron执行表达式 */
@Excel(name = "cron执行表达式")
private String cronExpression;
/** 计划执行策略1立即执行 2执行一次 3放弃执行 */
@Excel(name = "计划执行策略", readConverterExp = "1=立即执行,2=执行一次,3=放弃执行")
private String misfirePolicy;
/** 是否并发执行0允许 1禁止 */
@Excel(name = "是否并发执行", readConverterExp = "0=允许,1=禁止")
private String concurrent;
/** 状态0正常 1暂停 */
@Excel(name = "状态", readConverterExp = "0=正常,1=暂停")
private String status;
/** 对应定时任务ID */
@Excel(name = "对应定时任务ID")
private Long jobId;
/** 创建者 */
private String createBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** 备注 */
private String remark;
/** 更新者 */
private String updateBy;
}

View File

@ -0,0 +1,223 @@
package com.cpxt.biz.domain.vo;
import com.cpxt.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
*
*
* @author YIN
* @date 2024-12-16
*/
@Data
public class BizOrderVo
{
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 订单号 */
private String orderSn;
/** 订单状态 */
private String orderStatus;
/** 订单类型 */
private String orderType;
/** 客户ID */
private Long customerId;
/** 客户名称 */
@Excel(name = "客户名称")
private String customerName;
/** 路线ID */
private Long routeId;
/** 路线名称 */
@Excel(name = "路线名称")
private String routeName;
/** 仓库ID */
private Long warehouseId;
/** 仓库名称 */
@Excel(name = "仓库名称")
private String warehouseName;
/** 店铺ID */
private Long shopId;
/** 店铺名称 */
@Excel(name = "店铺名称")
private String shopName;
/** 配送车辆ID */
private Long carId;
/** 配送车牌号 */
@Excel(name = "配送车牌号")
private String carNo;
/** 配送司机ID */
private Long driverId;
/** 配送司机名称 */
@Excel(name = "配送司机名称")
private String driverName;
/** 副驾司机ID */
private Long copilotId;
/** 副驾司机名称 */
@Excel(name = "副驾司机名称")
private String copilotName;
/** 发件人名称 */
private String senderName;
/** 发件联系人 */
private String senderLinkman;
/** 发件人电话 */
private String senderPhone;
/** 发件人地址 */
private String senderAddress;
/** 发件人经度 */
private BigDecimal senderLng;
/** 发件人纬度 */
private BigDecimal senderLat;
/** 发件人公司名称 */
private String senderCompany;
/** 收件人名称 */
private String receiverName;
/** 收件联系人 */
private String receiverLinkman;
/** 收件人电话 */
private String receiverPhone;
/** 收件人地址 */
private String receiverAddress;
/** 收件人经度 */
private BigDecimal receiverLng;
/** 收件人纬度 */
private BigDecimal receiverLat;
/** 收件人公司名称 */
private String receiverCompany;
/** 物品类型 */
@Excel(name = "物品类型",dictType = "sys_goods_type")
private String goodsType;
/** 物品名称 */
@Excel(name = "物品名称")
private String goodsName;
/** 重量 */
@Excel(name = "重量")
private BigDecimal weight;
/** 体积 */
private BigDecimal volume;
/** 长(米) */
@Excel(name = "长")
private BigDecimal length;
/** 宽(米) */
@Excel(name = "宽")
private BigDecimal width;
/** 高(米) */
@Excel(name = "高")
private BigDecimal height;
/** 包裹总件数 */
private Integer totalQuantity;
/** 是否保价 */
private Integer insured;
/** 保价金额 */
private BigDecimal insuredMoney;
/** 保价费用 */
private BigDecimal insuredFee;
/** 订单费用 */
private BigDecimal orderFee;
/** 是否取消 */
private Integer isCancel;
/** 取消原因 */
private String cancelReason;
/** 取消时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date cancelTime;
/** 支付类型 寄付,到付,月结 */
private String payType;
/** 支付方式 支付宝,微信 */
private String payMode;
/** 支付系统订单号 */
private String payId;
/** 支付状态 */
private Integer payStatus;
/** 支付时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date payTime;
/** 状态 */
private Integer status;
/** 开始配送时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date startTime;
/** 到达时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date arriveTime;
/** 到达备注 */
private String arriveRemark;
/** 到达经度 */
private BigDecimal arriveLng;
/** 到达纬度 */
private BigDecimal arriveLat;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** 备注 */
@Excel(name = "备注")
private String remark;
}

View File

@ -0,0 +1,219 @@
package com.cpxt.biz.domain.vo;
import com.cpxt.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
*
*
* @author YIN
* @date 2024-12-16
*/
@Data
public class BizOrderVoCustomer
{
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 订单号 */
private String orderSn;
/** 订单状态 */
private String orderStatus;
/** 订单类型 */
private String orderType;
/** 客户ID */
private Long customerId;
/** 客户名称 */
private String customerName;
/** 路线ID */
private Long routeId;
/** 路线名称 */
@Excel(name = "路线名称")
private String routeName;
/** 仓库ID */
private Long warehouseId;
/** 仓库名称 */
@Excel(name = "仓库名称")
private String warehouseName;
/** 店铺ID */
private Long shopId;
/** 店铺名称 */
@Excel(name = "店铺名称")
private String shopName;
/** 配送车辆ID */
private Long carId;
/** 配送车牌号 */
private String carNo;
/** 配送司机ID */
private Long driverId;
/** 配送司机名称 */
private String driverName;
/** 副驾司机ID */
private Long copilotId;
/** 副驾司机名称 */
private String copilotName;
/** 发件人名称 */
private String senderName;
/** 发件联系人 */
private String senderLinkman;
/** 发件人电话 */
private String senderPhone;
/** 发件人地址 */
private String senderAddress;
/** 发件人经度 */
private BigDecimal senderLng;
/** 发件人纬度 */
private BigDecimal senderLat;
/** 发件人公司名称 */
private String senderCompany;
/** 收件人名称 */
private String receiverName;
/** 收件联系人 */
private String receiverLinkman;
/** 收件人电话 */
private String receiverPhone;
/** 收件人地址 */
private String receiverAddress;
/** 收件人经度 */
private BigDecimal receiverLng;
/** 收件人纬度 */
private BigDecimal receiverLat;
/** 收件人公司名称 */
private String receiverCompany;
/** 物品类型 */
@Excel(name = "物品类型",dictType = "sys_goods_type")
private String goodsType;
/** 物品名称 */
@Excel(name = "物品名称")
private String goodsName;
/** 重量 */
@Excel(name = "重量")
private BigDecimal weight;
/** 体积 */
private BigDecimal volume;
/** 长(米) */
@Excel(name = "长")
private BigDecimal length;
/** 宽(米) */
@Excel(name = "宽")
private BigDecimal width;
/** 高(米) */
@Excel(name = "高")
private BigDecimal height;
/** 包裹总件数 */
private Integer totalQuantity;
/** 是否保价 */
private Integer insured;
/** 保价金额 */
private BigDecimal insuredMoney;
/** 保价费用 */
private BigDecimal insuredFee;
/** 订单费用 */
private BigDecimal orderFee;
/** 是否取消 */
private Integer isCancel;
/** 取消原因 */
private String cancelReason;
/** 取消时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date cancelTime;
/** 支付类型 寄付,到付,月结 */
private String payType;
/** 支付方式 支付宝,微信 */
private String payMode;
/** 支付系统订单号 */
private String payId;
/** 支付状态 */
private Integer payStatus;
/** 支付时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date payTime;
/** 状态 */
private Integer status;
/** 开始配送时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date startTime;
/** 到达时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date arriveTime;
/** 到达备注 */
private String arriveRemark;
/** 到达经度 */
private BigDecimal arriveLng;
/** 到达纬度 */
private BigDecimal arriveLat;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** 备注 */
@Excel(name = "备注")
private String remark;
}

View File

@ -18,4 +18,8 @@ public interface BizCustomerMapper extends BaseMapper<BizCustomer>
{ {
@Select("select * from biz_customer where linkphone = #{username}") @Select("select * from biz_customer where linkphone = #{username}")
BizCustomer selectByLinkPhone(String username); BizCustomer selectByLinkPhone(String username);
@Select("select * from biz_customer where name = #{customerName} and status = 1")
BizCustomer selectByName(String customerName);
} }

View File

@ -5,7 +5,9 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cpxt.biz.domain.BizCustomerRoute; import com.cpxt.biz.domain.BizCustomerRoute;
import com.cpxt.biz.domain.BizCustomerRouteShop; import com.cpxt.biz.domain.BizCustomerRouteShop;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
/** /**
* 线Mapper * 线Mapper
@ -15,4 +17,10 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface BizCustomerRouteShopMapper extends BaseMapper<BizCustomerRouteShop> public interface BizCustomerRouteShopMapper extends BaseMapper<BizCustomerRouteShop>
{ } {
@Select("select shop_id from biz_customer_route_shop where route_id = ${id}")
List<Long> selectShopIdListByRouteId(Long id);
@Delete("delete from biz_customer_route_shop where route_id = ${id}")
void deleteByRouteId(Long id);
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cpxt.biz.domain.BizDriver; import com.cpxt.biz.domain.BizDriver;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
/** /**
* Mapper * Mapper
@ -14,4 +15,8 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface BizDriverMapper extends BaseMapper<BizDriver> public interface BizDriverMapper extends BaseMapper<BizDriver>
{ } {
@Select("select * from biz_driver where user_id = ${userId} and status = 1")
BizDriver selectByUserId(Long userId);
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cpxt.biz.domain.BizOrder; import com.cpxt.biz.domain.BizOrder;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
/** /**
* Mapper * Mapper
@ -14,4 +15,7 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface BizOrderMapper extends BaseMapper<BizOrder> public interface BizOrderMapper extends BaseMapper<BizOrder>
{ } {
@Select("select * from biz_order order by id desc limit 1")
BizOrder selectLastestOrder();
}

View File

@ -0,0 +1,19 @@
package com.cpxt.biz.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cpxt.biz.domain.BizOrderTask;
import org.apache.ibatis.annotations.Mapper;
/**
* Mapper
*
* @author ruoyi
* @date 2024-12-20
*/
@Mapper
public interface BizOrderTaskMapper extends BaseMapper<BizOrderTask>
{
}

View File

@ -4,6 +4,8 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cpxt.biz.domain.BizOrder; import com.cpxt.biz.domain.BizOrder;
import com.cpxt.biz.domain.vo.BizOrderVo;
import com.cpxt.biz.domain.vo.BizOrderVoCustomer;
/** /**
* Service * Service
@ -62,4 +64,10 @@ public interface IBizOrderService
public int deleteBizOrderById(Long id); public int deleteBizOrderById(Long id);
Page<BizOrder> selectBizOrderPage(BizOrder bizOrder, int pageNum, int pageSize); Page<BizOrder> selectBizOrderPage(BizOrder bizOrder, int pageNum, int pageSize);
String importOrder(List<BizOrderVo> orderList, boolean updateSupport);
String importOrderCustomer(List<BizOrderVoCustomer> orderList, boolean updateSupport);
Page<BizOrder> selectBizOrderPageByDriver(String orderStatus,int pageNum, int pageSize);
} }

View File

@ -0,0 +1,61 @@
package com.cpxt.biz.service;
import com.cpxt.biz.domain.BizOrderTask;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2024-12-20
*/
public interface IBizOrderTaskService
{
/**
*
*
* @param id
* @return
*/
public BizOrderTask selectBizOrderTaskById(Integer id);
/**
*
*
* @param bizOrderTask
* @return
*/
public List<BizOrderTask> selectBizOrderTaskList(BizOrderTask bizOrderTask);
/**
*
*
* @param bizOrderTask
* @return
*/
public int insertBizOrderTask(BizOrderTask bizOrderTask);
/**
*
*
* @param bizOrderTask
* @return
*/
public int updateBizOrderTask(BizOrderTask bizOrderTask);
/**
*
*
* @param ids
* @return
*/
public int deleteBizOrderTaskByIds(Integer[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteBizOrderTaskById(Integer id);
}

View File

@ -6,6 +6,8 @@ import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.cpxt.biz.domain.BizCustomer; import com.cpxt.biz.domain.BizCustomer;
import com.cpxt.biz.domain.BizCustomerRouteShop;
import com.cpxt.biz.mapper.BizCustomerRouteShopMapper;
import com.cpxt.common.utils.DateUtils; import com.cpxt.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -25,6 +27,9 @@ public class BizCustomerRouteServiceImpl implements IBizCustomerRouteService
@Autowired @Autowired
private BizCustomerRouteMapper bizCustomerRouteMapper; private BizCustomerRouteMapper bizCustomerRouteMapper;
@Autowired
private BizCustomerRouteShopMapper bizCustomerRouteShopMapper;
/** /**
* 线 * 线
* *
@ -34,7 +39,11 @@ public class BizCustomerRouteServiceImpl implements IBizCustomerRouteService
@Override @Override
public BizCustomerRoute selectBizCustomerRouteById(Long id) public BizCustomerRoute selectBizCustomerRouteById(Long id)
{ {
return bizCustomerRouteMapper.selectById(id); BizCustomerRoute bizCustomerRoute = bizCustomerRouteMapper.selectById(id);
// 根据路线id查询关联的店铺id
List<Long> ids = bizCustomerRouteShopMapper.selectShopIdListByRouteId(id);
bizCustomerRoute.setShops(ids);
return bizCustomerRoute;
} }
/** /**
@ -60,7 +69,17 @@ public class BizCustomerRouteServiceImpl implements IBizCustomerRouteService
@Override @Override
public int insertBizCustomerRoute(BizCustomerRoute bizCustomerRoute) public int insertBizCustomerRoute(BizCustomerRoute bizCustomerRoute)
{ {
return bizCustomerRouteMapper.insert(bizCustomerRoute); int insert = bizCustomerRouteMapper.insert(bizCustomerRoute);
// 新增完路线将路线和店铺关联起来入关联表
List<Long> shops = bizCustomerRoute.getShops();
for (int i = 0; i < shops.size(); i++) {
BizCustomerRouteShop bizCustomerRouteShop = new BizCustomerRouteShop();
bizCustomerRouteShop.setRouteId(bizCustomerRoute.getId());
bizCustomerRouteShop.setShopId(shops.get(i));
bizCustomerRouteShop.setSort(i);
bizCustomerRouteShopMapper.insert(bizCustomerRouteShop);
}
return insert;
} }
/** /**
@ -72,6 +91,17 @@ public class BizCustomerRouteServiceImpl implements IBizCustomerRouteService
@Override @Override
public int updateBizCustomerRoute(BizCustomerRoute bizCustomerRoute) public int updateBizCustomerRoute(BizCustomerRoute bizCustomerRoute)
{ {
// 修改完路线同步修改到路线和店铺的关联表
List<Long> shops = bizCustomerRoute.getShops();
// 先删除再新增
bizCustomerRouteShopMapper.deleteByRouteId(bizCustomerRoute.getId());
for (int i = 0; i < shops.size(); i++) {
BizCustomerRouteShop bizCustomerRouteShop = new BizCustomerRouteShop();
bizCustomerRouteShop.setRouteId(bizCustomerRoute.getId());
bizCustomerRouteShop.setShopId(shops.get(i));
bizCustomerRouteShop.setSort(i);
bizCustomerRouteShopMapper.insert(bizCustomerRouteShop);
}
return bizCustomerRouteMapper.updateById(bizCustomerRoute); return bizCustomerRouteMapper.updateById(bizCustomerRoute);
} }
@ -84,6 +114,10 @@ public class BizCustomerRouteServiceImpl implements IBizCustomerRouteService
@Override @Override
public int deleteBizCustomerRouteByIds(Long[] ids) public int deleteBizCustomerRouteByIds(Long[] ids)
{ {
// 同步删除路线和店铺的关联表
for (Long id : ids) {
bizCustomerRouteShopMapper.deleteByRouteId(id);
}
UpdateWrapper<BizCustomerRoute> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<BizCustomerRoute> updateWrapper = new UpdateWrapper<>();
updateWrapper.in("id", (Object[]) ids); updateWrapper.in("id", (Object[]) ids);
updateWrapper.set("status","2"); //状态改为删除 updateWrapper.set("status","2"); //状态改为删除

View File

@ -1,19 +1,30 @@
package com.cpxt.biz.service.impl; package com.cpxt.biz.service.impl;
import java.util.Arrays; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cpxt.biz.domain.*; import com.cpxt.biz.domain.*;
import com.cpxt.biz.domain.vo.BizOrderVo;
import com.cpxt.biz.domain.vo.BizOrderVoCustomer;
import com.cpxt.biz.mapper.*; import com.cpxt.biz.mapper.*;
import com.cpxt.common.exception.ServiceException;
import com.cpxt.common.utils.SecurityUtils; import com.cpxt.common.utils.SecurityUtils;
import com.cpxt.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.cpxt.biz.service.IBizOrderService; import com.cpxt.biz.service.IBizOrderService;
import javax.validation.Validator;
/** /**
* Service * Service
* *
@ -21,8 +32,13 @@ import com.cpxt.biz.service.IBizOrderService;
* @date 2024-12-16 * @date 2024-12-16
*/ */
@Service @Service
public class BizOrderServiceImpl implements IBizOrderService public class BizOrderServiceImpl implements IBizOrderService {
{
private static final Logger log = LoggerFactory.getLogger(BizOrderServiceImpl.class);
@Autowired
protected Validator validator;
@Autowired @Autowired
private BizOrderMapper bizOrderMapper; private BizOrderMapper bizOrderMapper;
@ -51,8 +67,7 @@ public class BizOrderServiceImpl implements IBizOrderService
* @return * @return
*/ */
@Override @Override
public BizOrder selectBizOrderById(Long id) public BizOrder selectBizOrderById(Long id) {
{
return bizOrderMapper.selectById(id); return bizOrderMapper.selectById(id);
} }
@ -65,7 +80,23 @@ public class BizOrderServiceImpl implements IBizOrderService
@Override @Override
public Page<BizOrder> selectBizOrderPage(BizOrder bizOrder, int pageNum, int pageSize) { public Page<BizOrder> selectBizOrderPage(BizOrder bizOrder, int pageNum, int pageSize) {
LambdaQueryWrapper<BizOrder> queryWrapper = buildQueryWrapper(bizOrder); LambdaQueryWrapper<BizOrder> queryWrapper = buildQueryWrapper(bizOrder);
return bizOrderMapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); return bizOrderMapper.selectPage(new Page<>(pageNum, pageSize), queryWrapper);
}
/**
* -
*
* @return
*/
@Override
public Page<BizOrder> selectBizOrderPageByDriver(String orderStatus ,int pageNum, int pageSize) {
BizDriver bizDriver = bizDriverMapper.selectByUserId(SecurityUtils.getUserId());
LambdaQueryWrapper<BizOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BizOrder::getStatus,1);
queryWrapper.eq(BizOrder::getOrderStatus,orderStatus);
queryWrapper.and(wq -> wq.like(BizOrder::getDriverName,bizDriver.getName()).or().like(BizOrder::getCopilotName,bizDriver.getName()));
queryWrapper.orderByDesc(BizOrder::getCreateTime);
return bizOrderMapper.selectPage(new Page<>(pageNum, pageSize), queryWrapper);
} }
/** /**
@ -75,186 +106,186 @@ public class BizOrderServiceImpl implements IBizOrderService
* @return * @return
*/ */
@Override @Override
public List<BizOrder> selectBizOrderList(BizOrder bizOrder) public List<BizOrder> selectBizOrderList(BizOrder bizOrder) {
{
LambdaQueryWrapper<BizOrder> queryWrapper = buildQueryWrapper(bizOrder); LambdaQueryWrapper<BizOrder> queryWrapper = buildQueryWrapper(bizOrder);
return bizOrderMapper.selectList(queryWrapper); return bizOrderMapper.selectList(queryWrapper);
} }
private LambdaQueryWrapper<BizOrder> buildQueryWrapper(BizOrder bizOrder) { private LambdaQueryWrapper<BizOrder> buildQueryWrapper(BizOrder bizOrder) {
LambdaQueryWrapper<BizOrder> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BizOrder> queryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(bizOrder.getOrderSn())){ if (ObjectUtil.isNotEmpty(bizOrder.getOrderSn())) {
queryWrapper.like(BizOrder::getOrderSn, bizOrder.getOrderSn()); queryWrapper.like(BizOrder::getOrderSn, bizOrder.getOrderSn());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getOrderStatus())){ if (ObjectUtil.isNotEmpty(bizOrder.getOrderStatus())) {
queryWrapper.eq(BizOrder::getOrderStatus, bizOrder.getOrderStatus()); queryWrapper.eq(BizOrder::getOrderStatus, bizOrder.getOrderStatus());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getOrderType())){ if (ObjectUtil.isNotEmpty(bizOrder.getOrderType())) {
queryWrapper.eq(BizOrder::getOrderType, bizOrder.getOrderType()); queryWrapper.eq(BizOrder::getOrderType, bizOrder.getOrderType());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getCustomerId())){ if (ObjectUtil.isNotEmpty(bizOrder.getCustomerId())) {
queryWrapper.eq(BizOrder::getCustomerId, bizOrder.getCustomerId()); queryWrapper.eq(BizOrder::getCustomerId, bizOrder.getCustomerId());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getCustomerName())){ if (ObjectUtil.isNotEmpty(bizOrder.getCustomerName())) {
queryWrapper.like(BizOrder::getCustomerName, bizOrder.getCustomerName()); queryWrapper.like(BizOrder::getCustomerName, bizOrder.getCustomerName());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getRouteId())){ if (ObjectUtil.isNotEmpty(bizOrder.getRouteId())) {
queryWrapper.eq(BizOrder::getRouteId, bizOrder.getRouteId()); queryWrapper.eq(BizOrder::getRouteId, bizOrder.getRouteId());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getRouteName())){ if (ObjectUtil.isNotEmpty(bizOrder.getRouteName())) {
queryWrapper.like(BizOrder::getRouteName, bizOrder.getRouteName()); queryWrapper.like(BizOrder::getRouteName, bizOrder.getRouteName());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getWarehouseId())){ if (ObjectUtil.isNotEmpty(bizOrder.getWarehouseId())) {
queryWrapper.eq(BizOrder::getWarehouseId, bizOrder.getWarehouseId()); queryWrapper.eq(BizOrder::getWarehouseId, bizOrder.getWarehouseId());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getWarehouseName())){ if (ObjectUtil.isNotEmpty(bizOrder.getWarehouseName())) {
queryWrapper.like(BizOrder::getWarehouseName, bizOrder.getWarehouseName()); queryWrapper.like(BizOrder::getWarehouseName, bizOrder.getWarehouseName());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getShopId())){ if (ObjectUtil.isNotEmpty(bizOrder.getShopId())) {
queryWrapper.eq(BizOrder::getShopId, bizOrder.getShopId()); queryWrapper.eq(BizOrder::getShopId, bizOrder.getShopId());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getShopName())){ if (ObjectUtil.isNotEmpty(bizOrder.getShopName())) {
queryWrapper.like(BizOrder::getShopName, bizOrder.getShopName()); queryWrapper.like(BizOrder::getShopName, bizOrder.getShopName());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getCarId())){ if (ObjectUtil.isNotEmpty(bizOrder.getCarId())) {
queryWrapper.eq(BizOrder::getCarId, bizOrder.getCarId()); queryWrapper.eq(BizOrder::getCarId, bizOrder.getCarId());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getCarNo())){ if (ObjectUtil.isNotEmpty(bizOrder.getCarNo())) {
queryWrapper.like(BizOrder::getCarNo, bizOrder.getCarNo()); queryWrapper.like(BizOrder::getCarNo, bizOrder.getCarNo());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getDriverId())){ if (ObjectUtil.isNotEmpty(bizOrder.getDriverId())) {
queryWrapper.eq(BizOrder::getDriverId, bizOrder.getDriverId()); queryWrapper.eq(BizOrder::getDriverId, bizOrder.getDriverId());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getDriverName())){ if (ObjectUtil.isNotEmpty(bizOrder.getDriverName())) {
queryWrapper.like(BizOrder::getDriverName, bizOrder.getDriverName()); queryWrapper.like(BizOrder::getDriverName, bizOrder.getDriverName());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getCopilotId())){ if (ObjectUtil.isNotEmpty(bizOrder.getCopilotId())) {
queryWrapper.eq(BizOrder::getCopilotId, bizOrder.getCopilotId()); queryWrapper.eq(BizOrder::getCopilotId, bizOrder.getCopilotId());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getCopilotName())){ if (ObjectUtil.isNotEmpty(bizOrder.getCopilotName())) {
queryWrapper.like(BizOrder::getCopilotName, bizOrder.getCopilotName()); queryWrapper.like(BizOrder::getCopilotName, bizOrder.getCopilotName());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getSenderName())){ if (ObjectUtil.isNotEmpty(bizOrder.getSenderName())) {
queryWrapper.like(BizOrder::getSenderName, bizOrder.getSenderName()); queryWrapper.like(BizOrder::getSenderName, bizOrder.getSenderName());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getSenderLinkman())){ if (ObjectUtil.isNotEmpty(bizOrder.getSenderLinkman())) {
queryWrapper.like(BizOrder::getSenderLinkman, bizOrder.getSenderLinkman()); queryWrapper.like(BizOrder::getSenderLinkman, bizOrder.getSenderLinkman());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getSenderPhone())){ if (ObjectUtil.isNotEmpty(bizOrder.getSenderPhone())) {
queryWrapper.like(BizOrder::getSenderPhone, bizOrder.getSenderPhone()); queryWrapper.like(BizOrder::getSenderPhone, bizOrder.getSenderPhone());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getSenderAddress())){ if (ObjectUtil.isNotEmpty(bizOrder.getSenderAddress())) {
queryWrapper.like(BizOrder::getSenderAddress, bizOrder.getSenderAddress()); queryWrapper.like(BizOrder::getSenderAddress, bizOrder.getSenderAddress());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getSenderLng())){ if (ObjectUtil.isNotEmpty(bizOrder.getSenderLng())) {
queryWrapper.eq(BizOrder::getSenderLng, bizOrder.getSenderLng()); queryWrapper.eq(BizOrder::getSenderLng, bizOrder.getSenderLng());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getSenderLat())){ if (ObjectUtil.isNotEmpty(bizOrder.getSenderLat())) {
queryWrapper.eq(BizOrder::getSenderLat, bizOrder.getSenderLat()); queryWrapper.eq(BizOrder::getSenderLat, bizOrder.getSenderLat());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getSenderCompany())){ if (ObjectUtil.isNotEmpty(bizOrder.getSenderCompany())) {
queryWrapper.like(BizOrder::getSenderCompany, bizOrder.getSenderCompany()); queryWrapper.like(BizOrder::getSenderCompany, bizOrder.getSenderCompany());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getReceiverName())){ if (ObjectUtil.isNotEmpty(bizOrder.getReceiverName())) {
queryWrapper.like(BizOrder::getReceiverName, bizOrder.getReceiverName()); queryWrapper.like(BizOrder::getReceiverName, bizOrder.getReceiverName());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getReceiverLinkman())){ if (ObjectUtil.isNotEmpty(bizOrder.getReceiverLinkman())) {
queryWrapper.like(BizOrder::getReceiverLinkman, bizOrder.getReceiverLinkman()); queryWrapper.like(BizOrder::getReceiverLinkman, bizOrder.getReceiverLinkman());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getReceiverPhone())){ if (ObjectUtil.isNotEmpty(bizOrder.getReceiverPhone())) {
queryWrapper.like(BizOrder::getReceiverPhone, bizOrder.getReceiverPhone()); queryWrapper.like(BizOrder::getReceiverPhone, bizOrder.getReceiverPhone());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getReceiverAddress())){ if (ObjectUtil.isNotEmpty(bizOrder.getReceiverAddress())) {
queryWrapper.like(BizOrder::getReceiverAddress, bizOrder.getReceiverAddress()); queryWrapper.like(BizOrder::getReceiverAddress, bizOrder.getReceiverAddress());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getReceiverLng())){ if (ObjectUtil.isNotEmpty(bizOrder.getReceiverLng())) {
queryWrapper.eq(BizOrder::getReceiverLng, bizOrder.getReceiverLng()); queryWrapper.eq(BizOrder::getReceiverLng, bizOrder.getReceiverLng());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getReceiverLat())){ if (ObjectUtil.isNotEmpty(bizOrder.getReceiverLat())) {
queryWrapper.eq(BizOrder::getReceiverLat, bizOrder.getReceiverLat()); queryWrapper.eq(BizOrder::getReceiverLat, bizOrder.getReceiverLat());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getReceiverCompany())){ if (ObjectUtil.isNotEmpty(bizOrder.getReceiverCompany())) {
queryWrapper.like(BizOrder::getReceiverCompany, bizOrder.getReceiverCompany()); queryWrapper.like(BizOrder::getReceiverCompany, bizOrder.getReceiverCompany());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getGoodsType())){ if (ObjectUtil.isNotEmpty(bizOrder.getGoodsType())) {
queryWrapper.eq(BizOrder::getGoodsType, bizOrder.getGoodsType()); queryWrapper.eq(BizOrder::getGoodsType, bizOrder.getGoodsType());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getGoodsName())){ if (ObjectUtil.isNotEmpty(bizOrder.getGoodsName())) {
queryWrapper.like(BizOrder::getGoodsName, bizOrder.getGoodsName()); queryWrapper.like(BizOrder::getGoodsName, bizOrder.getGoodsName());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getWeight())){ if (ObjectUtil.isNotEmpty(bizOrder.getWeight())) {
queryWrapper.eq(BizOrder::getWeight, bizOrder.getWeight()); queryWrapper.eq(BizOrder::getWeight, bizOrder.getWeight());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getVolume())){ if (ObjectUtil.isNotEmpty(bizOrder.getVolume())) {
queryWrapper.eq(BizOrder::getVolume, bizOrder.getVolume()); queryWrapper.eq(BizOrder::getVolume, bizOrder.getVolume());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getLength())){ if (ObjectUtil.isNotEmpty(bizOrder.getLength())) {
queryWrapper.eq(BizOrder::getLength, bizOrder.getLength()); queryWrapper.eq(BizOrder::getLength, bizOrder.getLength());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getWidth())){ if (ObjectUtil.isNotEmpty(bizOrder.getWidth())) {
queryWrapper.eq(BizOrder::getWidth, bizOrder.getWidth()); queryWrapper.eq(BizOrder::getWidth, bizOrder.getWidth());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getHeight())){ if (ObjectUtil.isNotEmpty(bizOrder.getHeight())) {
queryWrapper.eq(BizOrder::getHeight, bizOrder.getHeight()); queryWrapper.eq(BizOrder::getHeight, bizOrder.getHeight());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getTotalQuantity())){ if (ObjectUtil.isNotEmpty(bizOrder.getTotalQuantity())) {
queryWrapper.eq(BizOrder::getTotalQuantity, bizOrder.getTotalQuantity()); queryWrapper.eq(BizOrder::getTotalQuantity, bizOrder.getTotalQuantity());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getInsured())){ if (ObjectUtil.isNotEmpty(bizOrder.getInsured())) {
queryWrapper.eq(BizOrder::getInsured, bizOrder.getInsured()); queryWrapper.eq(BizOrder::getInsured, bizOrder.getInsured());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getInsuredMoney())){ if (ObjectUtil.isNotEmpty(bizOrder.getInsuredMoney())) {
queryWrapper.eq(BizOrder::getInsuredMoney, bizOrder.getInsuredMoney()); queryWrapper.eq(BizOrder::getInsuredMoney, bizOrder.getInsuredMoney());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getInsuredFee())){ if (ObjectUtil.isNotEmpty(bizOrder.getInsuredFee())) {
queryWrapper.eq(BizOrder::getInsuredFee, bizOrder.getInsuredFee()); queryWrapper.eq(BizOrder::getInsuredFee, bizOrder.getInsuredFee());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getOrderFee())){ if (ObjectUtil.isNotEmpty(bizOrder.getOrderFee())) {
queryWrapper.eq(BizOrder::getOrderFee, bizOrder.getOrderFee()); queryWrapper.eq(BizOrder::getOrderFee, bizOrder.getOrderFee());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getIsCancel())){ if (ObjectUtil.isNotEmpty(bizOrder.getIsCancel())) {
queryWrapper.eq(BizOrder::getIsCancel, bizOrder.getIsCancel()); queryWrapper.eq(BizOrder::getIsCancel, bizOrder.getIsCancel());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getCancelReason())){ if (ObjectUtil.isNotEmpty(bizOrder.getCancelReason())) {
queryWrapper.like(BizOrder::getCancelReason, bizOrder.getCancelReason()); queryWrapper.like(BizOrder::getCancelReason, bizOrder.getCancelReason());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getCancelTime())){ if (ObjectUtil.isNotEmpty(bizOrder.getCancelTime())) {
queryWrapper.like(BizOrder::getCancelTime, bizOrder.getCancelTime()); queryWrapper.like(BizOrder::getCancelTime, bizOrder.getCancelTime());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getPayType())){ if (ObjectUtil.isNotEmpty(bizOrder.getPayType())) {
queryWrapper.eq(BizOrder::getPayType, bizOrder.getPayType()); queryWrapper.eq(BizOrder::getPayType, bizOrder.getPayType());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getPayMode())){ if (ObjectUtil.isNotEmpty(bizOrder.getPayMode())) {
queryWrapper.eq(BizOrder::getPayMode, bizOrder.getPayMode()); queryWrapper.eq(BizOrder::getPayMode, bizOrder.getPayMode());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getPayId())){ if (ObjectUtil.isNotEmpty(bizOrder.getPayId())) {
queryWrapper.eq(BizOrder::getPayId, bizOrder.getPayId()); queryWrapper.eq(BizOrder::getPayId, bizOrder.getPayId());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getPayStatus())){ if (ObjectUtil.isNotEmpty(bizOrder.getPayStatus())) {
queryWrapper.eq(BizOrder::getPayStatus, bizOrder.getPayStatus()); queryWrapper.eq(BizOrder::getPayStatus, bizOrder.getPayStatus());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getPayTime())){ if (ObjectUtil.isNotEmpty(bizOrder.getPayTime())) {
queryWrapper.like(BizOrder::getPayTime, bizOrder.getPayTime()); queryWrapper.like(BizOrder::getPayTime, bizOrder.getPayTime());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getStatus())){ if (ObjectUtil.isNotEmpty(bizOrder.getStatus())) {
queryWrapper.eq(BizOrder::getStatus, bizOrder.getStatus()); queryWrapper.eq(BizOrder::getStatus, bizOrder.getStatus());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getStartTime())){ if (ObjectUtil.isNotEmpty(bizOrder.getStartTime())) {
queryWrapper.like(BizOrder::getStartTime, bizOrder.getStartTime()); queryWrapper.like(BizOrder::getStartTime, bizOrder.getStartTime());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getArriveTime())){ if (ObjectUtil.isNotEmpty(bizOrder.getArriveTime())) {
queryWrapper.like(BizOrder::getArriveTime, bizOrder.getArriveTime()); queryWrapper.like(BizOrder::getArriveTime, bizOrder.getArriveTime());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getArriveRemark())){ if (ObjectUtil.isNotEmpty(bizOrder.getArriveRemark())) {
queryWrapper.like(BizOrder::getArriveRemark, bizOrder.getArriveRemark()); queryWrapper.like(BizOrder::getArriveRemark, bizOrder.getArriveRemark());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getArriveLng())){ if (ObjectUtil.isNotEmpty(bizOrder.getArriveLng())) {
queryWrapper.eq(BizOrder::getArriveLng, bizOrder.getArriveLng()); queryWrapper.eq(BizOrder::getArriveLng, bizOrder.getArriveLng());
} }
if (ObjectUtil.isNotEmpty(bizOrder.getArriveLat())){ if (ObjectUtil.isNotEmpty(bizOrder.getArriveLat())) {
queryWrapper.eq(BizOrder::getArriveLat, bizOrder.getArriveLat()); queryWrapper.eq(BizOrder::getArriveLat, bizOrder.getArriveLat());
} }
queryWrapper.eq(BizOrder::getStatus,1); queryWrapper.eq(BizOrder::getStatus, 1);
queryWrapper.orderByDesc(BizOrder::getCreateTime);
return queryWrapper; return queryWrapper;
} }
@ -265,10 +296,9 @@ public class BizOrderServiceImpl implements IBizOrderService
* @return * @return
*/ */
@Override @Override
public int insertBizOrder(BizOrder bizOrder) public int insertBizOrder(BizOrder bizOrder) {
{
Long customerId = bizOrder.getCustomerId(); // 客户id Long customerId = bizOrder.getCustomerId(); // 客户id
if (ObjectUtil.isEmpty(customerId)){ if (ObjectUtil.isEmpty(customerId)) {
String username = SecurityUtils.getUsername(); String username = SecurityUtils.getUsername();
BizCustomer bizCustomer = bizCustomerMapper.selectByLinkPhone(username); BizCustomer bizCustomer = bizCustomerMapper.selectByLinkPhone(username);
customerId = bizCustomer.getId(); customerId = bizCustomer.getId();
@ -280,9 +310,12 @@ public class BizOrderServiceImpl implements IBizOrderService
Long driverId = bizOrder.getDriverId(); // 配送司机id Long driverId = bizOrder.getDriverId(); // 配送司机id
Long copilotId = bizOrder.getCopilotId(); // 副驾司机id Long copilotId = bizOrder.getCopilotId(); // 副驾司机id
setBizOrderSn(bizOrder); // 填充订单编号
bizOrder.setCustomerName(bizCustomerMapper.selectById(customerId).getName()); bizOrder.setCustomerName(bizCustomerMapper.selectById(customerId).getName());
if (ObjectUtil.isNotEmpty(routeId)) bizOrder.setRouteName(bizCustomerRouteMapper.selectById(routeId).getName()); if (ObjectUtil.isNotEmpty(routeId)) bizOrder.setRouteName(bizCustomerRouteMapper.selectById(routeId).getName());
if (ObjectUtil.isNotEmpty(warehouseId)) bizOrder.setWarehouseName(bizCustomerWarehouseMapper.selectById(warehouseId).getName()); if (ObjectUtil.isNotEmpty(warehouseId))
bizOrder.setWarehouseName(bizCustomerWarehouseMapper.selectById(warehouseId).getName());
if (ObjectUtil.isNotEmpty(shopId)) bizOrder.setShopName(bizCustomerShopMapper.selectById(shopId).getName()); if (ObjectUtil.isNotEmpty(shopId)) bizOrder.setShopName(bizCustomerShopMapper.selectById(shopId).getName());
if (ObjectUtil.isNotEmpty(carId)) bizOrder.setCarNo(bizCarMapper.selectById(carId).getCarNo()); if (ObjectUtil.isNotEmpty(carId)) bizOrder.setCarNo(bizCarMapper.selectById(carId).getCarNo());
if (ObjectUtil.isNotEmpty(driverId)) bizOrder.setDriverName(bizDriverMapper.selectById(driverId).getName()); if (ObjectUtil.isNotEmpty(driverId)) bizOrder.setDriverName(bizDriverMapper.selectById(driverId).getName());
@ -297,8 +330,7 @@ public class BizOrderServiceImpl implements IBizOrderService
* @return * @return
*/ */
@Override @Override
public int updateBizOrder(BizOrder bizOrder) public int updateBizOrder(BizOrder bizOrder) {
{
return bizOrderMapper.updateById(bizOrder); return bizOrderMapper.updateById(bizOrder);
} }
@ -309,12 +341,11 @@ public class BizOrderServiceImpl implements IBizOrderService
* @return * @return
*/ */
@Override @Override
public int deleteBizOrderByIds(Long[] ids) public int deleteBizOrderByIds(Long[] ids) {
{
UpdateWrapper<BizOrder> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<BizOrder> updateWrapper = new UpdateWrapper<>();
updateWrapper.in("id", (Object[]) ids); updateWrapper.in("id", (Object[]) ids);
updateWrapper.set("status","2"); //状态改为删除 updateWrapper.set("status", "2"); //状态改为删除
return bizOrderMapper.update(null,updateWrapper); return bizOrderMapper.update(null, updateWrapper);
} }
/** /**
@ -324,12 +355,268 @@ public class BizOrderServiceImpl implements IBizOrderService
* @return * @return
*/ */
@Override @Override
public int deleteBizOrderById(Long id) public int deleteBizOrderById(Long id) {
{
UpdateWrapper<BizOrder> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<BizOrder> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id); updateWrapper.eq("id", id);
updateWrapper.set("status","2"); //状态改为删除 updateWrapper.set("status", "2"); //状态改为删除
return bizOrderMapper.update(null,updateWrapper); return bizOrderMapper.update(null, updateWrapper);
} }
/**
*
*
* @param orderList
* @param updateSupport
* @return
*/
@Override
public String importOrder(List<BizOrderVo> orderList, boolean updateSupport) {
if (StringUtils.isNull(orderList) || orderList.size() == 0) {
throw new ServiceException("导入订单数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (BizOrderVo vo : orderList) {
BizOrder bizOrder = new BizOrder();
BeanUtils.copyProperties(vo,bizOrder);
// 设置订单属性
setBizOrder(bizOrder);
try {
bizOrderMapper.insert(bizOrder);
successNum++;
successMsg.append("<br/>").append(successNum).append("、订单 ").append(bizOrder.getOrderSn()).append(" 导入成功");
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、订单 " + bizOrder.getOrderSn() + " 导入失败:";
failureMsg.append(msg).append(e.getMessage());
log.error(msg, e);
}
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
/**
*
*
* @param orderList
* @param updateSupport
* @return
*/
@Override
public String importOrderCustomer(List<BizOrderVoCustomer> orderList, boolean updateSupport) {
if (StringUtils.isNull(orderList) || orderList.size() == 0) {
throw new ServiceException("导入订单数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (BizOrderVoCustomer voCustomer : orderList) {
BizOrder bizOrder = new BizOrder();
BeanUtils.copyProperties(voCustomer,bizOrder);
// 设置订单属性
setBizOrderCustomer(bizOrder);
try {
bizOrderMapper.insert(bizOrder);
successNum++;
successMsg.append("<br/>").append(successNum).append("、订单 ").append(bizOrder.getOrderSn()).append(" 导入成功");
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、订单 " + bizOrder.getOrderSn() + " 导入失败:";
failureMsg.append(msg).append(e.getMessage());
log.error(msg, e);
}
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
// 设置订单相关属性(调度员导入)
private void setBizOrder(BizOrder bizOrder) {
setBizOrderSn(bizOrder);
String customerName = bizOrder.getCustomerName(); // 客户名称
String routeName = bizOrder.getRouteName(); // 路线名称
String warehouseName = bizOrder.getWarehouseName(); // 仓库名称
String shopName = bizOrder.getShopName(); // 店铺名称
String carNo = bizOrder.getCarNo(); // 配送车牌号
String driverName = bizOrder.getDriverName(); // 配送司机名称
String copilotName = bizOrder.getCopilotName(); // 副驾司机名称
String goodsType = bizOrder.getGoodsType(); // 物品类型
String goodsName = bizOrder.getGoodsName(); // 物品名称
BigDecimal weight = bizOrder.getWeight(); // 重量
BigDecimal length = bizOrder.getLength(); // 长
BigDecimal width = bizOrder.getWidth(); // 宽
BigDecimal height = bizOrder.getHeight(); // 高
String remark = bizOrder.getRemark(); // 备注
BizCustomer bizCustomer = bizCustomerMapper.selectByName(customerName);
Long customerId = bizCustomer.getId();
bizOrder.setCustomerId(customerId);
LambdaQueryWrapper<BizCustomerRoute> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BizCustomerRoute::getCustomerId,customerId);
queryWrapper.eq(BizCustomerRoute::getName,routeName);
queryWrapper.eq(BizCustomerRoute::getStatus,"1");
BizCustomerRoute bizCustomerRoute = bizCustomerRouteMapper.selectOne(queryWrapper);
bizOrder.setRouteId(bizCustomerRoute.getId());
LambdaQueryWrapper<BizCustomerWarehouse> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(BizCustomerWarehouse::getCustomerId,customerId);
queryWrapper1.eq(BizCustomerWarehouse::getName,warehouseName);
queryWrapper1.eq(BizCustomerWarehouse::getStatus,1);
BizCustomerWarehouse bizCustomerWarehouse = bizCustomerWarehouseMapper.selectOne(queryWrapper1);
bizOrder.setWarehouseId(bizCustomerWarehouse.getId());
// 发件人信息就是仓库信息
bizOrder.setSenderName(bizCustomerWarehouse.getName());
bizOrder.setSenderLinkman(bizCustomerWarehouse.getLinkman());
bizOrder.setSenderPhone(bizCustomerWarehouse.getLinkphone());
bizOrder.setSenderAddress(bizCustomerWarehouse.getAddress());
bizOrder.setSenderLng(bizCustomerWarehouse.getLng());
bizOrder.setSenderLat(bizCustomerWarehouse.getLat());
LambdaQueryWrapper<BizCustomerShop> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(BizCustomerShop::getCustomerId,customerId);
queryWrapper2.eq(BizCustomerShop::getName,shopName);
queryWrapper2.eq(BizCustomerShop::getStatus,1);
BizCustomerShop bizCustomerShop = bizCustomerShopMapper.selectOne(queryWrapper2);
bizOrder.setShopId(bizCustomerShop.getId());
// 收件人信息就是店铺信息
bizOrder.setReceiverName(bizCustomerShop.getName());
bizOrder.setReceiverLinkman(bizCustomerShop.getLinkman());
bizOrder.setReceiverPhone(bizCustomerShop.getLinkphone());
bizOrder.setReceiverAddress(bizCustomerShop.getAddress());
bizOrder.setReceiverLng(bizCustomerShop.getLng());
bizOrder.setReceiverLat(bizCustomerShop.getLat());
if (ObjectUtil.isNotEmpty(carNo)){
LambdaQueryWrapper<BizCar> queryWrapper3 = new LambdaQueryWrapper<>();
queryWrapper3.eq(BizCar::getCarNo,carNo);
queryWrapper3.eq(BizCar::getStatus,1);
BizCar bizCar = bizCarMapper.selectOne(queryWrapper3);
bizOrder.setCarId(bizCar.getId());
}
if (ObjectUtil.isNotEmpty(driverName)){
LambdaQueryWrapper<BizDriver> queryWrapper4= new LambdaQueryWrapper<>();
queryWrapper4.eq(BizDriver::getName,driverName);
queryWrapper4.eq(BizDriver::getStatus,1);
BizDriver bizDriver = bizDriverMapper.selectOne(queryWrapper4);
bizOrder.setDriverId(bizDriver.getId());
}
if (ObjectUtil.isNotEmpty(copilotName)){
LambdaQueryWrapper<BizDriver> queryWrapper5= new LambdaQueryWrapper<>();
queryWrapper5.eq(BizDriver::getName,copilotName);
queryWrapper5.eq(BizDriver::getStatus,1);
BizDriver copilot = bizDriverMapper.selectOne(queryWrapper5);
bizOrder.setCopilotId(copilot.getId());
}
bizOrder.setGoodsType(goodsType);
bizOrder.setGoodsName(goodsName);
bizOrder.setWeight(weight);
bizOrder.setLength(length);
bizOrder.setWidth(width);
bizOrder.setHeight(height);
if (ObjectUtil.isNotEmpty(length) && ObjectUtil.isNotEmpty(width) && ObjectUtil.isNotEmpty(height)){
bizOrder.setVolume(length.multiply(width).multiply(height));
}
bizOrder.setRemark(remark);
}
// 设置订单相关属性(客户导入)
private void setBizOrderCustomer(BizOrder bizOrder) {
setBizOrderSn(bizOrder);
String routeName = bizOrder.getRouteName(); // 路线名称
String warehouseName = bizOrder.getWarehouseName(); // 仓库名称
String shopName = bizOrder.getShopName(); // 店铺名称
String goodsType = bizOrder.getGoodsType(); // 物品类型
String goodsName = bizOrder.getGoodsName(); // 物品名称
BigDecimal weight = bizOrder.getWeight(); // 重量
BigDecimal length = bizOrder.getLength(); // 长
BigDecimal width = bizOrder.getWidth(); // 宽
BigDecimal height = bizOrder.getHeight(); // 高
String remark = bizOrder.getRemark(); // 备注
BizCustomer bizCustomer = bizCustomerMapper.selectByLinkPhone(SecurityUtils.getUsername());
Long customerId = bizCustomer.getId();
bizOrder.setCustomerId(customerId);
bizOrder.setCustomerName(bizCustomer.getName());
LambdaQueryWrapper<BizCustomerRoute> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BizCustomerRoute::getCustomerId,customerId);
queryWrapper.eq(BizCustomerRoute::getName,routeName);
queryWrapper.eq(BizCustomerRoute::getStatus,"1");
BizCustomerRoute bizCustomerRoute = bizCustomerRouteMapper.selectOne(queryWrapper);
bizOrder.setRouteId(bizCustomerRoute.getId());
LambdaQueryWrapper<BizCustomerWarehouse> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(BizCustomerWarehouse::getCustomerId,customerId);
queryWrapper1.eq(BizCustomerWarehouse::getName,warehouseName);
queryWrapper1.eq(BizCustomerWarehouse::getStatus,1);
BizCustomerWarehouse bizCustomerWarehouse = bizCustomerWarehouseMapper.selectOne(queryWrapper1);
bizOrder.setWarehouseId(bizCustomerWarehouse.getId());
// 发件人信息就是仓库信息
bizOrder.setSenderName(bizCustomerWarehouse.getName());
bizOrder.setSenderLinkman(bizCustomerWarehouse.getLinkman());
bizOrder.setSenderPhone(bizCustomerWarehouse.getLinkphone());
bizOrder.setSenderAddress(bizCustomerWarehouse.getAddress());
bizOrder.setSenderLng(bizCustomerWarehouse.getLng());
bizOrder.setSenderLat(bizCustomerWarehouse.getLat());
LambdaQueryWrapper<BizCustomerShop> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(BizCustomerShop::getCustomerId,customerId);
queryWrapper2.eq(BizCustomerShop::getName,shopName);
queryWrapper2.eq(BizCustomerShop::getStatus,1);
BizCustomerShop bizCustomerShop = bizCustomerShopMapper.selectOne(queryWrapper2);
bizOrder.setShopId(bizCustomerShop.getId());
// 收件人信息就是店铺信息
bizOrder.setReceiverName(bizCustomerShop.getName());
bizOrder.setReceiverLinkman(bizCustomerShop.getLinkman());
bizOrder.setReceiverPhone(bizCustomerShop.getLinkphone());
bizOrder.setReceiverAddress(bizCustomerShop.getAddress());
bizOrder.setReceiverLng(bizCustomerShop.getLng());
bizOrder.setReceiverLat(bizCustomerShop.getLat());
bizOrder.setGoodsType(goodsType);
bizOrder.setGoodsName(goodsName);
bizOrder.setWeight(weight);
bizOrder.setLength(length);
bizOrder.setWidth(width);
bizOrder.setHeight(height);
if (ObjectUtil.isNotEmpty(length) && ObjectUtil.isNotEmpty(width) && ObjectUtil.isNotEmpty(height)){
bizOrder.setVolume(length.multiply(width).multiply(height));
}
bizOrder.setRemark(remark);
}
// 订单号生成规则
private void setBizOrderSn(BizOrder bizOrder) {
String format = DateUtil.format(new Date(), "yyyyMMdd"); // 20241220
String orderSn;
BizOrder order = bizOrderMapper.selectLastestOrder();
if (order == null){
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;
}
bizOrder.setOrderSn(orderSn);
}
} }

View File

@ -0,0 +1,144 @@
package com.cpxt.biz.service.impl;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import cn.hutool.captcha.generator.RandomGenerator;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.cpxt.biz.domain.BizCar;
import com.cpxt.biz.domain.BizOrderTask;
import com.cpxt.biz.mapper.BizOrderTaskMapper;
import com.cpxt.biz.service.IBizOrderTaskService;
import com.cpxt.common.utils.DateUtils;
import com.cpxt.quartz.domain.SysJob;
import com.cpxt.quartz.mapper.SysJobMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service
*
* @author ruoyi
* @date 2024-12-20
*/
@Service
public class BizOrderTaskServiceImpl implements IBizOrderTaskService
{
@Autowired
private BizOrderTaskMapper bizOrderTaskMapper;
@Autowired
private SysJobMapper sysJobMapper;
/**
*
*
* @param id
* @return
*/
@Override
public BizOrderTask selectBizOrderTaskById(Integer id)
{
return bizOrderTaskMapper.selectById(id);
}
/**
*
*
* @param bizOrderTask
* @return
*/
@Override
public List<BizOrderTask> selectBizOrderTaskList(BizOrderTask bizOrderTask)
{
LambdaQueryWrapper<BizOrderTask> queryWrapper = new LambdaQueryWrapper<>();
return bizOrderTaskMapper.selectList(queryWrapper);
}
/**
*
*
* @param bizOrderTask
* @return
*/
@Override
public int insertBizOrderTask(BizOrderTask bizOrderTask)
{
String uuid = UUID.randomUUID().toString();
SysJob sysJob = new SysJob();
sysJob.setJobName(bizOrderTask.getName());
sysJob.setInvokeTarget("orderTask.generateOrder('" + uuid +"')");
sysJob.setCronExpression(bizOrderTask.getCronExpression());
sysJob.setMisfirePolicy(bizOrderTask.getMisfirePolicy());
sysJob.setConcurrent(bizOrderTask.getConcurrent());
sysJob.setStatus(bizOrderTask.getStatus());
sysJob.setCreateBy(bizOrderTask.getCreateBy());
sysJob.setCreateTime(bizOrderTask.getCreateTime());
sysJob.setUpdateBy(bizOrderTask.getUpdateBy());
sysJob.setUpdateTime(bizOrderTask.getUpdateTime());
sysJob.setRemark(bizOrderTask.getRemark());
sysJobMapper.insertJob(sysJob);
bizOrderTask.setCode(uuid);
bizOrderTask.setJobId(sysJob.getJobId());
return bizOrderTaskMapper.insert(bizOrderTask);
}
/**
*
*
* @param bizOrderTask
* @return
*/
@Override
public int updateBizOrderTask(BizOrderTask bizOrderTask)
{
// 同步修改订单任务
SysJob sysJob = sysJobMapper.selectJobById(bizOrderTask.getJobId());
sysJob.setJobName(bizOrderTask.getName());
sysJob.setCronExpression(bizOrderTask.getCronExpression());
sysJob.setMisfirePolicy(bizOrderTask.getMisfirePolicy());
sysJob.setConcurrent(bizOrderTask.getConcurrent());
sysJob.setStatus(bizOrderTask.getStatus());
sysJob.setCreateBy(bizOrderTask.getCreateBy());
sysJob.setCreateTime(bizOrderTask.getCreateTime());
sysJob.setUpdateBy(bizOrderTask.getUpdateBy());
sysJob.setUpdateTime(bizOrderTask.getUpdateTime());
sysJob.setRemark(bizOrderTask.getRemark());
sysJobMapper.updateJob(sysJob);
return bizOrderTaskMapper.updateById(bizOrderTask);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteBizOrderTaskByIds(Integer[] ids)
{
// 同步删除job表中的任务
for (Integer id : ids) {
Long jobId = bizOrderTaskMapper.selectById(id).getJobId();
sysJobMapper.deleteJobById(jobId);
}
return bizOrderTaskMapper.deleteBatchIds(Arrays.asList(ids));
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteBizOrderTaskById(Integer id)
{
return bizOrderTaskMapper.deleteById(id);
}
}