Просмотр исходного кода

update 增加承运单导出接口/增补运单详情字段

chenlin 2 лет назад
Родитель
Сommit
adb9bf75b9

+ 19 - 3
sckw-modules/sckw-report/src/main/java/com/sckw/report/controller/KwTransportController.java

@@ -85,7 +85,7 @@ public class KwTransportController {
      * @param query 查询参数
      * @return
      */
-    @RequestMapping(value = "/export", method = RequestMethod.POST)
+    @RequestMapping(value = "/acceptCarriageOrderExport", method = RequestMethod.POST)
     public HttpResult exportAcceptCarriage(@Validated @RequestBody AcceptCarriageOrderQuery query) {
         HttpServletResponse response = RequestHolder.getResponse();
         List<AcceptCarriageOrderExcelVo> list = acceptCarriageService.exportAcceptCarriage(query,"2");
@@ -96,6 +96,22 @@ public class KwTransportController {
         return HttpResult.ok("没有可导出的数据");
     }
 
+    /**
+     * 托运订单导出
+     *
+     * @param query 查询参数
+     * @return
+     */
+    @RequestMapping(value = "/consignOrderExport", method = RequestMethod.POST)
+    public HttpResult consignOrderExport(@Validated @RequestBody AcceptCarriageOrderQuery query) {
+        HttpServletResponse response = RequestHolder.getResponse();
+        List<AcceptCarriageOrderExcelVo> list = acceptCarriageService.exportAcceptCarriage(query,"2");
+        if (!org.springframework.util.CollectionUtils.isEmpty(list)) {
+            ExcelUtil.download(response, AcceptCarriageOrderExcelVo.class, list);
+            return null;
+        }
+        return HttpResult.ok("没有可导出的数据");
+    }
 
     /**
      * 托运订单首页条件查询
@@ -116,7 +132,7 @@ public class KwTransportController {
     }
 
     /**
-     * 托运订单top统计
+     * 托运订单-top统计
      *
      * @param query
      * @return
@@ -132,7 +148,7 @@ public class KwTransportController {
     }
 
     /**
-     * 托运订单导出
+     * 托运订单-导出
      *
      * @param query 查询参数
      * @return

+ 41 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/LogisticsConsignmentController.java

@@ -1,18 +1,25 @@
 package com.sckw.transport.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.sckw.core.exception.BusinessException;
+import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.transport.model.dto.OrderFinishDTO;
 import com.sckw.transport.model.param.LogisticsConsignmentParam;
+import com.sckw.transport.model.vo.PurchaseLogisticOrderExcelVo;
+import com.sckw.transport.model.vo.SellLogisticOrderExcelVo;
 import com.sckw.transport.service.LogisticsConsignmentService;
 import io.seata.spring.annotation.GlobalTransactional;
+import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.Valid;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -292,4 +299,38 @@ public class LogisticsConsignmentController {
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
         }
     }
+
+
+
+    /**
+     * @desc: 采购订单-托运运单列表导出
+     * @author: jc
+     * @date: 2023-08-09 20:16:22
+     * @Param params:
+     * @return: com.sckw.core.web.response.HttpResult
+     */
+    @PostMapping(value = "/logisticOrderByPurchaseOrderIdExport", produces = MediaType.APPLICATION_JSON_VALUE)
+    public void logisticOrderByPurchaseOrderIdExport(@RequestParam("ids") @NotBlank(message = "单据id不能为空") String ids, HttpServletResponse response) {
+        List<PurchaseLogisticOrderExcelVo> list = logisticsConsignmentService.logisticOrderByPurchaseOrderIdExport(ids);
+        if (CollectionUtils.isEmpty(list)) {
+            throw new BusinessException("导出数据为空!");
+        }
+        ExcelUtil.downData(response, PurchaseLogisticOrderExcelVo.class, list);
+    }
+
+    /**
+     * @desc: 销售订单-托运运单列表导出
+     * @author: jc
+     * @date: 2023-08-09 20:16:22
+     * @Param params:
+     * @return: com.sckw.core.web.response.HttpResult
+     */
+    @PostMapping(value = "/logisticOrderBySellOrderIdExport", produces = MediaType.APPLICATION_JSON_VALUE)
+    public void logisticOrderBySellOrderIdExport(@RequestParam("ids") @NotBlank(message = "单据id不能为空") String ids, HttpServletResponse response) {
+        List<SellLogisticOrderExcelVo> list = logisticsConsignmentService.logisticOrderBySellOrderIdExport(ids);
+        if (CollectionUtils.isEmpty(list)) {
+            throw new BusinessException("导出数据为空!");
+        }
+        ExcelUtil.downData(response, SellLogisticOrderExcelVo.class, list);
+    }
 }

+ 9 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java

@@ -53,6 +53,15 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
      */
     List<com.sckw.transport.model.dto.LogisticsOrderDTO> selectOrderListNotPage(@Param("id") String id, @Param("type") String type);
 
+    /**
+     * 销售订单-采购订单-托运详情(导出)
+     *
+     * @param ids
+     * @param type
+     * @return
+     */
+    List<com.sckw.transport.model.dto.LogisticsOrderDTO> selectOrderListByIdsAndUnitType(@Param("ids") List<String> ids, @Param("type") String type);
+
     /**
      * 销售订单-采购订单-托运列表-数据统计
      *

+ 25 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/WayBillDetailDTO.java

@@ -23,6 +23,11 @@ public class WayBillDetailDTO{
     @JsonProperty("wOrderNo")
     private String wOrderNo;
 
+    /**
+     * 承运车队
+     */
+    private String fleetName;
+
     /**
      * 承运单号
      */
@@ -90,21 +95,41 @@ public class WayBillDetailDTO{
      */
     private String createBy;
 
+    /**
+     * 创建人
+     */
+    private String createByPhone;
+
     /**
      * 计费方式
      */
     private String priceType;
 
+    /**
+     * 计费方式-字符
+     */
+    private String priceTypeLabe;
+
     /**
      * 商品名
      */
     private String goodsName;
 
+    /**
+     * 装载地址名称
+     */
+    private String loadName;
+
     /**
      * 装载地址
      */
     private String loadDetailAddress;
 
+    /**
+     * 卸货地址名称
+     */
+    private String unloadName;
+
     /**
      * 卸货地址
      */

+ 55 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/PurchaseLogisticOrderExcelVo.java

@@ -0,0 +1,55 @@
+package com.sckw.transport.model.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.sckw.excel.annotation.ExcelContext;
+import lombok.Data;
+
+/**
+ * @author lfdc
+ * @description 承运订单导出vo[对采购单]
+ * @date 2023-07-24 13:07:44
+ */
+@Data
+@ExcelContext(fileName = "托运订单列表", sheetName = "托运订单列表")
+public class PurchaseLogisticOrderExcelVo {
+
+    @ExcelProperty(value = "序号" )
+    private String serialNumber;
+
+    @ExcelProperty(value = "采购单号")
+    private String tOrderNo;
+
+    @ExcelProperty(value = "承运订单号")
+    private String lOrderNo;
+
+    @ExcelProperty(value = "状态")
+    private String status;
+
+    @ExcelProperty(value = "承运单位")
+    private String companyName;
+
+    @ExcelProperty(value = "计划量")
+    private String amount;
+
+    @ExcelProperty(value = "计划运价")
+    private String price;
+
+    @ExcelProperty(value = "合理损耗")
+    private String loss;
+
+    @ExcelProperty(value = "扣亏货值")
+    private String goodsPrice;
+
+    @ExcelProperty(value = "联系人")
+    private String contacts;
+
+    @ExcelProperty(value = "联系电话")
+    private String phone;
+
+    @ExcelProperty(value = "指派托运时间")
+    private String createTime;
+
+    @ExcelProperty(value = "创建人")
+    private String createBy;
+
+}

+ 55 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/SellLogisticOrderExcelVo.java

@@ -0,0 +1,55 @@
+package com.sckw.transport.model.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.sckw.excel.annotation.ExcelContext;
+import lombok.Data;
+
+/**
+ * @author lfdc
+ * @description 承运订单导出vo[对销售单]
+ * @date 2023-07-24 13:07:44
+ */
+@Data
+@ExcelContext(fileName = "托运订单列表", sheetName = "托运订单列表")
+public class SellLogisticOrderExcelVo {
+
+    @ExcelProperty(value = "序号" )
+    private String serialNumber;
+
+    @ExcelProperty(value = "销售单号")
+    private String tOrderNo;
+
+    @ExcelProperty(value = "承运订单号")
+    private String lOrderNo;
+
+    @ExcelProperty(value = "状态")
+    private String status;
+
+    @ExcelProperty(value = "承运单位")
+    private String companyName;
+
+    @ExcelProperty(value = "计划量")
+    private String amount;
+
+    @ExcelProperty(value = "计划运价")
+    private String price;
+
+    @ExcelProperty(value = "合理损耗")
+    private String loss;
+
+    @ExcelProperty(value = "扣亏货值")
+    private String goodsPrice;
+
+    @ExcelProperty(value = "联系人")
+    private String contacts;
+
+    @ExcelProperty(value = "联系电话")
+    private String phone;
+
+    @ExcelProperty(value = "指派托运时间")
+    private String createTime;
+
+    @ExcelProperty(value = "创建人")
+    private String createBy;
+
+}

+ 4 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillCarVO.java

@@ -24,6 +24,10 @@ public class WaybillCarVO {
      * 车辆类型
      */
     private String type;
+    /**
+     * 车辆类型-字符
+     */
+    private String typeLabel;
     /**
      * 司机ID
      */

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillTrackVO.java

@@ -25,7 +25,7 @@ public class WaybillTrackVO {
      */
     private String status;
     /**
-     * 记录员
+     * 操作员名
      */
     private String createBy;
     /**

+ 64 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/LogisticsConsignmentService.java

@@ -19,6 +19,7 @@ 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.excel.utils.DateUtil;
 import com.sckw.excel.utils.ValidUtil;
 import com.sckw.fleet.api.RemoteFleetService;
 import com.sckw.fleet.api.model.vo.RTruckVo;
@@ -39,6 +40,8 @@ import com.sckw.transport.model.dto.LogisticsOrderDTO;
 import com.sckw.transport.model.dto.OrderCarDTO;
 import com.sckw.transport.model.dto.OrderFinishDTO;
 import com.sckw.transport.model.param.LogisticsConsignmentParam;
+import com.sckw.transport.model.vo.PurchaseLogisticOrderExcelVo;
+import com.sckw.transport.model.vo.SellLogisticOrderExcelVo;
 import com.sckw.transport.model.vo.OrderFinishVO;
 import io.seata.core.context.RootContext;
 import jakarta.annotation.Resource;
@@ -52,6 +55,7 @@ import org.springframework.util.ObjectUtils;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 /**
@@ -1651,4 +1655,64 @@ public class LogisticsConsignmentService {
         httpResult.setData(orderFinishVO);
         return httpResult;
     }
+
+    /**
+     * 导出销售/采购订单对应的运单列表
+     * @param ids 销售/采购订单IDs
+     * @return
+     */
+    public List<PurchaseLogisticOrderExcelVo> logisticOrderByPurchaseOrderIdExport(String ids) {
+        List<String> idList = StringUtils.splitStrToList(ids, String.class);
+        List<PurchaseLogisticOrderExcelVo> logisticOrderExcelVos = new ArrayList<>();
+        List<LogisticsOrderDTO> orders = kwtLogisticsOrderMapper.selectOrderListByIdsAndUnitType(idList, "1");
+        AtomicInteger i = new AtomicInteger(1);
+        orders.forEach(e -> {
+            PurchaseLogisticOrderExcelVo vo = new PurchaseLogisticOrderExcelVo();
+            vo.setSerialNumber(String.valueOf(i.getAndIncrement()));
+            vo.setLOrderNo(e.getLOrderNo());
+            vo.setTOrderNo(e.getTOrderNo());
+            vo.setStatus(LogisticsOrderEnum.getDestination(e.getStatus()));
+            vo.setCompanyName(e.getCompanyName());
+            vo.setAmount(String.valueOf(e.getAmount()));
+            vo.setPrice(e.getPrice());
+            vo.setLoss(e.getLoss());
+            vo.setGoodsPrice(e.getGoodsPrice());
+            vo.setContacts(e.getContacts());
+            vo.setPhone(e.getPhone());
+            vo.setCreateTime(e.getCreateTime());
+            vo.setCreateBy(e.getCreateBy());
+            logisticOrderExcelVos.add(vo);
+        });
+        return logisticOrderExcelVos;
+    }
+
+    /**
+     * 导出销售/采购订单对应的运单列表
+     * @param ids 销售/采购订单IDs
+     * @return
+     */
+    public List<SellLogisticOrderExcelVo> logisticOrderBySellOrderIdExport(String ids) {
+        List<String> idList = StringUtils.splitStrToList(ids, String.class);
+        List<SellLogisticOrderExcelVo> logisticOrderExcelVos = new ArrayList<>();
+        List<LogisticsOrderDTO> orders = kwtLogisticsOrderMapper.selectOrderListByIdsAndUnitType(idList, "2");
+        AtomicInteger i = new AtomicInteger(1);
+        orders.forEach(e -> {
+            SellLogisticOrderExcelVo vo = new SellLogisticOrderExcelVo();
+            vo.setSerialNumber(String.valueOf(i.getAndIncrement()));
+            vo.setLOrderNo(e.getLOrderNo());
+            vo.setTOrderNo(e.getTOrderNo());
+            vo.setStatus(LogisticsOrderEnum.getDestination(e.getStatus()));
+            vo.setCompanyName(e.getCompanyName());
+            vo.setAmount(String.valueOf(e.getAmount()));
+            vo.setPrice(e.getPrice());
+            vo.setLoss(e.getLoss());
+            vo.setGoodsPrice(e.getGoodsPrice());
+            vo.setContacts(e.getContacts());
+            vo.setPhone(e.getPhone());
+            vo.setCreateTime(e.getCreateTime());
+            vo.setCreateBy(e.getCreateBy());
+            logisticOrderExcelVos.add(vo);
+        });
+        return logisticOrderExcelVos;
+    }
 }

+ 22 - 9
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java

@@ -102,6 +102,7 @@ public class WaybillManagementService {
             wayBillDetailDTO.setWOrderNo(info.getWOrderNo());
             wayBillDetailDTO.setLOrderId(info.getLOrderId());
             wayBillDetailDTO.setLOrderNo(info.getLOrderNo());
+            wayBillDetailDTO.setLOrderNo(info.getLOrderNo());
             wayBillDetailDTO.setEntrustAmount(String.valueOf(info.getEntrustAmount()));
             wayBillDetailDTO.setType(String.valueOf(info.getType()));
             wayBillDetailDTO.setStartTime(DateUtil.getDateTime(info.getStartTime()));
@@ -110,19 +111,27 @@ public class WaybillManagementService {
             wayBillDetailDTO.setGoodsName(info.getGoodsName());
             wayBillDetailDTO.setLoadDetailAddress(info.getLoadCityName().concat(info.getLoadDetailAddress()));
             wayBillDetailDTO.setUnloadDetailAddress(info.getUnloadCityName().concat(info.getUnloadDetailAddress()));
-            // 计价方式
+            wayBillDetailDTO.setLoadName(info.getLoadName());
+            wayBillDetailDTO.setUnloadName(info.getUnloadName());
+            // 计费方式
             KwtLogisticsOrder kwtLogisticsOrder = kwtLogisticsOrderMapper.selectById(info.getLOrderId());
             if(!ObjectUtils.isEmpty(kwtLogisticsOrder)) {
+                wayBillDetailDTO.setPriceType(kwtLogisticsOrder.getBillingMode());
                 SysDictResDto billingMode = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.CHARGING_TYPE.getType(), kwtLogisticsOrder.getBillingMode());
                 if(!ObjectUtils.isEmpty(billingMode)) {
-                    wayBillDetailDTO.setPriceType(billingMode.getLabel());
+                    wayBillDetailDTO.setPriceTypeLabe(billingMode.getLabel());
                 }
             }
             wayBillDetailDTO.setCheckFirmName(info.getCheckFirmName());
+            // 派车人信息
+            UserCacheResDto createUser = remoteSystemService.queryUserCacheById(info.getCreateBy());
+            if(!ObjectUtils.isEmpty(createUser)) {
+                wayBillDetailDTO.setCreateByPhone(createUser.getPhone());
+            }
             // 车辆信息
             SysDictResDto truckTypeString = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.TRUCK_TYPE.getType(), info.getTruckType());
             if(!ObjectUtils.isEmpty(truckTypeString)) {
-                waybillCarVO.setType(truckTypeString.getLabel());
+                waybillCarVO.setTypeLabel(truckTypeString.getLabel());
             }
             waybillCarVO.setTruckId(String.valueOf(info.getTruckId()));
             waybillCarVO.setTruckNo(info.getTruckNo());
@@ -156,8 +165,8 @@ public class WaybillManagementService {
             List<Long> userIds = new ArrayList<>();
             kwtWaybillOrderTracks.forEach(e -> userIds.add(e.getCreateBy()));
             List<UserCacheResDto> users = remoteSystemService.queryUserCacheByIds(userIds);
-            Map<Long, String> usersMap = new HashMap<>();
-            users.forEach(e -> usersMap.put(e.getId(), e.getName()));
+            Map<Long, UserCacheResDto> usersMap = new HashMap<>();
+            users.forEach(e -> usersMap.put(e.getId(), e));
             for (KwtWaybillOrderTrack kwtWaybillOrderTrack: kwtWaybillOrderTracks) {
                 for (WaybillStatusVO statusVO:statusVOS) {
                     if(statusVO.getCode().equals(kwtWaybillOrderTrack.getStatus())) {
@@ -167,7 +176,7 @@ public class WaybillManagementService {
                         statusVO.setOperateTime(kwtWaybillOrderTrack.getOperateTime() == null
                                 ? null : DateUtil.getDateTime(kwtWaybillOrderTrack.getOperateTime()));
                         statusVO.setCreateByName(usersMap.get(kwtWaybillOrderTrack.getCreateBy()) == null
-                                ? null : usersMap.get(kwtWaybillOrderTrack.getCreateBy()));
+                                ? null : usersMap.get(kwtWaybillOrderTrack.getCreateBy()).getName());
                         break;
                     }
                 }
@@ -176,7 +185,9 @@ public class WaybillManagementService {
                         .setRemark(kwtWaybillOrderTrack.getRemark())
                         .setStatus(String.valueOf(kwtWaybillOrderTrack.getStatus()))
                         .setCreateBy(usersMap.get(kwtWaybillOrderTrack.getCreateBy()) == null
-                                ? null : usersMap.get(kwtWaybillOrderTrack.getCreateBy()))
+                                ? null : usersMap.get(kwtWaybillOrderTrack.getCreateBy()).getName())
+                        .setCreateByPhone(usersMap.get(kwtWaybillOrderTrack.getCreateBy()) == null
+                                ? null : usersMap.get(kwtWaybillOrderTrack.getCreateBy()).getPhone())
                         .setCreateTime(DateUtil.getDateTime(kwtWaybillOrderTrack.getCreateTime()));
                 waybillTrackVOS.add(waybillTrackVO);
             }
@@ -235,8 +246,10 @@ public class WaybillManagementService {
             waybillBoardListVO.setTruckNo(String.valueOf(sckwWaybillOrder.getTruckNo()));
             waybillBoardListVO.setLoadGrossAmount(sckwWaybillOrder.getLoadGrossAmount() != null ? String.valueOf(sckwWaybillOrder.getLoadGrossAmount()) : null);
             waybillBoardListVO.setUnloadGrossAmount(sckwWaybillOrder.getUnloadGrossAmount() != null ? String.valueOf(sckwWaybillOrder.getUnloadGrossAmount()) : null);
-            waybillBoardListVO.setLoadUrls(sckwWaybillOrder.getLoadUrls() != null ? FileUtils.getOSSAddressPrefix() + sckwWaybillOrder.getLoadUrls() : null);
-            waybillBoardListVO.setUnloadUrls(sckwWaybillOrder.getUnloadUrls() != null ? FileUtils.getOSSAddressPrefix() + sckwWaybillOrder.getUnloadUrls() : null);
+            waybillBoardListVO.setLoadUrls(sckwWaybillOrder.getLoadUrls());
+//            waybillBoardListVO.setLoadUrls(sckwWaybillOrder.getLoadUrls() != null ? FileUtils.getOSSAddressPrefix() + sckwWaybillOrder.getLoadUrls() : null);
+//            waybillBoardListVO.setUnloadUrls(sckwWaybillOrder.getUnloadUrls() != null ? FileUtils.getOSSAddressPrefix() + sckwWaybillOrder.getUnloadUrls() : null);
+            waybillBoardListVO.setUnloadUrls(sckwWaybillOrder.getUnloadUrls());
             List<WaybillStatusVO> statusVOS2 = new ArrayList<>();
             statusVOS.forEach(e -> {
                 WaybillStatusVO temp = new WaybillStatusVO();

+ 29 - 0
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

@@ -540,4 +540,33 @@
             8
             )
     </select>
+
+    <select id="selectOrderListByIdsAndUnitType" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
+        SELECT a.id          as lOrderId,
+               a.l_order_no  as lOrderNo,
+               b.`status`    as `status`,
+               a.t_order_id  as tOrderId,
+               a.t_order_no  as tOrderNo,
+               a.payment     as payment,
+               a.amount,
+               a.price,
+               a.loss,
+               a.goods_price as goodsPrice,
+               c.firm_name   as companyName,
+               c.contacts,
+               c.phone,
+               a.create_by   as createBy,
+               a.create_time as createTime
+        FROM kwt_logistics_order a
+                 LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
+                 LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
+        WHERE a.del_flag = '0'
+          AND b.del_flag = '0'
+          AND a.t_order_id IN
+            <foreach collection="ids" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        order by createTime desc
+    </select>
+
 </mapper>