package com.steerinfo.dil.controller; import com.alibaba.fastjson.JSON; import com.steerinfo.dil.feign.ESFeign; import com.steerinfo.dil.model.RmsCarDriver; import com.steerinfo.dil.service.impl.RmsCarDriverServiceImpl; 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 com.steerinfo.framework.utils.misc.IdGenerator; import com.steerinfo.framework.utils.upload.UploadUtils; 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 org.springframework.web.multipart.MultipartFile; import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Description: * @Author:ZhouZhou * @CreateTime:2021/11/6 9:47 * @Version:V1.0 */ @RestController @RequestMapping("/${api.version}/rmscardriver") public class RmsCarDriverController extends BaseRESTfulController { @Autowired RmsCarDriverServiceImpl rmsCarDriverService; @Autowired ColumnDataUtil columnDataUtil; @Autowired ESFeign esFeign; /** *增加司机 * @param * @return */ @ApiOperation(value="创建", notes="根据RmsCarDriver对象创建") @ApiImplicitParam(name = "rmsCarDriver", value = "详细实体rmsCarDriver", required = true, dataType = "RmsCarDriver") @PostMapping(value = "/insertCarDriver") public RESTfulResult insertCarDriver(@RequestBody(required = false) Map mapValue){ int result = rmsCarDriverService.insertCarDriver(mapValue); if (result <= 0){ return failed(); } return success(result); } /** *更新司机 * @param rmsCarDriver * @return */ @PostMapping(value = "/updateCarDriver", produces = "application/json;charset=UTF-8") public RESTfulResult updateCarDriver(@RequestBody RmsCarDriver rmsCarDriver){ int result = rmsCarDriverService.updateCarDriver(rmsCarDriver); return success(result); } /** *删除司机 * @param id * @return */ @ApiOperation(value="删除", notes="根据url的id来指定删除对象") @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal") @PostMapping(value = "/deleteCarDriver/{id}")//BigDecimal public RESTfulResult deleteCarDriver(@PathVariable("id") BigDecimal id){ return success(rmsCarDriverService.deleteCarDriver(id)); } /** * 根据id获取司机 * @param id * @return */ @ApiOperation(value="获取详细信息", notes="根据url的id来获取详细信息") @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal") @PostMapping(value = "/getCarDriverById/{id}") public RESTfulResult getCarDriverById(@PathVariable("id") BigDecimal id){ List> map= rmsCarDriverService.getCarDriverById(id); return success(map); } @ApiOperation(value = "司机模糊查询", notes = "分页查询") @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"), @ApiImplicitParam(name = "apiId", value = "196", required = false, dataType = "BigDecimal"), }) @PostMapping(value = "/getCarDriverList") public RESTfulResult getCarDriverList(@RequestBody(required = false) Map mapValue, Integer pageNum, Integer pageSize, Integer apiId, String con) { if (mapValue==null){ mapValue=new HashMap<>(); } //框计算 if (con != null) { if (!"undefined".equals(con)) { //设置要查询的索引名称 String index = "get_car_driver_list"; //获取查询结果 return success(esFeign.getConResult(mapValue, index, apiId, pageNum, pageSize, con)); } } //初始化过滤 List> listTotal = null; //如果有条件查询则跳过初始化,和创建索引 if (mapValue.size() == 0) { //将查询结果存入索引中 listTotal = rmsCarDriverService.getCarDriverList(null); Map map = new HashMap<>(); //添加索引 map.put("index", "get_car_driver_list"); //添加id map.put("indexId", "driverId"); listTotal.add(map); //新建索引 String s = JSON.toJSONString(listTotal); esFeign.insertIndex(listTotal); //删除 listTotal.remove(listTotal.size() - 1); } if (listTotal == null) { listTotal = rmsCarDriverService.getCarDriverList(mapValue); } PageHelper.startPage(pageNum, pageSize); //分页查询数据 List> columnList = rmsCarDriverService.getCarDriverList(mapValue); PageListAdd data = columnDataUtil.tableColumnData(apiId, listTotal, columnList); return success(data); } /* * 运输类型下拉框 * */ @GetMapping("/getTransportTypeId") public RESTfulResult getTransportTypeId(){ return success(rmsCarDriverService.getTransportTypeId()); } /* *边写边搜索承运商 * */ @ApiOperation(value="根据用户输入输出承运商", notes="模糊查询") @ApiImplicitParams({ @ApiImplicitParam(name = "con",value = "用户输入的承运商名", required = false, dataType = "String") }) @PostMapping("/getCarrierName") public RESTfulResult getCarrierName(@RequestParam(value ="state") String state){ List> carrierName = rmsCarDriverService.getCarrierName(state); return success(carrierName); } //根据司机id查询承运商 @PostMapping(value = "/getCarrierNameByDriverId/{id}") public RESTfulResult getCarrierNameByDriverId(@PathVariable("id") BigDecimal id){ Map map = rmsCarDriverService.getCarrierNameByDriverId(id); return success(map); } }