Newer
Older
huludao / src / main / java / com / newfiber / api / pc / controller / River / PatrolProblemOneMapController.java
package com.newfiber.api.pc.controller.River;


import com.alibaba.fastjson.JSON;
import com.newfiber.api.core.annotation.SysLog;
import com.newfiber.api.core.bean.ReqBodyObj;
import com.newfiber.api.core.bean.RespBodyObj;
import com.newfiber.api.core.support.HttpCode;
import com.newfiber.api.pc.model.River.PatrolTypeCountDto;
import com.newfiber.api.pc.model.River.ProblemDto;
import com.newfiber.api.pc.service.PatrolManageProblemService;
import com.newfiber.api.pc.service.PatrolManageProcessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;


/**
 *  patrolManageProblem控制层
 *
 * @author luzhan
 * @since 2021-07-15
 */
@RestController
@RequestMapping("/onemap")
@Api(value = "API - PatrolManageProblemController", description = "巡查问题统计")
public class PatrolProblemOneMapController {

    private static final Logger log = LoggerFactory.getLogger(PatrolProblemOneMapController.class);

    @Autowired
    public PatrolManageProblemService patrolManageProblemService;

    @Autowired
    private PatrolManageProcessService patrolManageProcessService;

    /**
     * 获取patrolManageProblem信息(分页)
     * @param params
     * @return
     */
    @PostMapping("getList")
    @ApiOperation(value = "获取patrol_manage_problem列表",notes="")
    @SysLog(value="获取patrol_manage_problem列表",actionType="4")
    public RespBodyObj<Map<String,Object>> getList(@RequestBody ReqBodyObj<Map<String, Object>> params) {
        Integer patrolType = StringUtils.isEmpty(params.getData().get("patrolType").toString())?null:Integer.valueOf(params.getData().get("patrolType").toString());
        Map<String,Object> patrolManageProblem =patrolManageProblemService.getList(patrolType);
        return RespBodyObj.ok(patrolManageProblem);
    }

    /**
     * 一张图中的几个echart统计
     * @param params
     * @return
     */
    @PostMapping("getCount")
    @ApiOperation(value = "获取patrol_manage_problem列表",notes="")
    @SysLog(value="获取patrol_manage_problem列表",actionType="4")
    public RespBodyObj<Map<String,Object>> getCount(@RequestBody ReqBodyObj<Map<String, Object>> params) {
        Integer patrolType = StringUtils.isEmpty(params.getData().get("patrolType").toString())?null:Integer.valueOf(params.getData().get("patrolType").toString());
        String startTime = org.springframework.util.StringUtils.isEmpty(params.getData().get("startTime"))?null:params.getData().get("startTime").toString();
        String endTime = org.springframework.util.StringUtils.isEmpty(params.getData().get("endTime"))?null:params.getData().get("endTime").toString();
        Map<String,Object> patrolManageProblem =patrolManageProblemService.getCount(patrolType,startTime,endTime);
        return RespBodyObj.ok(patrolManageProblem);
    }

    /**
     * 巡查达标人员的列表
     * @param params
     * @return
     */
    @PostMapping("getRank")
    @ApiOperation(value = "获取达标巡查问题人员排名",notes="")
    @SysLog(value="获取达标巡查问题人员排名",actionType="4")
    public RespBodyObj getRank(@RequestBody ReqBodyObj<Map<String, Object>> params) {
        Integer patrolType = StringUtils.isEmpty(params.getData().get("patrolType").toString())?null:Integer.valueOf(params.getData().get("patrolType").toString());
        List<PatrolTypeCountDto> rank = patrolManageProblemService.getRank(patrolType);
        return RespBodyObj.ok(rank);
    }

    /**
     * 一张图中的统计当前巡查人数,巡查记录次数和巡查问题次数
     * @param params
     * @return
     */
    @PostMapping("getTotalData")
    @ApiOperation(value = "获取巡查类型人数",notes="")
    @SysLog(value="获取巡查类型人数",actionType="4")
    public RespBodyObj getTotalData(@RequestBody ReqBodyObj<Map<String, Object>> params) {
        Integer patrolType = StringUtils.isEmpty(params.getData().get("patrolType").toString())?null:Integer.valueOf(params.getData().get("patrolType").toString());
        Map<String,Object> map = patrolManageProblemService.getTotalData(patrolType);
        return RespBodyObj.ok(map);
    }


    /**
     * 一张图中的指派操作
     * @param param
     * @param request
     * @return
     */
    @SysLog(value="指派",actionType="3")
    @PostMapping("/appoint")
    public RespBodyObj appoint(@RequestBody ReqBodyObj<ProblemDto> param, HttpServletRequest request){
        log.info("指派操作:{}", JSON.toJSONString(param));
        if(param == null){
            return RespBodyObj.error(HttpCode.BAD_REQUEST);
        }
        return patrolManageProcessService.onemapAppoint(param.getData());
    }

}