123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- package com.steerinfo.dil.controller;
- import com.alibaba.fastjson.JSON;
- import com.steerinfo.dil.feign.ESFeign;
- import com.steerinfo.dil.model.RmsWarehouse;
- import com.steerinfo.dil.service.impl.RmsWarehouseServiceImpl;
- 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;
- /**
- * @Description:
- * @Author:ZhouZhou
- * @CreateTime:2021/11/10 14:12
- * @Version:V1.0
- */
- @RestController
- @RequestMapping("/${api.version}/rmswarehouse")
- public class RmsWarehouseController extends BaseRESTfulController {
- @Autowired
- RmsWarehouseServiceImpl rmsWarehouseService;
- @Autowired
- ColumnDataUtil columnDataUtil;
- @Autowired
- ESFeign esFeign;
- /**
- *增加原料工厂
- * @param rmsWarehouse
- * @return
- */
- @ApiOperation(value="创建", notes="根据RmsWarehouse对象创建")
- @ApiImplicitParam(name = "rmsWarehouse", value = "详细实体rmsWarehouse", required = true, dataType = "RmsWarehouse")
- @PostMapping(value = "/insertWarehouse")
- public RESTfulResult insertWarehouse(@RequestBody(required = false) RmsWarehouse rmsWarehouse){
- int result = rmsWarehouseService.insertWarehouse(rmsWarehouse);
- if (result==-1){
- return failed();
- }
- return success(result);
- }
- /**
- *更新原料工厂
- * @param rmsWarehouse
- * @return
- */
- @ApiOperation(value="更新详细信息", notes="根据url的id来指定更新对象,并根据传过来的rmsCarDriver信息来更新详细信息")
- @ApiImplicitParams({
- @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal"),
- @ApiImplicitParam(name = "rmsWarehouse", value = "详细实体rmsWarehouse", required = true, dataType = "RmsWarehouse")
- })
- @PostMapping(value = "/updateWarehouse", produces = "application/json;charset=UTF-8")
- public RESTfulResult updateWarehouse( @RequestBody RmsWarehouse rmsWarehouse){
- int result = rmsWarehouseService.updateWarehouse(rmsWarehouse);
- return success(result);
- }
- /**
- *删除原料工厂
- * @param id
- * @return
- */
- @ApiOperation(value="删除", notes="根据url的id来指定删除对象")
- @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal")
- @PostMapping(value = "/deleteWarehouse/{id}")//BigDecimal
- public RESTfulResult deleteWarehouse(@PathVariable("id") BigDecimal id){
- return success(rmsWarehouseService.deleteWarehouse(id));
- }
- /**
- * 根据id获取原料仓库信息
- * @param id
- * @return
- */
- @ApiOperation(value="获取详细信息", notes="根据url的id来获取详细信息")
- @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal")
- @PostMapping(value = "/getWarehouseById/{id}")
- public RESTfulResult getWarehouseById(@PathVariable("id") BigDecimal id){
- // List<Map<String,Object>> list= rmsWarehouseService.getWarehouseById(id);
- Map<String,Object> list= rmsWarehouseService.getWarehouseById(id);
- return success(list);
- }
- /*
- * 获取原料仓库类型下拉
- * */
- @GetMapping(value = "getWarehouseTypeId")
- public RESTfulResult getWarehouseTypeId(){
- return success(rmsWarehouseService.getWarehouseTypeId());
- }
- /*
- *
- * 获取港存库所属港口下拉
- * */
- @GetMapping(value = "getPortId")
- public RESTfulResult getPortId(){
- return success(rmsWarehouseService.getPortId());
- }
- @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 = "/getWarehouseList")
- public RESTfulResult getWarehouseList(@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_warehouse_list";
- //获取查询结果
- return success(esFeign.getConResult(mapValue, index, apiId, pageNum, pageSize, con));
- }
- }
- //初始化过滤
- List<Map<String, Object>> listTotal = null;
- //如果有条件查询则跳过初始化,和创建索引
- if (mapValue.size() == 0) {
- //将查询结果存入索引中
- listTotal = rmsWarehouseService.getWarehouseList(null);
- Map<String, Object> map = new HashMap<>();
- //添加索引
- map.put("index", "get_warehouse_list");
- //添加id
- map.put("indexId", "warehouseId");
- listTotal.add(map);
- //新建索引
- String s = JSON.toJSONString(listTotal);
- esFeign.insertIndex(listTotal);
- //删除
- listTotal.remove(listTotal.size() - 1);
- }
- if (listTotal == null) {
- listTotal = rmsWarehouseService.getWarehouseList(mapValue);
- }
- PageHelper.startPage(pageNum, pageSize);
- //分页查询数据
- List<Map<String, Object>> columnList = rmsWarehouseService.getWarehouseList(mapValue);
- PageListAdd data = columnDataUtil.tableColumnData(apiId, listTotal, columnList);
- return success(data);
- }
- }
|