package cn.com.countrygarden.bi.main.controller.bigholderAduit;

import cn.com.countrygarden.bi.main.dao.BigholderRightManagerMapper;
import cn.com.countrygarden.bi.main.dao.twerp.hm.TbSysOrganMapper;
import cn.com.countrygarden.bi.main.model.BigholderSatisfacationInfo;
import cn.com.countrygarden.bi.main.model.bigholderAduit.eunm.AuditStatus;
import cn.com.countrygarden.bi.main.model.bigholderAduit.eunm.ExceptionStruts;
import cn.com.countrygarden.bi.main.model.twerp.hm.TbSysUser;
import cn.com.countrygarden.bi.main.service.bigholderAduit.BigholderAduitService;
import cn.com.countrygarden.bi.main.service.bigholderAduit.BigholderExceptionInfoService;
import cn.com.countrygarden.bi.main.service.bigholderAduit.BigholderPushPerdataService;
import cn.com.countrygarden.bi.main.service.bigholderSatisfy.BigholderSatisfyService1;
import org.smartframework.common.ComTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/api/bigholder/aduit")
public class BigholderAreaAduitCotroller {

	@Autowired
	BigholderSatisfyService1 bigholderSatisfyService1;

	@Autowired
	BigholderAduitService bigholderAduitService;

	@Autowired
	BigholderExceptionInfoService bigholderExceptionInfoService;

	@Autowired
	BigholderPushPerdataService bigholderPushPerdataService;

	@Autowired
	TbSysOrganMapper tbSysOrganMapper;

	@Autowired
	BigholderRightManagerMapper bigholderRightManagerMapper;

	/**
	 * 公共方法，对区域进行值处理
	 * 
	 * @param area
	 * @return
	 */
	public String changeArea(String area) {
		if (area != null) {
			area = area.length() == 0 ? null : area;
			if (area != null && area.equals("全部区域")) {
				area = null;
			}
		}
		return area;
	}

	/**
	 * 公共方法，对选择的id进行值处理
	 * 
	 * @param id
	 * @return
	 */
	public String[] changeId(String id[]) {
		if (id.length == 0) {
			id = null;
		}
		return id;
	}

	/**
	 * 我的区域等待提交审核 AccessToken=570D87B4934D3EA3BC9809A221C99760
	 * 
	 * @param request
	 *            myareaWaitSubmit
	 * @param yearMon
	 * @param area
	 * @return /api/bigholder/aduit/waitSubmitAduit
	 * @throws IOException
	 */
	@RequestMapping(value = "/waitSubmitAduit", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object waitSubmitAduitList(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMon,
			@RequestParam(value = "area", defaultValue = "") String area,
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken) throws IOException {
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);
		area = this.changeArea(area);
		Map<String, Object> resultMap = new HashMap<>();
		// PageRowBounds pageRowBounds = new
		// PageRowBounds(Integer.valueOf(page),Integer.valueOf(pageSize));
		List<Map<String, Object>> data = bigholderSatisfyService1.selectByMonAndArea(yearMon, area,
				tbSysUser.getUserCode());
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", data);
		return resultMap;
	}

