|
|
@@ -0,0 +1,540 @@
|
|
|
+package com.sckw.transport.service;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.sckw.contract.api.RemoteContractService;
|
|
|
+import com.sckw.contract.api.model.dto.res.ContractCommonInfoResDto;
|
|
|
+import com.sckw.core.common.enums.NumberConstant;
|
|
|
+import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
+import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
+import com.sckw.core.model.constant.Global;
|
|
|
+import com.sckw.core.model.enums.LogisticsOrderEnum;
|
|
|
+import com.sckw.core.model.page.PageRes;
|
|
|
+import com.sckw.core.utils.CollectionUtils;
|
|
|
+import com.sckw.core.utils.StringUtils;
|
|
|
+import com.sckw.core.web.constant.HttpStatus;
|
|
|
+import com.sckw.core.web.context.LoginUserHolder;
|
|
|
+import com.sckw.core.web.response.HttpResult;
|
|
|
+import com.sckw.mongo.model.TableTops;
|
|
|
+import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
+import com.sckw.order.api.model.OrderDetailRes;
|
|
|
+import com.sckw.order.api.model.UnitInfoDetailRes;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
+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.param.ManagementLogisticsOrderQuery;
|
|
|
+import com.sckw.transport.model.vo.ManagementLogsiticsOrderVO;
|
|
|
+import com.sckw.transport.model.vo.OrderDetailVO;
|
|
|
+import com.sckw.transport.model.vo.execlVo.ManagementLogisticsOrderExcelVo;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author lfdc
|
|
|
+ * @description 运营管理端service
|
|
|
+ * @date 2023-09-11 09:09:09
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class ManagementLogisticsOrderService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CommonService commonService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ KwtLogisticsOrderMapper logisticsOrderMapper;
|
|
|
+
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
|
|
|
+ RemoteSystemService remoteSystemService;
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
|
|
|
+ TradeOrderInfoService tradeOrderInfoService;
|
|
|
+
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
|
|
|
+ RemoteContractService remoteContractService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderGoodsMapper logisticsOrderGoodsMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderContractMapper logisticsOrderContractMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderAddressMapper logisticsOrderAddressMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderTrackMapper logisticsOrderTrackMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderUnitMapper logisticsOrderUnitMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtWaybillOrderMapper waybillOrderMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param query
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PageRes selectLogisticsOrder(ManagementLogisticsOrderQuery query) {
|
|
|
+ Long entId = LoginUserHolder.getEntId();
|
|
|
+ PageHelper.startPage(query.getPage(), query.getPageSize());
|
|
|
+ List<Integer> orderList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(query.getStatus())) {
|
|
|
+ if (String.valueOf(NumberConstant.SEVEN).equals(query.getStatus())) {
|
|
|
+ orderList.add(LogisticsOrderEnum.REJECT_ORDER.getCode());
|
|
|
+ orderList.add(LogisticsOrderEnum.CANCEL_ORDER.getCode());
|
|
|
+ } else {
|
|
|
+ orderList.add(Integer.valueOf(query.getStatus()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //装卸货地址
|
|
|
+ String loadCode = query.getLoadAddressCode();
|
|
|
+ if (StringUtils.isNotBlank(loadCode)) {
|
|
|
+ switch (query.getLoadAddressLevel()) {
|
|
|
+ case 1 -> query.setLoadAddressCode(
|
|
|
+ loadCode.substring(0, 2).trim());
|
|
|
+ case 2 -> query.setLoadAddressCode(
|
|
|
+ loadCode.substring(0, 4).trim());
|
|
|
+ case 3 -> query.setLoadAddressCode(loadCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String unloadCode = query.getUnloadAddressCode();
|
|
|
+ if (StringUtils.isNotBlank(unloadCode)) {
|
|
|
+ switch (query.getUnloadAddressLevel()) {
|
|
|
+ case 1 -> query.setUnloadAddressCode(
|
|
|
+ loadCode.substring(0, 2).trim());
|
|
|
+ case 2 -> query.setUnloadAddressCode(
|
|
|
+ loadCode.substring(0, 4).trim());
|
|
|
+ case 3 -> query.setUnloadAddressCode(loadCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Long> longs = LoginUserHolder.getAuthUserIdList();
|
|
|
+ longs.add(LoginUserHolder.getUserId());
|
|
|
+ List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
|
|
|
+// LoginUserHolder.getIsMain()
|
|
|
+ List<ManagementLogsiticsOrderVO> list = logisticsOrderMapper.selectManagementLogisticsOrderList(query, orderList, entId, longList, longList);
|
|
|
+ PageInfo<ManagementLogsiticsOrderVO> pageInfo = new PageInfo<>(list);
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return PageRes.build(pageInfo, list);
|
|
|
+ }
|
|
|
+// List<AcceptCarriageOrderVO> detailRes = new ArrayList<>();
|
|
|
+ /**计量单位*/
|
|
|
+ Map<String, String> unitTypeDictData = commonService.getDictData(DictTypeEnum.UNIT_TYPE.getType());
|
|
|
+ /**运价方式*/
|
|
|
+ Map<String, String> priceDictData = commonService.getDictData(DictTypeEnum.PRICE_TYPE.getType());
|
|
|
+ /**计费方式*/
|
|
|
+ Map<String, String> chargingDictData = commonService.getDictData(DictTypeEnum.CHARGING_TYPE.getType());
|
|
|
+ /**结算周期*/
|
|
|
+ Map<String, String> settlementDictData = commonService.getDictData(DictTypeEnum.SETTLEMENT_CYCLE.getType());
|
|
|
+ /**签约方式*/
|
|
|
+ Map<String, String> signingWay = commonService.getDictData(DictTypeEnum.SIGNING_TYPE.getType());
|
|
|
+ /**合理损耗*/
|
|
|
+// Map<String, String> taxRateTypeDictData = getDictData(DictTypeEnum.TAX_RATE_TYPE.getType());
|
|
|
+ Map<Long, UserCacheResDto> longUserMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ List<Long> collect = list.stream().map(ManagementLogsiticsOrderVO::getCreateBy).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
+ longUserMap = remoteSystemService.queryUserCacheMapByIds(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (ManagementLogsiticsOrderVO vo : list) {
|
|
|
+ vo.setAccountsCycleLabel(settlementDictData.get(vo.getAccountsCycle()));
|
|
|
+ vo.setAppointor(longUserMap.get(vo.getCreateBy()) == null ? null : longUserMap.get(vo.getCreateBy()).getName());
|
|
|
+ vo.setBillingModeLabel(chargingDictData.get(vo.getBillingMode()));
|
|
|
+ vo.setSigningLabel(signingWay.get(vo.getSigning()));
|
|
|
+ vo.setStatusLabel(LogisticsOrderEnum.getName(vo.getStatus()));
|
|
|
+ vo.setLoadAddress(vo.getLoadCityName() + vo.getLoadAddress());
|
|
|
+ vo.setUnloadAddress(vo.getUnloadCityName() + vo.getUnloadAddress());
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vo.setWaitDistributionAmount(vo.getCarryingCapacity().subtract(vo.getSubcontractAmount()).subtract(vo.getEntrustAmount()));
|
|
|
+ String tOrderId = vo.getTOrderId();
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return PageRes.build(pageInfo, list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public HttpResult statisticsLogisticsOrder(ManagementLogisticsOrderQuery query) {
|
|
|
+ Long entId = LoginUserHolder.getEntId();
|
|
|
+ List<Integer> orderList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(query.getStatus())) {
|
|
|
+ if (String.valueOf(NumberConstant.EIGHT).equals(query.getStatus())) {
|
|
|
+ orderList.add(LogisticsOrderEnum.REJECT_ORDER.getCode());
|
|
|
+ orderList.add(LogisticsOrderEnum.CANCEL_ORDER.getCode());
|
|
|
+ } else {
|
|
|
+ orderList.add(Integer.valueOf(query.getStatus()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //装卸货地址
|
|
|
+ String loadCode = query.getLoadAddressCode();
|
|
|
+ if (StringUtils.isNotBlank(loadCode)) {
|
|
|
+ switch (query.getLoadAddressLevel()) {
|
|
|
+ case 1 -> query.setLoadAddressCode(
|
|
|
+ loadCode.substring(0, 2).trim());
|
|
|
+ case 2 -> query.setLoadAddressCode(
|
|
|
+ loadCode.substring(0, 4).trim());
|
|
|
+ case 3 -> query.setLoadAddressCode(loadCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String unloadCode = query.getUnloadAddressCode();
|
|
|
+ if (StringUtils.isNotBlank(unloadCode)) {
|
|
|
+ switch (query.getUnloadAddressLevel()) {
|
|
|
+ case 1 -> query.setUnloadAddressCode(
|
|
|
+ loadCode.substring(0, 2).trim());
|
|
|
+ case 2 -> query.setUnloadAddressCode(
|
|
|
+ loadCode.substring(0, 4).trim());
|
|
|
+ case 3 -> query.setUnloadAddressCode(loadCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Long> longs = LoginUserHolder.getAuthUserIdList();
|
|
|
+ longs.add(LoginUserHolder.getUserId());
|
|
|
+ List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
|
|
|
+ List<TableTops> list = logisticsOrderMapper.countManagementLogisticsOrderListByStatus(query, orderList, entId, longList, longList);
|
|
|
+ List<TableTops> arrayList = new ArrayList<>();
|
|
|
+ arrayList.addAll(list);
|
|
|
+ /**补全数据状态不齐的情况*/
|
|
|
+ arrayList = commonService.packageReturnStatistics(list, arrayList);
|
|
|
+ // 查询结果
|
|
|
+ Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ map.put("tableTop", arrayList);
|
|
|
+ // 查询结果
|
|
|
+ return HttpResult.ok(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ManagementLogisticsOrderExcelVo> exportLogisticsOrder(ManagementLogisticsOrderQuery query) {
|
|
|
+ Long entId = LoginUserHolder.getEntId();
|
|
|
+// PageHelper.startPage(query.getPage(), query.getPageSize());
|
|
|
+ List<Integer> orderList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(query.getStatus())) {
|
|
|
+ if (String.valueOf(NumberConstant.SEVEN).equals(query.getStatus())) {
|
|
|
+ orderList.add(LogisticsOrderEnum.REJECT_ORDER.getCode());
|
|
|
+ orderList.add(LogisticsOrderEnum.CANCEL_ORDER.getCode());
|
|
|
+ } else {
|
|
|
+ orderList.add(Integer.valueOf(query.getStatus()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //装卸货地址
|
|
|
+ String loadCode = query.getLoadAddressCode();
|
|
|
+ if (StringUtils.isNotBlank(loadCode)) {
|
|
|
+ switch (query.getLoadAddressLevel()) {
|
|
|
+ case 1 -> query.setLoadAddressCode(
|
|
|
+ loadCode.substring(0, 2).trim());
|
|
|
+ case 2 -> query.setLoadAddressCode(
|
|
|
+ loadCode.substring(0, 4).trim());
|
|
|
+ case 3 -> query.setLoadAddressCode(loadCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String unloadCode = query.getUnloadAddressCode();
|
|
|
+ if (StringUtils.isNotBlank(unloadCode)) {
|
|
|
+ switch (query.getUnloadAddressLevel()) {
|
|
|
+ case 1 -> query.setUnloadAddressCode(
|
|
|
+ loadCode.substring(0, 2).trim());
|
|
|
+ case 2 -> query.setUnloadAddressCode(
|
|
|
+ loadCode.substring(0, 4).trim());
|
|
|
+ case 3 -> query.setUnloadAddressCode(loadCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Long> longs = LoginUserHolder.getAuthUserIdList();
|
|
|
+ longs.add(LoginUserHolder.getUserId());
|
|
|
+ List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
|
|
|
+ List<ManagementLogsiticsOrderVO> list = logisticsOrderMapper.selectManagementLogisticsOrderList(query, orderList, entId, longList, longList);
|
|
|
+ /**计费方式*/
|
|
|
+ Map<String, String> chargingDictData = commonService.getDictData(DictTypeEnum.CHARGING_TYPE.getType());
|
|
|
+ /**结算周期*/
|
|
|
+ Map<String, String> settlementDictData = commonService.getDictData(DictTypeEnum.SETTLEMENT_CYCLE.getType());
|
|
|
+ /**签约方式*/
|
|
|
+ Map<String, String> signingWay = commonService.getDictData(DictTypeEnum.SIGNING_TYPE.getType());
|
|
|
+ /**合理损耗单位*/
|
|
|
+ Map<String, String> taxRate = commonService.getDictData(DictTypeEnum.TAX_RATE_TYPE.getType());
|
|
|
+ /**运价方式*/
|
|
|
+ Map<String, String> priceType = commonService.getDictData(DictTypeEnum.PRICE_TYPE.getType());
|
|
|
+ Map<Long, UserCacheResDto> longUserMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ List<Long> collect = list.stream().map(ManagementLogsiticsOrderVO::getCreateBy).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
+ longUserMap = remoteSystemService.queryUserCacheMapByIds(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<ManagementLogisticsOrderExcelVo> exportList = new ArrayList<>();
|
|
|
+ for (ManagementLogsiticsOrderVO vo : list) {
|
|
|
+ ManagementLogisticsOrderExcelVo managementLogisticsOrderExcelVo = new ManagementLogisticsOrderExcelVo();
|
|
|
+ BeanUtils.copyProperties(vo, managementLogisticsOrderExcelVo);
|
|
|
+ managementLogisticsOrderExcelVo.setPriceLabel(vo.getPrice() == null ? null : vo.getPrice().toString() + priceType.get(vo.getPriceType()));
|
|
|
+ managementLogisticsOrderExcelVo.setLossUnitLabel(vo.getLoss() == null ? null : vo.getLoss().toString() + taxRate.get(vo.getLossUnit()));
|
|
|
+ managementLogisticsOrderExcelVo.setGoodsPriceLabel(vo.getGoodsPrice() == null ? null : vo.getGoodsPrice().toString() + priceType.get(vo.getGoodsPriceUnit()));
|
|
|
+ managementLogisticsOrderExcelVo.setAccountsCycleLabel(settlementDictData.get(vo.getAccountsCycle()));
|
|
|
+ managementLogisticsOrderExcelVo.setAppointor(longUserMap.get(vo.getCreateBy()) == null ? null : longUserMap.get(vo.getCreateBy()).getName());
|
|
|
+ managementLogisticsOrderExcelVo.setBillingModeLabel(chargingDictData.get(vo.getBillingMode()));
|
|
|
+ managementLogisticsOrderExcelVo.setSigningLabel(signingWay.get(vo.getSigning()));
|
|
|
+ managementLogisticsOrderExcelVo.setStatusLabel(LogisticsOrderEnum.getName(vo.getStatus()));
|
|
|
+ managementLogisticsOrderExcelVo.setLoadAddress(vo.getLoadCityName() + vo.getLoadAddress());
|
|
|
+ managementLogisticsOrderExcelVo.setUnloadAddress(vo.getUnloadCityName() + vo.getUnloadAddress());
|
|
|
+ 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())) {
|
|
|
+ managementLogisticsOrderExcelVo.setShipmentsUnit(detailRes.getFirmName());
|
|
|
+ } else {
|
|
|
+ managementLogisticsOrderExcelVo.setReceiveGoodsUnit(detailRes.getFirmName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BigDecimal subtract = vo.getCarryingCapacity().subtract(vo.getSubcontractAmount()).subtract(vo.getEntrustAmount());
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
+ managementLogisticsOrderExcelVo.setWaitDistributionAmount(subtract == null ? null : df.format(subtract));
|
|
|
+ String tOrderId = vo.getTOrderId();
|
|
|
+ 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())) {
|
|
|
+ managementLogisticsOrderExcelVo.setReceiveGoodsUnit(detailRes.getFirmName());
|
|
|
+ }
|
|
|
+ if ("2".equals(detailRes.getUnitType())) {
|
|
|
+ managementLogisticsOrderExcelVo.setShipmentsUnit(detailRes.getFirmName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ managementLogisticsOrderExcelVo.setSubcontractAmount(Objects.isNull(vo.getSubcontractAmount()) ? null : df.format(vo.getSubcontractAmount()) + priceType.get(vo.getPriceType()));
|
|
|
+ managementLogisticsOrderExcelVo.setEntrustAmount(Objects.isNull(vo.getEntrustAmount()) ? null : df.format(vo.getEntrustAmount()) + priceType.get(vo.getPriceType()));
|
|
|
+ managementLogisticsOrderExcelVo.setLoadAmount(Objects.isNull(vo.getLoadAmount()) ? null : df.format(vo.getLoadAmount()) + priceType.get(vo.getPriceType()));
|
|
|
+ managementLogisticsOrderExcelVo.setUnloadAmount(Objects.isNull(vo.getUnloadAmount()) ? null : df.format(vo.getUnloadAmount()) + priceType.get(vo.getPriceType()));
|
|
|
+ exportList.add(managementLogisticsOrderExcelVo);
|
|
|
+ }
|
|
|
+ return exportList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public HttpResult getOrderDetail(String orderIdStr, String orderNo) {
|
|
|
+ HttpResult httpResult = new HttpResult();
|
|
|
+ httpResult.setCode(HttpStatus.SUCCESS_CODE);
|
|
|
+ List<Long> orderIds = StringUtils.splitStrToList(orderIdStr, Long.class);
|
|
|
+ Long orderId = orderIds.get(0);
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
+ .eq(KwtLogisticsOrder::getId, orderId)
|
|
|
+ .eq(StringUtils.isNotBlank(orderNo), KwtLogisticsOrder::getLOrderNo, orderNo)
|
|
|
+ /**.eq(KwtLogisticsOrder::getEntId, LoginUserHolder.getEntId())*/);
|
|
|
+ if (logisticsOrder == null) {
|
|
|
+ log.info("运营端-物流订单-获取订单详情参数:单据id:{},单据编号:{}", orderId, orderNo);
|
|
|
+ throw new RuntimeException("查无单据");
|
|
|
+
|
|
|
+ }
|
|
|
+ KwtLogisticsOrderContract contract = logisticsOrderContractMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderContract>()
|
|
|
+ .eq(StringUtils.isNotBlank(orderId), KwtLogisticsOrderContract::getLOrderId, orderId));
|
|
|
+ KwtLogisticsOrderUnit unitOne = logisticsOrderUnitMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
|
|
|
+ .eq(StringUtils.isNotBlank(orderId), KwtLogisticsOrderUnit::getLOrderId, orderId)
|
|
|
+ .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.ONE));
|
|
|
+ KwtLogisticsOrderUnit unitTwo = logisticsOrderUnitMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
|
|
|
+ .eq(StringUtils.isNotBlank(orderId), KwtLogisticsOrderUnit::getLOrderId, orderId)
|
|
|
+ .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.TWO));
|
|
|
+ KwtLogisticsOrderAddress loadOrderAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
|
|
|
+ .eq(StringUtils.isNotBlank(orderId), KwtLogisticsOrderAddress::getLOrderId, orderId)
|
|
|
+ .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE));
|
|
|
+ KwtLogisticsOrderAddress unloadOrderAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
|
|
|
+ .eq(StringUtils.isNotBlank(orderId), KwtLogisticsOrderAddress::getLOrderId, orderId)
|
|
|
+ .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.TWO));
|
|
|
+ KwtLogisticsOrderGoods orderGoods = logisticsOrderGoodsMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderGoods>()
|
|
|
+ .eq(StringUtils.isNotBlank(logisticsOrder.getId()), KwtLogisticsOrderGoods::getLOrderId, logisticsOrder.getId()));
|
|
|
+ OrderDetailVO orderDetailVO = new OrderDetailVO();
|
|
|
+ orderDetailVO.setId(String.valueOf(logisticsOrder.getId()));
|
|
|
+ if (contract != null) {
|
|
|
+ orderDetailVO.setContractId(contract.getContractId() == null ? null : String.valueOf(contract.getContractId()));
|
|
|
+ //todo 接口调用合同服务查询合同信息
|
|
|
+ List<Long> list = new ArrayList<>(NumberConstant.SIXTEEN);
|
|
|
+ list.add(contract.getContractId());
|
|
|
+ Map<Long, ContractCommonInfoResDto> contractBaseInfo = remoteContractService.queryContractBaseInfo(list);
|
|
|
+ if (CollectionUtils.isNotEmpty(contractBaseInfo) && !ObjectUtils.isEmpty(contractBaseInfo.get(contract.getContractId()))) {
|
|
|
+ orderDetailVO.setContractName(contractBaseInfo.get(contract.getContractId()).getContactName());
|
|
|
+ orderDetailVO.setContractNo(contractBaseInfo.get(contract.getContractId()).getContractCode());
|
|
|
+ orderDetailVO.setSigningWay(contractBaseInfo.get(contract.getContractId()).getSigningWay());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (unitOne != null) {
|
|
|
+ orderDetailVO.setConsignCompanyId(unitOne.getId());
|
|
|
+ orderDetailVO.setConsignCompany(unitOne.getFirmName());
|
|
|
+ orderDetailVO.setConsignContacts(unitOne.getContacts());
|
|
|
+ orderDetailVO.setConsignPhone(unitOne.getPhone());
|
|
|
+ orderDetailVO.setCollectionCompany(unitOne.getFirmName());
|
|
|
+ }
|
|
|
+ if (unitTwo != null) {
|
|
|
+ orderDetailVO.setCarrierCompanyId(unitTwo.getId());
|
|
|
+ orderDetailVO.setCarrierCompany(unitTwo.getFirmName());
|
|
|
+ orderDetailVO.setCarrierContacts(unitTwo.getContacts());
|
|
|
+ orderDetailVO.setCarrierPhone(unitTwo.getPhone());
|
|
|
+ }
|
|
|
+ orderDetailVO.setGoodsId(String.valueOf(orderGoods == null ? null : orderGoods.getGoodsId()));
|
|
|
+ orderDetailVO.setGoodsName(orderGoods == null ? null : orderGoods.getGoodsName());
|
|
|
+ orderDetailVO.setNumber(logisticsOrder.getAmount() == null ? null : logisticsOrder.getAmount());
|
|
|
+ orderDetailVO.setPrice(logisticsOrder.getPrice() == null ? null : logisticsOrder.getPrice());
|
|
|
+ orderDetailVO.setLoss(logisticsOrder.getLoss() == null ? null : logisticsOrder.getLoss());
|
|
|
+ orderDetailVO.setDeduct(logisticsOrder.getGoodsPrice() == null ? null : logisticsOrder.getGoodsPrice());
|
|
|
+ orderDetailVO.setLoadName(loadOrderAddress.getName());
|
|
|
+ orderDetailVO.setLoadAddress(loadOrderAddress.getCityName());
|
|
|
+ orderDetailVO.setLoadContacts(loadOrderAddress.getContacts());
|
|
|
+ orderDetailVO.setLoadPhone(loadOrderAddress.getPhone());
|
|
|
+ orderDetailVO.setLoadAddressDetail(loadOrderAddress.getDetailAddress());
|
|
|
+ orderDetailVO.setUnloadName(unloadOrderAddress.getName());
|
|
|
+ orderDetailVO.setUnloadAddress(unloadOrderAddress.getCityName());
|
|
|
+ orderDetailVO.setUnloadContacts(unloadOrderAddress.getContacts());
|
|
|
+ orderDetailVO.setUnloadPhone(unloadOrderAddress.getPhone());
|
|
|
+ orderDetailVO.setUnloadAddressDetail(unloadOrderAddress.getDetailAddress());
|
|
|
+ orderDetailVO.setSettlementCycle(logisticsOrder.getSettlementCycle() == null ? null : String.valueOf(logisticsOrder.getSettlementCycle()));
|
|
|
+ if (logisticsOrder.getSettlementCycle() != null) {
|
|
|
+ Map<String, SysDictResDto> dtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.SETTLEMENT_CYCLE.getType());
|
|
|
+ orderDetailVO.setSettlementCycleLabel(dtoMap.isEmpty() ? null :
|
|
|
+ (dtoMap.get(String.valueOf(logisticsOrder.getSettlementCycle())) == null ? null : dtoMap.get(String.valueOf(logisticsOrder.getSettlementCycle())).getLabel()));
|
|
|
+ }
|
|
|
+ orderDetailVO.setBillingMode(logisticsOrder.getBillingMode());
|
|
|
+ if (logisticsOrder.getBillingMode() != null) {
|
|
|
+ Map<String, SysDictResDto> dictResDtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.CHARGING_TYPE.getType());
|
|
|
+ orderDetailVO.setBillingModeLabel(dictResDtoMap.isEmpty() ? null :
|
|
|
+ (dictResDtoMap.get(logisticsOrder.getBillingMode()) == null ? null : dictResDtoMap.get(logisticsOrder.getBillingMode()).getLabel()));
|
|
|
+ }
|
|
|
+ orderDetailVO.setScheduleStartTime(logisticsOrder.getStartTime() == null ? null : logisticsOrder.getStartTime());
|
|
|
+ orderDetailVO.setScheduleEndTime(logisticsOrder.getEndTime() == null ? null : logisticsOrder.getEndTime());
|
|
|
+ if (logisticsOrder.getBillingMode().equals(String.valueOf(NumberConstant.ONE))) {
|
|
|
+ orderDetailVO.setPerformanceAmount(logisticsOrder.getTotalLoadAmount() == null ? null : logisticsOrder.getTotalLoadAmount());
|
|
|
+ } else if (logisticsOrder.getBillingMode().equals(String.valueOf(NumberConstant.TWO))) {
|
|
|
+ orderDetailVO.setPerformanceAmount(logisticsOrder.getUnloadAmount() == null ? null : logisticsOrder.getUnloadAmount());
|
|
|
+ }
|
|
|
+// orderDetailVO.setPerformanceAmount(logisticsOrder.getLoadAmount() == null ? null : logisticsOrder.getLoadAmount());
|
|
|
+ orderDetailVO.setTotalLoadAmount(logisticsOrder.getTotalLoadAmount() == null ? new BigDecimal("0.00") : logisticsOrder.getTotalLoadAmount());
|
|
|
+ orderDetailVO.setTotalUnloadAmount(logisticsOrder.getTotalUnloadAmount() == null ? new BigDecimal("0.00") : logisticsOrder.getTotalUnloadAmount());
|
|
|
+ orderDetailVO.setCreateTime(logisticsOrder.getCreateTime());
|
|
|
+ orderDetailVO.setPayment(logisticsOrder.getPayment());
|
|
|
+ if (logisticsOrder.getPayment() != null) {
|
|
|
+ Map<String, SysDictResDto> dictResDtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.TRADE_TYPE.getType());
|
|
|
+ if (dictResDtoMap.isEmpty()) {
|
|
|
+ orderDetailVO.setPaymentLabel(null);
|
|
|
+ } else {
|
|
|
+ if (dictResDtoMap.get(logisticsOrder.getPayment().toString()) != null) {
|
|
|
+ orderDetailVO.setPaymentLabel(dictResDtoMap.get(logisticsOrder.getPayment().toString()).getLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (orderDetailVO.getSigningWay() != null) {
|
|
|
+ Map<String, SysDictResDto> dictResDtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.SIGNING_TYPE.getType());
|
|
|
+ if (dictResDtoMap.isEmpty()) {
|
|
|
+ orderDetailVO.setPaymentLabel(null);
|
|
|
+ } else {
|
|
|
+ if (dictResDtoMap.get(String.valueOf(orderDetailVO.getSigningWay())) != null) {
|
|
|
+ orderDetailVO.setSigningWayLabel(dictResDtoMap.get(orderDetailVO.getSigningWay().toString()).getLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (logisticsOrder.getGoodsPriceUnit() != null) {
|
|
|
+ SysDictResDto sysDictResDto = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), logisticsOrder.getGoodsPriceUnit());
|
|
|
+ orderDetailVO.setDeductLabel(sysDictResDto == null ? null : sysDictResDto.getLabel());
|
|
|
+ }
|
|
|
+ if (logisticsOrder.getLossUnit() != null) {
|
|
|
+ SysDictResDto sysDictResDto = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.TAX_RATE_TYPE.getType(), logisticsOrder.getLossUnit());
|
|
|
+ orderDetailVO.setLossLabel(sysDictResDto == null ? null : sysDictResDto.getLabel());
|
|
|
+ }
|
|
|
+ if (logisticsOrder.getUnit() != null) {
|
|
|
+ SysDictResDto sysDictResDto = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.UNIT_TYPE.getType(), logisticsOrder.getUnit());
|
|
|
+ orderDetailVO.setNumberLabel(sysDictResDto == null ? null : sysDictResDto.getLabel());
|
|
|
+ }
|
|
|
+ if (logisticsOrder.getPriceType() != null) {
|
|
|
+ SysDictResDto sysDictResDto = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), String.valueOf(logisticsOrder.getPriceType()));
|
|
|
+ orderDetailVO.setPriceLabel(sysDictResDto == null ? null : sysDictResDto.getLabel());
|
|
|
+ }
|
|
|
+ orderDetailVO.setRemark(logisticsOrder.getRemark());
|
|
|
+ /**亏吨量/吨->装货量-卸货量
|
|
|
+ * 合理损耗值=装货量*合理损耗
|
|
|
+ 扣亏量/吨->亏吨量-合理损耗值
|
|
|
+ 罚款值 扣亏量/吨*扣亏货值
|
|
|
+ 总运价:
|
|
|
+ 按照装货量 运输运价*装货量
|
|
|
+ 按照卸货量 卸货量*运输单价-罚款值
|
|
|
+ 按照趟次=运输运价
|
|
|
+ */
|
|
|
+ //合理损耗
|
|
|
+ BigDecimal loss = logisticsOrder.getLoss() == null ? new BigDecimal("0.00") : logisticsOrder.getLoss();
|
|
|
+
|
|
|
+ Integer status = logisticsOrder.getStatus();
|
|
|
+ List<Integer> orderStatusFinish = new ArrayList<>();
|
|
|
+ orderStatusFinish.add(LogisticsOrderEnum.HAVE_FINISHED.getCode());
|
|
|
+ orderStatusFinish.add(LogisticsOrderEnum.HAVE_RECONCILED.getCode());
|
|
|
+ orderStatusFinish.add(LogisticsOrderEnum.HAVE_ALREADY_SETTLED.getCode());
|
|
|
+ /**根据当前单据状态进行订单金额计算*/
|
|
|
+ if (orderStatusFinish.contains(status)) {
|
|
|
+ /**亏吨量/吨->装货量-卸货量
|
|
|
+ 扣亏量/吨->亏吨量-合理损耗值
|
|
|
+ 扣亏量/吨->亏吨量-合理损耗值(装货量*合理损耗)*/
|
|
|
+ BigDecimal loadAmount = logisticsOrder.getLoadAmount() == null ? new BigDecimal("0.00") : logisticsOrder.getLoadAmount();
|
|
|
+ BigDecimal unloadAmount = logisticsOrder.getUnloadAmount() == null ? new BigDecimal("0.00") : logisticsOrder.getUnloadAmount();
|
|
|
+ //运价
|
|
|
+ BigDecimal price = logisticsOrder.getPrice() == null ? new BigDecimal("0.00") : logisticsOrder.getPrice();
|
|
|
+ //亏吨量
|
|
|
+ BigDecimal defectiveWeighNumber = loadAmount.subtract(unloadAmount);
|
|
|
+ //合理损耗值
|
|
|
+ BigDecimal lossAmount = loadAmount.multiply(loss);
|
|
|
+ //扣亏量/吨
|
|
|
+ BigDecimal deductWeighNumber = defectiveWeighNumber.subtract(lossAmount);
|
|
|
+ if (deductWeighNumber.compareTo(new BigDecimal("0")) < 0) {
|
|
|
+ deductWeighNumber = new BigDecimal("0.00");
|
|
|
+ }
|
|
|
+ //罚款值
|
|
|
+ BigDecimal fineValue = (logisticsOrder.getGoodsPrice() == null ? new BigDecimal("0.00") : logisticsOrder.getGoodsPrice()).multiply(deductWeighNumber);
|
|
|
+ if (DictEnum.CHARGING_TYPE_1.getValue().equals(logisticsOrder.getBillingMode())) {
|
|
|
+ orderDetailVO.setOrderAmount(price.multiply(loadAmount));
|
|
|
+ } else if (DictEnum.CHARGING_TYPE_2.getValue().equals(logisticsOrder.getBillingMode())) {
|
|
|
+ orderDetailVO.setOrderAmount(unloadAmount.multiply(price).subtract(fineValue));
|
|
|
+ } else if (DictEnum.CHARGING_TYPE_3.getValue().equals(logisticsOrder.getBillingMode())) {
|
|
|
+ orderDetailVO.setOrderAmount(price);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ orderDetailVO.setOrderAmount(logisticsOrder.getAmount().multiply(logisticsOrder.getPrice()));
|
|
|
+ }
|
|
|
+ httpResult.setData(orderDetailVO);
|
|
|
+ return httpResult;
|
|
|
+ }
|
|
|
+}
|