package cn.com.countrygarden.bi.main.service.bigholderSatisfy.impl;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;

import javax.xml.rpc.ServiceException;

import org.smartframework.common.ComTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageRowBounds;
import com.mysql.fabric.xmlrpc.base.Array;

import cn.com.countrygarden.bi.main.dao.BigholderRightManagerMapper;
import cn.com.countrygarden.bi.main.dao.bigholderAduit.BigholderAduitMapper;
import cn.com.countrygarden.bi.main.dao.bigholderAduit.BigholderExceptionInfoMapper;
import cn.com.countrygarden.bi.main.dao.bigholderAduit.BigholderLandEstateMapper;
import cn.com.countrygarden.bi.main.dao.bigholderSatisfy.BigholderSatisfyMapper1;
import cn.com.countrygarden.bi.main.dao.sys.RoleMapper;
import cn.com.countrygarden.bi.main.dao.twerp.hm.TbHsprCommunityMapper;
import cn.com.countrygarden.bi.main.dao.twerp.hm.TbSysOrganMapper;
import cn.com.countrygarden.bi.main.model.BigholderLandEstate;
import cn.com.countrygarden.bi.main.model.BigholderRightManager;
import cn.com.countrygarden.bi.main.model.BigholderSatisfacationInfo;
import cn.com.countrygarden.bi.main.model.bigholderAduit.BigholderAreaAudit;
import cn.com.countrygarden.bi.main.model.bigholderAduit.BigholderExceptionInfo;
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.common.Organ;
import cn.com.countrygarden.bi.main.model.sys.Role;
import cn.com.countrygarden.bi.main.model.twerp.ErpCommunity;
import cn.com.countrygarden.bi.main.model.twerp.hm.TbSysOrgan;
import cn.com.countrygarden.bi.main.model.twerp.hm.TbSysUser;
import cn.com.countrygarden.bi.main.service.bigholderSatisfy.BigholderSatisfyService1;

@Service
@Transactional
public class BigholderSatisfyServiceImpl1 implements BigholderSatisfyService1 {

	@Autowired
	private BigholderSatisfyMapper1 bigholderSatisfyMapper1;

	@Autowired
	private BigholderExceptionInfoMapper bigholderExceptionInfoMapper;

	@Autowired
	TbHsprCommunityMapper tbHsprCommunityMapper;

	@Autowired
	TbSysOrganMapper tbSysOrganMapper;

	@Autowired
	BigholderRightManagerMapper bigholderRightManagerMapper;

	@Autowired
	RoleMapper roleMapper;

	@Autowired
	BigholderAduitMapper bigholderAduitMapper;

	@Autowired
	BigholderLandEstateMapper bigholderLandEstateMapper;
	/**
	 * 大业主总部负责人
	 */
	public static final String BIGHEADQUATERS = "dyz_admin";

	/**
	 * 大业主区域负责人
	 */
	public static final String BIGHEADAREA = "dyz_ordinary";

	/**
	 * 公共方法，对区域进行值处理
	 * 
	 * @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;
	}

	public List<String> getHandRight(String area, String tbUserCode) {
		List<String> list = new ArrayList<>();
		List<BigholderRightManager> bigholderRightManagers = bigholderRightManagerMapper
				.getRightManagerByHandmanId(tbUserCode);
		// if (bigholderRightManagers.size() == 0) {
		// try {
		// throw new ServiceException("没有配置区域负责人");
		// } catch (ServiceException e) {
		// e.printStackTrace();
		// }
		// }
		for (BigholderRightManager bigholderRightManager : bigholderRightManagers) {
			if (area != null) {
				if (bigholderRightManager.getArea().equals(area)) {
					list.add(area);
				}
			} else {
				list.add(bigholderRightManager.getArea());
			}
		}
		return list;
	}

	/**
	 * 除法的四舍五入
	 * 
	 * @param num
	 * @param total
	 * @param scale
	 * @return
	 */
	public static String accuracy(double num, double total, int scale) {
		DecimalFormat df = new DecimalFormat("0.00");
		double accuracyNum = 0.0;
		if (total != 0) {
			accuracyNum = num / total * 100;
		}
		return accuracyNum == 0.0 ? "0.00" : df.format(accuracyNum);
	}