	/**
	 * 已经提交审核（我的区域）
	 * 
	 * @param request
	 * @param yearMon
	 * @param area
	 * @param accessToken
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/havaSubmitAduit", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object havaSubmitAduitList(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMon,
			@RequestParam(value = "area", defaultValue = "") String area,
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken) throws IOException {
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);
		area = this.changeArea(area);
		Map<String, Object> resultMap = new HashMap<>();
		// Page<BigholderSatisfacationInfo> objects =
		// PageHelper.startPage(page,size);
		List<Map<String, Object>> data = bigholderSatisfyService1.selectByMonAndArea1(yearMon, area,
				tbSysUser.getUserCode());
		// PageData pd = new PageData(objects);
		// pd.setData(objects.getResult());
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", data);
		return resultMap;
	}

	/**
	 * 显示我的区域各个类型的数量
	 * 
	 * @param request
	 * @param yearMon
	 * @param area
	 * @param accessToken
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/aduitTypeNum", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object aduitTypeNum(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMon,
			@RequestParam(value = "area", defaultValue = "") String area,
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken) throws IOException {
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);
		area = this.changeArea(area);
		Map<String, Object> resultMap = new HashMap<>();
		List<Map<String, Object>> data = bigholderSatisfyService1.getAduitTypeNum(yearMon, area,
				tbSysUser.getUserCode());
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", data);
		return resultMap;
	}

	/**
	 * 获取对应项目列表
	 * 
	 * @param request
	 * @param area
	 * @return/api/bigholder/aduit/selectCommIdByarea
	 * @throws IOException
	 */
	@RequestMapping(value = "/selectCommIdByarea", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object selectCommIdByarea(HttpServletRequest request,
			@RequestParam(value = "area", defaultValue = "") String area,
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken) throws IOException {
		area = this.changeArea(area);
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);
		List<Map<String, Object>> data = bigholderAduitService.findCommBaseByOrgCodes(area, tbSysUser.getUserCode());
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", data);
		return resultMap;
	}

	/**
	 * 获取对应区域列表(我的区域)
	 * 
	 * @param request
	 * @param accessToken
	 * @return
	 * @throws IOException
	 *             /api/bigholder/aduit/selectAreaByUserId
	 */
	@RequestMapping(value = "/selectAreaByUserId", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object selectAreaByUserId(HttpServletRequest request,
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken) throws IOException {
		// List<Map<String,Object>>
		// data=bigholderAduitService.findCommBaseByOrgCodes(area);
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);

		List<Map<String, Object>> data = bigholderSatisfyService1.selectAreaByUserId(tbSysUser.getUserCode(), false);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", data);
		return resultMap;
	}

	/**
	 * 获取对应区域列表(总部)
	 * 
	 * @param request
	 * @param accessToken
	 * @return
	 * @throws IOException
	 *             /api/bigholder/aduit/selectAreaByUserId
	 */
	@RequestMapping(value = "/selectArea", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object selectArea(HttpServletRequest request,
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken) throws IOException {
		// List<Map<String,Object>>
		// data=bigholderAduitService.findCommBaseByOrgCodes(area);
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);

		List<Map<String, Object>> data = bigholderSatisfyService1.selectAreaByUserId(tbSysUser.getUserCode(), true);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", data);
		return resultMap;
	}

	/**
	 * 修改待提交审核对应项目
	 * 
	 * @param request
	 * @param yearMon
	 * @param area
	 * @param correspondProject
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/updateWaitSubmitAduit", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object updateWaitSubmitAduitList(HttpServletRequest request,
			@RequestParam(value = "correspondProject", defaultValue = "") String correspondProject,
			@RequestParam(value = "id", defaultValue = "") String id,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMonth,
			@RequestParam(value = "area", defaultValue = "") String area) throws Exception {
		area = this.changeArea(area);
		String a = bigholderSatisfyService1.updateBigholderSatisfy(correspondProject, id, yearMonth, area);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", a);
		return resultMap;
		// return Response.response("OK");
	}

	/**
	 * 查看满意度信息
	 * 
	 * @param request
	 * @param id
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/viewSatisfactionInfo", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object viewSatisfactionInfo(HttpServletRequest request,
			@RequestParam(value = "id", defaultValue = "") String id) throws IOException {
		List<Map<String, Object>> data = bigholderSatisfyService1.getViewInfo(id);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", data);
		return resultMap;
	}

	/**
	 * 纠错提交到总部
	 * 
	 * @param request
	 * @param id
	 * @return
	 * @throws IOException
	 */
	
