|
@@ -1,5 +1,7 @@
|
|
|
package com.sckw.transport.service;
|
|
package com.sckw.transport.service;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateField;
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -47,6 +49,7 @@ import com.sckw.transport.model.dto.*;
|
|
|
import com.sckw.transport.model.param.AcceptCarriageOrderQuery;
|
|
import com.sckw.transport.model.param.AcceptCarriageOrderQuery;
|
|
|
import com.sckw.transport.model.param.ConsignOrderQuery;
|
|
import com.sckw.transport.model.param.ConsignOrderQuery;
|
|
|
import com.sckw.transport.model.param.DriverParam;
|
|
import com.sckw.transport.model.param.DriverParam;
|
|
|
|
|
+import com.sckw.transport.model.param.LogisticsOrderStatisticsParam;
|
|
|
import com.sckw.transport.model.vo.*;
|
|
import com.sckw.transport.model.vo.*;
|
|
|
import com.sckw.transport.model.vo.execlVo.ConsignOrderExcelVo;
|
|
import com.sckw.transport.model.vo.execlVo.ConsignOrderExcelVo;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
@@ -62,11 +65,14 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
|
|
|
+import java.text.ParseException;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
+import static com.sckw.excel.utils.DateUtil.DEF_DATE_FORMAT;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @author lfdc
|
|
* @author lfdc
|
|
|
* @description 托运订单service
|
|
* @description 托运订单service
|
|
@@ -814,7 +820,7 @@ public class ConsignOrderService {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
/**是否是一级订单,是->推送至贸易,否,数据推送至物流订单上级*/
|
|
/**是否是一级订单,是->推送至贸易,否,数据推送至物流订单上级*/
|
|
|
- if (logisticsOrder.getPid() != null) {
|
|
|
|
|
|
|
+ if (logisticsOrder.getPid() == null && logisticsOrder.getType().equals("1")) {
|
|
|
//数据推送至贸易订单
|
|
//数据推送至贸易订单
|
|
|
CompleteLogisticsOrderParam tradeOrder = new CompleteLogisticsOrderParam();
|
|
CompleteLogisticsOrderParam tradeOrder = new CompleteLogisticsOrderParam();
|
|
|
//todo 2023-09-07 修改为不传递总量,只传递当前单据页面传递值
|
|
//todo 2023-09-07 修改为不传递总量,只传递当前单据页面传递值
|
|
@@ -1677,38 +1683,47 @@ public class ConsignOrderService {
|
|
|
vo.setUnloadAddress(vo.getUnloadCityName() + vo.getUnloadAddress());
|
|
vo.setUnloadAddress(vo.getUnloadCityName() + vo.getUnloadAddress());
|
|
|
vo.setPriceLabel(vo.getPriceType() == null ? null : priceDictData.get(vo.getPriceType()));
|
|
vo.setPriceLabel(vo.getPriceType() == null ? null : priceDictData.get(vo.getPriceType()));
|
|
|
if (vo.getTOrderId() != null) {
|
|
if (vo.getTOrderId() != null) {
|
|
|
- OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.valueOf(vo.getTOrderId()));
|
|
|
|
|
- if (orderDetailRes != null) {
|
|
|
|
|
- List<UnitInfoDetailRes> unitInfo = orderDetailRes.getUnitInfo();
|
|
|
|
|
- for (UnitInfoDetailRes detailRes : unitInfo) {
|
|
|
|
|
- if (String.valueOf(NumberConstant.ONE).equals(detailRes.getUnitType())) {
|
|
|
|
|
- vo.setShipmentsUnitEntId(String.valueOf(detailRes.getEntId()));
|
|
|
|
|
- vo.setShipmentsUnit(detailRes.getFirmName());
|
|
|
|
|
- } else {
|
|
|
|
|
- vo.setReceiveGoodsUnitEntId(String.valueOf(detailRes.getEntId()));
|
|
|
|
|
- vo.setReceiveGoodsUnit(detailRes.getFirmName());
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.valueOf(vo.getTOrderId()));
|
|
|
|
|
+ if (orderDetailRes != null) {
|
|
|
|
|
+ List<UnitInfoDetailRes> unitInfo = orderDetailRes.getUnitInfo();
|
|
|
|
|
+ for (UnitInfoDetailRes detailRes : unitInfo) {
|
|
|
|
|
+ if (String.valueOf(NumberConstant.ONE).equals(detailRes.getUnitType())) {
|
|
|
|
|
+ vo.setShipmentsUnitEntId(String.valueOf(detailRes.getEntId()));
|
|
|
|
|
+ vo.setShipmentsUnit(detailRes.getFirmName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ vo.setReceiveGoodsUnitEntId(String.valueOf(detailRes.getEntId()));
|
|
|
|
|
+ vo.setReceiveGoodsUnit(detailRes.getFirmName());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+// throw new RuntimeException(e);
|
|
|
|
|
+ log.info(vo.getTOrderId() + "查询错误:{}", e.getMessage(), e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
vo.setWaitDistributionAmount(vo.getCarryingCapacity().subtract(vo.getSubcontractAmount()).subtract(vo.getEntrustAmount()));
|
|
vo.setWaitDistributionAmount(vo.getCarryingCapacity().subtract(vo.getSubcontractAmount()).subtract(vo.getEntrustAmount()));
|
|
|
String tOrderId = vo.getTOrderId();
|
|
String tOrderId = vo.getTOrderId();
|
|
|
if (StringUtils.isNotBlank(tOrderId)) {
|
|
if (StringUtils.isNotBlank(tOrderId)) {
|
|
|
- OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
|
|
|
|
|
- if (orderDetailById != null) {
|
|
|
|
|
- List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(unitInfo)) {
|
|
|
|
|
- for (UnitInfoDetailRes detailRes : unitInfo) {
|
|
|
|
|
- if ("1".equals(detailRes.getUnitType())) {
|
|
|
|
|
- vo.setReceiveGoodsUnit(detailRes.getFirmName());
|
|
|
|
|
- vo.setReceiveGoodsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
|
|
|
|
|
- }
|
|
|
|
|
- if ("2".equals(detailRes.getUnitType())) {
|
|
|
|
|
- vo.setShipmentsUnit(detailRes.getFirmName());
|
|
|
|
|
- vo.setShipmentsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
|
|
|
|
|
+ if (orderDetailById != null) {
|
|
|
|
|
+ List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(unitInfo)) {
|
|
|
|
|
+ for (UnitInfoDetailRes detailRes : unitInfo) {
|
|
|
|
|
+ if ("1".equals(detailRes.getUnitType())) {
|
|
|
|
|
+ vo.setReceiveGoodsUnit(detailRes.getFirmName());
|
|
|
|
|
+ vo.setReceiveGoodsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("2".equals(detailRes.getUnitType())) {
|
|
|
|
|
+ vo.setShipmentsUnit(detailRes.getFirmName());
|
|
|
|
|
+ vo.setShipmentsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.info(vo.getTOrderId() + "查询错误:{}", e.getMessage(), e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2019,6 +2034,17 @@ public class ConsignOrderService {
|
|
|
StatisticsByOrderVO lastStatisticsByOrderVO = kwtLogisticsOrderMapper.selectAcceptCarriageAwaitFinishOrder(statusList, lastWeekDateStart, lastWeekDateEnd, id, OrderTypeEnum.CONSIGN_ORDER.getType());
|
|
StatisticsByOrderVO lastStatisticsByOrderVO = kwtLogisticsOrderMapper.selectAcceptCarriageAwaitFinishOrder(statusList, lastWeekDateStart, lastWeekDateEnd, id, OrderTypeEnum.CONSIGN_ORDER.getType());
|
|
|
//全部的未履约量
|
|
//全部的未履约量
|
|
|
BigDecimal lastWaitingAmount = lastStatistics.getWaitingAmount().add(lastStatisticsByOrderVO.getWaitingAmount());
|
|
BigDecimal lastWaitingAmount = lastStatistics.getWaitingAmount().add(lastStatisticsByOrderVO.getWaitingAmount());
|
|
|
|
|
+ BigDecimal lastAmount = lastStatistics.getAmount().add(lastStatisticsByOrderVO.getAmount());
|
|
|
|
|
+ BigDecimal lastEntrustAmount = lastStatistics.getEntrustAmount().add(lastStatisticsByOrderVO.getEntrustAmount());
|
|
|
|
|
+ BigDecimal lastSubcontractAmount = lastStatistics.getSubcontractAmount().add(lastStatisticsByOrderVO.getSubcontractAmount());
|
|
|
|
|
+ BigDecimal lastTotalPrice = lastStatistics.getTotalPrice().add(lastStatisticsByOrderVO.getTotalPrice());
|
|
|
|
|
+
|
|
|
|
|
+ vo.setLastWaitingAmount(lastWaitingAmount);
|
|
|
|
|
+ vo.setLastAmount(lastAmount);
|
|
|
|
|
+ vo.setLastEntrustAmount(lastEntrustAmount);
|
|
|
|
|
+ vo.setLastSubcontractAmount(lastSubcontractAmount);
|
|
|
|
|
+ vo.setLastTotalPrice(lastTotalPrice);
|
|
|
|
|
+
|
|
|
//环比计算
|
|
//环比计算
|
|
|
BigDecimal chainRatio = new BigDecimal("0.00");
|
|
BigDecimal chainRatio = new BigDecimal("0.00");
|
|
|
Integer flag = 1;
|
|
Integer flag = 1;
|
|
@@ -2031,7 +2057,7 @@ public class ConsignOrderService {
|
|
|
} else if (lastWaitingAmount.compareTo(new BigDecimal("0.00")) == 0) {
|
|
} else if (lastWaitingAmount.compareTo(new BigDecimal("0.00")) == 0) {
|
|
|
chainRatio = new BigDecimal("100.00").subtract(chainRatio);
|
|
chainRatio = new BigDecimal("100.00").subtract(chainRatio);
|
|
|
} else {
|
|
} else {
|
|
|
- chainRatio = (waitingAmount.subtract(lastWaitingAmount)).divide(lastWaitingAmount,NumberConstant.SIX, BigDecimal.ROUND_HALF_UP)
|
|
|
|
|
|
|
+ chainRatio = (waitingAmount.subtract(lastWaitingAmount)).divide(lastWaitingAmount, NumberConstant.SIX, BigDecimal.ROUND_HALF_UP)
|
|
|
.multiply(new BigDecimal("100.00")).setScale(NumberConstant.TWO, BigDecimal.ROUND_HALF_UP);
|
|
.multiply(new BigDecimal("100.00")).setScale(NumberConstant.TWO, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
}
|
|
|
if (chainRatio.compareTo(new BigDecimal("0.00")) == -1) {
|
|
if (chainRatio.compareTo(new BigDecimal("0.00")) == -1) {
|
|
@@ -2042,4 +2068,58 @@ public class ConsignOrderService {
|
|
|
httpResult.setData(vo);
|
|
httpResult.setData(vo);
|
|
|
return httpResult;
|
|
return httpResult;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 工作台-物流运输数据统计
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public HttpResult workbenchLogisticsOrderStatistics(LogisticsOrderStatisticsParam logisticsOrderStatistics) {
|
|
|
|
|
+// List<String> stringList = StringUtils.splitStrToList(logisticsOrderStatistics.getTypes(), String.class);
|
|
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
|
|
|
|
|
+ if (entCacheResDto == null) {
|
|
|
|
|
+ return HttpResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+ Long id = entCacheResDto.getId();
|
|
|
|
|
+ //获取完结的单据-排除掉不做统计中的数据
|
|
|
|
|
+ List<Integer> statusList = new ArrayList<>();
|
|
|
|
|
+ statusList.add(LogisticsOrderEnum.TO_BE_PLANNED.getCode());
|
|
|
|
|
+ statusList.add(LogisticsOrderEnum.PENDING_ORDER.getCode());
|
|
|
|
|
+ statusList.add(LogisticsOrderEnum.WAIT_DELIVERY.getCode());
|
|
|
|
|
+ statusList.add(LogisticsOrderEnum.IN_TRANSIT.getCode());
|
|
|
|
|
+ statusList.add(LogisticsOrderEnum.HAVE_FINISHED.getCode());
|
|
|
|
|
+ statusList.add(LogisticsOrderEnum.HAVE_RECONCILED.getCode());
|
|
|
|
|
+ statusList.add(LogisticsOrderEnum.HAVE_ALREADY_SETTLED.getCode());
|
|
|
|
|
+
|
|
|
|
|
+ /**1.目前只统计承运单位属性的数据
|
|
|
|
|
+ * 2.月统计->默认当前往前推12个月
|
|
|
|
|
+ * 3.日统计->默认当前往前推30天*/
|
|
|
|
|
+ if (String.valueOf(NumberConstant.THREE).equals(logisticsOrderStatistics.getDateType())) {
|
|
|
|
|
+ //本月
|
|
|
|
|
+ //开始时间
|
|
|
|
|
+ DateTime dateTime = cn.hutool.core.date.DateUtil.truncate(new Date(), DateField.MONTH);
|
|
|
|
|
+ LocalDateTime localDateTime = dateTime.toLocalDateTime().minusMonths(11);
|
|
|
|
|
+ String dateStart = cn.hutool.core.date.DateUtil.format(localDateTime, DEF_DATE_FORMAT);
|
|
|
|
|
+ //结束时间
|
|
|
|
|
+ String dateEnd = cn.hutool.core.date.DateUtil.format(dateTime, DEF_DATE_FORMAT);
|
|
|
|
|
+
|
|
|
|
|
+ List<LogisticsOrderStatisticsVO> list = kwtLogisticsOrderMapper.workbenchLogisticsOrderStatisticsByMonth(id, statusList, OrderTypeEnum.ACCEPT_CARRIAGE_ORDER.getType(), dateStart, dateEnd);
|
|
|
|
|
+ return HttpResult.ok(list);
|
|
|
|
|
+ } else if (String.valueOf(NumberConstant.ONE).equals(logisticsOrderStatistics.getDateType())) {
|
|
|
|
|
+ //开始时间
|
|
|
|
|
+ String format = cn.hutool.core.date.DateUtil.format(LocalDateTime.now(), DEF_DATE_FORMAT);
|
|
|
|
|
+ String dateStart = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ dateStart = DateUtil.getThirtyDaysDate(format, 29);
|
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ //结束时间
|
|
|
|
|
+ String dateEnd = DateUtil.getLastWeekDateEndToString(0);
|
|
|
|
|
+ List<LogisticsOrderStatisticsVO> list = kwtLogisticsOrderMapper.workbenchLogisticsOrderStatisticsByDays(id, statusList, OrderTypeEnum.ACCEPT_CARRIAGE_ORDER.getType(), dateStart, dateEnd);
|
|
|
|
|
+ return HttpResult.ok(list);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|