	@Override
	public List<Map<String, Object>> selectByMonAndArea(String yearMonth, String area, String tbUserCode) {
		List<String> areaList = this.getHandRight(area, tbUserCode);
		areaList = areaList.size() == 0 ? null : areaList;
		List<Map<String, Object>> list = new ArrayList<>();
		if (areaList != null) {
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos = bigholderSatisfyMapper1
					.getSelectByMonAndAreas(yearMonth, areaList);
			for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos) {
				String a = bigholderSatisfacationInfo.getAuditStatus() != null
						? bigholderSatisfacationInfo.getAuditStatus() : "";
				String b = bigholderSatisfacationInfo.getExceptionStruts() != null
						? bigholderSatisfacationInfo.getExceptionStruts() : "";
				if ((a.equals("") || a.equals(AuditStatus.REJECTED) || a.equals(AuditStatus.NOAUDIT))
						&& (b.equals("") || b.equals(ExceptionStruts.NORMAL))) {
					Map<String, Object> data = new HashMap<String, Object>();
					data.put("id", bigholderSatisfacationInfo.getId());
					data.put("area", bigholderSatisfacationInfo.getEstateArea());
					// 原始项目名
					data.put("originalProjectName", bigholderSatisfacationInfo.getProjectName());
					// 审核状态
					data.put("auditStatus", a);
					// 异常状态
					data.put("exceptionInfoAuditStruts", b);
					// 异常信息
					data.put("exceptionMessage", bigholderSatisfacationInfo.getExceptionMessage());
					// 对应项目
					List<ErpCommunity> erpCommunitys = tbHsprCommunityMapper
							.findBaseCommByCommId(bigholderSatisfacationInfo.getCorrespondProject());
					data.put("correspondProject", erpCommunitys.size() > 0 ? erpCommunitys.get(0).getCommName() : "");
					// 岗位
					data.put("job", bigholderSatisfacationInfo.getJob());
					// 姓名
					data.put("name", bigholderSatisfacationInfo.getName());
					// 满意度分数
					data.put("satisfactionScores", bigholderSatisfacationInfo.getA2());
					// a1问
					data.put("a1", bigholderSatisfacationInfo.getA1());
					// a2问
					data.put("a2", bigholderSatisfacationInfo.getA2());
					// a3问
					data.put("a3", bigholderSatisfacationInfo.getA3());
					// a41问
					data.put("a41", bigholderSatisfacationInfo.getA41());
					// a42问
					data.put("a42", bigholderSatisfacationInfo.getA42());
					// a43问
					data.put("a43", bigholderSatisfacationInfo.getA43());
					// a44问
					data.put("a44", bigholderSatisfacationInfo.getA44());
					// a51问
					data.put("a51", bigholderSatisfacationInfo.getA51());
					// a52问
					data.put("a52", bigholderSatisfacationInfo.getA52());
					// a53问
					data.put("a53", bigholderSatisfacationInfo.getA53());
					// a54问
					data.put("a54", bigholderSatisfacationInfo.getA54());
					// a61问
					data.put("a61", bigholderSatisfacationInfo.getA61());
					// a62问
					data.put("a62", bigholderSatisfacationInfo.getA62());
					// a71问
					data.put("a71", bigholderSatisfacationInfo.getA71());
					// a72问
					data.put("a72", bigholderSatisfacationInfo.getA72());
					// a73问
					data.put("a73", bigholderSatisfacationInfo.getA73());
					// a8问
					data.put("a8", bigholderSatisfacationInfo.getA8());
					// a9问
					data.put("a9", bigholderSatisfacationInfo.getA9());
					// a10问
					data.put("a10", bigholderSatisfacationInfo.getA10());
					// 驳回原因
					data.put("rejectedMessage", bigholderSatisfacationInfo.getRejectedMessage());
					list.add(data);
				}
			}
		}
		return list;
	}

	@Override
	public String updateBigholderSatisfy(String correspondProject, String id, String yearMonth, String area)
			throws Exception {
		List<ErpCommunity> erpCommunitys = tbHsprCommunityMapper.findBaseCommByCommId(correspondProject);
		if (erpCommunitys.size() > 0) {
			bigholderSatisfyMapper1.updateBigholderSatisfy(correspondProject, id, null);
			return "修改成功";
		}
		return "没有对应的项目，不能修改";
	}

	@Override
	public List<Map<String, Object>> getViewInfo(String id) {
		List<Map<String, Object>> list = new ArrayList<>();
		Map<String, Object> data = new HashMap<>();
		BigholderSatisfacationInfo bigholderSatisfacationInfo = bigholderSatisfyMapper1.getViewInfo(id);
		if (bigholderSatisfacationInfo != null) {
			data.put("a1", bigholderSatisfacationInfo.getA1());
			data.put("a2", bigholderSatisfacationInfo.getA2());
			data.put("a3", bigholderSatisfacationInfo.getA3());
			data.put("a41", bigholderSatisfacationInfo.getA41());
			data.put("a42", bigholderSatisfacationInfo.getA42());
			data.put("a43", bigholderSatisfacationInfo.getA43());
			data.put("a44", bigholderSatisfacationInfo.getA44());
			data.put("a51", bigholderSatisfacationInfo.getA51());
			data.put("a52", bigholderSatisfacationInfo.getA52());
			data.put("a53", bigholderSatisfacationInfo.getA53());
			data.put("a54", bigholderSatisfacationInfo.getA54());
			data.put("a61", bigholderSatisfacationInfo.getA61());
			data.put("a62", bigholderSatisfacationInfo.getA62());
			data.put("a71", bigholderSatisfacationInfo.getA71());
			data.put("a72", bigholderSatisfacationInfo.getA72());
			data.put("a73", bigholderSatisfacationInfo.getA73());
			data.put("a8", bigholderSatisfacationInfo.getA8());
			data.put("a9", bigholderSatisfacationInfo.getA9());
			data.put("a10", bigholderSatisfacationInfo.getA10());
			data.put("area", bigholderSatisfacationInfo.getEstateArea());
			data.put("projectName", bigholderSatisfacationInfo.getProjectName());
			data.put("name", bigholderSatisfacationInfo.getName());
			data.put("job", bigholderSatisfacationInfo.getJob());
		} else {
			data.put("a1", null);
			data.put("a2", null);
			data.put("a3", null);
			data.put("a41", null);
			data.put("a42", null);
			data.put("a43", null);
			data.put("a44", null);
			data.put("a51", null);
			data.put("a52", null);
			data.put("a53", null);
			data.put("a54", null);
			data.put("a61", null);
			data.put("a62", null);
			data.put("a71", null);
			data.put("a72", null);
			data.put("a73", null);
			data.put("a8", null);
			data.put("a9", null);
			data.put("a10", null);
			data.put("area", null);
			data.put("projectName", null);
			data.put("name", null);
			data.put("job", null);
		}
		list.add(data);
		return list;
	}

	public String getFlag(String a) {
		if (a.length() == 0) {
			return "0";
		}
		for (int i = 0; i <= 10; i++) {
			if ((i + "").equals(a)) {
				return a;
			}
		}
		return "0";
	}

	@Override
	public void updateExceptionStatus(String id, String tbUserId, String yearMonth, String exceptionInfoAuditStruts,
			String exceptionMessage) {
		bigholderSatisfyMapper1.updateExceptionStatus(id, exceptionInfoAuditStruts, exceptionMessage);
		BigholderSatisfacationInfo bigholderSatisfacationInfo = bigholderSatisfyMapper1.getViewInfo(id);
		if (bigholderSatisfacationInfo != null) {
			BigholderExceptionInfo bigholderExceptionInfo1 = bigholderExceptionInfoMapper
					.selectBySatisfactionInfoId(bigholderSatisfacationInfo.getId());
			if (bigholderExceptionInfo1 != null
					&& ExceptionStruts.EXCEPT.equals(bigholderExceptionInfo1.getExceptionAduitStatus())) {

			} else {
				int totalScore = bigholderSatisfacationInfo.getA2();
				BigholderExceptionInfo bigholderExceptionInfo = new BigholderExceptionInfo();
				bigholderExceptionInfo.setExceptionMessage(exceptionMessage);
				bigholderExceptionInfo.setSatisfactionInfoId(id);
				bigholderExceptionInfo.setExceptionAduitStatus(exceptionInfoAuditStruts);
				bigholderExceptionInfo.setTbUserId(tbUserId);
				bigholderExceptionInfo.setYearMonth(yearMonth);
				bigholderExceptionInfo.setArea(bigholderSatisfacationInfo.getEstateArea());
				bigholderExceptionInfo.setOriginalProjectName(bigholderSatisfacationInfo.getProjectName());
				bigholderExceptionInfo.setCorrespondProject(bigholderSatisfacationInfo.getCorrespondProject());
				bigholderExceptionInfo.setJobs(bigholderSatisfacationInfo.getJob());
				bigholderExceptionInfo.setTotalScore(totalScore + "");
				bigholderExceptionInfoMapper.insertBigholderExceptionInfo(bigholderExceptionInfo);
			}
		}
	}

	@Override
	public void deleteExceptionStatus(String id) {
		BigholderExceptionInfo bigholderExceptionInfo = bigholderExceptionInfoMapper.selectById(id);
		bigholderExceptionInfoMapper.deleteBigholderExInfo(Integer.valueOf(id));
		if (bigholderExceptionInfo != null) {
			bigholderSatisfyMapper1.deleteExceptionStatus(bigholderExceptionInfo.getSatisfactionInfoId());
		}
	}

	@Override
	public List<Map<String, Object>> selectByMonAndArea1(String yearMonth, String area, String tbUserCode) {
		List<String> areaList = this.getHandRight(area, tbUserCode);
		areaList = areaList.size() == 0 ? null : areaList;
		List<Map<String, Object>> list = new ArrayList<>();
		if (areaList != null) {
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos = bigholderSatisfyMapper1
					.getSelectByMonAndAreas(yearMonth, areaList);

			for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos) {
				String a = bigholderSatisfacationInfo.getAuditStatus() != null
						? bigholderSatisfacationInfo.getAuditStatus() : "";
				String b = bigholderSatisfacationInfo.getExceptionStruts() != null
						? bigholderSatisfacationInfo.getExceptionStruts() : "";
				if (a.equals(AuditStatus.PASS) || a.equals(AuditStatus.WAITAUDIT)) {
					Map<String, Object> data = new HashMap<String, Object>();
					data.put("id", bigholderSatisfacationInfo.getId());
					data.put("area", bigholderSatisfacationInfo.getEstateArea());
					// 原始项目名
					data.put("originalProjectName", bigholderSatisfacationInfo.getProjectName());
					// 审核状态
					data.put("auditStatus", a);
					// 异常状态
					data.put("exceptionInfoAuditStruts", b);
					// 对应项目
					List<ErpCommunity> erpCommunitys = tbHsprCommunityMapper
							.findBaseCommByCommId(bigholderSatisfacationInfo.getCorrespondProject());
					data.put("correspondProject", erpCommunitys.size() > 0 ? erpCommunitys.get(0).getCommName() : "");
					// 岗位
					data.put("job", bigholderSatisfacationInfo.getJob());
					// 姓名
					data.put("name", bigholderSatisfacationInfo.getName());
					// 满意度分数
					data.put("satisfactionScores", bigholderSatisfacationInfo.getA2());
					// a1问
					data.put("a1", bigholderSatisfacationInfo.getA1());
					// a2问
					data.put("a2", bigholderSatisfacationInfo.getA2());
					// a3问
					data.put("a3", bigholderSatisfacationInfo.getA3());
					// a41问
					data.put("a41", bigholderSatisfacationInfo.getA41());
					// a42问
					data.put("a42", bigholderSatisfacationInfo.getA42());
					// a43问
					data.put("a43", bigholderSatisfacationInfo.getA43());
					// a44问
					data.put("a44", bigholderSatisfacationInfo.getA44());
					// a51问
					data.put("a51", bigholderSatisfacationInfo.getA51());
					// a52问
					data.put("a52", bigholderSatisfacationInfo.getA52());
					// a53问
					data.put("a53", bigholderSatisfacationInfo.getA53());
					// a54问
					data.put("a54", bigholderSatisfacationInfo.getA54());
					// a61问
					data.put("a61", bigholderSatisfacationInfo.getA61());
					// a62问
					data.put("a62", bigholderSatisfacationInfo.getA62());
					// a71问
					data.put("a71", bigholderSatisfacationInfo.getA71());
					// a72问
					data.put("a72", bigholderSatisfacationInfo.getA72());
					// a73问
					data.put("a73", bigholderSatisfacationInfo.getA73());
					// a8问
					data.put("a8", bigholderSatisfacationInfo.getA8());
					// a9问
					data.put("a9", bigholderSatisfacationInfo.getA9());
					// a10问
					data.put("a10", bigholderSatisfacationInfo.getA10());
					// 驳回原因
					data.put("rejectedMessage", bigholderSatisfacationInfo.getRejectedMessage());
					list.add(data);
				}
			}
		}
		// Map<String,Object> map=new HashMap<>();
		// map.put("totalNum", bigholderSatisfacationInfos.size());
		// list.add(map);
		return list;
	}

	@Override
	public List<Map<String, Object>> selectAreaByUserId(String tbUserId, boolean flag) {
		List<Map<String, Object>> list = new ArrayList<>();
		List<BigholderRightManager> bigholderRightManagers = new ArrayList<>();
		Map<String, Object> map1 = new HashMap();
		map1.put("text", "全部区域");
		map1.put("value", "全部区域");
		list.add(map1);
		if (!flag) {
			Set<String> arList = new HashSet<>();
			bigholderRightManagers = bigholderRightManagerMapper.getRightManagerByHandmanId(tbUserId);
			for (BigholderRightManager bigholderRightManager : bigholderRightManagers) {
				arList.add(bigholderRightManager.getArea());
			}
			for (String area : arList) {
				Map<String, Object> map = new HashMap<>();
				map.put("text", area);
				map.put("value", area);
				list.add(map);
			}
		} else {
			Set<String> arList = new HashSet<>();
			List<TbSysOrgan> tbSysOrgans = tbSysOrganMapper.findAllActive();
			for (TbSysOrgan tbSysOrgan : tbSysOrgans) {
				arList.add(tbSysOrgan.getOrganName());
			}
			for (String area : arList) {
				Map<String, Object> map = new HashMap<>();
				map.put("text", area);
				map.put("value", area);
				list.add(map);
			}
		}
		return list;
	}

	@Override
	public List<Map<String, Object>> getAduitTypeNum(String yearMonth, String area, String tbUserCode) {
		List<Map<String, Object>> lists = new ArrayList<>();
		Map<String, Object> map = new HashMap<>();
		int waitSubmitNum = 0;
		int exceptionNum = 0;
		List<String> areaList = this.getHandRight(area, tbUserCode);
		// 待提交的数量
		areaList = areaList.size() == 0 ? null : areaList;
		if (areaList != null) {
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos = bigholderSatisfyMapper1
					.getSelectByMonAndAreas(yearMonth, areaList);
			for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos) {
				String a = bigholderSatisfacationInfo.getAuditStatus() == null ? ""
						: bigholderSatisfacationInfo.getAuditStatus();
				String b = bigholderSatisfacationInfo.getExceptionStruts() == null ? ""
						: bigholderSatisfacationInfo.getExceptionStruts();
				if (a.equals("") || a.equals(AuditStatus.NOAUDIT) || a.equals(AuditStatus.REJECTED)) {
					if (b.equals("") || b.equals(ExceptionStruts.NORMAL)) {
						waitSubmitNum++;
					} else {
						exceptionNum++;
					}
				}
			}
		}

		List<String> list1 = new ArrayList<>();
		list1.add(AuditStatus.WAITAUDIT);
		list1.add(AuditStatus.PASS);
		// 已提交的数量
		List<BigholderSatisfacationInfo> bigholderSatisfacationInfos1 = new ArrayList<>();
		if (areaList != null) {
			bigholderSatisfacationInfos1 = bigholderSatisfyMapper1.getSelectByMonAreasAduit(yearMonth, areaList, list1);
		}

		map.put("waitSubmitNum", waitSubmitNum);
		map.put("havaSubmitNum", bigholderSatisfacationInfos1.size());
		map.put("exceptionNum", exceptionNum);
		lists.add(map);
		return lists;
	}

	@Override
	public List<Map<String, Object>> getDealAduitTypeNum(String yearMonth, String area) {
		List<Map<String, Object>> lists = new ArrayList<>();
		Map<String, Object> map = new HashMap<>();
		int waitAuditNum = 0;
		int haveAuditNum = 0;
		int exceptionNum = 0;

		// 待审核的数量
		List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.getBigholderAreaAduits(yearMonth, area,
				null);

		List<BigholderExceptionInfo> bigholderExceptionInfos = bigholderExceptionInfoMapper
				.getBigholderExceptionInfo(yearMonth, area, ExceptionStruts.EXCEPT);
		for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
			String a = bigholderAreaAudit.getAuditStatus() == null ? "" : bigholderAreaAudit.getAuditStatus();
			String b = bigholderAreaAudit.getExceptionStatus() == null ? "" : bigholderAreaAudit.getExceptionStatus();
			if (a.equals(AuditStatus.WAITAUDIT)) {
				if (b.equals("") || b.equals(ExceptionStruts.NORMAL)) {
					waitAuditNum++;
				}
			}

			if (a.equals(AuditStatus.PASS) && (b.equals("") || b.equals(ExceptionStruts.NORMAL))) {
				haveAuditNum++;
			}
		}
		// if ((a.equals(AuditStatus.WAITAUDIT) ||
		// a.equals(AuditStatus.REJECTED) || a.equals(AuditStatus.PASS))
		// && (b.equals(ExceptionStruts.EXCEPT))) {
		// exceptionNum++;
		// }

		map.put("waitSubmitNum", waitAuditNum);
		map.put("havaSubmitNum", haveAuditNum);
		map.put("exceptionNum", bigholderExceptionInfos.size());
		lists.add(map);
		return lists;
	}

	@Override
	public List<BigholderSatisfacationInfo> getSelectByMonAndArea(String yearMon, String area) {
		return bigholderSatisfyMapper1.getSelectByMonAndArea(yearMon, area);
	}

	@Override
	public List<BigholderSatisfacationInfo> getSelectByMonAndAreas(String yearMon, List<String> area) {
		return bigholderSatisfyMapper1.getSelectByMonAndAreas(yearMon, area);
	}

	/**
	 * 判断是否是总部
	 * 
	 * @param roles
	 * @param tbSysOrgans
	 * @param userCode
	 * @return
	 */
	public List<TbSysOrgan> isHeadquarters(List<Role> roles, List<TbSysOrgan> tbSysOrgans, String userCode,
			List<String> yearMonth, String area) {
		for (Role role : roles) {
			// 判断是否是总部
			if (role.getCode().equals(BIGHEADQUATERS)) {
				Set<TbSysOrgan> areaSet = this.commTbSysOrgan(yearMonth, area);
				for (TbSysOrgan tbSysOrgan : areaSet) {
					tbSysOrgans.add(tbSysOrgan);
				}
				// 非总部管理员
			} else if (role.getCode().equals(BIGHEADAREA)) {
				List<TbSysOrgan> tbSysOrgans1 = new ArrayList<>();
				for (Role role1 : roles) {
					if (role1.getCode().equals(BIGHEADQUATERS)) {
						Set<TbSysOrgan> areaSet = this.commTbSysOrgan(yearMonth, area);
						for (TbSysOrgan tbSysOrgan : areaSet) {
							tbSysOrgans1.add(tbSysOrgan);
						}
						return tbSysOrgans1;
					}
				}
				Set<TbSysOrgan> areaSet = this.commTbSysOrgan(yearMonth, area);
				for (TbSysOrgan tbSysOrgan : areaSet) {
					List<BigholderRightManager> bigholderRightManagers = bigholderRightManagerMapper
							.getRightManagerByHandmanId(userCode);
					for (BigholderRightManager bigholderRightManager : bigholderRightManagers) {
						String a = bigholderRightManager.getArea();
						if (a.equals(tbSysOrgan.getOrganName())) {
							tbSysOrgans.add(tbSysOrgan);
						}
					}

				}
			}
		}
		return tbSysOrgans;
	}

	public Set<TbSysOrgan> commTbSysOrgan(List<String> yearMonth, String area) {
		Set<TbSysOrgan> areaSet = new HashSet<>();
		List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearMonth, area,
				AuditStatus.PASS);
		for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
			TbSysOrgan tbSysOrgan = tbSysOrganMapper.findByOrganName(bigholderAreaAudit.getArea());
			if (tbSysOrgan != null) {
				areaSet.add(tbSysOrgan);
			}
		}
		return areaSet;
	}
	
	
	public List<String> isHeadquarters1(List<Role> roles, List<String> tbSysOrgans, String userCode,
			List<String> yearMonth, String area) {
		for (Role role : roles) {
			// 判断是否是总部
			if (role.getCode().equals(BIGHEADQUATERS)) {
				Set<String> areaSet = this.commTbSysOrgan1(yearMonth, area);
				for (String tbSysOrgan : areaSet) {
					tbSysOrgans.add(tbSysOrgan);
				}
				// 非总部管理员
			} else if (role.getCode().equals(BIGHEADAREA)) {
				List<String> tbSysOrgans1 = new ArrayList<>();
				for (Role role1 : roles) {
					if (role1.getCode().equals(BIGHEADQUATERS)) {
						Set<String> areaSet = this.commTbSysOrgan1(yearMonth, area);
						for (String tbSysOrgan : areaSet) {
							tbSysOrgans1.add(tbSysOrgan);
						}
						return tbSysOrgans1;
					}
				}
				Set<String> areaSet = this.commTbSysOrgan1(yearMonth, area);
				for (String tbSysOrgan : areaSet) {
					List<BigholderRightManager> bigholderRightManagers = bigholderRightManagerMapper
							.getRightManagerByHandmanId(userCode);
					for (BigholderRightManager bigholderRightManager : bigholderRightManagers) {
						String a = bigholderRightManager.getArea();
						if (a.equals(tbSysOrgan)) {
							tbSysOrgans.add(tbSysOrgan);
						}
					}

				}
			}
		}
		return tbSysOrgans;
	}

	public Set<String> commTbSysOrgan1(List<String> yearMonth, String area) {
		Set<String> areaSet = new HashSet<>();
		List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearMonth, area,
				AuditStatus.PASS);
		for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
			if(bigholderAreaAudit.getArea()!=null){
				areaSet.add(bigholderAreaAudit.getArea());
			}
		}
		return areaSet;
	}

	/**
	 * 区域评分(所有区域)
	 * 
	 * @param tbSysOrgans
	 * @param yearMon
	 * @return
	 */
	public String regionalScaleTotal(List<String> tbSysOrgans, List<String> yearMon) {
		Double regionalScaleTotal = 0.0;
		int count = 0;
		for (String tbSysOrgan : tbSysOrgans) {
			String regionalScale = this.commList2(tbSysOrgan, yearMon);
			if (!"".equals(regionalScale)) {
				regionalScaleTotal += Double.valueOf(regionalScale);
				count++;
			}
		}
		String regionalScaleTotal1 = "";
		if (count != 0) {
			regionalScaleTotal1 = ComTool.accuracy(regionalScaleTotal / count, 2);
		}
		return regionalScaleTotal1;
	}

	/**
	 * 区域评分(区域)
	 * 
	 * @param tbSysOrgan
	 * @return
	 */
	public String regionalScale(String tbSysOrgan, List<String> yearMonth) {
		String regionlScale = this.commList2(tbSysOrgan, yearMonth);
		return regionlScale;
	}

	public String commList2(String tbSysOrgan, List<String> yearMonth) {
		Double b = 0.0;
		int count = 0;
		String regionlScale = "";
		// List<Object> list = new ArrayList<>();
		List<BigholderLandEstate> bigholderLandEstates = bigholderLandEstateMapper
				.getLandEstatebyAreaOrYearMon(tbSysOrgan, yearMonth);
		for (BigholderLandEstate bigholderLandEstate : bigholderLandEstates) {
			String a3 = bigholderLandEstate.getA3()==null?"跳过":bigholderLandEstate.getA3()+"";
			String a4 = bigholderLandEstate.getA4()==null?"跳过":bigholderLandEstate.getA4()+"";
//			Double a = (double) (a3 + a4) / 2;
			Double projectScore = 0.0;
			if(a3.equals("跳过")&&!a4.equals("跳过")){
				projectScore = (double)Double.valueOf(a4);
				count++;
			}else if(a4.equals("跳过")&&!a3.equals("跳过")){
				projectScore = (double)Double.valueOf(a3);
				count++;
			}else if(!a4.equals("跳过")&&!a3.equals("跳过")){
				projectScore = (double)((Double.valueOf(a3) +Double.valueOf(a4))/ 2);
				count++;
			}
			b += projectScore;
		}
		if (count != 0) {
			regionlScale = ComTool.accuracy(b / count, 2);
		}
		return regionlScale;
	}

	// /**
	// * 满意度(所有区域)
	// */
	// public Double getAllSatisfactionTotal(List<TbSysOrgan> tbSysOrgans,
	// List<String> yearMon) {
	// Double satisfactionTotal = 0.0;
	// int count = 0;
	// for (TbSysOrgan tbSysOrgan : tbSysOrgans) {
	// String satisfaction = this.getSatis(yearMon, tbSysOrgan);
	// if (!satisfaction.equals("")) {
	// satisfactionTotal += Double.valueOf(satisfaction);
	// count++;
	// }
	// }
	// if (count != 0) {
	// return satisfactionTotal / count;
	// } else {
	// return 0.0;
	// }
	// }

	public Double getSatisAll(List<String> yearMon, List<TbSysOrgan> tbSysOrgans) {
		Double satisfactions = 0.0;
		int count = 0;
		for (TbSysOrgan tbSysOrgan : tbSysOrgans) {
			List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearMon,
					tbSysOrgan.getOrganName(), AuditStatus.PASS);
			for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
				String satisfaction = bigholderAreaAudit.getSatisfactionScores();
				if (satisfaction != null && satisfaction.length() > 0) {
					satisfactions += Double.valueOf(satisfaction);
					count++;
				}
			}
		}
		if (count != 0) {
			satisfactions = satisfactions / count;
		}
		return satisfactions;
	}
	
	public Double getSatisAll1(List<String> yearMon, List<String> tbSysOrgans) {
		Double satisfactions = 0.0;
		int count = 0;
		for (String tbSysOrgan : tbSysOrgans) {
			List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearMon,
					tbSysOrgan, AuditStatus.PASS);
			for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
				String satisfaction = bigholderAreaAudit.getSatisfactionScores();
				if (satisfaction != null && satisfaction.length() > 0) {
					satisfactions += Double.valueOf(satisfaction);
					count++;
				}
			}
		}
		if (count != 0) {
			satisfactions = satisfactions / count;
		}
		return satisfactions;
	}

	/**
	 * 满意度(区域)
	 * 
	 * @param bigholderSatisfacationInfo
	 * @param count2
	 * @param count3
	 * @param satisfaction2
	 * @param satisfaction3
	 * @return
	 */
	@Override
	public String getSatisfaction(List<BigholderSatisfacationInfo> bigholderSatisfacationInfos, List<String> yearMon) {
		String satisfaction = this.commuList(bigholderSatisfacationInfos, yearMon);
		return satisfaction;
	}

	public String commuList(List<BigholderSatisfacationInfo> bigholderSatisfacationInfos, List<String> yearMon) {
		int count2 = 0;
		Double satisfaction2 = 0.0;

		int count3 = 0;
		Double satisfaction3 = 0.0;

		String satisfaction = "";
		for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos) {
			if (bigholderSatisfacationInfo.getJob() != null) {
				if (bigholderSatisfacationInfo.getJob().substring(0, 3).equals("项目总")) {
					count2++;
					satisfaction2 += bigholderSatisfacationInfo.getA2();
				}
				if (bigholderSatisfacationInfo.getJob().substring(0, 3).equals("项目营")) {
					count3++;
					satisfaction3 += bigholderSatisfacationInfo.getA2();
				}
			}
		}
		if (count2 != 0 && count3 != 0) {
			satisfaction = (((satisfaction2 / count2) + (satisfaction3 / count3)) / 2) + "";
		}
		return satisfaction;
	}

	/**
	 * 满意率(所有区域)
	 * 
	 * @param tbSysOrgans
	 * @param yearMon
	 * @return
	 */
	public String sfRateTotal(List<String> tbSysOrgans, List<String> yearMon) {
		int sRatecount = 0;
		int sRatecount1 = 0;
		int areaProScore = 0;
		int areaProScore1 = 0;
		for (String tbSysOrgan : tbSysOrgans) {
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos1 = bigholderSatisfyMapper1
					.getByMonsAndArea(yearMon, tbSysOrgan);
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos=new ArrayList<>();
			for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos1) {
				if(AuditStatus.PASS.equals(bigholderSatisfacationInfo.getAuditStatus())){
					bigholderSatisfacationInfos.add(bigholderSatisfacationInfo);
				}
			}
			for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos) {
					sRatecount1++;
					int satisfaction = bigholderSatisfacationInfo.getA2();
					if (satisfaction >= 4) {
						sRatecount++;
					}
				
				List<BigholderLandEstate> bigholderLandEstates = bigholderLandEstateMapper
						.getLandEstatebyAreaOrYearMon(tbSysOrgan, yearMon);
				for (BigholderLandEstate bigholderLandEstate : bigholderLandEstates) {
					String a3 = bigholderLandEstate.getA3()==null?"跳过":bigholderLandEstate.getA3()+"";
					String a4 = bigholderLandEstate.getA4()==null?"跳过":bigholderLandEstate.getA4()+"";
					Double projectScore = 0.0;
					if(a3.equals("跳过")&&!a4.equals("跳过")){
						projectScore = (double)Double.valueOf(a4);
						areaProScore1++;
					}else if(a4.equals("跳过")&&!a3.equals("跳过")){
						projectScore = (double)Double.valueOf(a3);
						areaProScore1++;
					}else if(!a4.equals("跳过")&&!a3.equals("跳过")){
						projectScore = (double)((Double.valueOf(a3) +Double.valueOf(a4))/ 2);
						areaProScore1++;
					}
					if (projectScore >= 4) {
						areaProScore++;
					}
				}
			}
