package com.steerinfo.dil.controller; import com.steerinfo.dil.feign.ColumnDataFeign; import com.steerinfo.dil.feign.ESFeign; import com.steerinfo.dil.service.impl.AmsDispatchSaleOrderServiceImpl; import com.steerinfo.dil.util.BaseRESTfulController; import com.steerinfo.dil.util.ColumnDataUtil; import com.steerinfo.dil.util.PageListAdd; import com.steerinfo.framework.controller.RESTfulResult; import com.steerinfo.framework.service.pagehelper.PageHelper; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; /** * AmsSaleOrder RESTful接口: * @author generator * @version 1.0-SNAPSHORT 2021-09-06 07:10 * 类描述 * 修订历史: * 日期:2021-09-06 * 作者:generator * 参考: * 描述:AmsSaleOrder RESTful接口 * @see null * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved. */ @RestController @RequestMapping("/${api.version}/amsdispatchsaleorders") public class AmsDispatchSaleOrderController extends BaseRESTfulController { @Autowired AmsDispatchSaleOrderServiceImpl amsDispatchSaleOrderService; @Autowired ColumnDataFeign columnDataFeign; @Autowired ColumnDataUtil columnDataUtil; @Autowired ESFeign esFeign; @ApiOperation(value="查询app端公开抢单") @PostMapping("/getDispatchSaleOrderList") public RESTfulResult getDispatchSaleOrderList(){ List> list = amsDispatchSaleOrderService.getDispatchSaleOrderList(); return success(list); } @ApiOperation(value="查询app端已抢的销售订单") @PostMapping("/getLockDispatchSaleOrderList") public RESTfulResult getLockDispatchSaleOrderList(Integer carrierId){ List> list = amsDispatchSaleOrderService.getLockDispatchSaleOrderList(carrierId); return success(list); } @ApiOperation(value="抢单/接收订单锁定") @PostMapping("/lockDispatchSaleOrder") public RESTfulResult lockDispatchSaleOrder(@RequestParam Integer dispatchId, @RequestParam Integer carrierId) { int result = amsDispatchSaleOrderService.lockDispatchSaleOrder(new BigDecimal(dispatchId),new BigDecimal(carrierId)); return success(result); } @ApiOperation(value="展示pc端司机已经抢到的订单") @ApiImplicitParams({ @ApiImplicitParam(name = "apiId(233)", value = "表头", required = false, dataType = "Interger") }) @PostMapping("/selectDispatchSaleOrderList") public RESTfulResult selectDispatchSaleOrderList(@RequestBody(required=false) Map mapValue, Integer apiId, Integer pageNum, Integer pageSize, Integer carrierId){ if (mapValue == null) { mapValue = new HashMap<>(); } mapValue.put("carrierId",new BigDecimal(carrierId)); List> amsSaleOrder = amsDispatchSaleOrderService.getLockDispatchSaleOrderListForPc(mapValue); PageHelper.startPage(pageNum,pageSize); List> amsSaleOrder1 = amsDispatchSaleOrderService.getLockDispatchSaleOrderListForPc(mapValue); PageListAdd pageList = columnDataUtil.tableColumnData(apiId, amsSaleOrder,amsSaleOrder1); return success(pageList); } @ApiOperation(value="查询PC端公开抢单") @ApiImplicitParams({ @ApiImplicitParam(name = "apiId(242)", value = "表头", required = false, dataType = "Interger") }) @PostMapping("/getPCDispatchSaleOrderList") public RESTfulResult getPCDispatchSaleOrderList(@RequestBody(required=false) Map mapValue, Integer apiId, Integer pageNum, Integer pageSize, Integer dispatchType, String con){ if (con != null) { if(!"undefined".equals(con)){ String index="get_pc_dispatch";//设置要查询的索引名称 return success(esFeign.getConResult(mapValue,index,apiId,pageNum,pageSize,con));//获取查询结果 } } mapValue.put("dispatchType",dispatchType); List> dispatchSaleOrderList = null; if (mapValue.size() == 1) { //将查询结果存入索引中 dispatchSaleOrderList = amsDispatchSaleOrderService.getPCDispatchSaleOrderList(mapValue); Map map1 = new HashMap<>(); //添加索引 map1.put("index","get_pc_dispatch"); //添加id map1.put("indexId","dispatchId"); dispatchSaleOrderList.add(map1); //新建索引 esFeign.insertIndex(dispatchSaleOrderList); //删除 dispatchSaleOrderList.remove(dispatchSaleOrderList.size()-1); } if (dispatchSaleOrderList == null) { dispatchSaleOrderList = amsDispatchSaleOrderService.getPCDispatchSaleOrderList(mapValue); } PageHelper.startPage(pageNum,pageSize); List> columnList = amsDispatchSaleOrderService.getPCDispatchSaleOrderList(mapValue); PageListAdd pageList = columnDataUtil.tableColumnData(apiId, dispatchSaleOrderList,columnList); return success(pageList); } }