|
|
|
@ -50,39 +50,39 @@ public class LogisticsOrderController { |
|
|
|
@Autowired |
|
|
|
private SecurityUtil securityUtil; |
|
|
|
|
|
|
|
@PostMapping(value = "/addLogisticsOrder") |
|
|
|
@PostMapping("/addLogisticsOrder") |
|
|
|
@ApiOperation("新增物流订单") |
|
|
|
public Result addLogisticsOrder(@RequestBody LogisticsOrder logisticsOrder) { |
|
|
|
//单号命名规则 物流公司首字母-yyyyMMdd-递增流水号
|
|
|
|
String orderNumber = PinYinUtils.getFirstSpell(logisticsOrder.getCompanyName())+"-"+ DateUtil.COMPAT.getDateText(new Date())+"-"; |
|
|
|
String orderNumber = PinYinUtils.getFirstSpell(logisticsOrder.getCompanyName()) + '-' + DateUtil.COMPAT.getDateText(new Date()) + '-'; |
|
|
|
//查询一下这个物流公司,今天最后一条数据的单号是多少,如果没有,默认为1
|
|
|
|
LogisticsOrder lastOrder = logisticsOrderService.getLogisticsOrderByCompanyId(logisticsOrder); |
|
|
|
if(lastOrder != null){ |
|
|
|
int newNumber = Integer.parseInt(lastOrder.getOrderNumber().split("-")[2])+1; |
|
|
|
final LogisticsOrder lastOrder = logisticsOrderService.getLogisticsOrderByCompanyId(logisticsOrder); |
|
|
|
if (lastOrder != null) { |
|
|
|
final int newNumber = Integer.parseInt(lastOrder.getOrderNumber().split("-")[2]) + 1; |
|
|
|
orderNumber += newNumber; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
orderNumber += 1; |
|
|
|
} |
|
|
|
logisticsOrder.setOrderNumber(orderNumber); |
|
|
|
// 设置创建人姓名
|
|
|
|
final LogiticsCompany logiticsCompany = securityUtil.getCurrCompany(); |
|
|
|
logisticsOrder.setCreateBy(logiticsCompany.getId()); |
|
|
|
logisticsOrder.setCreateByName(logiticsCompany.getContacts()); |
|
|
|
final LogiticsCompany logiticsCompany = securityUtil.getCurrCompany(); |
|
|
|
logisticsOrder.setCreateBy(logiticsCompany.getId()); |
|
|
|
logisticsOrder.setCreateByName(logiticsCompany.getContacts()); |
|
|
|
// 20241015 保存收发货人地址簿,先保存地址簿,方便后边获取收发货人id
|
|
|
|
boolean b = logisticsAddressBookService.saveLogisticsAddressBook(logisticsOrder); |
|
|
|
if(b){ |
|
|
|
final boolean b = logisticsAddressBookService.saveLogisticsAddressBook(logisticsOrder); |
|
|
|
if (b) { |
|
|
|
// 获取收货人id
|
|
|
|
Map<String, LogisticsAddressBook> logisticsAddressBook = logisticsAddressBookService.getByOrder(logisticsOrder); |
|
|
|
if(logisticsAddressBook.containsKey("shipperLogisticsAddressBook")){ |
|
|
|
final Map<String, LogisticsAddressBook> logisticsAddressBook = logisticsAddressBookService.getByOrder(logisticsOrder); |
|
|
|
if (logisticsAddressBook.containsKey("shipperLogisticsAddressBook")) { |
|
|
|
logisticsOrder.setShipperId(logisticsAddressBook.get("shipperLogisticsAddressBook").getId()); |
|
|
|
} |
|
|
|
|
|
|
|
if(logisticsAddressBook.containsKey("receiverLogisticsAddressBook")){ |
|
|
|
if (logisticsAddressBook.containsKey("receiverLogisticsAddressBook")) { |
|
|
|
logisticsOrder.setReceiverId(logisticsAddressBook.get("receiverLogisticsAddressBook").getId()); |
|
|
|
} |
|
|
|
logisticsOrderService.saveOrUpdate(logisticsOrder); |
|
|
|
return ResultUtil.success("保存成功!"); |
|
|
|
}else{ |
|
|
|
return ResultUtil.data(logisticsOrder); |
|
|
|
} else { |
|
|
|
return ResultUtil.success("保存失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -95,36 +95,55 @@ public class LogisticsOrderController { |
|
|
|
* @author 王富康 |
|
|
|
* @date 2024/8/24 |
|
|
|
*/ |
|
|
|
@PostMapping(value = "/updateLogisticsOrder") |
|
|
|
@PostMapping("/updateLogisticsOrder") |
|
|
|
@ApiOperation("更新物流订单") |
|
|
|
public Result updateLogisticsOrder(@RequestBody LogisticsOrder logisticsOrder) { |
|
|
|
if (StringUtils.isEmpty(logisticsOrder.getId())) { |
|
|
|
return ResultUtil.error("订单id不能为空!"); |
|
|
|
} |
|
|
|
//先查询出旧的数据
|
|
|
|
LogisticsOrder oldLogisticsOrder = logisticsOrderService.getById(logisticsOrder.getId()); |
|
|
|
final LogisticsOrder oldLogisticsOrder = logisticsOrderService.getById(logisticsOrder.getId()); |
|
|
|
// 设置创建人姓名
|
|
|
|
final LogiticsCompany logiticsCompany = securityUtil.getCurrCompany(); |
|
|
|
logisticsOrder.setUpdateBy(logiticsCompany.getId()); |
|
|
|
final boolean b = logisticsOrderService.saveOrUpdate(logisticsOrder); |
|
|
|
// 根据收发货人获取信息,如果名字变了,那么修改收发货人的信息
|
|
|
|
// 设置创建人姓名
|
|
|
|
logisticsOrder.setCreateBy(logiticsCompany.getId()); |
|
|
|
logisticsOrder.setCreateByName(logiticsCompany.getContacts()); |
|
|
|
// 20241015 保存收发货人地址簿,先保存地址簿,方便后边获取收发货人id
|
|
|
|
final boolean b = logisticsAddressBookService.saveLogisticsAddressBook(logisticsOrder); |
|
|
|
if (b) { |
|
|
|
//如果更新成功,把修改记录保存一下
|
|
|
|
Gson gson = new Gson(); |
|
|
|
LogisticsOrderChangeLog logisticsOrderChangeLog = new LogisticsOrderChangeLog(); |
|
|
|
logisticsOrderChangeLog.setCreateBy(logiticsCompany.getId()); |
|
|
|
logisticsOrderChangeLog.setCreateByName(logiticsCompany.getContacts()); |
|
|
|
logisticsOrderChangeLog.setOldData(gson.toJson(oldLogisticsOrder)); |
|
|
|
logisticsOrderChangeLog.setNewData(gson.toJson(logisticsOrder)); |
|
|
|
logisticsOrderChangeLog.setOrderId(logisticsOrder.getId()); |
|
|
|
logisticsOrderChangeLog.setCreateTime(new Date()); |
|
|
|
int status = logisticsOrderService.saveLogisticsOrderChangeLog(logisticsOrderChangeLog); |
|
|
|
if(status == 0){ |
|
|
|
return ResultUtil.error("保存修改记录失败!"); |
|
|
|
// 获取收货人id
|
|
|
|
final Map<String, LogisticsAddressBook> logisticsAddressBook = logisticsAddressBookService.getByOrder(logisticsOrder); |
|
|
|
if (logisticsAddressBook.containsKey("shipperLogisticsAddressBook")) { |
|
|
|
logisticsOrder.setShipperId(logisticsAddressBook.get("shipperLogisticsAddressBook").getId()); |
|
|
|
} |
|
|
|
|
|
|
|
if (logisticsAddressBook.containsKey("receiverLogisticsAddressBook")) { |
|
|
|
logisticsOrder.setReceiverId(logisticsAddressBook.get("receiverLogisticsAddressBook").getId()); |
|
|
|
} |
|
|
|
final boolean a = logisticsOrderService.saveOrUpdate(logisticsOrder); |
|
|
|
if (a) { |
|
|
|
//如果更新成功,把修改记录保存一下
|
|
|
|
final Gson gson = new Gson(); |
|
|
|
final LogisticsOrderChangeLog logisticsOrderChangeLog = new LogisticsOrderChangeLog(); |
|
|
|
logisticsOrderChangeLog.setCreateBy(logiticsCompany.getId()); |
|
|
|
logisticsOrderChangeLog.setCreateByName(logiticsCompany.getContacts()); |
|
|
|
logisticsOrderChangeLog.setOldData(gson.toJson(oldLogisticsOrder)); |
|
|
|
logisticsOrderChangeLog.setNewData(gson.toJson(logisticsOrder)); |
|
|
|
logisticsOrderChangeLog.setOrderId(logisticsOrder.getId()); |
|
|
|
logisticsOrderChangeLog.setCreateTime(new Date()); |
|
|
|
final int status = logisticsOrderService.saveLogisticsOrderChangeLog(logisticsOrderChangeLog); |
|
|
|
if (status == 0) { |
|
|
|
return ResultUtil.error("保存修改记录失败!"); |
|
|
|
} |
|
|
|
|
|
|
|
return ResultUtil.success("保存成功!"); |
|
|
|
} else { |
|
|
|
return ResultUtil.error("保存失败!"); |
|
|
|
} |
|
|
|
return ResultUtil.success("保存成功!"); |
|
|
|
} else { |
|
|
|
return ResultUtil.error("保存失败!"); |
|
|
|
} |
|
|
|
return ResultUtil.error("保存成功!"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -135,7 +154,7 @@ public class LogisticsOrderController { |
|
|
|
* @author 王富康 |
|
|
|
* @date 2024/8/24 |
|
|
|
*/ |
|
|
|
@PostMapping(value = "/deleteLogisticsOrder") |
|
|
|
@PostMapping("/deleteLogisticsOrder") |
|
|
|
@ApiOperation("删除物流订单") |
|
|
|
public Result deleteLogisticsOrder(String id) { |
|
|
|
if (StringUtils.isEmpty(id)) { |
|
|
|
@ -158,7 +177,7 @@ public class LogisticsOrderController { |
|
|
|
* @date 2024/8/24 |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/getLogisticsOrderPageList", method = RequestMethod.POST) |
|
|
|
@ApiOperation(value = "分页查询物流订单") |
|
|
|
@ApiOperation("分页查询物流订单") |
|
|
|
public Result<IPage<LogisticsOrder>> getLogisticsOrderPageList(@RequestBody(required = false) LogisticsOrderQueryVo logisticsOrderQueryVo) { |
|
|
|
final IPage<LogisticsOrder> result = logisticsOrderService.getLogisticsOrderPageList(logisticsOrderQueryVo); |
|
|
|
return new ResultUtil<IPage<LogisticsOrder>>().setData(result); |
|
|
|
@ -166,12 +185,13 @@ public class LogisticsOrderController { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查询订单的修改记录 |
|
|
|
* 查询订单的修改记录 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/getLogisticsOrderChangeLog", method = RequestMethod.GET) |
|
|
|
@ApiOperation(value = "查询物流订单修改记录") |
|
|
|
@ApiOperation("查询物流订单修改记录") |
|
|
|
public Result<List<LogisticsOrderChangeLogVo>> getLogisticsOrderChangeLog(String orderId) { |
|
|
|
|
|
|
|
return new ResultUtil<List<LogisticsOrderChangeLogVo>>().setData(logisticsOrderService.getLogisticsOrderChangeLog(orderId)); |
|
|
|
@ -179,49 +199,52 @@ public class LogisticsOrderController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询物流订单详情 |
|
|
|
* @author 王富康 |
|
|
|
* @date 2024/9/5 |
|
|
|
* |
|
|
|
* @param orderId |
|
|
|
* @return Result<LogisticsOrder> |
|
|
|
* @author 王富康 |
|
|
|
* @date 2024/9/5 |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/getLogisticsOrderDetail", method = RequestMethod.GET) |
|
|
|
@ApiOperation(value = "查询物流订单详情") |
|
|
|
@ApiOperation("查询物流订单详情") |
|
|
|
public Result<LogisticsOrder> getLogisticsOrderDetail(String orderId) { |
|
|
|
return new ResultUtil<LogisticsOrder>().setData(logisticsOrderService.getById(orderId)); |
|
|
|
} |
|
|
|
|
|
|
|
// 数据统计(可按照线路、物流公司、到达站搜索):客户总运费、运单数、客户数、运输费、装车费、小费、保费
|
|
|
|
@RequestMapping(value = "/getLogisticsOrderStatistics", method = RequestMethod.POST) |
|
|
|
@ApiOperation(value = "物流订单数据统计") |
|
|
|
@ApiOperation("物流订单数据统计") |
|
|
|
public Result getLogisticsOrderStatistics(@RequestBody(required = false) LogisticsOrderQueryVo logisticsOrderQueryVo) { |
|
|
|
try{ |
|
|
|
try { |
|
|
|
return new ResultUtil<StatisticsVo>().setData(logisticsOrderService.getLogisticsOrderStatistics(logisticsOrderQueryVo)); |
|
|
|
}catch (Exception e){ |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
return ResultUtil.error("查询物流统计失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 批量更新订单状态 |
|
|
|
* @author 王富康 |
|
|
|
* @date 2024/11/15 |
|
|
|
* |
|
|
|
* @param orderIds |
|
|
|
* @param status |
|
|
|
* @return Result |
|
|
|
* @author 王富康 |
|
|
|
* @date 2024/11/15 |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/batchUpdateOrderStatus", method = RequestMethod.POST) |
|
|
|
@ApiOperation(value = "批量更新订单状态") |
|
|
|
@ApiOperation("批量更新订单状态") |
|
|
|
public Result batchUpdateOrderStatus(String orderIds, String status) { |
|
|
|
if(StringUtils.isEmpty(orderIds)){ |
|
|
|
if (StringUtils.isEmpty(orderIds)) { |
|
|
|
return ResultUtil.error("订单id不能为空!"); |
|
|
|
} |
|
|
|
if(StringUtils.isEmpty(status)){ |
|
|
|
if (StringUtils.isEmpty(status)) { |
|
|
|
return ResultUtil.error("订单状态不能为空!"); |
|
|
|
} |
|
|
|
try{ |
|
|
|
try { |
|
|
|
logisticsOrderService.batchUpdateOrderStatus(orderIds, status); |
|
|
|
return ResultUtil.error("批量更新订单状态成功!"); |
|
|
|
}catch (Exception e){ |
|
|
|
} catch (Exception e) { |
|
|
|
return ResultUtil.error("批量更新订单状态失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|