//			String sfRate = this.satisfactionRate(bigholderSatisfacationInfos, yearMon, tbSysOrgan);
//			sfRateTotal += Double.valueOf(sfRate.split("%")[0]);
		}
		if (tbSysOrgans.size() != 0) {
			return (ComTool.accuracy(sRatecount + areaProScore, sRatecount1 + areaProScore1, 2));
		} else {
			return "0.00%";
		}
	}

	/**
	 * 满意率
	 * 
	 * @param bigholderSatisfacationInfo
	 * @param satisfaction1
	 * @param satisfaction
	 * @return
	 */
	public String satisfactionRate(List<BigholderSatisfacationInfo> bigholderSatisfacationInfos, List<String> yearMon,
			String tbSysOrgan) {
		String satisfactionRate = this.commuList1(bigholderSatisfacationInfos, yearMon, tbSysOrgan);
		return satisfactionRate;
	}

	public String commuList1(List<BigholderSatisfacationInfo> bigholderSatisfacationInfos, List<String> yearMon,
			String tbSysOrgan) {
		List<Object> list = new ArrayList<>();
		int sRatecount = 0;
		int sRatecount1 = 0;
		for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos) {
			sRatecount1++;
			int satisfaction = bigholderSatisfacationInfo.getA2();
			if (satisfaction >= 4) {
				sRatecount++;
			}
		}
		int areaProScore = 0;
		int areaProScore1 = 0;
		List<BigholderLandEstate> bigholderLandEstates = bigholderLandEstateMapper
				.getLandEstatebyAreaOrYearMon(tbSysOrgan, yearMon);
		for (BigholderLandEstate bigholderLandEstate : bigholderLandEstates) {
			String a3 = bigholderLandEstate.getA3()==null?"跳过":bigholderLandEstate.getA3()+"";
			String a4 = bigholderLandEstate.getA4()==null?"跳过":bigholderLandEstate.getA4()+"";
			Double projectScore = 0.0;
			if(a3.equals("跳过")&&!a4.equals("跳过")){
				projectScore = (double)Double.valueOf(a4);
				areaProScore1++;
			}else if(a4.equals("跳过")&&!a3.equals("跳过")){
				projectScore = (double)Double.valueOf(a3);
				areaProScore1++;
			}else if(!a4.equals("跳过")&&!a3.equals("跳过")){
				projectScore = (double)((Double.valueOf(a3) +Double.valueOf(a4))/ 2);
				areaProScore1++;
			}
			if (projectScore >= 4) {
				areaProScore++;
			}
		}
		return ComTool.accuracy(sRatecount + areaProScore, sRatecount1 + areaProScore1, 2);
	}

	public String commuSfRate(int sRatecount, int sRatecount1, String satisfactionRate) {
		if (sRatecount1 == 0) {
			satisfactionRate = "0.00%";
		} else {
			satisfactionRate = accuracy(sRatecount, sRatecount1, 2) + "%";
		}
		return satisfactionRate;
	}

	public List<String> commAreaAnalysis(List<String> yearMonth, List<String> yearMon, String annualState,
			String howQuarters) {
		int year = LocalDate.now().getYear();
		int month = LocalDate.now().getMonthValue();
		String month1 = month < 10 ? "0" + month : month + "";
		if (annualState.equals("0")) {
			// 月度
			yearMonth = yearMon;

		} else if (annualState.equals("1")) {
			// 季度
			if ("1".equals(howQuarters)) {
				yearMonth.add(year + "-01");
				yearMonth.add(year + "-02");
				yearMonth.add(year + "-03");
			} else if ("2".equals(howQuarters)) {
				yearMonth.add(year + "-04");
				yearMonth.add(year + "-05");
				yearMonth.add(year + "-06");
			} else if ("3".equals(howQuarters)) {
				yearMonth.add(year + "-07");
				yearMonth.add(year + "-08");
				yearMonth.add(year + "-09");
			} else if ("4".equals(howQuarters)) {
				yearMonth.add(year + "-10");
				yearMonth.add(year + "-11");
				yearMonth.add(year + "-12");
			}
		} else if (annualState.equals("2")) {
			// 年度
			yearMonth.add(year + "");
		}
		return yearMonth;
	}

	/**
	 * 区域满意度分析数据列表
	 * 
	 * @throws ParseException
	 * @throws ServiceException
	 */
	@Override
	public List<Map<String, Object>> getAreaAnalysis(String userCode, String area, String annualState,
			String howQuarters, boolean flag, String startMonth, String endMonth, String yearMon)
			throws ParseException, ServiceException {
		List<Role> roles = roleMapper.findByUserCode(userCode);
		List<String> yearMonth = new ArrayList<>();
		List<Map<String, Object>> list = new ArrayList<>();
		if (annualState.equals("0")) {
			// 月度
			yearMonth = this.getYearMon(startMonth, endMonth);
			list = this.getMonDataList(roles, yearMonth, userCode, area, annualState, howQuarters, startMonth, endMonth,
					yearMon);
		} else if (annualState.equals("1")) {
			int year = LocalDate.now().getYear();
			// 季度
			if ("1".equals(howQuarters)) {
				yearMonth.add(year + "-01");
				yearMonth.add(year + "-02");
				yearMonth.add(year + "-03");
			} else if ("2".equals(howQuarters)) {
				yearMonth.add(year + "-04");
				yearMonth.add(year + "-05");
				yearMonth.add(year + "-06");
			} else if ("3".equals(howQuarters)) {
				yearMonth.add(year + "-07");
				yearMonth.add(year + "-08");
				yearMonth.add(year + "-09");
			} else if ("4".equals(howQuarters)) {
				yearMonth.add(year + "-10");
				yearMonth.add(year + "-11");
				yearMonth.add(year + "-12");
			}
			list = this.quarterDataList(roles, yearMonth, userCode, area, annualState, howQuarters);
		}
		return list;
	}

	public List<String> getYearMon(String startMonth, String endMonth) {

		List<String> yearMonth = new ArrayList<>();

		String startYear = startMonth.split("-")[0];
		String startMon = startMonth.split("-")[1];

		String endYear = endMonth.split("-")[0];
		String endMon = endMonth.split("-")[1];

		int endMon1 = 0;
		if (Integer.valueOf(startMon) > Integer.valueOf(endMon)) {
			endMon1 = 12 + Integer.valueOf(endMon);
		} else {
			endMon1 = Integer.valueOf(endMon);
		}

		for (int i = Integer.valueOf(startMon); i <= endMon1; i++) {
			String mon = startYear + "-" + (i < 10 ? "0" + i : i);
			if (i > 12) {
				mon = endYear + "-" + (i - 12 < 10 ? "0" + (i - 12) : (i - 12) + "");
			}
			yearMonth.add(mon);
		}
		return yearMonth;
	}

	/**
	 * 季度数据列表
	 * 
	 * @param roles
	 * @param yearMonth
	 * @param userCode
	 * @param area
	 * @param annualState
	 * @param flag
	 * @return
	 * @throws ParseException
	 */
	public List<Map<String, Object>> quarterDataList(List<Role> roles, List<String> yearMonth, String userCode,
			String area, String annualState, String howQuarters) throws ParseException {

		List<String> tbSysOrgans = new ArrayList<>();
		tbSysOrgans = this.isHeadquarters1(roles, tbSysOrgans, userCode, yearMonth, area);
		// 上季度排名
		Map<String, List<Object>> lastRankMap = this.lastMonthRanking(roles, userCode, yearMonth, area, annualState);
		// 本季度排名
		Map<String, List<Object>> thisRankMap = this.areaRanking(roles, userCode, yearMonth, area);
//		List<TbSysOrgan> tbSysOrgans1 = new ArrayList<>();
		List<String> tbSysOrgans1 = new ArrayList<>();
		for (Object areaRank : thisRankMap.get("lista")) {
			String area1 = (String) areaRank;
			if (area == null) {
//				TbSysOrgan tbSysOran = tbSysOrganMapper.findByOrganName(area1);
//				tbSysOrgans1.add(tbSysOran);
				tbSysOrgans1.add(area1);
			} else {
				if (area.equals(area1)) {
//					TbSysOrgan tbSysOran = tbSysOrganMapper.findByOrganName(area);
//					tbSysOrgans1.add(tbSysOran);
					tbSysOrgans1.add(area);
				}
			}
		}
		// Double satisfactionTotal = this.getAllSatisfactionTotal(tbSysOrgans1,
		// yearMonth);
		//
		// String sfRateTotal = this.sfRateTotal(tbSysOrgans1, yearMonth);

		List<Map<String, Object>> list = new ArrayList<>();

		for (String tbSysOrgan : tbSysOrgans1) {
			Map<String, Object> map = new HashMap<>();
			List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearMonth,
					tbSysOrgan, AuditStatus.PASS);

			int areaRank1 = 0;
			for (int i = 0; i < thisRankMap.get("listc").size(); i++) {
				if (tbSysOrgan.equals(thisRankMap.get("lista").get(i))) {
					areaRank1 = "".equals(thisRankMap.get("listc").get(i)) ? 0 : (int) thisRankMap.get("listc").get(i);
					if (bigholderAreaAudits.size() > 0) {
						String satisfaction4 = this.getSatis1(yearMonth, tbSysOrgan);
						map.put("areaRank", satisfaction4.equals("") ? "" : areaRank1 == 0 ? "" : areaRank1);
					} else {
						map.put("areaRank", "");
					}
				}
			}

			// areaRank1 =
			// "".equals(thisRankMap.get("listc").get(i))?0:(int)thisRankMap.get("listc").get(i);
			// if (bigholderAreaAudits5.size() > 0) {
			// String satisfaction4 = this.getSatis(yearM, tbSysOrgan);
			// map.put("areaRank", satisfaction4.equals("") ? "" :
			// areaRank1==0?"":areaRank1);
			// } else {
			// map.put("areaRank", "");
			// }

			Set<Object> s = new HashSet<>();
			for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
				s.add(bigholderAreaAudit.getCorrespondProject());
			}

			// 区域评分
			String regionalScale = this.regionalScale(tbSysOrgan, yearMonth);

			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos5 = bigholderSatisfyMapper1
					.getByMonsAndArea(yearMonth, tbSysOrgan);
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos = new ArrayList<>();
			for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos5) {
				if(AuditStatus.PASS.equals(bigholderSatisfacationInfo.getAuditStatus())){
					bigholderSatisfacationInfos.add(bigholderSatisfacationInfo);
				}
			}
			// 满意率
			String satisfactionRate = this.satisfactionRate(bigholderSatisfacationInfos, yearMonth, tbSysOrgan);

			// 满意度
			String satisfaction = this.getSatis1(yearMonth, tbSysOrgan);

			//上季度满意度
			List<String> lastYearM1 = this.commlastMonth(yearMonth, annualState);
			String lastSatisfaction = this.getSatis1(lastYearM1, tbSysOrgan);
			
			// String annualState, String howQuarters
			Map<String, Object> map1 = new HashMap<>();
			if ("1".equals(annualState)) {
				if ("1".equals(howQuarters)) {
					map1.put("第1季度", satisfaction.equals("") ? "" : ComTool.accuracy(satisfaction, 2));
				} else if ("2".equals(howQuarters)) {
					map1.put("第2季度", satisfaction.equals("") ? "" : ComTool.accuracy(satisfaction, 2));
				} else if ("3".equals(howQuarters)) {
					map1.put("第3季度", satisfaction.equals("") ? "" : ComTool.accuracy(satisfaction, 2));
				} else if ("4".equals(howQuarters)) {
					map1.put("第4季度", satisfaction.equals("") ? "" : ComTool.accuracy(satisfaction, 2));
				}
			}
			map.put("satisfaction", map1);
			List<String> lastYearMonth = this.commlastMonth(yearMonth, annualState);
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos6 = bigholderSatisfyMapper1
					.getByMonsAndArea(lastYearMonth, tbSysOrgan);
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos1 = new ArrayList<>();
			for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos6) {
				if(AuditStatus.PASS.equals(bigholderSatisfacationInfo.getAuditStatus())){
					bigholderSatisfacationInfos1.add(bigholderSatisfacationInfo);
				}
			}
			// 上个月满意率
			String lastSatisfactionRate = this.lastSatisfactionRate(bigholderSatisfacationInfos1, yearMonth, tbSysOrgan,
						annualState);

			String lastMonthRanking = "";
			for (int i = 0; i < lastRankMap.get("listc").size(); i++) {
				String rankArea = (String) lastRankMap.get("lista").get(i);
				if (rankArea.equals(tbSysOrgan)) {

					if (bigholderSatisfacationInfos1.size() > 0) {
						lastMonthRanking = lastRankMap.get("listc").get(i) + "";
					} else {
						lastMonthRanking = "";
					}
				}
			}
			if (satisfactionRate.length() != 0) {
				if (!satisfactionRate.equals("0.00%")) {
					satisfactionRate = satisfactionRate.split("%")[0];
				}else {
					satisfactionRate = "0.00";
				}
			}
			if (lastSatisfactionRate.length() != 0) {
				if (!lastSatisfactionRate.equals("0.00%")) {
					lastSatisfactionRate = lastSatisfactionRate.split("%")[0];
				}else {
					lastSatisfactionRate = "0.00";
				}
			}
			// 区域名
			map.put("areaName", tbSysOrgan);
			// 项目数量
			map.put("projectNum", s.size());
			// 区域排名
			// map.put("areaRank", areaRank1);
			// 满意率
			map.put("satisfactionRate", satisfactionRate);
			// 区域评分
			map.put("regionalScale", regionalScale);
