DeployController.java 8.87 KB
package com.objecteye.controller;

import com.alibaba.fastjson.JSONObject;
import com.objecteye.common.CommonResult;
import com.objecteye.entity.MonitorMainTableQueryInfo;
import com.objecteye.entity.PageResult;
import com.objecteye.entity.SyDeploy;
import com.objecteye.service.DeployService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * controller
 *
 * @author Administrator
 */
@RestController
@Api(tags = "DeployController", description = "布控管理")
@RequestMapping("/deploy")
@CrossOrigin
public class DeployController {

    @Autowired
    private DeployService deployService;

    /**
     * 布控任务- 主列表查询
     *
     * @return
     */
    @ApiOperation("布控任务- 主列表查询")
    @RequestMapping(value = "/monitorMainTableByPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult monitorMainTableByPage(@RequestBody MonitorMainTableQueryInfo info) {
        PageResult pageResult = deployService.monitorMainTableByPage(info);
        if (pageResult.getRow() == null || pageResult.getRow().size() == 0) {
            return CommonResult.success(201, "无符合条件的数据", new PageResult<>());
        }
        return CommonResult.success(pageResult);
    }

    /**
     * 返回全部列表
     *
     * @return
     */
    @ApiOperation("查看全部的布控任务")
    @RequestMapping(value = "/findAll", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult findAll() {
        List<SyDeploy> all = deployService.findAll();
        if (all == null) {
            return CommonResult.success(201, "暂无布控任务", new ArrayList<>());
        }
        return CommonResult.success(all);
    }

    /**
     * 查看布控任务详细信息
     *
     * @return
     */
    @ApiOperation("查看布控任务详细信息")
    @RequestMapping(value = "/findOne", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult findOne(@RequestBody Map<String, Integer> param) {
        SyDeploy syDeploy = deployService.findOne(param.get("id"));
        if (syDeploy == null) {
            return CommonResult.success(201, "没有找到对应任务", new ArrayList<>());
        }
        return CommonResult.success(syDeploy);
    }

    /**
     * 分页返回列表
     *
     * @return
     */
    @ApiOperation("分页查看全部的布控任务")
    @RequestMapping(value = "/findPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult findPage(@RequestParam Integer currentpage, @RequestParam Integer pagevolume, @RequestParam Integer deployType) {
        SyDeploy syDeploy = new SyDeploy();
        syDeploy.setDeployType(deployType);
        PageResult page = deployService.findPage(syDeploy, currentpage, pagevolume);
        if (page == null) {
            return CommonResult.success(201, "无符合条件的数据", new PageResult<>());
        }
        return CommonResult.success(page);
    }

    /**
     * 分页查看全部的布控任务内容
     *
     * @param pagevolume  页面容量
     * @param currentpage 页码
     * @param deployId    任务id
     * @return 结果集
     */
    @ApiOperation("分页查看全部的布控任务内容")
    @RequestMapping(value = "/findMonitorTaskDetail", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult findMonitorTaskDetail(@RequestParam Integer currentpage, @RequestParam Integer pagevolume, @RequestParam Integer deployId) {
        PageResult page = deployService.findMonitorTaskDetail(deployId, currentpage, pagevolume);
        if (page.getRow().size() == 0) {
            return CommonResult.success(201, "无符合条件的数据", new PageResult<>());
        }
        return CommonResult.success(page);
    }

    /**
     * 增加
     *
     * @param deploy
     * @return
     */
    @ApiOperation("添加布控任务")
    @RequestMapping(value = "/addDeployTask", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult addDeployTask(@RequestBody SyDeploy deploy) {
        try {
            deployService.add(deploy);
            return CommonResult.success("操作成功");
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed();
        }
    }

    /**
     * 修改
     *
     * @param deploy
     * @return
     */
    @ApiOperation("修改布控任务")
    @RequestMapping(value = "/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult update(@RequestBody SyDeploy deploy) {
        try {
            deployService.update(deploy);
            return CommonResult.success("操作成功");
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed();
        }
    }

    /**
     * 批量删除
     *
     * @param map
     * @return
     */
    @ApiOperation("删除布控任务")
    @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult delete(@RequestBody Map<String, int[]> map) {
        try {
            int[] ids = map.get("ids");
            deployService.delete(ids);
            return CommonResult.success("操作成功");
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed();
        }
    }

    /**
     * 撤销- 布控任务撤销
     *
     * @param map 请求参数
     * @return 操作状态
     */
    @ApiOperation("撤销- 布控任务撤销")
    @RequestMapping(value = "/changeTaskStatus", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult changeTaskStatus(@RequestBody Map<String, Integer> map) {
        try {
            Integer status = deployService.cancelOrReNewDeployTask(map.get("deployId"));
            return CommonResult.success(status);
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.success(201, "布控时间已过期, 请更新布控时间后再操作", null);
        }
    }

    /**
     * 撤销- 车牌布控
     *
     * @param map 请求参数
     * @return 操作状态
     */
    @ApiOperation("撤销- 车牌布控")
    @RequestMapping(value = "/changeStatusPlateNum", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult changeStatusPlateNum(@RequestBody Map<String, String> map) {
        try {
            Integer status = deployService.cancelOrReNewTaskByPlate(Integer.parseInt(map.get("deployId")), map.get("plateNumber"));
            return CommonResult.success(status);
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed();
        }
    }

    /**
     * 撤销- 车辆布控
     *
     * @param map 请求参数
     * @return 操作状态
     */
    @ApiOperation("撤销- 车辆布控")
    @RequestMapping(value = "/changeStatusVehicle", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult changeStatusVehicle(@RequestBody Map<String, String> map) {
        try {
            Integer status = deployService.cancelOrReNewTaskByVehicleId(Integer.parseInt(map.get("deployId")),
                    Integer.parseInt(map.get("featureId")), map.get("id"));
            return CommonResult.success(status);
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed();
        }
    }

    /**
     * 撤销- 人像布控
     *
     * @param map 请求参数
     * @return 操作状态
     */
    @ApiOperation("撤销- 人像布控")
    @RequestMapping(value = "/changeStatusPerson", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public CommonResult changeStatusPerson(@RequestBody Map<String, String> map) {
        try {
            Integer status = deployService.cancelOrReNewTaskByPersonId(Integer.parseInt(map.get("deployId")),
                    Integer.parseInt(map.get("featureId")), Integer.parseInt(map.get("id")));
            return CommonResult.success(status);
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed();
        }
    }

    /**
     * 获取底库的相关信息
     *
     * @param map 请求参数
     * @return 操作状态
     */
    @ApiOperation("获取底库的相关信息")
    @RequestMapping(value = "/getLibMsgById", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public JSONObject getLibMsgById(@RequestBody Map<String, String> map) {
        return deployService.getLibMsgById(map.get("id"));
    }
}