	@RequestMapping(value = "/findError", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object findError(HttpServletRequest request,
			@RequestParam(value = "id", defaultValue = "") String id,
			@RequestParam(value = "exceptionMessage") String exceptionMessage,
			@RequestParam(value = "yearMonth") String yearMonth,
			@RequestParam(value = "AccessToken") String accessToken) throws IOException {
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);
		if(exceptionMessage.trim().length()==0){
			Map<String, Object> resultMap = new HashMap<>();
			resultMap.put("resultCode", 0);
			resultMap.put("resultMsg", "OK");
			resultMap.put("data", "异常信息不能空");
			return resultMap;
		}else{
			bigholderSatisfyService1.updateExceptionStatus(id, tbSysUser.getUserCode(), yearMonth, ExceptionStruts.EXCEPT,
				exceptionMessage);
		}
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", "OK");
		return resultMap;
	}

	/**
	 * 异常数据列表(我的区域)
	 * 
	 * @param request
	 * @param yearMon
	 * @param area
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/myArea/exceptionList", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object exceptionInfoList1(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMon,
			@RequestParam(value = "area", defaultValue = "") String area,
			// @RequestParam(value="page",defaultValue="1")Integer page
			// @RequestParam(value="pageSize",defaultValue="10")Integer
			// pageSize,
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken) throws IOException {
		area = this.changeArea(area);
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);
		// PageRowBounds pageRowBounds = new PageRowBounds(page,pageSize);
		// pageRowBounds.setCount(true);
		List<Map<String, Object>> data = bigholderExceptionInfoService.bigholderExceptionInfoList(yearMon, area,
				tbSysUser.getUserCode(), ExceptionStruts.EXCEPT, false);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", data);
		return resultMap;
	}

	/**
	 * 提交总部审核的平均满意度
	 * 
	 * @param request
	 * @param yearMon
	 * @param area
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/getAvgSatisfactionScores", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object getAvgSatisfactionScores(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMon,
			@RequestParam(value = "area", defaultValue = "") String area,
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken) throws IOException {
		area = this.changeArea(area);
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);
		String avgSatisfactionScores = bigholderAduitService.insertBigholderAduit(yearMon, area, tbSysUser.getUserCode(),
				false);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", ComTool.accuracy(avgSatisfactionScores,1));
		return resultMap;
	}

	/**
	 * 提交总部审核(另一种需求)
	 * 
	 * @param request
	 * @param yearMon
	 * @param area
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/submitAuditToHeadquarters", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object submitAuditToHeadquarters(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMon,
			@RequestParam(value = "area", defaultValue = "") String area,
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken) throws IOException {
		area = this.changeArea(area);
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);

		Boolean flag = bigholderExceptionInfoService.bigholderExceptionInfoLists(yearMon, area, tbSysUser.getUserCode(),
				ExceptionStruts.EXCEPT);
		if(!flag){
			Map<String, Object> resultMap = new HashMap<>();
			resultMap.put("resultCode", 0);
			resultMap.put("resultMsg", "OK");
			resultMap.put("data", "有异常数据，提交审核不成功");
			return resultMap;
		}
		List<BigholderSatisfacationInfo> bigholderSatisfacationInfos = new ArrayList<>();
		if (area == null) {
			List<String> areas = bigholderRightManagerMapper.findAreasByUserCode(tbSysUser.getUserCode());
			bigholderSatisfacationInfos = bigholderSatisfyService1.getSelectByMonAndAreas(yearMon, areas);
		} else {
			bigholderSatisfacationInfos = bigholderSatisfyService1.getSelectByMonAndArea(yearMon, area);
		}

		for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos) {
			if(!AuditStatus.WAITAUDIT.equals(bigholderSatisfacationInfo.getAuditStatus())
					&&!AuditStatus.PASS.equals(bigholderSatisfacationInfo.getAuditStatus())){
				if (bigholderSatisfacationInfo.getCorrespondProject() == null) {
					Map<String, Object> resultMap = new HashMap<>();
					resultMap.put("resultCode", 0);
					resultMap.put("resultMsg", "OK");
					resultMap.put("data", "对应的项目还没有选择完，提交审核不成功");
					return resultMap;
				}
			}
		}
		if (flag) {
			// 异常数据已经处理完了，可以提交审核到总部
			bigholderAduitService.insertBigholderAduit(yearMon, area, tbSysUser.getUserCode(), true);
		} 
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", "OK");
		return resultMap;
	}

	/**
	 * 显示总部各个类型的数量
	 * 
	 * @param request
	 * @param yearMon
	 * @param area
	 * @param accessToken
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/dealAduitTypeNum", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object dealAduitTypeNum(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMon,
			@RequestParam(value = "area", defaultValue = "") String area) throws IOException {
		area = this.changeArea(area);
		Map<String, Object> resultMap = new HashMap<>();
		List<Map<String, Object>> data = bigholderSatisfyService1.getDealAduitTypeNum(yearMon, area);
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", data);
		return resultMap;
	}

	
	/**
	 * 异常数据列表(总部)
	 * 
	 * @param request
	 * @param yearMon
	 * @param area
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/exceptionList", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object exceptionInfoList(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMon,
			@RequestParam(value = "area", defaultValue = "") String area,
			@RequestParam(value = "page", defaultValue = "1") Integer page,
			@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws IOException {
		area = this.changeArea(area);
		List<Map<String, Object>> data = bigholderExceptionInfoService.bigholderExceptionInfoList(
				yearMon, area, null, ExceptionStruts.EXCEPT, true);
		Map<String, Object> resultMap = new HashMap<>();
		Map<String, Object> map1 =  ComTool.commPage(data, page, pageSize);
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", map1);
		return resultMap;
	}

	/**
	 * 修改处理异常数据处理（总部）
	 * 
	 * @param request
	 * @param id
	 * @param correspondProject
	 * @param area
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/exceptionInfoUpdate", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object exceptionInfoUpdate(HttpServletRequest request,
			@RequestParam(value = "id", defaultValue = "") String id,
			@RequestParam(value = "correspondProject", defaultValue = "") String correspondProject,
			@RequestParam(value = "exceptionMessage", defaultValue = "") String exceptionMessage,
			@RequestParam(value = "area", defaultValue = "") String area) throws IOException {
		area = this.changeArea(area);
		if(correspondProject.length()==0){
			correspondProject=null;
		}
		String data=bigholderExceptionInfoService.updateBigholderExceptionInfo(id, correspondProject, area,exceptionMessage, false);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", data);
		return resultMap;
	}

	/**
	 * 保存修改处理异常数据处理（总部）
	 * 
	 * @param request
	 * @param id
	 * @param correspondProject
	 * @param area
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/saveExUpdate", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object saveExUpdate(HttpServletRequest request,
			@RequestParam(value = "id", defaultValue = "") String id,
			@RequestParam(value = "correspondProject", defaultValue = "") String correspondProject,
			@RequestParam(value = "exceptionMessage", defaultValue = "") String exceptionMessage,
			@RequestParam(value = "area", defaultValue = "") String area) throws IOException {
		area = this.changeArea(area);
		bigholderExceptionInfoService.updateBigholderExceptionInfo(id, correspondProject, area,exceptionMessage, true);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", "OK");
		return resultMap;
	}

	/**
	 * 删除异常
	 * 
	 * @param request
	 * @param id
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/exceptionInfoDelete", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object exceptionInfoDelete(HttpServletRequest request,
			@RequestParam(value = "id", defaultValue = "") String id,
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken) throws IOException {
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);
		bigholderExceptionInfoService.deleteBigholderExInfo(id,tbSysUser.getUserCode());
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", "OK");
		return resultMap;
	}

	/**
	 * 待审核的数据列表
	 * 
	 * @param request
	 * @param yearMonth
	 * @param area
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/waitAudit", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object waitAudit(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMonth,
			@RequestParam(value = "area", defaultValue = "") String area,
			@RequestParam(value = "page", defaultValue = "1") Integer page,
			@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws IOException {
		area = this.changeArea(area);
		List<Map<String, Object>> data = bigholderAduitService.getBigholderAreaAduits1( yearMonth, area,
				AuditStatus.WAITAUDIT);
		Map<String, Object> map1=ComTool.commPage(data, page, pageSize);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", map1);
		return resultMap;
	}

	/**
	 * 审核通过
	 * 
	 * @param request
	 * @param yearMonth
	 * @param area
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/passAudit", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object passAudit(HttpServletRequest request,
			@RequestParam(value = "ids", defaultValue = "") String ids[],
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMonth,
			@RequestParam(value = "area", defaultValue = "") String area) throws IOException {
		area = this.changeArea(area);
		ids = this.changeId(ids);
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);
		bigholderAduitService.passAduits(ids, tbSysUser.getUserCode(), yearMonth, area, null);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", AuditStatus.PASS);
		return resultMap;
	}

	/**
	 * 审核驳回
	 * 
	 * @param request
	 * @param yearMonth
	 * @param area
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/stripsNoPassAudit", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object stripsNoPassAudit(HttpServletRequest request,
			@RequestParam(value = "ids", defaultValue = "") String ids[],
			@RequestParam(value = "rejectedMessage", defaultValue = "") String rejectedMessage,
			@RequestParam(value = "AccessToken", defaultValue = "") String accessToken,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMonth,
			@RequestParam(value = "area", defaultValue = "") String area) throws IOException {
		area = this.changeArea(area);
		TbSysUser tbSysUser = bigholderAduitService.getTbSysUser(accessToken);
		if (ids.length != 0) {
			bigholderAduitService.stripsNoPassAudit(ids, rejectedMessage, tbSysUser.getUserCode(), yearMonth, area);
		} else {
			bigholderAduitService.stripsNoPassAudit(null, rejectedMessage, tbSysUser.getUserCode(), yearMonth, area);
		}
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", AuditStatus.REJECTED);
		return resultMap;
	}

	/**
	 * 已审核的数据列表
	 * 
	 * @param request
	 * @param yearMonth
	 * @param area
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/approved", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object approved(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMonth,
			@RequestParam(value = "area", defaultValue = "") String area,
			@RequestParam(value = "page", defaultValue = "1") Integer page,
			@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws IOException {
		area = this.changeArea(area);
//		PageRowBounds pageRowBounds = new PageRowBounds(page, pageSize);
		List<Map<String, Object>> data = bigholderAduitService.getBigholderAreaAduits2(yearMonth, area,
				AuditStatus.PASS);
		Map<String, Object> map1=ComTool.commPage(data, page, pageSize);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", map1);
		return resultMap;
	}

	/**
	 * 推送本月绩效数据
	 * 
	 * @param request
	 * @param yearMonth
	 * @param area
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/headquarters/pushPerdata", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object pushPerdata(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMonth,
			@RequestParam(value = "area", defaultValue = "") String area) throws IOException {
		area = this.changeArea(area);
		List<Map<String,Object>> data=bigholderPushPerdataService.insertBigholderPushPerdata(yearMonth, area, null, ExceptionStruts.EXCEPT);
//		String pustStatus=bigholderPushPerdataService.pushStatus(yearMonth);
//		Map<String,Object> map=new HashMap<>();
//		map.put("pushStatus",pustStatus);
//		data.add(map);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", data);
		return resultMap;
	}
	
	/**
	 * 只是用于测试的
	 * @param request
	 * @param yearMonth
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/aa", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
	public @ResponseBody Object aa(HttpServletRequest request,
			@RequestParam(value = "yearMonth", defaultValue = "") String yearMonth) throws IOException {
		bigholderAduitService.updateAllStatus(yearMonth);
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("resultCode", 0);
		resultMap.put("resultMsg", "OK");
		resultMap.put("data", "OK");
		return resultMap;
	}
	
	/**
	 * 调度测试
	 */
//	@Scheduled(cron="0/1 * * * * ?")//每隔1秒调用一次
	public void scheduledTest(){
		System.out.println("定时任务");
	}
}