package org.jeecg.modules.zrzyqc.gzvhb.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.aspect.annotation.PermissionData;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.zrzyqc.gzvhb.entity.QcSsgqzysytdqkGzv;
import org.jeecg.modules.zrzyqc.gzvhb.service.IQcSsgqzysytdqkGzvService;
import org.jeecg.modules.zrzyqc.qcsb.entity.QcSsgqzysytdqk;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: qc_ssgqzysytdqk_gzv
 * @Author: jeecg-boot
 * @Date:   2024-07-27
 * @Version: V1.0
 */
@Api(tags="qc_ssgqzysytdqk_gzv")
@RestController
//@RequestMapping("/qcsb/qcSsgqzysytdqk")
@RequestMapping("/qcsb/qcSsgqzysytdqk")
@Slf4j
public class QcSsgqzysytdqkGzvController extends JeecgController<QcSsgqzysytdqkGzv, IQcSsgqzysytdqkGzvService> {
	@Autowired
	private IQcSsgqzysytdqkGzvService qcSsgqzysytdqkGzvService;

	/**
	 * 分页列表查询
	 *
	 * @param qcSsgqzysytdqk
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	/**
	 * @AutoLog(value = "省属国企占有使用土地情况调查-分页列表查询")
	 */
	@ApiOperation(value = "省属国企占有使用土地情况调查-分页列表查询", notes = "省属国企占有使用土地情况调查-分页列表查询")
	@GetMapping(value = "/list")
	@PermissionData(pageComponent = "qcsb/QcSsgqzysytdqkList")
	public Result<IPage<QcSsgqzysytdqkGzv>> queryPageList(QcSsgqzysytdqkGzv qcSsgqzysytdqk,
													   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
													   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
													   HttpServletRequest req) {
		QueryWrapper<QcSsgqzysytdqkGzv> queryWrapper = QueryGenerator.initQueryWrapper(qcSsgqzysytdqk, req.getParameterMap());
		Page<QcSsgqzysytdqkGzv> page = new Page<QcSsgqzysytdqkGzv>(pageNo, pageSize);
		List<Integer> sbzts = new ArrayList<>();
		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		System.out.println(sysUser);
		if ("gzw".equals(sysUser.getUsername())) {
			queryWrapper.likeRight("sys_org_code", "A04");
		}
		queryWrapper.likeRight("sys_org_code", "A04");
		//sbzts.add(0);
		//sbzts.add(1);
		//queryWrapper.in("sfsb",sbzts);
		IPage<QcSsgqzysytdqkGzv> pageList = qcSsgqzysytdqkGzvService.page(page, queryWrapper);
		return Result.OK(pageList);
	}
	/**
	 * 分页列表查询
	 *
	 * @param qcSsgqzysytdqk
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "省属国企占有使用土地情况调查-已上报待审核分页列表查询")
	@ApiOperation(value = "省属国企占有使用土地情况调查-已上报待审核分页列表查询", notes = "省属国企占有使用土地情况调查-已上报待审核分页列表查询")
	@GetMapping(value = "/list1")
	public Result<IPage<QcSsgqzysytdqkGzv>> queryPageList1(QcSsgqzysytdqkGzv qcSsgqzysytdqk,
														   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
														   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
														   HttpServletRequest req) {
		QueryWrapper<QcSsgqzysytdqkGzv> queryWrapper = QueryGenerator.initQueryWrapper(qcSsgqzysytdqk, req.getParameterMap());
		Page<QcSsgqzysytdqkGzv> page = new Page<QcSsgqzysytdqkGzv>(pageNo, pageSize);
		List<Integer> sbzts = new ArrayList<>();
		sbzts.add(1);
		sbzts.add(2);
		queryWrapper.in("sfsb", sbzts);
		if (qcSsgqzysytdqk.getShzt() != null) {
			queryWrapper.eq("shzt", qcSsgqzysytdqk.getShzt());
		}
		queryWrapper.likeRight("sys_org_code", "A04");
		IPage<QcSsgqzysytdqkGzv> pageList = qcSsgqzysytdqkGzvService.page(page, queryWrapper);
		return Result.OK(pageList);
	}
	/**
	 * 分页列表查询
	 *
	 * @param qcSsgqzysytdqk
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "省属国企占有使用土地情况调查-审核错误退回分页列表查询")
	@ApiOperation(value = "省属国企占有使用土地情况调查-审核错误退回分页列表查询", notes = "省属国企占有使用土地情况调查-审核错误退回分页列表查询")
	@GetMapping(value = "/list4")
	@PermissionData(pageComponent = "qcsb/QcSsgqzysytdqkList4")
	public Result<IPage<QcSsgqzysytdqkGzv>> queryPageList4(QcSsgqzysytdqkGzv qcSsgqzysytdqk,
														@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
														@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
														HttpServletRequest req) {
		QueryWrapper<QcSsgqzysytdqkGzv> queryWrapper = QueryGenerator.initQueryWrapper(qcSsgqzysytdqk, req.getParameterMap());
		Page<QcSsgqzysytdqkGzv> page = new Page<QcSsgqzysytdqkGzv>(pageNo, pageSize);
		queryWrapper.eq("sfsb", 4);
		queryWrapper.likeRight("sys_org_code", "A04");
		IPage<QcSsgqzysytdqkGzv> pageList = qcSsgqzysytdqkGzvService.page(page, queryWrapper);
		return Result.OK(pageList);
	}


	/**
	 * 分页列表查询
	 *
	 * @param qcSsgqzysytdqk
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "省属国企占有使用土地情况调查-所有已经审核分页列表查询")
	@ApiOperation(value = "省属国企占有使用土地情况调查-所有已经审核分页列表查询", notes = "省属国企占有使用土地情况调查-所有已经审核分页列表查询")
	@GetMapping(value = "/list2")
	public Result<IPage<QcSsgqzysytdqkGzv>> queryPageList2(QcSsgqzysytdqkGzv qcSsgqzysytdqk,String year,
														@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
														@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
														HttpServletRequest req) {
		QueryWrapper<QcSsgqzysytdqkGzv> queryWrapper = QueryGenerator.initQueryWrapper(qcSsgqzysytdqk, req.getParameterMap());
		Page<QcSsgqzysytdqkGzv> page = new Page<QcSsgqzysytdqkGzv>(pageNo, pageSize);
		List<Integer> sbzts = new ArrayList<>();
		sbzts.add(3);
		sbzts.add(4);
		queryWrapper.in("sfsb", sbzts);
		queryWrapper.likeRight("sys_org_code", "A04");
		if (year!=null){
			queryWrapper.apply("TO_CHAR(create_time, 'YYYY') LIKE {0}", year + "%");
		}
		if (qcSsgqzysytdqk.getShzt() != null) {
			queryWrapper.eq("shzt", qcSsgqzysytdqk.getShzt());
		}
		IPage<QcSsgqzysytdqkGzv> pageList = qcSsgqzysytdqkGzvService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	/**
	 *
	 * @param qcSsgqzysytdqk
	 * @param year
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	@ApiOperation(value = "省属国企占有使用土地情况调查-已上报待审核分页列表查询", notes = "省属国企占有使用土地情况调查-已上报待审核分页列表查询")
	@GetMapping(value = "/listBygly")
	public Result<IPage<QcSsgqzysytdqkGzv>> queryPageListBygly(QcSsgqzysytdqkGzv qcSsgqzysytdqk,String year,
															@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
															@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
															HttpServletRequest req) {
		QueryWrapper<QcSsgqzysytdqkGzv> queryWrapper = QueryGenerator.initQueryWrapper(qcSsgqzysytdqk, req.getParameterMap());
		queryWrapper.likeRight("sys_org_code", "A04");
		queryWrapper.gt("sfsb", 0);
		if (year!=null){
			queryWrapper.apply("TO_CHAR(create_time, 'YYYY') LIKE {0}", year + "%");
		}
		Page<QcSsgqzysytdqkGzv> page = new Page<QcSsgqzysytdqkGzv>(pageNo, pageSize);
		IPage<QcSsgqzysytdqkGzv> pageList = qcSsgqzysytdqkGzvService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	/**
	 * 分页列表查询
	 *
	 * @param qcSsgqzysytdqk
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "省属国企占有使用土地情况调查-分页列表查询")
	@ApiOperation(value = "省属国企占有使用土地情况调查-分页列表查询", notes = "机关事业单位占有使用土地情况调查-分页列表查询")
	@GetMapping(value = "/list5")
	@PermissionData(pageComponent = "sydwqcsb/QcSsgqzysytdqkList")
	public Result<IPage<QcSsgqzysytdqkGzv>> queryPageList5(QcSsgqzysytdqkGzv qcSsgqzysytdqk,
														@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
														@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
														HttpServletRequest req) {
		QueryWrapper<QcSsgqzysytdqkGzv> queryWrapper = QueryGenerator.initQueryWrapper(qcSsgqzysytdqk, req.getParameterMap());
		Page<QcSsgqzysytdqkGzv> page = new Page<QcSsgqzysytdqkGzv>(pageNo, pageSize);
		List<Integer> sbzts = new ArrayList<>();
		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		queryWrapper.likeRight("sys_org_code", "A03");
		IPage<QcSsgqzysytdqkGzv> pageList = qcSsgqzysytdqkGzvService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	/**
	 * 分页列表查询
	 *
	 * @param qcSsgqzysytdqk
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "省属国企占有使用土地情况调查-所有已经审核分页列表查询")
	@ApiOperation(value = "省属国企占有使用土地情况调查-所有已经审核分页列表查询", notes = "省属国企占有使用土地情况调查-所有已经审核分页列表查询")
	@GetMapping(value = "/list9")
	@PermissionData(pageComponent = "sydwqcsb/QcSsgqzysytdqkList4")

	public Result<IPage<QcSsgqzysytdqkGzv>> queryPageList9(QcSsgqzysytdqkGzv qcSsgqzysytdqk,
														@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
														@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
														HttpServletRequest req) {
		QueryWrapper<QcSsgqzysytdqkGzv> queryWrapper = QueryGenerator.initQueryWrapper(qcSsgqzysytdqk, req.getParameterMap());
		Page<QcSsgqzysytdqkGzv> page = new Page<QcSsgqzysytdqkGzv>(pageNo, pageSize);
		List<Integer> sbzts = new ArrayList<>();
		sbzts.add(4);
		queryWrapper.in("sfsb", sbzts);
		queryWrapper.likeRight("sys_org_code", "A03");
		IPage<QcSsgqzysytdqkGzv> pageList = qcSsgqzysytdqkGzvService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	/**
	 * 分页列表查询
	 *
	 * @param qcSsgqzysytdqk
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "省属国企占有使用土地情况调查-已上报待审核分页列表查询")
	@ApiOperation(value = "省属国企占有使用土地情况调查-已上报待审核分页列表查询", notes = "省属国企占有使用土地情况调查-已上报待审核分页列表查询")
	@GetMapping(value = "/list6")
	public Result<IPage<QcSsgqzysytdqkGzv>> queryPageList6(QcSsgqzysytdqkGzv qcSsgqzysytdqk,
														@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
														@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
														HttpServletRequest req) {
		QueryWrapper<QcSsgqzysytdqkGzv> queryWrapper = QueryGenerator.initQueryWrapper(qcSsgqzysytdqk, req.getParameterMap());
		Page<QcSsgqzysytdqkGzv> page = new Page<QcSsgqzysytdqkGzv>(pageNo, pageSize);
		List sbzts = new ArrayList<>();
		sbzts.add(1);
		sbzts.add(2);
		queryWrapper.in("sfsb", sbzts);
		queryWrapper.likeRight("sys_org_code", "A03");
		if (qcSsgqzysytdqk.getShzt() != null) {
			queryWrapper.eq("shzt", qcSsgqzysytdqk.getShzt());
		}
		IPage<QcSsgqzysytdqkGzv> pageList = qcSsgqzysytdqkGzvService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	/**
	 * 分页列表查询
	 *
	 * @param qcSsgqzysytdqk
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "省属国企占有使用土地情况调查-所有已经审核分页列表查询")
	@ApiOperation(value = "省属国企占有使用土地情况调查-所有已经审核分页列表查询", notes = "省属国企占有使用土地情况调查-所有已经审核分页列表查询")
	@GetMapping(value = "/list7")
	public Result<IPage<QcSsgqzysytdqkGzv>> queryPageList7(QcSsgqzysytdqkGzv qcSsgqzysytdqk,String year,
														@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
														@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
														HttpServletRequest req) {
		QueryWrapper<QcSsgqzysytdqkGzv> queryWrapper = QueryGenerator.initQueryWrapper(qcSsgqzysytdqk, req.getParameterMap());
		Page<QcSsgqzysytdqkGzv> page = new Page<QcSsgqzysytdqkGzv>(pageNo, pageSize);
		List<Integer> sbzts = new ArrayList<>();
		sbzts.add(3);
		sbzts.add(4);
		queryWrapper.in("sfsb", sbzts);
		queryWrapper.likeRight("sys_org_code", "A03");
		if (year!=null){
			queryWrapper.apply("TO_CHAR(create_time, 'YYYY') LIKE {0}", year + "%");
		}
		if (qcSsgqzysytdqk.getShzt() != null) {
			queryWrapper.eq("shzt", qcSsgqzysytdqk.getShzt());
		}
		IPage<QcSsgqzysytdqkGzv> pageList = qcSsgqzysytdqkGzvService.page(page, queryWrapper);
		return Result.OK(pageList);
	}


}
