package com.prolog.rdc.tms.controller;

import com.prolog.common.util.DateUtils;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.dto.*;
import com.prolog.rdc.tms.model.dto.basicConfigure.ShipbillMatchCarrierDTO;
import com.prolog.rdc.tms.model.dto.planMng.PlanBillLoadingDTO;
import com.prolog.rdc.tms.model.dto.planMng.PlanGroupQueryRsDTO;
import com.prolog.rdc.tms.model.vo.*;
import com.prolog.rdc.tms.model.vo.planMng.PlanBillLoadingVO;
import com.prolog.rdc.tms.model.vo.planMng.PlanDispatchVO;
import com.prolog.rdc.tms.model.vo.planMng.PlanGroupQueryVO;
import com.prolog.rdc.tms.service.PendingDispatchService;
import com.prolog.wms.base.util.ExcelUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 调度管理-待调度控制层
 *
 * @author lhb
 * @since 2022-04-11 09:04:35
 */
@RestController
@Api(tags = "调度管理-待调度控制层")
@RequestMapping("/pending_dispatch")
public class PendingDispatchController {

    @Autowired
    private PendingDispatchService pendingDispatchService;

    @UserLog("待调度分页查询")
    @ApiOperation(value = "待调度分页查询", notes = "待调度分页查询")
    @PostMapping("/page")
    public RestMessage<Page<PendingDispatchPageDTO>> pagePendingReviewExecute(@RequestBody PendingDispatchPageVO pendingDispatchPageVO) {
        try {
            Page<PendingDispatchPageDTO> pendingDispatchPageDTOs = pendingDispatchService.pagePendingDispatchData(pendingDispatchPageVO);
            return RestMessage.newInstance(true, "查询成功", pendingDispatchPageDTOs);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("待调度高级查询")
    @ApiOperation(value = "待调度高级查询", notes = "待调度高级查询")
    @PostMapping("/advanced")
    public RestMessage<Page<PendingDispatchPageDTO>> pageAdvancedExecute(@RequestBody PendingDispatchAdvQueryVO advancedQueryVO) {
        try {
            Page<PendingDispatchPageDTO> pendingDispatchPageDTOs = pendingDispatchService.pageAdvanced(advancedQueryVO);
            return RestMessage.newInstance(true, "查询成功", pendingDispatchPageDTOs);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("待调度商品信息查询")
    @ApiOperation(value = "待调度商品信息查询", notes = "待调度商品信息查询")
    @PostMapping("/detail/list")
    public RestMessage<Page<PendingDispatchDetailDTO>> listShipbillDetailExecute(@RequestBody DetailItemPageVO detailItemPageVO) {
        try {
            Page<PendingDispatchDetailDTO> pendingReviewDetailDTOs = pendingDispatchService.listShipbillDetailData(detailItemPageVO);
            return RestMessage.newInstance(true, "查询成功", pendingReviewDetailDTOs);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("待调度折分商品信息查询")
    @ApiOperation(value = "待调度折分商品信息查询", notes = "待调度折分商品信息查询")
    @PostMapping("/split/detail/list")
    public RestMessage<List<PendingDispatchDetailDTO>> splitListShipbillDetailExecute(@RequestBody DetailItemSplitVO detailItemPageVO) {
        try {
            List<PendingDispatchDetailDTO> pendingReviewDetailDTOs = pendingDispatchService.splitListShipbillDetail(detailItemPageVO);
            return RestMessage.newInstance(true, "查询成功", pendingReviewDetailDTOs);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("待调度包裹信息查询")
    @ApiOperation(value = "待调度包裹信息查询", notes = "待调度包裹信息查询")
    @PostMapping("/package/list")
    public RestMessage<Page<PendingDispatchPackageDTO>> listShipbillPackageExecute(@RequestBody DetailItemPageVO detailItemPageVO) {
        try {
            Page<PendingDispatchPackageDTO> pendingReviewPackageDTOS = pendingDispatchService.listShipbillPackageData(detailItemPageVO);
            return RestMessage.newInstance(true, "查询成功", pendingReviewPackageDTOS);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("调度")
    @ApiOperation(value = "调度", notes = "调度")
    @PostMapping("/dispatch")
    public RestMessage<String> dispatchShipbillExecute(@RequestBody PendingDispatchVO vo) {
        try {
            pendingDispatchService.dispatch(vo);
            return RestMessage.newInstance(true, "调度成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("调度并审核")
    @ApiOperation(value = "调度并审核", notes = "调度并审核")
    @PostMapping("/dispatch_review")
    public RestMessage<String> dispatchReviewShipbillExecute(@RequestBody PendingDispatchVO vo) {
        try {
            pendingDispatchService.dispatchReview(vo);
            return RestMessage.newInstance(true, "调度并审核成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("获取调度单号")
    @ApiOperation(value = "获取调度单号", notes = "获取调度单号")
    @PostMapping("/get_dispatch_number")
    public RestMessage<String> getDispatchNumberExecute() {
        try {
            String dispatchNumber = pendingDispatchService.getDispatchNumber();
            return RestMessage.newInstance(true, "获取调度单号成功", dispatchNumber);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("分组调度")
    @ApiOperation(value = "分组调度", notes = "分组调度")
    @PostMapping("/group_dispatch")
    public RestMessage<String> groupDispatchShipbillExecute(@RequestBody List<GroupPendingDispatchVO> groupPendingDispatchVOs) {
        try {
            pendingDispatchService.groupDispatch(groupPendingDispatchVOs);
            return RestMessage.newInstance(true, "分组调度成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("分组调度并审核")
    @ApiOperation(value = "分组调度并审核", notes = "分组调度并审核")
    @PostMapping("/group_dispatch_review")
    public RestMessage<String> groupDispatchReviewShipbillExecute(@RequestBody List<GroupPendingDispatchReviewVO> groupDispatchReviewVOs) {
        try {
            pendingDispatchService.groupDispatchReview(groupDispatchReviewVOs);
            return RestMessage.newInstance(true, "分组调度并审核成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("系统分组-查询")
    @ApiOperation(value = "系统分组-查询", notes = "系统分组-查询")
    @PostMapping("/sys_group_query_new")
    public RestMessage<SysGroupQueryRsDTO> sysGroupQueryNewExecute(@RequestBody SysGroupQueryVO vo) {
        try {
            SysGroupQueryRsDTO sysGroupQueryDTOS = pendingDispatchService.sysGroupNewQuery(vo);
            return RestMessage.newInstance(true, "系统分组-查询成功", sysGroupQueryDTOS);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("运单货量统计")
    @ApiOperation(value = "运单货量统计", notes = "运单货量统计")
    @PostMapping("/goods_quantity_statistics")
    public RestMessage<PendingDispatchShipbillQtyDTO> goodsQuantityStatisticsExecute(@RequestBody SysGroupQueryVO vo) {
        try {
            PendingDispatchShipbillQtyDTO goodsQtyStatisticsDTO = pendingDispatchService.goodsQtyStatistics(vo);
            return RestMessage.newInstance(true, "运单货量统计成功", goodsQtyStatisticsDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("线路货量统计")
    @ApiOperation(value = "线路货量统计", notes = "线路货量统计")
    @PostMapping("/line_quantity_statistics")
    public RestMessage<List<PendingDispatchShipbillQtyByLineDTO>> lineQuantityStatisticsExecute(@RequestBody SysGroupQueryVO vo) {
        try {
            List<PendingDispatchShipbillQtyByLineDTO> lineQtyStatisticsList = pendingDispatchService.lineQtyStatistics(vo);
            return RestMessage.newInstance(true, "运单货量统计成功", lineQtyStatisticsList);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("调度前运单地图站点信息查询")
    @ApiOperation(value = "调度前运单地图站点信息查询", notes = "调度前运单地图站点信息查询")
    @PostMapping("/shipbill_map")
    public RestMessage<ShipbillMapDTO> shipbillMapSiteQueryExecute(@RequestBody SysGroupQueryVO vo) {
        try {
            ShipbillMapDTO siteQueryDTOS = pendingDispatchService.shipbillMapSiteQuery(vo);
            return RestMessage.newInstance(true, "运单地图站点信息查询成功", siteQueryDTOS);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("热力图站点信息查询")
    @ApiOperation(value = "热力图站点信息查询", notes = "热力图站点信息查询")
    @PostMapping("/shipbill_hot_map")
    public RestMessage<List<ShipbillHotMapDTO>> shipbillHotMapSiteQueryExecute(@RequestBody SysGroupQueryVO vo) {
        try {
            List<ShipbillHotMapDTO> siteQueryDTOS = pendingDispatchService.shipbillHotMapSiteQuery(vo);
            return RestMessage.newInstance(true, "查询成功", siteQueryDTOS);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("运单线路站点信息查询")
    @ApiOperation(value = "运单线路站点信息查询", notes = "运单线路站点信息查询")
    @PostMapping("/shipbill_sites")
    public RestMessage<List<SysGroupShipbillQueryDTO>> shipbillSiteQueryExecute(@RequestBody SysGroupQueryVO vo) {
        try {
            List<SysGroupShipbillQueryDTO> siteQueryDTOS = pendingDispatchService.shipbillSiteQuery(vo);
            return RestMessage.newInstance(true, "运单地图站点信息查询成功", siteQueryDTOS);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("系统分组-运单查询")
    @ApiOperation(value = "系统分组-运单查询", notes = "系统分组-运单查询")
    @PostMapping("/sys_group_shipbill_query")
    public RestMessage<List<SysGroupShipbillQueryDTO>> sysGroupShipbillQueryExecute(@RequestBody SysGroupQueryVO vo) {
        try {
            List<SysGroupShipbillQueryDTO> sysGroupQueryDTOS = pendingDispatchService.sysGroupShipbillQuery(vo);
            return RestMessage.newInstance(true, "系统分组-运单查询成功", sysGroupQueryDTOS);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("系统分组-配载单信息查询")
    @ApiOperation(value = "系统分组-配载单信息查询", notes = "系统分组-配载单信息查询")
    @PostMapping("/sys_group_loading_query")
    public RestMessage<SysGroupLoadingQueryDTO> sysGroupLoadingQueryExecute(@RequestBody SysGroupQueryVO vo) {
        try {
            SysGroupLoadingQueryDTO sysGroupLoadingQuery = pendingDispatchService.sysGroupLoadingQuery(vo);
            return RestMessage.newInstance(true, "系统分组-配载单信息查询成功", sysGroupLoadingQuery);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("待调度中转")
    @ApiOperation(value = "待调度中转", notes = "待调度中转")
    @PostMapping("/transit")
    public RestMessage<String> transitExecute(@RequestBody TransitVO transitVO) {
        try {
            pendingDispatchService.transit(transitVO);
            return RestMessage.newInstance(true, "待调度中转成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("地址解析查询")
    @ApiOperation(value = "地址解析查询", notes = "地址解析查询")
    @PostMapping("/address_resolution/page")
    public RestMessage<Page<PendingDispatchAddressPageDTO>> pageAddressResolutionExecute(@RequestBody PendingDispatchAddressPageVO pendingDispatchAddressPageVO) {
        Page<PendingDispatchAddressPageDTO> pendingDispatchAddressPageDTOs = pendingDispatchService.parseAddressQueryData(pendingDispatchAddressPageVO);
        return RestMessage.newInstance(true, "查询成功", pendingDispatchAddressPageDTOs);
    }

    @UserLog("待调度地址解析")
    @ApiOperation(value = "待调度地址解析", notes = "待调度地址解析")
    @PostMapping("/parse_address")
    public RestMessage<String> parseAddressShipbill(@RequestBody PendingDispatchParseAddressVO vo) {
        try {
            pendingDispatchService.parseAddressData(vo);
            return RestMessage.newInstance(true, "地址解析成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("待调度运单打印")
    @ApiOperation(value = "待调度运单打印", notes = "待调度运单打印")
    @PostMapping("/print")
    public RestMessage<Map<String, Object>> shipbillPrint(@RequestParam("shipbillId") String shipbillId) {
        try {
            Map<String, Object> map = pendingDispatchService.shipbillPrint(shipbillId);
            return RestMessage.newInstance(true, "打印成功", map);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("待调度导出所有数据")
    @ApiOperation(value = "待调度导出所有数据", notes = "待调度导出所有数据")
    @PostMapping("/export_all_detail")
    public RestMessage<Object> exportAllDetailExecute(@RequestBody PendingDispatchExportAllDataVO pendingDispatchExportAllDataVO, HttpServletResponse response) {
        try {
            List<PendingDispatchExportDetailDataDTO> list = pendingDispatchService.exportAllDetailData(pendingDispatchExportAllDataVO);
            ExcelUtils.export(response, PendingDispatchExportDetailDataDTO.class, DateUtils.format(DateUtils.nowDate(), DateUtils.PATTERN_FULL_SIMPLE), list);
            return RestMessage.newInstance(true, "导出成功！", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("待调度导出当前页数据")
    @ApiOperation(value = "待调度导出当前页数据", notes = "待调度导出当前页数据")
    @PostMapping("/export_current_page_detail")
    public RestMessage<Object> exportCurrentPageDetailExecute(@RequestBody PendingDispatchExportCurrenPageDataVO currentPageDataVO, HttpServletResponse response) {
        try {
            List<PendingDispatchExportDetailDataDTO> list = pendingDispatchService.exportCurrentPageDetailData(currentPageDataVO);
            ExcelUtils.export(response, PendingDispatchExportDetailDataDTO.class, DateUtils.format(DateUtils.nowDate(), DateUtils.PATTERN_FULL_SIMPLE), list);
            return RestMessage.newInstance(true, "导出成功！", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("待调度导出选择行数据")
    @ApiOperation(value = "待调度导出选择行数据", notes = "待调度导出选择行数据")
    @PostMapping("/export_select_line_detail")
    public RestMessage<Object> exportSelectLineDetailExecute(@RequestBody List<String> shipbillIdList, HttpServletResponse response) {
        try {
            List<PendingDispatchExportDetailDataDTO> list = pendingDispatchService.exportSelectLineData(shipbillIdList);
            ExcelUtils.export(response, PendingDispatchExportDetailDataDTO.class, DateUtils.format(DateUtils.nowDate(), DateUtils.PATTERN_FULL_SIMPLE), list);
            return RestMessage.newInstance(true, "导出成功！", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/pending_dispatch_view")
    @UserLog("待调度查看")
    @ApiOperation(value = "待调度查看", notes = "待调度查看")
    public RestMessage<PendingDispatchViewDTO> pendingDispatchViewExecute(@RequestParam("shipbillId") String shipbillId) {
        try {
            PendingDispatchViewDTO dto = pendingDispatchService.pendingDispatchView(shipbillId);
            return RestMessage.newInstance(true, "运单查看成功！", dto);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/goods_split")
    @UserLog("待调度按商品拆分")
    @ApiOperation(value = "待调度按商品拆分", notes = "待调度按商品拆分")
    public RestMessage<String> goodsSplitExecute(@RequestBody SplitVO splitVO) {
        try {
            pendingDispatchService.goodsSplit(splitVO);
            return RestMessage.newInstance(true, "商品拆分成功！", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/revoke")
    @UserLog("待调度撤销")
    @ApiOperation(value = "待调度撤销", notes = "待调度撤销")
    public RestMessage<String> revokeExecute(@RequestBody RevokeVO revokeVO) {
        try {
            pendingDispatchService.revoke(revokeVO);
            return RestMessage.newInstance(true, "撤销成功！", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/detail/package")
    @UserLog("待调度商品包裹信息查询")
    @ApiOperation(value = "待调度商品包裹信息查询", notes = "待调度商品包裹信息查询")
    public RestMessage<Page<PendingDispatchPackageDTO>> viewDetailPackageExecute(@RequestBody PendingDispatchPackageByDetailVO pendingDispatchPackageByDetailVO) {
        try {
            Page<PendingDispatchPackageDTO> pkgDtoList = pendingDispatchService.viewDetailPackage(pendingDispatchPackageByDetailVO);
            return RestMessage.newInstance(true, "包裹信息查询成功！", pkgDtoList);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/package/detail")
    @UserLog("待调度包裹商品信息查询")
    @ApiOperation(value = "待调度包裹商品信息查询", notes = "待调度包裹商品信息查询")
    public RestMessage<Page<PendingDispatchPackageDetailDTO>> viewPackageDetailExecute(@RequestBody PendingDispatchDetailByPackageVO pendingDispatchDetailByPackageVO) {
        try {
            Page<PendingDispatchPackageDetailDTO> detailDtoList = pendingDispatchService.viewPackageDetail(pendingDispatchDetailByPackageVO);
            return RestMessage.newInstance(true, "商品信息查询成功！", detailDtoList);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/shipbill_view")
    @UserLog("待调度点击运单查看运单相关信息")
    @ApiOperation(value = "待调度点击运单查看运单相关信息", notes = "待调度点击运单查看运单相关信息")
    public RestMessage<PendingDispatchViewDTO> viewShipbillExecute(@RequestParam("shipbillId") String shipbillId) {
        try {
            PendingDispatchViewDTO dto = pendingDispatchService.viewShipbillData(shipbillId);
            return RestMessage.newInstance(true, "运单查看成功！", dto);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/smart_split")
    @UserLog("智能拆分")
    @ApiOperation(value = "智能拆分", notes = "智能拆分")
    public RestMessage<List<SmartSplitDTO>> smartSplitExecute(@RequestBody SmartSplitVO smartSplitVO) {
        try {
            List<SmartSplitDTO> list = pendingDispatchService.smartSplitData(smartSplitVO);
            return RestMessage.newInstance(true, "操作成功！", list);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/smart_split_strategy")
    @UserLog("智能拆分(选择策略)")
    @ApiOperation(value = "智能拆分(选择策略)", notes = "智能拆分(选择策略)")
    public RestMessage<Object> smartSplitStrategyExecute(@RequestBody List<SmartSplitStrategyVO> smartSplitStrategyVOS) {
        try {
            pendingDispatchService.smartSplitStrategyData(smartSplitStrategyVOS);
            return RestMessage.newInstance(true, "操作成功！", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/carrier_dispatch_strategy")
    @UserLog("策略调度")
    @ApiOperation(value = "策略调度", notes = "策略调度")
    public RestMessage<Object> smartDispatchStrategyExecute(@RequestBody List<String> shipbillIds) {
        try {
            String msg = pendingDispatchService.smartDispatchStrategy(shipbillIds);
            return RestMessage.newInstance(true, msg, null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/smart_transfer")
    @UserLog("策略中转")
    @ApiOperation(value = "策略中转", notes = "策略中转")
    public RestMessage<Object> smartTransferExecute(@RequestBody List<String> shipbillIds) {
        try {
            pendingDispatchService.smartTransferData(shipbillIds);
            return RestMessage.newInstance(true, "中转成功！", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/query_dispatch_strategy")
    @UserLog("查询承调度策略")
    @ApiOperation(value = "查询调度策略", notes = "查询调度策略")
    public RestMessage<ShipbillMatchCarrierDTO> queryDispatchStrategyExecute(@RequestBody List<String> shipbillIds) {
        try {
            ShipbillMatchCarrierDTO strategyDTO = pendingDispatchService.queryDispatchStrategyData(shipbillIds);
            return RestMessage.newInstance(true, "查询成功！", strategyDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @PostMapping("/match_line")
    @UserLog("运单匹配线路")
    @ApiOperation(value = "运单匹配线路", notes = "运单匹配线路")
    public RestMessage<Object> matchLineStrategyExecute(@RequestBody SysGroupQueryVO vo) {
        try {
            pendingDispatchService.matchLineStrategy(vo);
            return RestMessage.newInstance(true, "查询成功！", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("根据站点计算总里程")
    @ApiOperation(value = "根据站点计算总里程", notes = "根据站点计算总里程")
    @PostMapping("/calculate_mileage")
    public RestMessage<CalculateMileageDTO> calculateMileageExecute(@RequestBody List<CalculateMileageVO> vos) {
        try {
            CalculateMileageDTO mileageDTO = pendingDispatchService.calculateTotalMileage(vos);
            return RestMessage.newInstance(true, "查询成功", mileageDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }


    @UserLog("计划调度配载单信息统计")
    @ApiOperation(value = "计划调度配载单信息统计", notes = "计划调度配载单信息统计")
    @PostMapping("/plan_dispatch_loading_statistics")
    public RestMessage<PlanBillLoadingDTO> planDispatchLoadingStatisticsExecute(@RequestBody PlanBillLoadingVO vo) {
        try {
            PlanBillLoadingDTO planBillLoadingDTO = pendingDispatchService.planDispatchLoadingStatistics(vo);
            return RestMessage.newInstance(true, "配载单查询成功", planBillLoadingDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }


    @UserLog("计划调度")
    @ApiOperation(value = "计划调度", notes = "计划调度")
    @PostMapping("/plan_dispatch")
    public RestMessage<String> planDispatchExecute(@RequestBody List<PlanDispatchVO> vos) {
        try {
            pendingDispatchService.planDispatch(vos);
            return RestMessage.newInstance(true, "调度成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("计划调度并审核")
    @ApiOperation(value = "计划调度并审核", notes = "计划调度并审核")
    @PostMapping("/plan_dispatch_review")
    public RestMessage<String> planDispatchReviewExecute(@RequestBody List<PlanDispatchVO> vos) {
        try {
            pendingDispatchService.planDispatchReview(vos);
            return RestMessage.newInstance(true, "调度并审核成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("计划调度系统分组-查询")
    @ApiOperation(value = "计划调度系统分组-查询", notes = "计划调度系统分组-查询")
    @PostMapping("/planDispatchGroupQuery")
    public RestMessage<PlanGroupQueryRsDTO> planDispatchGroupQueryExecute(@RequestBody PlanGroupQueryVO vo) {
        try {
            PlanGroupQueryRsDTO sysGroupQueryDTOS = pendingDispatchService.planDispatchGroupQuery(vo);
            return RestMessage.newInstance(true, "查询成功", sysGroupQueryDTOS);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }
}
