|
|
@@ -1,14 +1,14 @@
|
|
|
package com.sckw.transport.service;
|
|
|
|
|
|
-import com.alibaba.fastjson2.JSON;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
-import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.constant.NumberConstant;
|
|
|
import com.sckw.core.model.enums.*;
|
|
|
+import com.sckw.core.model.page.PageHelperUtil;
|
|
|
import com.sckw.core.model.page.PageResult;
|
|
|
+import com.sckw.core.model.vo.TableTop;
|
|
|
import com.sckw.core.utils.*;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
@@ -17,26 +17,16 @@ import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.fleet.api.RemoteFleetService;
|
|
|
import com.sckw.fleet.api.model.vo.RDriverVo;
|
|
|
import com.sckw.fleet.api.model.vo.RTruckVo;
|
|
|
-import com.sckw.mongo.enums.BusinessTypeEnum;
|
|
|
-import com.sckw.mongo.model.SckwLogisticsOrder;
|
|
|
-import com.sckw.mongo.model.SckwWaybillOrder;
|
|
|
import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
-import com.sckw.redis.constant.RedisConstant;
|
|
|
-import com.sckw.redis.utils.RedissonUtils;
|
|
|
-import com.sckw.stream.enums.MessageEnum;
|
|
|
-import com.sckw.stream.model.SckwBusSum;
|
|
|
-import com.sckw.stream.model.SckwMessage;
|
|
|
-import com.sckw.stream.model.UserInfo;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
-import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
+import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
|
import com.sckw.transport.dao.*;
|
|
|
import com.sckw.transport.model.*;
|
|
|
import com.sckw.transport.model.dto.*;
|
|
|
+import com.sckw.transport.model.enuma.CarWaybillTableTopEnum;
|
|
|
import com.sckw.transport.model.vo.*;
|
|
|
import jakarta.annotation.Resource;
|
|
|
-import jakarta.servlet.http.HttpServletRequest;
|
|
|
-import jakarta.validation.Valid;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -44,9 +34,6 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.cloud.stream.function.StreamBridge;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
@@ -79,14 +66,10 @@ public class KwtWaybillOrderV1Service {
|
|
|
@Autowired
|
|
|
KwtWaybillOrderSubtaskMapper waybillOrderSubtaskDao;
|
|
|
@Autowired
|
|
|
- KwtLogisticsOrderUnitMapper logisticsOrderUnitDao;
|
|
|
+ KwtLogisticsOrderAmountMapper logisticsOrderAmountDao;
|
|
|
@Autowired
|
|
|
KwtLogisticsOrderGoodsMapper logisticsOrderGoodsDao;
|
|
|
@Autowired
|
|
|
- KwtLogisticsOrderCirculateMapper logisticsOrderCirculateDao;
|
|
|
- @Autowired
|
|
|
- KwtLogisticsOrderAmountMapper logisticsOrderAmountDao;
|
|
|
- @Autowired
|
|
|
KwtWaybillOrderTicketService waybillOrderTicketService;
|
|
|
@Autowired
|
|
|
KwtLogisticsOrderGoodsService kwtLogisticsOrderGoodsService;
|
|
|
@@ -107,6 +90,80 @@ public class KwtWaybillOrderV1Service {
|
|
|
@Value("${message.waybill.refuseSendCar.pc}")
|
|
|
private String refuseSendCarPcUrl;
|
|
|
|
|
|
+ /**
|
|
|
+ * @param params 请求参数
|
|
|
+ * @desc 统计
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/8
|
|
|
+ **/
|
|
|
+ public List<TableTop> statistics(WaybillOrderQueryDto params){
|
|
|
+ //统计信息
|
|
|
+ List<TableTop> tableTops = waybillOrderV1Dao.statistics(params);
|
|
|
+
|
|
|
+ //数据处理
|
|
|
+ List<TableTop> topList = new ArrayList<>();
|
|
|
+ for (CarWaybillTableTopEnum entity:CarWaybillTableTopEnum.values()) {
|
|
|
+ TableTop top = new TableTop();
|
|
|
+ top.setName(entity.getName());
|
|
|
+ top.setValue(entity.getCode());
|
|
|
+ top.setTotal(Global.NUMERICAL_ZERO);
|
|
|
+ if (entity.getValue() == null) {
|
|
|
+ //全部数据
|
|
|
+ int totalCount = tableTops.stream().mapToInt(TableTop::getTotal).sum();
|
|
|
+ top.setTotal(totalCount);
|
|
|
+ } else {
|
|
|
+ tableTops.stream().filter(table -> entity.getValue().contains(String.valueOf(table.getValue()))).findAny().ifPresent(tableTop -> top.setTotal(tableTop.getTotal()));
|
|
|
+ }
|
|
|
+ topList.add(top);
|
|
|
+ }
|
|
|
+ return topList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params {page:页数、pageSize:每页条数、。。。}
|
|
|
+ * @desc 分页查询
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/8
|
|
|
+ **/
|
|
|
+ public PageResult findListPage(WaybillOrderQueryDto params){
|
|
|
+ params.setEntId(LoginUserHolder.getEntId());
|
|
|
+ // 设置分页参数
|
|
|
+ PageHelper.startPage(params.getPage(), params.getPageSize());
|
|
|
+ params.setQueryWstatus(CarWaybillTableTopEnum.getValue(params.getStatus()));
|
|
|
+ List<WaybillOrderSelectVo> list = waybillOrderV1Dao.findListPage(params);
|
|
|
+ for (WaybillOrderSelectVo waybillOrder:list) {
|
|
|
+ waybillOrder.setStatusLabel(CarWaybillEnum.getName(waybillOrder.getStatus()));
|
|
|
+ }
|
|
|
+ PageResult pageResult = PageHelperUtil.getPageResult(new PageInfo<>(list));
|
|
|
+ return pageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params {page:页数、pageSize:每页条数、。。。}
|
|
|
+ * @desc 分页查询
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/8
|
|
|
+ **/
|
|
|
+ public PageResult findNdexPage(WaybillOrderQueryDto params){
|
|
|
+ params.setEntId(LoginUserHolder.getEntId());
|
|
|
+ // 设置分页参数
|
|
|
+ PageHelper.startPage(params.getPage(), params.getPageSize());
|
|
|
+ params.setQueryWstatus(CarWaybillTableTopEnum.getValue(params.getStatus()));
|
|
|
+ List<WaybillOrderSelectVo> list = waybillOrderV1Dao.findListPage(params);
|
|
|
+ for (WaybillOrderSelectVo waybillOrder:list) {
|
|
|
+ waybillOrder.setStatusLabel(CarWaybillEnum.getName(waybillOrder.getStatus()));
|
|
|
+ }
|
|
|
+ PageResult pageResult = PageHelperUtil.getPageResult(new PageInfo<>(list));
|
|
|
+ return pageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @param params 派车参数
|
|
|
* @desc 派车-多装多卸
|
|
|
@@ -1458,6 +1515,171 @@ public class KwtWaybillOrderV1Service {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param wOrderId 运单ID
|
|
|
+ * @desc 修改单证查询运单
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/11
|
|
|
+ **/
|
|
|
+ public HttpResult ticketApproval(Long wOrderId) {
|
|
|
+ //车辆运单信息
|
|
|
+ KwtWaybillOrderV1 waybillOrder = waybillOrderV1Dao.selectById(wOrderId);
|
|
|
+ if (waybillOrder == null) {
|
|
|
+ return HttpResult.ok("车辆运单信息不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //操作人
|
|
|
+ List<KwtWaybillOrderTicket> tickets = waybillOrderTicketDao.findWaybillOrderTicket(wOrderId, null, null);
|
|
|
+ List<Long> userIds = tickets.stream().map(KwtWaybillOrderTicket::getCreateBy).toList();
|
|
|
+ List<UserCacheResDto> users = remoteSystemService.queryUserCacheByIds(userIds);
|
|
|
+ Map<Long, UserCacheResDto> usersMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
+ users.forEach(e -> usersMap.put(e.getId(), e));
|
|
|
+
|
|
|
+ /*数据处理*/
|
|
|
+ List<Map<String, Object>> addressList = new ArrayList<>();
|
|
|
+ List<Integer> typeList = new ArrayList<>(){{add(AddressDefaultTypeEnum.SHIPMENT.getCode()); add(AddressDefaultTypeEnum.TAKE.getCode());}};
|
|
|
+ for (Integer type:typeList) {
|
|
|
+ //装货地址
|
|
|
+ List<KwtWaybillOrderAddress> addresses = waybillOrderAddressDao.findByAddresses(wOrderId, type);
|
|
|
+ for (KwtWaybillOrderAddress address:addresses) {
|
|
|
+ //子单信息
|
|
|
+ KwtWaybillOrderSubtask subtask = waybillOrderSubtaskDao.selectById(address.getWSubtaskId());
|
|
|
+ //物流订单商品信息
|
|
|
+ KwtLogisticsOrderGoods goods = logisticsOrderGoodsDao.findByGoods(subtask != null ? subtask.getLOrderId() : null);
|
|
|
+ //榜单信息
|
|
|
+ KwtWaybillOrderTicket ticket = waybillOrderTicketDao.findWaybillOrderTicketV2(address.getId(), subtask.getUnit());
|
|
|
+ //辅助单位
|
|
|
+ List<WaybillOrderLoadingVO> loading = waybillOrderTicketService.agreementV1(subtask, type);
|
|
|
+
|
|
|
+ Map<String, Object> trackData = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ trackData.put("wTicketId", ticket != null ? ticket.getId() : null);
|
|
|
+ trackData.put("wOrderId", ticket != null ? ticket.getWOrderId() : null);
|
|
|
+ trackData.put("wSubtaskId", ticket != null ? ticket.getWSubtaskId() : null);
|
|
|
+ trackData.put("wAddressId", ticket != null ? ticket.getWAddressId() : null);
|
|
|
+ trackData.put("urls", ticket != null ? FileUtils.spliceBatch(ticket.getUrls()) : null);
|
|
|
+ trackData.put("operateTime", ticket != null ? DateUtil.dateTimeFormatter(ticket.getOperateTime()) : null);
|
|
|
+ trackData.put("createTime", ticket != null ? DateUtil.dateTimeFormatter(ticket.getCreateTime()) : null);
|
|
|
+ trackData.put("approvalStatus", ticket != null ? ticket.getStatus() : null);
|
|
|
+ trackData.put("createByName", ticket != null ? usersMap.get(ticket.getCreateBy()) == null ? waybillOrder.getDriverName() : usersMap.get(ticket.getCreateBy()).getName() : null);
|
|
|
+ trackData.put("cityName", address.getCityName());
|
|
|
+ trackData.put("detailAddress", address.getDetailAddress());
|
|
|
+ trackData.put("goodsName", goods != null ? goods.getGoodsName() : null);
|
|
|
+ trackData.put("loading", loading);
|
|
|
+ addressList.add(trackData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> result = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
+ result.put("wOrderId", wOrderId);
|
|
|
+ result.put("wOrderNo", waybillOrder.getWOrderNo());
|
|
|
+ result.put("status", waybillOrder.getStatus());
|
|
|
+ result.put("statusName", CarWaybillEnum.getName(waybillOrder.getStatus()));
|
|
|
+ result.put("truckNo", waybillOrder.getTruckNo());
|
|
|
+ result.put("driverName", waybillOrder.getDriverName());
|
|
|
+ result.put("driverPhone", waybillOrder.getDriverPhone());
|
|
|
+ result.put("driverIdcard", waybillOrder.getDriverIdcard());
|
|
|
+ result.put("createTime", waybillOrder.getCreateTime());
|
|
|
+ result.put("addressList", addressList);
|
|
|
+ return HttpResult.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param wOrderId 运单ID
|
|
|
+ * @desc 修改单证查询运单
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/11
|
|
|
+ **/
|
|
|
+ public HttpResult ticketWaybillOrder(Long wOrderId) {
|
|
|
+ //车辆运单信息
|
|
|
+ KwtWaybillOrderV1 waybillOrder = waybillOrderV1Dao.selectById(wOrderId);
|
|
|
+ if (waybillOrder == null) {
|
|
|
+ return HttpResult.ok("车辆运单信息不存在!");
|
|
|
+ }
|
|
|
+ //运单状态
|
|
|
+ List<KwtWaybillOrderTrack> tracks = waybillOrderTrackDao.findTrack(wOrderId, null, null, null);
|
|
|
+ //操作人
|
|
|
+ List<Long> userIds = tracks.stream().map(KwtWaybillOrderTrack::getCreateBy).toList();
|
|
|
+ List<UserCacheResDto> users = remoteSystemService.queryUserCacheByIds(userIds);
|
|
|
+ Map<Long, UserCacheResDto> usersMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
+ users.forEach(e -> usersMap.put(e.getId(), e));
|
|
|
+
|
|
|
+ /*数据处理*/
|
|
|
+ List<Map<String, Object>> trackList = new ArrayList<>();
|
|
|
+ //运单状态(待接单、待出车、出车)
|
|
|
+ List<Integer> statusList = CarWaybillEnum.initWaybillStatusV1();
|
|
|
+ for (Integer status:statusList) {
|
|
|
+ KwtWaybillOrderTrack track = waybillOrderTrackDao.findWaybillOrderTrack(wOrderId, null, null, status);
|
|
|
+ Map<String, Object> trackData = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ trackData.put("id", track != null ? track.getId() : null);
|
|
|
+ trackData.put("wOrderId", track != null ? track.getWOrderId() : null);
|
|
|
+ trackData.put("wSubtaskId", track != null ? track.getWSubtaskId() : null);
|
|
|
+ trackData.put("wAddressId", track != null ? track.getWAddressId() : null);
|
|
|
+ trackData.put("operateTime", track != null ? track.getOperateTime() : null);
|
|
|
+ trackData.put("createTime", track != null ? track.getCreateTime() : null);
|
|
|
+ trackData.put("createByName", track != null ? usersMap.get(track.getCreateBy()) == null ? waybillOrder.getDriverName() : usersMap.get(track.getCreateBy()).getName() : null);
|
|
|
+ trackData.put("status", status);
|
|
|
+ trackData.put("statusName", CarWaybillEnum.getName(status));
|
|
|
+ trackData.put("operateStatus", track != null);
|
|
|
+ trackList.add(trackData);
|
|
|
+ }
|
|
|
+
|
|
|
+ //运单状态处理(到达装货点、已装货、到达卸货点、已卸货)
|
|
|
+ List<KwtWaybillOrderAddress> addresses = waybillOrderAddressDao.findByAddresses(wOrderId, null);
|
|
|
+ for (KwtWaybillOrderAddress address:addresses) {
|
|
|
+ if (address.getAddressType().equals(AddressDefaultTypeEnum.SHIPMENT.getCode())) {
|
|
|
+ statusList = new ArrayList<>(){{add(CarWaybillEnum.WAIT_LOADING.getCode()); add(CarWaybillEnum.COMPLETION_LOADING.getCode());}};
|
|
|
+ } else {
|
|
|
+ statusList = new ArrayList<>(){{add(CarWaybillEnum.WAIT_UNLOADING.getCode()); add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());}};
|
|
|
+ }
|
|
|
+
|
|
|
+ //子单信息
|
|
|
+ KwtWaybillOrderSubtask subtask = waybillOrderSubtaskDao.selectById(address.getWSubtaskId());
|
|
|
+ //物流订单商品信息
|
|
|
+ KwtLogisticsOrderGoods goods = logisticsOrderGoodsDao.findByGoods(subtask != null ? subtask.getLOrderId() : null);
|
|
|
+ for (Integer status:statusList) {
|
|
|
+ KwtWaybillOrderTrack track = waybillOrderTrackDao.findWaybillOrderTrack(wOrderId, null, null, status);
|
|
|
+ Map<String, Object> trackData = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ trackData.put("id", track != null ? track.getId() : null);
|
|
|
+ trackData.put("wOrderId", track != null ? track.getWOrderId() : null);
|
|
|
+ trackData.put("wSubtaskId", track != null ? track.getWSubtaskId() : null);
|
|
|
+ trackData.put("wAddressId", track != null ? track.getWAddressId() : null);
|
|
|
+ trackData.put("operateTime", track != null ? track.getOperateTime() : null);
|
|
|
+ trackData.put("createTime", track != null ? track.getCreateTime() : null);
|
|
|
+ trackData.put("createByName", track != null ? usersMap.get(track.getCreateBy()) == null ? waybillOrder.getDriverName() : usersMap.get(track.getCreateBy()).getName() : null);
|
|
|
+ trackData.put("status", status);
|
|
|
+ trackData.put("statusName", CarWaybillEnum.getName(status));
|
|
|
+ trackData.put("operateStatus", track != null);
|
|
|
+ trackData.put("planTime", track != null ? address.getPlanTime() : null);
|
|
|
+ trackData.put("entrustAmount", track != null ? address.getEntrustAmount() : null);
|
|
|
+ trackData.put("goodsName", goods != null ? goods.getGoodsName() : null);
|
|
|
+ trackList.add(trackData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> result = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
+ result.put("wOrderId", wOrderId);
|
|
|
+ result.put("wOrderNo", waybillOrder.getWOrderNo());
|
|
|
+ result.put("status", waybillOrder.getStatus());
|
|
|
+ result.put("statusName", CarWaybillEnum.getName(waybillOrder.getStatus()));
|
|
|
+ result.put("truckNo", waybillOrder.getTruckNo());
|
|
|
+ result.put("driverName", waybillOrder.getDriverName());
|
|
|
+ result.put("driverPhone", waybillOrder.getDriverPhone());
|
|
|
+ result.put("driverIdcard", waybillOrder.getDriverIdcard());
|
|
|
+ result.put("createTime", waybillOrder.getCreateTime());
|
|
|
+ result.put("trackList", trackList);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return HttpResult.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|