Newer
Older
huludao / src / main / java / com / newfiber / api / mobile / controller / RiverPatrolController.java
package com.newfiber.api.mobile.controller;

import com.newfiber.api.config.FileVisitProperty;
import com.newfiber.api.core.annotation.SysLog;
import com.newfiber.api.core.base.BaseController;
import com.newfiber.api.core.base.BaseUrl;
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.core.utils.JsonTools;
import com.newfiber.api.mobile.dao.RiverBusinessPicsDao;
import com.newfiber.api.mobile.model.domain.InspectTheDistance;
import com.newfiber.api.mobile.model.domain.RiverBusinessPics;
import com.newfiber.api.mobile.service.RiverPatrolService;
import com.newfiber.api.pc.model.River.RiverPatrol;
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;

/**
 * 河长巡查表 Controller
 * @author xcc
 * @date 2018-12-04 16:39:34
 */
@RestController
@RequestMapping("/riverpatrol")
public class RiverPatrolController extends BaseController{
	@Autowired
	private RiverPatrolService riverPatrolService;

	@Autowired
	private RiverBusinessPicsDao riverBusinessPicsDao;

	@Autowired
	private FileVisitProperty fileVisitProperty;

	/** 
	 * @Description: 根据行政区划编号查询对应的巡河列表
	 * @param param 
	 * @return: com.newfiber.api.core.bean.RespBodyObj<com.newfiber.api.pc.model.River.RiverPatrol>
	 * @Author: Wmj 
	 * @Date: 2018/12/6 9:31 
	 */ 
	@PostMapping(BaseUrl.QUERY_LIST)
	@SysLog(value="根据行政区划编号查询对应的巡河列表",actionType="4")
	public RespBodyObj<List<RiverPatrol>> selectListByDivisionNo(@RequestBody ReqBodyObj<Map<String,Object>> param,HttpServletRequest request){
		if(param == null){
			return RespBodyObj.error(HttpCode.BAD_REQUEST);
		}
		Integer pageNo = param.getCurrent();
		Integer pageSize = param.getSize();
		Integer startRow = (pageNo != null && pageSize != null)?(pageNo-1)*pageSize:null;
		String userNo = request.getHeader("userNo");
		String divisionNo = (String)param.getData().get("divisionNo");
		List<RiverPatrol> riverPatrolList = riverPatrolService.queryList(startRow,pageSize,userNo,divisionNo);
		return RespBodyObj.ok(riverPatrolList);
	}

	/**
	 * @Description: 查询巡河具体信息
	 * @param param
	 * @return: com.newfiber.api.core.bean.RespBodyObj<java.util.List<com.newfiber.api.pc.model.River.RiverPatrol>>
	 * @Author: Wmj
	 * @Date: 2018/12/6 18:54
	 */
	@PostMapping(BaseUrl.QUERY_BY_PARAM)
	@SysLog(value="查询巡河具体信息",actionType="4")
	public RespBodyObj<RiverPatrol> selectInfoByPatrolNo(@RequestBody ReqBodyObj<RiverPatrol> param,HttpServletRequest request){
		if(param == null){
			return RespBodyObj.error(HttpCode.BAD_REQUEST);
		}
		RiverPatrol riverPatrol = riverPatrolService.queryInfoByPatrolNo(request.getHeader("userNo"),param.getData().getPatrolNo());
		if(riverPatrol != null){
			if(riverPatrol.getPatrolPicsNo() != null && !riverPatrol.getPatrolPicsNo().equals("")){
				String riverPicsNo = riverPatrol.getPatrolPicsNo();
				List<RiverBusinessPics> picsList = riverBusinessPicsDao.queryListByPicsNo(riverPicsNo);
				if(!picsList.isEmpty()){
					for (RiverBusinessPics riverBusinessPics : picsList) {
						riverBusinessPics.setRealPath(fileVisitProperty.getWebFile()+riverBusinessPics.getRiverPicsAddress());
					}
				}
				riverPatrol.setPicsList(picsList);
			}
		}
		return RespBodyObj.ok(riverPatrol);
	}
	
	/** 保存巡查记录 */
	@SysLog(value="保存巡查记录",actionType="1")
	@PostMapping("/savePatrol")
	public RespBodyObj<RiverPatrol> savePatrol(@RequestBody ReqBodyObj<RiverPatrol> param,HttpServletRequest request) throws Exception{
		if(param == null){
			return RespBodyObj.error(HttpCode.BAD_REQUEST);
		}
		Map<String,Object> map = JsonTools.transBean2Map(param.getData());
		riverPatrolService.insertData(map,request);
		return RespBodyObj.ok();
	}

	/** 保存巡查问题 */
	@SysLog(value="保存巡查问题",actionType="1")
	@PostMapping("/saveProblem")
	public RespBodyObj saveProblem(@RequestBody ReqBodyObj<RiverPatrol> param,HttpServletRequest request) throws Exception{
		if(param == null){
			return RespBodyObj.error(HttpCode.BAD_REQUEST);
		}
		Map<String,Object> map = JsonTools.transBean2Map(param.getData());
		return riverPatrolService.saveProblem(map,request);
	}