//			// 月度提升值
//			if ("".equals(lastSatisfactionRate)) {
//				map.put("monthAppreciate", "");
//			} else {
//				if(satisfactionRate.equals("0.00")||lastSatisfactionRate.equals("0.00")){
//					map.put("monthAppreciate", "");
//				}else{
//					Double a = Double.valueOf(satisfactionRate) - Double.valueOf(lastSatisfactionRate);
//					map.put("monthAppreciate", a == 0 ? "0.00%" : ComTool.accuracy(a, 2) + "%");
//				}
//			}
			// 月度提升值
			if ("".equals(lastSatisfaction)||"".equals(satisfaction)) {
				map.put("monthAppreciate", "");
			} else {
				Double a = Double.valueOf(satisfaction) - Double.valueOf(lastSatisfaction);
				map.put("monthAppreciate", a == 0 ? "0.00" : ComTool.accuracy(a, 2));
			}
			// 上月（上个季度或者上一年）排名
			map.put("lastMonthRanking", lastMonthRanking);
			// 排名变动
			map.put("turnover", "".equals(lastMonthRanking) ? "" : areaRank1==0?"":areaRank1 - Integer.valueOf(lastMonthRanking));
			list.add(map);
		}
		return list;
	}

	/**
	 * 月度数据列表
	 * 
	 * @param roles
	 * @param dateList
	 * @param userCode
	 * @param area
	 * @param annualState
	 * @param howQuarters
	 * @param startMonth
	 * @param endMonth
	 * @return
	 * @throws ParseException
	 * @throws ServiceException
	 */
	@SuppressWarnings({ "unchecked", "static-access" })
	public List<Map<String, Object>> getMonDataList(List<Role> roles, List<String> dateList, String userCode,
			String area, String annualState, String howQuarters, String startMonth, String endMonth, String yearMon)
			throws ParseException, ServiceException {
		List<Map<String, Object>> list1 = new ArrayList<>();

//		List<String> tbSysOrgans = new ArrayList<>();
		List<String> yearM = new ArrayList<>();
		yearM.add(yearMon);
//		tbSysOrgans = this.isHeadquarters1(roles, tbSysOrgans, userCode, yearM, area);
		// 本月区域排名
		Map<String, List<Object>> thisRankMap = this.areaRanking(roles, userCode, yearM, area);
//		List<TbSysOrgan> tbSysOrgans1 = new ArrayList<>();
		List<String> tbSysOrgans1 = new ArrayList<>();
		for (Object areaRank : thisRankMap.get("lista")) {
			String area1 = (String) areaRank;
			if (area != null) {
				if (area.equals(area1)) {
//					TbSysOrgan tbSysOran = tbSysOrganMapper.findByOrganName(area);
//					tbSysOrgans1.add(tbSysOran);
					tbSysOrgans1.add(area);
				}
			} else {
//				TbSysOrgan tbSysOran = tbSysOrganMapper.findByOrganName(area1);
//				tbSysOrgans1.add(tbSysOran);
				tbSysOrgans1.add(area1);
			}
		}
		for (String tbSysOrgan : tbSysOrgans1) {
			Map<String, Object> map = new HashMap<>();
//			TbSysOrgan tbSysOran = tbSysOrganMapper.findByOrganName(tbSysOrgan);
			List<BigholderAreaAudit> bigholderAreaAudits5 = bigholderAduitMapper.findByMonthsOrArea(yearM,
					tbSysOrgan, AuditStatus.PASS);
			// 区域名
			map.put("areaName", tbSysOrgan);
			// 区域排名
			int areaRank1 = 0;
			for (int i = 0; i < thisRankMap.get("listc").size(); i++) {
				if (tbSysOrgan.equals(thisRankMap.get("lista").get(i))) {
					areaRank1 = "".equals(thisRankMap.get("listc").get(i)) ? 0 : (int) thisRankMap.get("listc").get(i);
					if (bigholderAreaAudits5.size() > 0) {
						String satisfaction4 = this.getSatis1(yearM, tbSysOrgan);
						map.put("areaRank", satisfaction4.equals("") ? "" : areaRank1 == 0 ? "" : areaRank1);
					} else {
						map.put("areaRank", "");
					}
				}
			}
			// 项目数
			int projectTotalNum = this.projectNum(tbSysOrgan, yearM);
			map.put("projectNum", projectTotalNum);
			Map<String, Object> map1 = new TreeMap<>();
			for (String date : dateList) {
				List<String> a1 = new ArrayList<>();
				a1.add(date);
				List<BigholderAreaAudit> bigholderAreaAudit = bigholderAduitMapper.findByMonthsOrArea(a1,
						tbSysOrgan, AuditStatus.PASS);
				if (bigholderAreaAudit.size() > 0) {
					String satisfaction = this.getSatis1(a1, tbSysOrgan);
					map1.put(date, satisfaction.equals("") ? "" : ComTool.accuracy(satisfaction, 2));
				} else {
					map1.put(date, "");
				}
			}
			map1 = this.sortMap(map1);
			// 满意度
			map.put("satisfaction", map1);
			//本月满意度
			String thisSatisfactions = "";
			List<BigholderAreaAudit> thisBigholderAreaAudit = bigholderAduitMapper.findByMonthsOrArea(yearM,
					tbSysOrgan, AuditStatus.PASS);
			if (thisBigholderAreaAudit.size() > 0) {
				String thisSatisfaction = this.getSatis1(yearM, tbSysOrgan);
//				map1.put(date, satisfaction.equals("") ? "" : ComTool.accuracy(satisfaction, 2));
				thisSatisfactions = thisSatisfaction.equals("") ? "" : ComTool.accuracy(thisSatisfaction, 2);
			} 
			
			//上月满意度
			String lastSatisfactions = "";
			List<String> lastYearM1 = this.commlastMonth(yearM, annualState);
			List<BigholderAreaAudit> lastBigholderAreaAudit = bigholderAduitMapper.findByMonthsOrArea(lastYearM1,
					tbSysOrgan, AuditStatus.PASS);
			if (lastBigholderAreaAudit.size() > 0) {
				String lastSatisfaction = this.getSatis1(lastYearM1, tbSysOrgan);
//				map1.put(date, satisfaction.equals("") ? "" : ComTool.accuracy(satisfaction, 2));
				lastSatisfactions = lastSatisfaction.equals("") ? "" : ComTool.accuracy(lastSatisfaction, 2);
			} 
			// 上个月区域排名计算
			Map<String, List<Object>> lastRankMap = this.lastMonthRanking(roles, userCode, yearM, area, annualState);
			String lastMonthRanking = "";
			for (int i = 0; i < lastRankMap.get("listc").size(); i++) {
				String rankArea = (String) lastRankMap.get("lista").get(i);
				if (rankArea.equals(tbSysOrgan)) {
					List<String> lastYearMonth = this.commlastMonth(yearM, annualState);
					List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper
							.findByMonthsOrArea(lastYearMonth, tbSysOrgan, AuditStatus.PASS);
					if (bigholderAreaAudits.size() > 0) {
						String satisfaction4 = this.getSatis1(yearM, tbSysOrgan);
						lastMonthRanking = satisfaction4.equals("") ? "" : lastRankMap.get("listc").get(i) + "";
					} else {
						lastMonthRanking = "";
					}
				}
			}

			// 区域评分
			String regionalScale = this.regionalScale(tbSysOrgan, yearM);
			map.put("regionalScale", regionalScale);
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos5 = bigholderSatisfyMapper1
					.getByMonsAndArea(yearM, tbSysOrgan);
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos = new ArrayList<>();
			for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos5) {
				if(AuditStatus.PASS.equals(bigholderSatisfacationInfo.getAuditStatus())){
					bigholderSatisfacationInfos.add(bigholderSatisfacationInfo);
				}
			}
			// 满意率
			String satisfactionRate = this.satisfactionRate(bigholderSatisfacationInfos, yearM, tbSysOrgan);
			// 满意率
			map.put("satisfactionRate", satisfactionRate.equals("0.00%") ? "" : satisfactionRate);
			List<String> lastYearMonth = this.commlastMonth(yearM, annualState);
			// List<BigholderAreaAudit>
			// bigholderAreaAudits1=bigholderAduitMapper.findByMonthsOrArea(lastYearMonth,
			// tbSysOrgan.getOrganName(), AuditStatus.PASS);
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos6 = bigholderSatisfyMapper1
					.getByMonsAndArea(lastYearMonth, tbSysOrgan);
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos2 = new ArrayList<>();
			for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos6) {
				if(AuditStatus.PASS.equals(bigholderSatisfacationInfo.getAuditStatus())){
					bigholderSatisfacationInfos2.add(bigholderSatisfacationInfo);
				}
			}
			// 上个月满意率
			String lastSatisfactionRate = this.lastSatisfactionRate(bigholderSatisfacationInfos2, yearM, tbSysOrgan,
						annualState);

			// 上个月区域排名
			map.put("lastMonthRanking", lastMonthRanking);

			if (satisfactionRate.length() != 0) {
				if (!satisfactionRate.equals("0.00%")) {
					satisfactionRate = satisfactionRate.split("%")[0];
				} else {
					satisfactionRate = "0.00";
				}
			}
			if (lastSatisfactionRate.length() != 0) {
				if (!lastSatisfactionRate.equals("0.00%")) {
					lastSatisfactionRate = lastSatisfactionRate.split("%")[0];
				} else {
					lastSatisfactionRate = "0.00";
				}
			}

