AsraDailyController.java 5.25 KB
package com.zteits.oa.report.web;

import com.alibaba.fastjson.JSONObject;
import com.xiaoleilu.hutool.date.DateUtil;
import com.xiaoleilu.hutool.util.CollectionUtil;
import com.zteits.oa.api.base.bean.BizResult;
import com.zteits.oa.api.base.bean.PageBean;
import com.zteits.oa.api.base.constants.ErrorType;
import com.zteits.oa.api.base.constants.SessionEnum;
import com.zteits.oa.api.base.exception.BizException;
import com.zteits.oa.api.dto.asradaily.AsraDailyDTO;
import com.zteits.oa.api.dto.asradaily.AsraDailyOpNumForCurrentDayDTO;
import com.zteits.oa.api.dto.asradaily.QueryAsraDailyAllForListReqDTO;
import com.zteits.oa.api.dto.asradaily.param.AsraDailyForTotalNumAndDetailReq;
import com.zteits.oa.api.dto.asradaily.param.AsraDailyQueryReq;
import com.zteits.oa.api.dto.asraop.AsraOpDTO;
import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq;
import com.zteits.oa.api.dto.asraoprelations.AsraOpRelationsDTO;
import com.zteits.oa.api.dto.asraoprelations.param.AsraOpRelationsQueryReq;
import com.zteits.oa.api.service.report.query.AsraDailyQueryService;
import com.zteits.oa.api.service.report.query.AsraOpQueryService;
import com.zteits.oa.api.service.report.query.AsraOpRelationsQueryService;
import com.zteits.oa.report.domain.AsraDaily;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Api(value = "日报系统-日报管理", description = "日报系统-日报管理")
@RestController
@RequestMapping("/asraDaily")
public class AsraDailyController {

	private static final Logger logger = LoggerFactory.getLogger(AsraDailyController.class);

	@Autowired
	private AsraOpQueryService asraOpQueryService;

	@Autowired
	private AsraDailyQueryService asraDailyQueryService;


	@RequestMapping(value="/queryAsraDailyList",method = RequestMethod.POST)
	public BizResult<List<AsraDailyDTO>> queryAsraDailyList(@RequestBody AsraDailyQueryReq asraDailyQueryReq, HttpServletRequest request){
		logger.info("日报系统-日报管理-根据登录人分页查询员工信息入参:{}", JSONObject.toJSON(asraDailyQueryReq));
		/**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/
		AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key());

		/**2.判断登录人和时间查询日报*/
		Date dailyDate = asraDailyQueryReq.getDailyDate();
		Integer week = DateUtil.weekOfYear(dailyDate);//第N周
		Integer year = DateUtil.year(dailyDate);//第N周
		asraDailyQueryReq.setAsarOpId(asraOpDTO.getId());
		asraDailyQueryReq.setWeeks(week);
		asraDailyQueryReq.setYears(year);
		BizResult<List<AsraDailyDTO>> result = asraDailyQueryService.queryAsraDailyList(asraDailyQueryReq);
		logger.info("日报系统-日报管理-根据登录人分页查询员工信息结束");
		return result;
	}
	
	/**
	 * 工时查询-当天提交及未提交人数汇总.<br/>
	 * @param request
	 * @return
	 * 2018年8月1日  wangfs.<br/>
	 */
	@RequestMapping("/queryAsraDailyOpNumForCurrentDay")
	@ApiOperation("工时查询-当天填报人数统计(汇总)")
	public BizResult<AsraDailyOpNumForCurrentDayDTO> queryAsraDailyOpNumForCurrentDay(@RequestBody AsraDailyForTotalNumAndDetailReq request,HttpServletRequest  servletRequest){
		logger.info("--begin工时查询-当天填报人数统计(汇总),入参={}",JSONObject.toJSON(request));
		AsraOpDTO asraOpDTO = (AsraOpDTO)servletRequest.getSession().getAttribute(SessionEnum.USER_INFO.key());
		if(asraOpDTO == null ){
			throw new BizException(ErrorType.PARAMM_NULL,"获取session为空");
		}
		request.setOpId(asraOpDTO.getId());
		BizResult<AsraDailyOpNumForCurrentDayDTO> result = asraDailyQueryService.queryAsraDailyOpNumForCurrentDay(request);
		logger.info("--end工时查询-当天填报人数统计(汇总),结果={}",JSONObject.toJSON(result));
		return result;
	}
	
	
	/**
	 * 工时查询-所有员工及自己或者自己日报.<br/>
	 * @param request
	 * @return
	 * 2018年8月1日  wangfs.<br/>
	 */
	@RequestMapping("/queryAsraDailyAllForList")
	@ApiOperation("工时查询-所有员工及自己或者自己日报")
	public BizResult<QueryAsraDailyAllForListReqDTO> queryAsraDailyAllForList(@RequestBody AsraDailyForTotalNumAndDetailReq request,HttpServletRequest  servletRequest){
		logger.info("--begin工时查询-所有员工及自己或者自己日报,入参={}",JSONObject.toJSON(request));
		AsraOpDTO asraOpDTO = (AsraOpDTO)servletRequest.getSession().getAttribute(SessionEnum.USER_INFO.key());
		if(asraOpDTO == null ){
			throw new BizException(ErrorType.PARAMM_NULL,"获取session为空");
		}
		request.setOpId(asraOpDTO.getId());
		BizResult<QueryAsraDailyAllForListReqDTO> result = asraDailyQueryService.queryAsraDailyAllForList(request);
		logger.info("--end工时查询-所有员工及自己或者自己日报,结果={}",JSONObject.toJSON(result));
		return result;
	}


}