123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- 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<String,Object> 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<String,Object>> 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<String, Object> 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<Map<String, Object>> listTotal = null;
- //如果有条件查询则跳过初始化,和创建索引
- if (mapValue.size() == 0) {
- //将查询结果存入索引中
- listTotal = rmsCarDriverService.getCarDriverList(null);
- Map<String, Object> 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<Map<String, Object>> 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<Map<String, Object>> carrierName = rmsCarDriverService.getCarrierName(state);
- return success(carrierName);
- }
- //根据司机id查询承运商
- @PostMapping(value = "/getCarrierNameByDriverId/{id}")
- public RESTfulResult getCarrierNameByDriverId(@PathVariable("id") BigDecimal id){
- Map<String,Object> map = rmsCarDriverService.getCarrierNameByDriverId(id);
- return success(map);
- }
- }
|