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

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.mobile.service.RiverInfoBasisService;
import com.newfiber.api.pc.dao.RiverManage.RiverChiefDao;
import com.newfiber.api.pc.dao.RiverManage.RiverInfoBasisDao;
import com.newfiber.api.pc.dao.RiverManage.RiverPicsDao;
import com.newfiber.api.pc.model.River.RiverInfoBasis;
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;

/**
 * 河道基础信息表 Controller
 * @author xcc
 * @date 2018-12-04 16:39:34
 */
@RestController
@RequestMapping("/riverinfobasis")
public class RiverInfoBasisController extends BaseController{
	@Autowired
	private RiverInfoBasisService riverInfoBasisService;

	@Autowired
	private RiverInfoBasisDao riverInfoBasisDao;

	@Autowired
	private RiverPicsDao riverPicsDao;

	@Autowired
	private RiverChiefDao riverChiefDao;



	/** 获取河道基础信息表列表 */
	@PostMapping(BaseUrl.QUERY_LIST)
	@SysLog(value="获取河道基础信息表列表",actionType="4")
	public RespBodyObj<List<RiverInfoBasis>> queryRiverListByDivisionNo(@RequestBody ReqBodyObj<RiverInfoBasis> param, HttpServletRequest request){
		if( param == null ){
			return RespBodyObj.error(HttpCode.BAD_REQUEST);
		}
		String userNo = request.getHeader("userNo");
		List<RiverInfoBasis> riverInfoBasisList = riverInfoBasisService.queryRiverListDivisionNo(userNo);
		return RespBodyObj.ok(riverInfoBasisList);
	}

	/** 获取河道基础信息表详细信息 */
	@PostMapping(BaseUrl.QUERY_BY_PARAM)
	@SysLog(value="获取河道基础信息表详细信息",actionType="4")
	public RespBodyObj<RiverInfoBasis> queryInfo(@RequestBody ReqBodyObj<RiverInfoBasis> param,HttpServletRequest request){
		if( param == null ){
			return RespBodyObj.error(HttpCode.BAD_REQUEST);
		}
		String userNo = request.getHeader("userNo");
		if("Admin".equalsIgnoreCase(userNo)){
			userNo = null;
		}
		RiverInfoBasis riverInfoBasis = riverInfoBasisService.queryRiverInfoByRivertNo(param.getData().getRiverNo(),userNo);
		return RespBodyObj.ok(riverInfoBasis);
	}

	/** 根据父级河道编号获取子级河道具体信息 */
	@PostMapping("searchByParentRiverNo")
	@SysLog(value="根据父级河道编号获取子级河道具体信息",actionType="4")
	public RespBodyObj<List<RiverInfoBasis>> queryListByParentRiverNo(@RequestBody ReqBodyObj<RiverInfoBasis> param){
		if( param == null ){
			return RespBodyObj.error(HttpCode.BAD_REQUEST);
		}
		List<RiverInfoBasis> riverInfoBasisList = riverInfoBasisService.queryRiverListByParentRiverNo(param.getData().getParentRiverNo());
		return RespBodyObj.ok(riverInfoBasisList);
	}

	/** 根据父级河道编号获取子级河道具体信息 */
	@PostMapping("queryListByDivisionNo")
	@SysLog(value="根据父级河道编号获取子级河道具体信息",actionType="4")
	public RespBodyObj<List<RiverInfoBasis>> queryListByDivisionNo(@RequestBody ReqBodyObj<RiverInfoBasis> param){
		if( param == null ){
			return RespBodyObj.error(HttpCode.BAD_REQUEST);
		}
		List<RiverInfoBasis> riverInfoBasisList = riverInfoBasisService.queryRiverListByDivisionNo(param.getData().getDivisionNo());
		return RespBodyObj.ok(riverInfoBasisList);
	}


	/**
	 * 河湖基本信息
	 * @param params
	 * @return
	 */
	/*@PostMapping("queryByParam")
	@ResponseBody
	public RespBodyObj<Page<RiverInfoBasis>> selectRiverInfoBasisByDivisionNo(@RequestBody ReqBodyObj<RiverInfoBasis> params){
		RiverInfoBasis ri = params.getData();
		Page<RiverInfoBasis> result = new Page<>();
		try{
			PageHelper.startPage(params.getCurrent(), params.getSize());
			List<RiverInfoBasis> riverInfoBasisList = riverInfoBasisDao.selectRiverInfoBasisByDivisionNoo(ri.getDivisionNo(),ri.getRiverNo());
			if(riverInfoBasisList != null && riverInfoBasisList.size() > 0){
				for(RiverInfoBasis riverInfoBasis : riverInfoBasisList){
					String riverPicsNo = riverInfoBasis.getRiverPicsNo();
					if(!StringUtils.isEmpty(riverPicsNo)){
						List<RiverPics> riverPicsList = riverPicsDao.selectRiverPicsList(riverPicsNo);
						if(!riverPicsList.isEmpty()){
							List<Image> images = new ArrayList<>();
							riverPicsList.stream().forEach(e->{
								Image image = new Image();
								image.setPath(e.getRiverPicsAddress());
								image.setRealPath(nginxfile+e.getRiverPicsAddress());
								images.add(image);
							});
							riverInfoBasis.setImagesList(images);
						}
					}else{
						riverInfoBasis.setImagesList(new ArrayList<Image>());
					}

					String riverNo1 = riverInfoBasis.getRiverNo();
					//查询该河道是否已经配置过河长用户
					List<RiverChief> riverChiefList = riverChiefDao.selectRiverChiefByRiverNo(riverNo1);
					if(riverChiefList != null && riverChiefList.size() > 0){
						riverInfoBasis.setIsNull("1");
					}else{
						riverInfoBasis.setIsNull("0");
					}
				}
			}
			PageInfo<RiverInfoBasis> info  = new PageInfo<>(riverInfoBasisList);
			result.setTotal(info.getTotal());
			result.setRecords(riverInfoBasisList);
			return RespBodyObj.ok(result);
		}catch(Exception e){
			e.printStackTrace();
			return RespBodyObj.error("查询异常");
		}
	}*/

}