//			// 月度提升值
//			if ("".equals(lastSatisfactionRate)||"".equals(satisfactionRate)) {
//				map.put("monthAppreciate", "");
//			} else {
//				if(satisfactionRate.equals("0.00")||lastSatisfactionRate.equals("0.00")){
//					map.put("monthAppreciate", "");
//				}else{
//					Double a1 = Double.valueOf(satisfactionRate) - Double.valueOf(lastSatisfactionRate);
//					map.put("monthAppreciate", a1 == 0 ? "0.00%" : ComTool.accuracy(a1,2) + "%");
//				}
//			}
			// 月度提升值
			if ("".equals(lastSatisfactions)||"".equals(thisSatisfactions)) {
				map.put("monthAppreciate", "");
			} else {
				Double a1 = Double.valueOf(thisSatisfactions) - Double.valueOf(lastSatisfactions);
				map.put("monthAppreciate", a1 == 0 ? "0.00" : ComTool.accuracy(a1,2));
			}
			
			// 排名变动
			map.put("turnover", "".equals(lastMonthRanking) ? "" : areaRank1==0?"":areaRank1 - Integer.valueOf(lastMonthRanking));
			map.put("biaoRedSastis", yearMon);
			list1.add(map);
		}
		return list1;
	}

	public int projectNum(String tbSysOrgan, List<String> yearMonth) {
		int projectTotalNum = 0;
		List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearMonth,
				tbSysOrgan, AuditStatus.PASS);
		Set<Object> s = new HashSet<>();
		for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
			s.add(bigholderAreaAudit.getCorrespondProject());
		}
		projectTotalNum = s.size();
		return projectTotalNum;
	}

	@Override
	public List<Map<String, Object>> getAreaAnalysis1(String userCode, String area, String annualState,
			String howQuarters, boolean flag, String startMonth, String endMonth) throws ParseException {
		List<Role> roles = roleMapper.findByUserCode(userCode);
		Map<String, Object> map = new HashMap<>();
		List<Map<String, Object>> list = new ArrayList<>();

		List<String> yearMon = new ArrayList<>();
		List<String> yearMonth = new ArrayList<>();

		String startYear = startMonth.split("-")[0];
		String startMon = startMonth.split("-")[1];

		String endYear = endMonth.split("-")[0];
		String endMon = endMonth.split("-")[1];

		int endMon1 = 0;
		if (Integer.valueOf(startMon) > Integer.valueOf(endMon)) {
			endMon1 = 12 + Integer.valueOf(endMon);
		} else {
			endMon1 = Integer.valueOf(endMon);
		}

		for (int i = Integer.valueOf(startMon); i <= endMon1; i++) {

			String mon = startYear + "-" + (i < 10 ? "0" + i : i);
			if (i > 12) {
				mon = endYear + "-" + (i - 12 < 10 ? "0" + (i - 12) : (i - 12) + "");
			}
			yearMon.add(mon);
		}
		yearMonth = this.commAreaAnalysis(yearMonth, yearMon, annualState, howQuarters);
		list = this.monList(roles, yearMonth, userCode, area, annualState, endMonth);
		return list;
	}

	public List<Map<String, Object>> monList(List<Role> roles, List<String> yearMonth, String userCode, String area,
			String annualState, String endMonth) throws ParseException {
		String date = "";
		List<BigholderSatisfacationInfo> bigholderSaInfos = bigholderSatisfyMapper1.importTime(endMonth);
		if (bigholderSaInfos.size() > 0) {
			date = bigholderSaInfos.get(0).getCreateDate().substring(0, 4) + "年"
					+ bigholderSaInfos.get(0).getCreateDate().substring(5, 7) + "月"
					+ bigholderSaInfos.get(0).getCreateDate().substring(8, 10) + "日";
		}
		List<String> yearM1 = new ArrayList<>();
//		if ("0".equals(annualState)) {
//			yearM1.add(endMonth);
//		} else {
			yearM1 = yearMonth;
//		}
		List<String> tbSysOrgans = new ArrayList<>();
		tbSysOrgans = this.isHeadquarters1(roles, tbSysOrgans, userCode, yearM1, area);

		Double satisfactionTotal = this.getSatisAll1(yearM1, tbSysOrgans);

		String sfRateTotal = this.sfRateTotal(tbSysOrgans, yearM1);

		List<Map<String, Object>> list = new ArrayList<>();
		int count = 0;

		int projectTotalNum = 0;
		Map<String, Object> map = new HashMap<>();
		for (String tbSysOrgan : tbSysOrgans) {
			count++;
			List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearM1,
					tbSysOrgan, AuditStatus.PASS);

			Set<Object> s = new HashSet<>();
			for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
				s.add(bigholderAreaAudit.getCorrespondProject());
			}
			projectTotalNum += s.size();
		}

		map.put("importTime", date);
		// 本月满意率
		map.put("currentSfRateTotal", "0.00%".equals(sfRateTotal) ? "" : sfRateTotal);
		// 本月满意度
		map.put("currentSfTotal", satisfactionTotal.equals(0.00)?"":ComTool.accuracy(satisfactionTotal, 2));
		// 项目总数
		map.put("projectTotalNum", projectTotalNum);
		// 区域总数
		map.put("areaTotalNum", count);
		list.add(map);
		return list;
	}
	/**
	 * 上月的年月时间处理
	 * 
	 * @param yearMon
	 * @return
	 */
	public List<String> commlastMonth(List<String> yearMon, String annualState) {
		List<String> list = new ArrayList<>();
		if ("2".equals(annualState)) {
			list.add((Integer.valueOf(yearMon.get(0)) - 1) + "");
		} else if ("1".equals(annualState)) {
			for (String yearMonth : yearMon) {
				int month = Integer.valueOf(yearMonth.substring(5, 7));
				int year = Integer.valueOf(yearMonth.substring(0, 4));
				if (month <= 3) {
					year--;
					month = month - 3;
					if (month == 0) {
						month = 12;
					} else if (month == -1) {
						month = 11;
					} else if (month == -2) {
						month = 10;
					}
				} else {
					month = month - 3;
				}
				String lastYearMonth = year + "-" + (month < 10 ? "0" + month : month);
				list.add(lastYearMonth);
			}
		} else if ("0".equals(annualState)) {
			for (String yearMonth : yearMon) {
				int month = Integer.valueOf(yearMonth.substring(5, 7));
				int year = Integer.valueOf(yearMonth.substring(0, 4));
				if (month == 1) {
					year--;
					month = 12;
				} else {
					month = month - 1;
				}
				String lastYearMonth = year + "-" + (month < 10 ? "0" + month : month);
				list.add(lastYearMonth);
			}
		}
		return list;
	}

	/**
	 * 查询上一个月的满意度
	 * 
	 * @param erpCommunity
	 * @param yearMon
	 * @return
	 */
	public String lastMonSatisfaction(List<BigholderSatisfacationInfo> bigholderSatisfacationInfos,
			List<String> yearMon, String area, String annualState) {
		List<String> lastYearMonth = this.commlastMonth(yearMon, annualState);
		List<BigholderSatisfacationInfo> bigholderSfInfos = bigholderSatisfyMapper1.getByMonsAndArea(lastYearMonth,
				area);
		String lastSatisfaction = getSatisfaction(bigholderSfInfos, lastYearMonth);
		return lastSatisfaction;
	}

	/**
	 * 查询上个月份的满意率
	 * 
	 * @param erpCommunitys
	 * @param yearMon
	 * @return
	 */
	public String lastSatisfactionRate(List<BigholderSatisfacationInfo> bigholderSatisfacationInfos2,
			List<String> yearMon, String tbSysOrgan, String annualState) {
		List<String> lastYearMonth = this.commlastMonth(yearMon, annualState);
		String lastSatisfactionRate = this.satisfactionRate(bigholderSatisfacationInfos2, lastYearMonth, tbSysOrgan);
		return lastSatisfactionRate;
	}

	public String getSatis(List<String> yearMon, TbSysOrgan tbSysOrgan) {
		Double satisfactions = 0.0;
		String satisfactions1 = "";
		int count = 0;
		List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearMon,
				tbSysOrgan.getOrganName(), AuditStatus.PASS);
		for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
			String satisfaction = bigholderAreaAudit.getSatisfactionScores();
			if (satisfaction != null && satisfaction.length() > 0) {
				satisfactions += Double.valueOf(satisfaction);
				count++;
			}
		}
		if (count != 0) {
			satisfactions = satisfactions / count;
			satisfactions1 = satisfactions + "";
		} else {
			satisfactions = 0.0;
			satisfactions1 = "";
		}
		return satisfactions1;
	}
	
	public String getSatis1(List<String> yearMon, String tbSysOrgan) {
		Double satisfactions = 0.0;
		String satisfactions1 = "";
		int count = 0;
		List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearMon,
				tbSysOrgan, AuditStatus.PASS);
		for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
			String satisfaction = bigholderAreaAudit.getSatisfactionScores();
			if (satisfaction != null && satisfaction.length() > 0) {
				satisfactions += Double.valueOf(satisfaction);
				count++;
			}
		}
		if (count != 0) {
			satisfactions = satisfactions / count;
			satisfactions1 = satisfactions + "";
		} else {
			satisfactions = 0.0;
			satisfactions1 = "";
		}
		return satisfactions1;
	}

	/**
	 * 本月区域排名
	 * 
	 * @param yearMon
	 * @param tbSysOrganList
	 * @return
	 */
	public Map<String, List<Object>> areaRanking(List<Role> roles, String userCode, List<String> yearMon, String area) {
		List<Double> lists = new ArrayList<>();
		List<String> lists1 = new ArrayList<>();
		List<String> lists2 = new ArrayList<>();

		List<String> tbSysOrgans = new ArrayList<>();
		tbSysOrgans = this.isHeadquarters1(roles, tbSysOrgans, userCode, yearMon, null);
		for (String tbSysOrgan : tbSysOrgans) {
			String satisfactions = this.getSatis1(yearMon, tbSysOrgan);
			if (!satisfactions.equals("")) {
				lists1.add(tbSysOrgan);
				lists.add(Double.valueOf(ComTool.accuracy(satisfactions, 2)));
			} else {
				lists2.add(tbSysOrgan);
			}
		}
		Collections.sort(lists2);
		for (int i = 0; i < lists.size() - 1; i++) {
			for (int j = 1; j < lists.size() - i; j++) {
				Double a;
				String b;
				if ((lists.get(j - 1)).compareTo(lists.get(j)) <= 0) { // 比较两个整数的大小
					if ((lists.get(j - 1)).compareTo(lists.get(j)) < 0){
						a = lists.get(j - 1);
						lists.set((j - 1), lists.get(j));
						lists.set(j, a);
	
						b = lists1.get(j - 1);
						lists1.set((j - 1), lists1.get(j));
						lists1.set(j, b);
					}else if((lists.get(j - 1)).compareTo(lists.get(j))==0){
						List<Double> list0=new ArrayList<>();
						list0.add(lists.get(j - 1));
						list0.add(lists.get(j));
						Collections.sort(list0);
						lists.set((j - 1), list0.get(0));
						lists.set(j, list0.get(1));
						
						List<String> list01=new ArrayList<>();
						list01.add(lists1.get(j - 1)+"");
						list01.add(lists1.get(j)+"");
						Collections.sort(list01);
						lists1.set((j - 1), list01.get(0));
						lists1.set(j, list01.get(1));
					}
				}
			}
		}

		Map<String, List<Object>> map = new Hashtable<>();
		List<Object> lista = new ArrayList<>();
		List<Object> listc = new ArrayList<>();
		int count = 1;
		for (int i = 0; i < lists1.size(); i++) {
			if (i == 0) {
				lista.add(lists1.get(i));
				listc.add(count);
			} else {
				Double a = lists.get(i - 1);
				Double b = lists.get(i);
				if (lists.get(i - 1).equals(lists.get(i))) {
					lista.add(lists1.get(i));
					listc.add(count);
				} else {
					lista.add(lists1.get(i));
					listc.add(++count);
				}
			}
		}
		// for (int i=0;i<listc.size();i++) {
		//
		// }
		for (String area1 : lists2) {
			lista.add(area1);
			listc.add("");
		}
		map.put("lista", lista);
		map.put("listc", listc);
		return map;
	}

	/**
	 * 上月区域排名
	 * 
	 * @param yearMon
	 * @param tbSysOrganList
	 * @return
	 */
	public Map<String, List<Object>> lastMonthRanking(List<Role> roles, String userCode, List<String> yearMonth,
			String area, String annualState) {
		List<String> lastYearMonth = this.commlastMonth(yearMonth, annualState);
		Map<String, List<Object>> map = this.areaRanking(roles, userCode, lastYearMonth, area);
		return map;
	}

	@Override
	public List<Map<String, Object>> getViewPresidentQs(String yearMon, String area, String annualState,
			String howQuarters) {

		List<Map<String, Object>> list = new ArrayList<>();
		List<String> yearMonth = new ArrayList<>();
		List<String> yearMon1 = new ArrayList<>();
		yearMon1.add(yearMon);
		yearMonth = this.commAreaAnalysis(yearMonth, yearMon1, annualState, howQuarters);
		list = this.getViewPresidentQsList(yearMonth, area);
		return list;
	}

	public List<Map<String, Object>> getViewPresidentQsList(List<String> yearMonth, String area) {
		List<Map<String, Object>> list = new ArrayList<>();
		List<BigholderLandEstate> bigholderLandEstates = new ArrayList<>();
		bigholderLandEstates = bigholderLandEstateMapper.selectLandEstatebyMonArea(area, yearMonth);
		for (BigholderLandEstate bigholderLandEstate : bigholderLandEstates) {
			Map<String, Object> map = new HashMap<>();
			map.put("landArea", bigholderLandEstate.getLandArea());
			map.put("estateArea", bigholderLandEstate.getEstateArea());
			map.put("a2", bigholderLandEstate.getA2());
			map.put("a3", bigholderLandEstate.getA3()==null?"":bigholderLandEstate.getA3());
			map.put("a4", bigholderLandEstate.getA4()==null?"":bigholderLandEstate.getA4());
			map.put("a8", bigholderLandEstate.getA8());
			map.put("a9", bigholderLandEstate.getA9());
			map.put("a10", bigholderLandEstate.getA10());
			map.put("a11", bigholderLandEstate.getA11());
			map.put("a12", bigholderLandEstate.getA12());
			list.add(map);
		}
		return list;
	}

	/**
	 * 区域或全国
	 */
	@Override
	public List<Map<String, Object>> getAreaViewPresidentQs(String area, String userCode, String annualState,
			String howQuarters, String startMonth, String endMonth) {
		List<Map<String, Object>> list = new ArrayList<>();
		List<String> yearMonth = new ArrayList<>();
		yearMonth = this.comSM(yearMonth, area, userCode, annualState, howQuarters, startMonth, endMonth);
		list = this.getAreaViewList(yearMonth, userCode, area, startMonth, endMonth, annualState);
		return list;
	}

	public List<Map<String, Object>> getAreaViewList(List<String> yearMonth, String userCode, String area,
			String startMonth, String endMonth, String annualState) {
		List<Map<String, Object>> list = new ArrayList<>();
		Map<String, Object> map = new HashMap<>();
		List<String> yearM = new ArrayList<>();
//		if (annualState.equals("0")) {
//			yearM.add(endMonth);
//		} else {
			yearM = yearMonth;
//		}
		List<Role> roles = roleMapper.findByUserCode(userCode);
		List<String> tbSysOrgans = new ArrayList<>();
		tbSysOrgans = this.isHeadquarters1(roles, tbSysOrgans, userCode, yearM, area);

		// 所有区域满意度
		Double satisfactionTotal = this.getSatisAll1(yearM, tbSysOrgans);
		map.put("satisfactionTotal", satisfactionTotal.equals(0.0)?"":ComTool.accuracy(satisfactionTotal, 2));
		// 所有区域满意率
		String sfRateTotal = this.sfRateTotal(tbSysOrgans, yearM);
		map.put("sfRateTotal", "0.00%".equals(sfRateTotal) ? "" : sfRateTotal);
		// 所有区域区域评分
		String regionalScaleTotal = this.regionalScaleTotal(tbSysOrgans, yearM);
		map.put("regionalScaleTotal", regionalScaleTotal);
		list.add(map);
		// 统计得分
		// Map<String, Object> map1 = this.scoringStatistics(tbSysOrgans,
		// yearM);
		// list.add(map1);
		return list;
	}

	/**
	 * 项目
	 */
	@Override
	public List<Map<String, Object>> getProjectViewPresidentQs(String area, String userCode, String projectName,
			String annualState, String howQuarters, String startMonth, String endMonth) {
		Map<String, Object> map = new HashMap<>();
		List<Map<String, Object>> list = new ArrayList<>();
		List<String> yearMonth = new ArrayList<>();
		yearMonth = this.comSM(yearMonth, area, userCode, annualState, howQuarters, startMonth, endMonth);
		list = this.getProjectViewList(yearMonth, area, userCode, projectName, annualState, howQuarters, startMonth,
				endMonth);
		return list;
	}

	public List<Map<String, Object>> getProjectViewList(List<String> yearMonth, String area, String userCode,
			String projectName, String annualState, String howQuarters, String startMonth, String endMonth) {
		List<Map<String, Object>> list = new ArrayList<>();
		Map<String, Object> map = new HashMap<>();
		List<String> yearM = new ArrayList<>();
//		if ("0".equals(annualState)) {
//			yearM.add(endMonth);
//		} else {
			yearM = yearMonth;
//		}
//		TbSysOrgan tbSysOrgan = tbSysOrganMapper.findByOrganName(area);
		// 项目满意度
		List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearM, area,
				AuditStatus.PASS);
		Double satisfaction1=0.0;
		int count=0;
		for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
			if (projectName.equals(bigholderAreaAudit.getCorrespondProject())) {
				if(bigholderAreaAudit.getSatisfactionScores() != null){
					satisfaction1 += bigholderAreaAudit.getSatisfactionScores() == null ? 0.0
							: Double.valueOf(bigholderAreaAudit.getSatisfactionScores());
					count++;
				}
				
			}
		}
		if (count==0) {
			map.put("satisfactionTotal", "");
		} else {
			map.put("satisfactionTotal", ComTool.accuracy(satisfaction1/count, 2));
		}
		List<BigholderSatisfacationInfo> bigholderSatisfacationInfos1 = bigholderSatisfyMapper1
				.getBSByProNameOrMonYear(yearM, projectName, area);
		List<BigholderSatisfacationInfo> bigholderSatisfacationInfos = new ArrayList<>();
		for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos1) {
			if(AuditStatus.PASS.equals(bigholderSatisfacationInfo)){
				bigholderSatisfacationInfos.add(bigholderSatisfacationInfo);
			}
		}
		String sfRate = this.satisfactionRate(bigholderSatisfacationInfos, yearM, area);
		map.put("sfRateTotal", sfRate.equals("0.00%")?"":sfRate);
		// 区域评分
		String regionalScale = this.commList2(area, yearM);
		map.put("regionalScaleTotal", regionalScale);
		list.add(map);
		return list;
	}

	/**
	 * 得分统计(切换全国和区域)
	 * 
	 * @param tbSysOrgans
	 * @param yearMonth
	 * @return
	 */
	public List<Map<String, Object>> scoringStatistics(List<TbSysOrgan> tbSysOrgans, List<String> yearMonth) {
		List<Map<String, Object>> list = new ArrayList<>();
		List<String> satisfactionList = new ArrayList<>();
		Set<String> satisfactionSet = new HashSet<>();
		for (TbSysOrgan tbSysOrgan : tbSysOrgans) {
			// String satisfaction = this.getSatis(yearMonth, tbSysOrgan);
			List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearMonth,
					tbSysOrgan.getOrganName(), AuditStatus.PASS);
			if (bigholderAreaAudits.size() > 0) {
				for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
					String satisfaction = bigholderAreaAudit.getSatisfactionScores();
					if (satisfaction != null) {
						satisfactionList.add(satisfaction);
						satisfactionSet.add(satisfaction);
					}
				}
			}
		}
		for (String satisfa : satisfactionSet) {
			Map<String, Object> map = new HashMap<>();
			int count = 0;
			for (String satisfa1 : satisfactionList) {
				if (satisfa.equals(satisfa1)) {
					count++;
				}
			}
			map.put("score", ComTool.accuracy(satisfa, 2) + "分");
			map.put("count", count);
			list.add(map);
		}
		return list;
	}

	/**
	 * 得分统计(项目)
	 */
	public List<Map<String, Object>> scoringStProject(List<String> yearMonth, String area, String userCode,
			String projectName) {
		List<Map<String, Object>> list = new ArrayList<>();
		List<BigholderAreaAudit> bigholderAreaAudits = bigholderAduitMapper.findByMonthsOrArea(yearMonth, area,
				AuditStatus.PASS);
		List<BigholderAreaAudit> bigholderAreaAudits1 = new ArrayList<>();
		for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits) {
			if (projectName != null) {
				if (projectName.equals(bigholderAreaAudit.getCorrespondProject())) {
					bigholderAreaAudits1.add(bigholderAreaAudit);
				}
			}
		}
		for (BigholderAreaAudit bigholderAreaAudit : bigholderAreaAudits1) {
			Map<String, Object> map = new HashMap<>();
			if (bigholderAreaAudit.getSatisfactionScores() == null) {
				return list;
			} else {
				map.put("score", ComTool.accuracy(bigholderAreaAudit.getSatisfactionScores(), 2) + "分");
				map.put("count", 1);
				list.add(map);
			}
		}
		return list;
	}

	/**
	 * 主观评价(切换区域和全国)
	 * 
	 * @param pageRowBounds
	 * @param yearMonth
	 * @param area
	 * @param userCode
	 * @return
	 */
	@Override
	public List<Map<String, Object>> mainEvaluation(String area, String userCode, String annualState,
			String howQuarters, String startMonth, String endMonth) {
		Map<String, Object> map = new HashMap<>();
		List<Map<String, Object>> list = new ArrayList<>();

		List<String> yearMon = new ArrayList<>();
		List<String> yearMonth = new ArrayList<>();

		String startYear = startMonth.split("-")[0];
		String startMon = startMonth.split("-")[1];

		String endYear = endMonth.split("-")[0];
		String endMon = endMonth.split("-")[1];

		int endMon1 = 0;
		if (Integer.valueOf(startMon) > Integer.valueOf(endMon)) {
			endMon1 = 12 + Integer.valueOf(endMon);
		} else {
			endMon1 = Integer.valueOf(endMon);
		}

		for (int i = Integer.valueOf(startMon); i <= endMon1; i++) {

			String mon = startYear + "-" + (i < 10 ? "0" + i : i);
			if (i > 12) {
				mon = endYear + "-" + (i - 12 < 10 ? "0" + (i - 12) : (i - 12) + "");
			}
			yearMon.add(mon);
		}
		yearMonth = this.commAreaAnalysis(yearMonth, yearMon, annualState, howQuarters);
		list = this.getMainEvaluate(yearMonth, area, userCode, annualState, howQuarters, startMonth, endMonth);
		return list;
	}

	public List<Map<String, Object>> getMainEvaluate(List<String> yearMonth, String area, String userCode,
			String annualState, String howQuarters, String startMonth, String endMonth) {
		List<Map<String, Object>> list = new ArrayList<>();
		List<Role> roles = roleMapper.findByUserCode(userCode);
		List<TbSysOrgan> tbSysOrgans = new ArrayList<>();
		List<String> yearM = new ArrayList<>();
		if ("0".equals(annualState)) {
			yearM.add(endMonth);
		} else {
			yearM = yearMonth;
		}

		tbSysOrgans = this.isHeadquarters(roles, tbSysOrgans, userCode, yearM, area);

		List<BigholderSatisfacationInfo> bigholderSatisfacationInfos = new ArrayList<>();

		List<BigholderLandEstate> bigholderLandEstate = new ArrayList<>();

		for (TbSysOrgan tbSysOrgan : tbSysOrgans) {
			bigholderLandEstate = bigholderLandEstateMapper.selectLandEstatebyMonArea(tbSysOrgan.getOrganName(),
					yearMonth);

			bigholderSatisfacationInfos = bigholderSatisfyMapper1.getByMonsAndArea(yearM, tbSysOrgan.getOrganName());
			for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos) {
				if (AuditStatus.PASS.equals(bigholderSatisfacationInfo.getAuditStatus())) {
					Map<String, Object> map = new HashMap<>();
					map.put("area", bigholderSatisfacationInfo.getEstateArea());
					List<ErpCommunity> erpCommunitys = tbHsprCommunityMapper
							.findBaseCommByCommId(bigholderSatisfacationInfo.getCorrespondProject());
					map.put("projectName", erpCommunitys.size() > 0 ? erpCommunitys.get(0).getCommName() : "");
					map.put("a11", bigholderLandEstate.size() > 0 ? bigholderLandEstate.get(0).getA11() : null);
					map.put("a12", bigholderLandEstate.size() > 0 ? bigholderLandEstate.get(0).getA12() : null);
					map.put("a8", bigholderSatisfacationInfo.getA8());
					map.put("a9", bigholderSatisfacationInfo.getA9());
					map.put("a10", bigholderSatisfacationInfo.getA10());
					list.add(map);
				}
			}
		}
		return list;
	}

	public boolean changeStringToZero(boolean flag, int a) {
		for (int i = 0; i <= 10; i++) {
			if (a == i) {
				flag = true;
			}
		}
		return flag;
	}

	/**
	 * 主观评价（项目）
	 * 
	 * @param yearMonth
	 * @param projectName
	 * @param userCode
	 * @return
	 */
	@Override
	public List<Map<String, Object>> mainEvaluationPro(String projectName, String userCode, String area,
			String annualState, String howQuarters, String startMonth, String endMonth) {

		Map<String, Object> map = new HashMap<>();
		List<Map<String, Object>> list = new ArrayList<>();

		List<String> yearMon = new ArrayList<>();
		List<String> yearMonth = new ArrayList<>();

		String startYear = startMonth.split("-")[0];
		String startMon = startMonth.split("-")[1];

		String endYear = endMonth.split("-")[0];
		String endMon = endMonth.split("-")[1];

		int endMon1 = 0;
		if (Integer.valueOf(startMon) > Integer.valueOf(endMon)) {
			endMon1 = 12 + Integer.valueOf(endMon);
		} else {
			endMon1 = Integer.valueOf(endMon);
		}

		for (int i = Integer.valueOf(startMon); i <= endMon1; i++) {

			String mon = startYear + "-" + (i < 10 ? "0" + i : i);
			if (i > 12) {
				mon = endYear + "-" + (i - 12 < 10 ? "0" + (i - 12) : (i - 12) + "");
			}
			yearMon.add(mon);
		}
		yearMonth = this.commAreaAnalysis(yearMonth, yearMon, annualState, howQuarters);
		list = this.getMainEvaluationProList(yearMonth, projectName, userCode, area, annualState, howQuarters,
				startMonth, endMonth);
		return list;
	}

	public List<Map<String, Object>> getMainEvaluationProList(List<String> yearMonth, String projectName,
			String userCode, String area, String annualState, String howQuarters, String startMonth, String endMonth) {
		List<Map<String, Object>> list = new ArrayList<>();
		Map<String, Object> map = new HashMap<>();
		List<String> yearM = new ArrayList<>();
		if ("0".equals(annualState)) {
			yearM.add(endMonth);
		} else {
			yearM = yearMonth;
		}
		List<Role> roles = roleMapper.findByUserCode(userCode);
		List<TbSysOrgan> tbSysOrgans = new ArrayList<>();
		tbSysOrgans = this.isHeadquarters(roles, tbSysOrgans, userCode, yearM, area);
		for (TbSysOrgan tbSysOrgan : tbSysOrgans) {
			List<BigholderLandEstate> bigholderLandEstate = bigholderLandEstateMapper
					.selectLandEstatebyMonArea(tbSysOrgan.getOrganName(), yearM);
			List<BigholderSatisfacationInfo> bigholderSatisfacationInfos = bigholderSatisfyMapper1
					.getBSByProNameOrMonYear(yearMonth, projectName, tbSysOrgan.getOrganName());
			for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos) {
				map.put("area", bigholderSatisfacationInfo.getEstateArea());
				List<ErpCommunity> erpCommunities = tbHsprCommunityMapper
						.findBaseCommByCommId(bigholderSatisfacationInfo.getCorrespondProject());
				map.put("projectName", erpCommunities.size() > 0 ? erpCommunities.get(0).getCommName() : "");
				map.put("a11", bigholderLandEstate.size() > 0 ? bigholderLandEstate.get(0).getA11() : null);
				map.put("a12", bigholderLandEstate.size() > 0 ? bigholderLandEstate.get(0).getA12() : null);
				map.put("a8", bigholderSatisfacationInfo.getA8());
				map.put("a9", bigholderSatisfacationInfo.getA9());
				map.put("a10", bigholderSatisfacationInfo.getA10());
				list.add(map);
			}
		}
		return list;
	}

	public List<Map<String, Object>> comT1(String area, String projectName, List<Map<String, Object>> list) {
		Set<String> projectList = new HashSet<>();
		List<BigholderSatisfacationInfo> bigholderSatisfacationInfos = bigholderSatisfyMapper1.getByAreaOrProName(area,
				projectName);
		for (BigholderSatisfacationInfo bigholderSatisfacationInfo : bigholderSatisfacationInfos) {
			projectList.add(bigholderSatisfacationInfo.getProjectName());
		}
		for (String projectName1 : projectList) {
			Map<String, Object> map = new HashMap<>();
			map.put("text", projectName1);
			map.put("value", projectName1);
			list.add(map);
		}
		return list;
	}

	/**
	 * 获取项目列表
	 */
	@Override
	public List<Map<String, Object>> getProjectName(String userCode, String area, String projectName,
			TbSysUser tbSysUser) {
		List<Map<String, Object>> list = new ArrayList<>();
		list = this.comT2(area, list, tbSysUser);
		return list;
	}

	public List<Map<String, Object>> comT2(String area, List<Map<String, Object>> list, TbSysUser tbSysUser) {
		Set<TbSysOrgan> tbSysOrgans = this.a(area, tbSysUser);
		Set<ErpCommunity> erpCommunitys1 = new HashSet<>();
		for (TbSysOrgan tbSysOrgan : tbSysOrgans) {
			List<ErpCommunity> erpCommunitys = tbHsprCommunityMapper.slectErpCommunityByOrganCode(tbSysOrgan.getOrganCode());
			for (ErpCommunity erpCommunity : erpCommunitys) {
				erpCommunitys1.add(erpCommunity);
			}
		}
		for (ErpCommunity erpCommunity : erpCommunitys1) {
			Map<String, Object> map = new HashMap<>();
			map.put("text", erpCommunity.getCommId());
			map.put("value", erpCommunity.getCommName());
			list.add(map);
		}
		return list;
	}

	public Set<TbSysOrgan> b(String area, TbSysUser tbSysUser) {
		Set<TbSysOrgan> tbOrgans = new HashSet<>();
		if (area != null) {
			TbSysOrgan tbOrgan = tbSysOrganMapper.findByOrganName(area);
			tbOrgans.add(tbOrgan);
		} else {
			List<TbSysOrgan> tbOrgans1 = tbSysOrganMapper.findAllActive();
			for (TbSysOrgan tbSysOrgan2 : tbOrgans1) {
				tbOrgans.add(tbSysOrgan2);
			}
		}
		return tbOrgans;
	}

	public Set<TbSysOrgan> a(String area, TbSysUser tbSysUser) {
		Set<TbSysOrgan> tbs = new HashSet<>();
		List<Role> roles = roleMapper.findByUserCode(tbSysUser.getUserCode());
		for (Role role : roles) {
			// 判断是否是总部
			if (role.getCode().equals(BIGHEADQUATERS)) {
				tbs=this.b(area, tbSysUser);
				// 非总部管理员
			} else if (role.getCode().equals(BIGHEADAREA)) {
				for (Role role1 : roles) {
					if (role1.getCode().equals(BIGHEADQUATERS)) {
						return this.b(area, tbSysUser);
					}
				}
				if (area == null) {
					List<BigholderRightManager> bigholderRightManagers = bigholderRightManagerMapper
							.getRightManagerByHandmanId(tbSysUser.getUserCode());
					for (BigholderRightManager bigholderRightManager : bigholderRightManagers) {
						String area1 = bigholderRightManager.getArea();
						TbSysOrgan tbSysOrgan = tbSysOrganMapper.findByOrganName(area1);
						tbs.add(tbSysOrgan);
					}
				} else {
					TbSysOrgan tbSysOrgan = tbSysOrganMapper.findByOrganName(area);
					tbs.add(tbSysOrgan);
				}
			}
		}
		return tbs;
	}

	public List<Map<String, Object>> comA1(String area, List<Map<String, Object>> list) {
		Set<String> areaList = new HashSet<>();
		List<TbSysOrgan> tbSysOrgans = tbSysOrganMapper.findAllActive();
		for (TbSysOrgan tbSysOrgan : tbSysOrgans) {
			areaList.add(tbSysOrgan.getOrganName());
		}
		for (String ar : areaList) {
			Map<String, Object> map = new HashMap<>();
			map.put("text", ar);
			map.put("value", ar);
			list.add(map);
		}
		return list;
	}

	/**
	 * 获取所有区域
	 */
	@Override
	public List<Map<String, Object>> getAreas(String area, String userCode, String a) {
		List<Role> roles = roleMapper.findByUserCode(userCode);
		List<Map<String, Object>> list = new ArrayList<>();
		if ("1".equals(a)) {
			Map<String, Object> map1 = new HashMap<>();
			map1.put("text", "全部区域");
			map1.put("value", "全部区域");
			list.add(map1);
		}
		for (Role role : roles) {
			if (role.getCode().equals(BIGHEADQUATERS)) {
				list = this.comA1(area, list);
			} else if (role.getCode().equals(BIGHEADAREA)) {
				List<Map<String, Object>> list1 = new ArrayList<>();
				if ("1".equals(a)) {
					Map<String, Object> map1 = new HashMap<>();
					map1.put("text", "全部区域");
					map1.put("value", "全部区域");
					list1.add(map1);
				}
				for (Role role1 : roles) {
					if (role1.getCode().equals(BIGHEADQUATERS)) {
						list1 = this.comA1(area, list1);
						return list1;
					}
				}
				Set<String> arList = new HashSet<>();
				List<BigholderRightManager> bigholderRightManagers = bigholderRightManagerMapper
						.getRightManagerByHandmanId(userCode);
				for (BigholderRightManager bigholderRightManager : bigholderRightManagers) {
					arList.add(bigholderRightManager.getArea());
				}
				for (String ar : arList) {
					for (BigholderRightManager bigholderRightManager : bigholderRightManagers) {
						if (bigholderRightManager.getArea().equals(ar)) {
							Map<String, Object> map = new HashMap<>();
							map.put("text", bigholderRightManager.getArea());
							map.put("value", bigholderRightManager.getArea());
							list.add(map);
						}
					}
				}
			}
		}
		return list;
	}

	/**
	 * map集合排序方法
	 * 
	 * @param args
	 */
	public static Map sortMap(Map map) {
		List<Map.Entry<String, String>> list = new ArrayList<Map.Entry<String, String>>(
				(Collection<? extends Entry<String, String>>) map.entrySet());
		Collections.sort(list, new Comparator<Map.Entry<String, String>>() {
			// 升序排序 比较器
			@Override
			public int compare(Entry<String, String> o1, Entry<String, String> o2) {
				return o1.getKey().compareTo(o2.getKey());
			}
		});
		Map<String, String> map1 = new TreeMap<String, String>();
		for (Map.Entry<String, String> mapping : list) {
			map1.put(mapping.getKey(), mapping.getValue());
		}
		return map;
	}

	public static void main(String[] args) {
		BigholderSatisfyServiceImpl1 b = new BigholderSatisfyServiceImpl1();
		Map<String, String> map = new HashMap<>();
		map.put("湖北区域", "2");
		map.put("东北区域", "2");
		map.put("东北区域", "2");
		map.put("湖北区域", "2");
		map.put("海南区域", "2");
		map.put("海南区域", "2");
		b.sortMap(map);
		for (String area : map.keySet()) {
			System.out.println(area);
		}
	}

	public List<String> comSM(List<String> yearMonth, String area, String userCode, String annualState,
			String howQuarters, String startMonth, String endMonth) {
		List<String> yearMon = new ArrayList<>();
		String startYear = startMonth.split("-")[0];
		String startMon = startMonth.split("-")[1];

		String endYear = endMonth.split("-")[0];
		String endMon = endMonth.split("-")[1];

		int endMon1 = 0;
		if (Integer.valueOf(startMon) > Integer.valueOf(endMon)) {
			endMon1 = 12 + Integer.valueOf(endMon);
		} else {
			endMon1 = Integer.valueOf(endMon);
		}

		for (int i = Integer.valueOf(startMon); i <= endMon1; i++) {

			String mon = startYear + "-" + (i < 10 ? "0" + i : i);
			if (i > 12) {
				mon = endYear + "-" + (i - 12 < 10 ? "0" + (i - 12) : (i - 12) + "");
			}
			yearMon.add(mon);
		}
		yearMonth = this.commAreaAnalysis(yearMonth, yearMon, annualState, howQuarters);
		return yearMonth;
	}

	@Override
	public List<Map<String, Object>> getAreaStatisticalScores(String area, String userCode, String annualState,
			String howQuarters, String startMonth, String endMonth) {
		List<Map<String, Object>> list = new ArrayList<>();

		List<String> yearMonth = new ArrayList<>();
		yearMonth = this.comSM(yearMonth, area, userCode, annualState, howQuarters, startMonth, endMonth);
		List<String> yearM = new ArrayList<>();
		if ("0".equals(annualState)) {
			yearM.add(endMonth);
		} else {
			yearM = yearMonth;
		}
		List<Role> roles = roleMapper.findByUserCode(userCode);
		List<TbSysOrgan> tbSysOrgans = new ArrayList<>();
		tbSysOrgans = this.isHeadquarters(roles, tbSysOrgans, userCode, yearM, area);
		list = this.scoringStatistics(tbSysOrgans, yearM);
		return list;
	}

	@Override
	public List<Map<String, Object>> getProjectStatisticalScores(String area, String userCode, String projectName,
			String annualState, String howQuarters, String startMonth, String endMonth) {
		List<Map<String, Object>> list = new ArrayList<>();
		List<String> yearMonth = new ArrayList<>();
		yearMonth = this.comSM(yearMonth, area, userCode, annualState, howQuarters, startMonth, endMonth);
		List<String> yearM = new ArrayList<>();
		if ("0".equals(annualState)) {
			yearM.add(endMonth);
		} else {
			yearM = yearMonth;
		}
		list = this.scoringStProject(yearM, area, userCode, projectName);
		
		return list;
	}
}