	/**
	 * 获取同级河长应巡检、未巡检次数
	 * @author chg
	 * @date 2018-12-10
	 * @param params
	 * @param request
	 * @return
	 */
	@SysLog(value="获取同级河长应巡检、未巡检次数",actionType = "4")
	@PostMapping("pollingTimesCurrnt")
	public RespBodyObj<Map<String,Object>> pollingTimesCurrnt(@RequestBody ReqBodyObj<Map<String,Object>> params,HttpServletRequest request){
		String sid = request.getHeader("sid");
		Map<String,Object> map = params.getData();
		map.put("sid",sid);
		try {
			Map<String,Object> result = riverPatrolService.pollingTimesCurrnt(map);
			return RespBodyObj.ok(result);
		}catch (Exception e){
			e.printStackTrace();
			return RespBodyObj.error("请求失败!");
		}
	}

	/**
	 * 获取河长的巡查记录(每次巡查上报问题数,处理问题数)
	 * @author chg
	 * @date 2018-12-10
	 * @param params
	 * @return
	 */
	@SysLog(value = "获取河长的巡查记录(每次巡查上报问题数,处理问题数)",actionType = "4")
	@PostMapping("pollingList")
	public RespBodyObj<List<Map<String,Object>>> pollingList(@RequestBody ReqBodyObj<Map<String,Object>> params){
		Map<String,Object> map = params.getData();
		try {
			List<Map<String,Object>> result = riverPatrolService.pollingList(map);
			return RespBodyObj.ok(result);
		}catch (Exception e){
			e.printStackTrace();
			return RespBodyObj.error("请求失败!");
		}
	}

	/**
	 * 下级巡查统计(所有区域应巡人数,已巡人数,最高里程,巡检最多)
	 * @author chg
	 * @date 2018-12-11
	 * @param params
	 * @return
	 */
	@SysLog(value = "下级巡查统计(所有区域应巡人数,已巡人数,最高里程,巡检最多)",actionType = "4")
	@PostMapping("patrolStatisticsSubordinate")
	public RespBodyObj<Map<String,Object>> patrolStatisticsSubordinate(@RequestBody ReqBodyObj<Map<String,Object>> params,HttpServletRequest request){
		String sid = request.getHeader("sid");
		Map<String,Object> map = params.getData();
		map.put("sid",sid);
		try {
			Map<String,Object> result = riverPatrolService.statisticalLowerLevel(map);
			return RespBodyObj.ok(result);
		}catch (Exception e){
			e.printStackTrace();
			return RespBodyObj.error("请求失败!");
		}
	}

	/**
	 * 下级区域所有河长巡查距离统计
	 * @author chg
	 * @date 2018-12-11
	 * @param params
	 * @param request
	 * @return
	 */
	@SysLog(value = "下级区域所有河长巡查距离统计",actionType = "4")
	@PostMapping("queryDistance")
	public RespBodyObj<List<InspectTheDistance>> queryDistance(@RequestBody ReqBodyObj<Map<String,Object>> params,HttpServletRequest request){
		String sid = request.getHeader("sid");
		Map<String,Object> map = params.getData();
		map.put("sid",sid);
		try {
			List<InspectTheDistance> result = riverPatrolService.queryDistance(map);
			return RespBodyObj.ok(result);
		}catch (Exception e){
			e.printStackTrace();
			return RespBodyObj.error("请求失败!");
		}
	}

	/**
	 * 下级区域所有河长巡查次数统计
	 * @author chg
	 * @date 2018-12-11
	 * @param params
	 * @param request
	 * @return
	 */
	@SysLog(value = "下级区域所有河长巡查距离统计",actionType = "4")
	@PostMapping("pollingTimesSubordinate")
	public RespBodyObj<List<InspectTheDistance>> pollingTimesSubordinate(@RequestBody ReqBodyObj<Map<String,Object>> params,HttpServletRequest request){
		String sid = request.getHeader("sid");
		Map<String,Object> map = params.getData();
		map.put("sid",sid);
		try {
			List<InspectTheDistance> result = riverPatrolService.pollingTimesSubordinate(map);
			return RespBodyObj.ok(result);
		}catch (Exception e){
			e.printStackTrace();
			return RespBodyObj.error("请求失败!");
		}
	}

	/**
	 * 获取指定区域所有河长巡查次数
	 * @author chg
	 * @date 2018-12-11
	 * @param params
	 * @param request
	 * @return
	 */
	@SysLog(value = "获取指定区域所有河长巡查次数",actionType = "4")
	@PostMapping("pollingTimesByDivisionNo")
	public RespBodyObj<List<InspectTheDistance>> pollingTimesByDivisionNo(@RequestBody ReqBodyObj<Map<String,Object>> params,HttpServletRequest request){
		Map<String,Object> map = params.getData();
		try {
			List<InspectTheDistance> result = riverPatrolService.pollingTimesByDivisionNo(map);
			return RespBodyObj.ok(result);
		}catch (Exception e){
			e.printStackTrace();
			return RespBodyObj.error("请求失败!");
		}
	}
}