package cn.com.countrygarden.bi.main.util;

import cn.com.countrygarden.bi.main.dao.performance.PerformanceCompanyMapper;
import cn.com.countrygarden.bi.main.dao.performance.PerformanceWeightMapper;
import cn.com.countrygarden.bi.main.model.performance.*;
import cn.com.countrygarden.bi.main.model.performance.dto.RecordPerformanceDto;
import cn.com.countrygarden.bi.main.service.performance.*;
import cn.com.countrygarden.bi.main.model.performance.monthly.AllMonth;
import cn.com.countrygarden.bi.main.service.performance.*;
import cn.com.countrygarden.bi.main.service.performance.common.PerformanceAreaService;
import cn.com.countrygarden.bi.main.service.performance.common.PerformanceRecordService;
import cn.com.countrygarden.bi.main.util.erp.StringUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.BufferedInputStream;
import java.math.BigDecimal;
import java.util.*;

/**
 * Created by tracy on 2018/4/3.
 */

/**
 * @Author: modify by white
 * @Description: 添加excel导入的功能，红黄牌
 * @Date: 2018-06-30 12:57
 */

@Service
public class ExcelAnalysis {
    private final Logger logger = LoggerFactory.getLogger(ExcelAnalysis.class);

    @Autowired
    private PerformanceEnvService performanceEnvService;

    @Autowired
    private PerformanceScoreService performanceScoreService;

    @Autowired
    private PerformanceStatisticsService performanceStatisticsService;

    @Autowired
    private PerformanceTargetService performanceTargetService;

    @Autowired
    private PerformanceMonthlyService performanceMonthlyService;

    @Autowired
    private PerformanceCompanyMapper performanceCompanyMapper;

    @Autowired
    private PerformanceRecordService performanceRecordService;

    @Autowired
    private PerformanceAreaService performanceAreaService;

    //
    //值
    private final static HashMap<String, HashMap<String, HashMap<String, Integer>>> PerformanceScore = GetPerformanceScore();
    //目标
    private final static HashMap<String, HashMap<String, HashMap<String, Integer>>> PerformanceTarget = GetPerformanceTarget();
    //频率
    private final static HashMap<String, HashMap<String, String>> PerformanceFrequency = GetPerformanceFrequency();

    private static HashMap<String, HashMap<String, HashMap<String, Integer>>> GetPerformanceScore() {
        HashMap<String, HashMap<String, HashMap<String, Integer>>> CellMap = new HashMap<String, HashMap<String, HashMap<String, Integer>>>();

        //1001 	大客户满意度	服务指标	1
        HashMap<String, HashMap<String, Integer>> n1001 = new HashMap<String, HashMap<String, Integer>>();

//    	//s1
//    	HashMap<String,Integer> n10011 = new HashMap<String,Integer>();
//    	n10011.put("完成值", 11);
//    	n10011.put("指标单项得分", 20);
//    	n10011.put("指标加权得分", 22);
//    	n1001.put("10011", n10011);

//    	//s2
//    	HashMap<String,Integer> n10012 = new HashMap<String,Integer>();
//    	n10012.put("完成值", 12);
//    	n10012.put("指标单项得分", 20);
//    	n10012.put("指标加权得分", 22);
//    	n1001.put("10012", n10012);
//
//    	//s3
//    	HashMap<String,Integer> n10013 = new HashMap<String,Integer>();
//    	n10013.put("完成值", 13);
//    	n10013.put("指标单项得分", 20);
//    	n10013.put("指标加权得分", 22);
//    	n1001.put("10013", n10013);
//
//    	//s4
//    	HashMap<String,Integer> n10014 = new HashMap<String,Integer>();
//    	n10014.put("完成值", 14);
//    	n10014.put("指标单项得分", 20);
//    	n10014.put("指标加权得分", 22);
//    	n1001.put("10014", n10014);
//
        //全年
        HashMap<String, Integer> n10015 = new HashMap<String, Integer>();
        n10015.put("完成值", 15);
        n10015.put("指标单项得分", 20);
        n10015.put("指标加权得分", 22);
        n1001.put("10015", n10015);

        CellMap.put("1001", n1001);

        //1002 	小业主满意率	服务指标	1
        HashMap<String, HashMap<String, Integer>> n1002 = new HashMap<String, HashMap<String, Integer>>();

        HashMap<String, Integer> n10021 = new HashMap<String, Integer>();
        n10021.put("指标单项得分", 35);
        n10021.put("指标加权得分", 37);
        n1002.put("10021", n10021);
        CellMap.put("1002", n1002);

        //1002001 	综合满意率	服务指标	2	1002
        HashMap<String, HashMap<String, Integer>> n1002001 = new HashMap<String, HashMap<String, Integer>>();

        HashMap<String, Integer> n10020011 = new HashMap<String, Integer>();
        n10020011.put("完成值", 23);
        n10020011.put("指标单项得分", 28);
        n1002001.put("10020011", n10020011);
        CellMap.put("1002001", n1002001);

        //1002002 	管家服务满意率	服务指标	2	1002
        HashMap<String, HashMap<String, Integer>> n1002002 = new HashMap<String, HashMap<String, Integer>>();

        HashMap<String, Integer> n10020021 = new HashMap<String, Integer>();
        n10020021.put("完成值", 29);
        n10020021.put("指标单项得分", 34);
        n1002002.put("10020021", n10020021);
        CellMap.put("1002002", n1002002);

        //1003 	物业服务费收缴率	经营指标	1
        HashMap<String, HashMap<String, Integer>> n1003 = new HashMap<String, HashMap<String, Integer>>();

        HashMap<String, Integer> n10031 = new HashMap<String, Integer>();
        n10031.put("指标单项得分", 80);
        n10031.put("指标加权得分", 82);
        n1003.put("10031", n10031);
        CellMap.put("1003", n1003);

        //1003001 	综合收缴率	经营指标	2	1003
        HashMap<String, HashMap<String, Integer>> n1003001 = new HashMap<String, HashMap<String, Integer>>();

        HashMap<String, Integer> n10030011 = new HashMap<String, Integer>();
        n10030011.put("完成值", 38);
        n10030011.put("指标单项得分", 43);
        n1003001.put("10030011", n10030011);
        CellMap.put("1003001", n1003001);

        //1003002  	已收楼收缴率（综合）	经营指标	2	1003
        HashMap<String, HashMap<String, Integer>> n1003002 = new HashMap<String, HashMap<String, Integer>>();

//    	//S1 n10030021
//    	HashMap<String,Integer> n10030021 = new HashMap<String,Integer>();
//    	n10030021.put("完成值", 44);
//    	n10030021.put("指标单项得分", 49);
//    	n1003002.put("10030021", n10030021);

//    	//S2 n10030022
//    	HashMap<String,Integer> n10030022 = new HashMap<String,Integer>();
//    	n10030022.put("完成值", 50);
//    	n10030022.put("指标单项得分", 55);
//    	n1003002.put("10030022", n10030022);
//
//    	//S3 n10030023
//    	HashMap<String,Integer> n10030023 = new HashMap<String,Integer>();
//    	n10030023.put("完成值", 56);
//    	n10030023.put("指标单项得分", 60);
//    	n1003002.put("10030023", n10030023);
//
        //S4 n10030024
        HashMap<String, Integer> n10030024 = new HashMap<String, Integer>();
        n10030024.put("完成值", 62);
        n10030024.put("指标单项得分", 67);
        n1003002.put("10030024", n10030024);

        CellMap.put("1003002", n1003002);

        //1003003 	已收楼收缴率（外拓）	经营指标	2	1003
        HashMap<String, HashMap<String, Integer>> n1003003 = new HashMap<String, HashMap<String, Integer>>();

//    	//上半年 n10030031
//    	HashMap<String,Integer> n10030031 = new HashMap<String,Integer>();
//    	n10030031.put("完成值", 68);
//    	n10030031.put("指标单项得分", 73);
//    	n1003003.put("10030031", n10030031);

        //年度 n10030032
        HashMap<String, Integer> n10030032 = new HashMap<String, Integer>();
        n10030032.put("完成值", 74);
        n10030032.put("指标单项得分", 79);
        n1003003.put("10030032", n10030032);

        CellMap.put("1003003", n1003003);

        //1004 	物业服务费欠费追缴率	经营指标	1
        HashMap<String, HashMap<String, Integer>> n1004 = new HashMap<String, HashMap<String, Integer>>();

        //s1 n10041
//    	HashMap<String,Integer> n10041 = new HashMap<String,Integer>();
//    	n10041.put("完成值", 83);
//    	n10041.put("指标单项得分", 88);
//    	n10041.put("指标加权得分", 109);
//    	n1004.put("10041", n10041);

//    	//s2 n10042
//    	HashMap<String,Integer> n10042 = new HashMap<String,Integer>();
//    	n10042.put("完成值", 89);
//    	n10042.put("指标单项得分", 94);
//    	n10042.put("指标加权得分", 109);
//    	n1004.put("10042", n10042);
//
//    	//s3 n10043
//    	HashMap<String,Integer> n10043 = new HashMap<String,Integer>();
//    	n10043.put("完成值", 95);
//    	n10043.put("指标单项得分", 100);
//    	n10043.put("指标加权得分", 109);
//    	n1004.put("10043", n10043);
//
        //s4 n10044
        HashMap<String, Integer> n10044 = new HashMap<String, Integer>();
        n10044.put("完成值", 101);
        n10044.put("指标单项得分", 106);
        n10044.put("指标加权得分", 109);
        n1004.put("10044", n10044);

        CellMap.put("1004", n1004);

        //1005 	税前利润	经营指标	1
        HashMap<String, HashMap<String, Integer>> n1005 = new HashMap<String, HashMap<String, Integer>>();

        HashMap<String, Integer> n10051 = new HashMap<String, Integer>();
        n10051.put("指标单项得分", 134);
        n10051.put("指标加权得分", 136);
        n1005.put("10051", n10051);
        CellMap.put("1005", n1005);

        //1005001 	综合税前利润	经营指标	2	1005
        HashMap<String, HashMap<String, Integer>> n1005001 = new HashMap<String, HashMap<String, Integer>>();

        //上半年度综合税前利润
//    	HashMap<String,Integer> n10050011 = new HashMap<String,Integer>();
//    	n10050011.put("完成值", 110);
//    	n10050011.put("指标单项得分", 115);
//    	n1005001.put("10050011", n10050011);

        //年度综合税前利润
        HashMap<String, Integer> n10050012 = new HashMap<String, Integer>();
        n10050012.put("完成值", 116);
        n10050012.put("指标单项得分", 121);
        n1005001.put("10050012", n10050012);

        CellMap.put("1005001", n1005001);


        //1005002 	社区经营服务（N）税前利润	经营指标	2	1005
        HashMap<String, HashMap<String, Integer>> n1005002 = new HashMap<String, HashMap<String, Integer>>();

        //上半年社区增值服务（N）税前利润
//    	HashMap<String,Integer> n10050021 = new HashMap<String,Integer>();
//    	n10050021.put("完成值", 122);
//    	n10050021.put("指标单项得分", 127);
//    	n1005002.put("10050021", n10050021);

        //年度社区增值服务（N）税前利润
        HashMap<String, Integer> n10050022 = new HashMap<String, Integer>();
        n10050022.put("完成值", 128);
        n10050022.put("指标单项得分", 133);
        n1005002.put("10050022", n10050022);

        CellMap.put("1005002", n1005002);


        //1006 	社区经营服务	经营指标	1
        HashMap<String, HashMap<String, Integer>> n1006 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10061 = new HashMap<String, Integer>();
        n10061.put("指标单项得分", 175);
        n10061.put("指标加权得分", 177);
        n1006.put("10061", n10061);
        CellMap.put("1006", n1006);


        //1006001 	社区增值服务	经营指标	2	1006
        HashMap<String, HashMap<String, Integer>> n1006001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060011 = new HashMap<String, Integer>();
        n10060011.put("指标单项得分", 155);
        n1006001.put("10060011", n10060011);
        CellMap.put("1006001", n1006001);


        //1006001001 	税前利润	经营指标	3	1006001
        HashMap<String, HashMap<String, Integer>> n1006001001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060010011 = new HashMap<String, Integer>();
        n10060010011.put("完成值", 137);
        n1006001001.put("10060010011", n10060010011);
        CellMap.put("1006001001", n1006001001);

        //1006001002 	业务结构系数	经营指标	3	1006001
//		HashMap<String,HashMap<String,Integer>> n1006001002 = new HashMap<String,HashMap<String,Integer>>();
//		HashMap<String,Integer> n10060010021 = new HashMap<String,Integer>();
//		n10060010021.put("指标单项得分",155);
//		n1006001002.put("10060010021",n10060010021);
//		CellMap.put("1006001002",n1006001002);

        //1006001002001 	房屋配套	经营指标	4	1006001002
        HashMap<String, HashMap<String, Integer>> n1006001002001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060010020011 = new HashMap<String, Integer>();
        n10060010020011.put("完成值", 142);
        n1006001002001.put("10060010020011", n10060010020011);
        CellMap.put("1006001002001", n1006001002001);

        //1006001002002 	生活团购	经营指标	4	1006001002
        HashMap<String, HashMap<String, Integer>> n1006001002002 = new HashMap<String, HashMap<String, Integer>>();

        HashMap<String, Integer> n10060010020021 = new HashMap<String, Integer>();
        n10060010020021.put("完成值", 145);
        n1006001002002.put("10060010020021", n10060010020021);
        CellMap.put("1006001002002", n1006001002002);


        //1006001002003 社区广告	经营指标	4	1006001002
        HashMap<String, HashMap<String, Integer>> n1006001002003 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060010020031 = new HashMap<String, Integer>();
        n10060010020031.put("完成值", 148);
        n1006001002003.put("10060010020031", n10060010020031);
        CellMap.put("1006001002003", n1006001002003);


        //1006001002004 资源经营	经营指标	4	1006001002
        HashMap<String, HashMap<String, Integer>> n1006001002004 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060010020041 = new HashMap<String, Integer>();
        n10060010020041.put("完成值", 151);
        n1006001002004.put("10060010020041", n10060010020041);
        CellMap.put("1006001002004", n1006001002004);


        //1006002 	房产租售服务	经营指标	2	1006
        HashMap<String, HashMap<String, Integer>> n1006002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060021 = new HashMap<String, Integer>();
        n10060021.put("指标单项得分", 168);
        n1006002.put("10060021", n10060021);
        CellMap.put("1006002", n1006002);


        //1006002001 	税前利润	经营指标	3	1006002
        HashMap<String, HashMap<String, Integer>> n1006002001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060020011 = new HashMap<String, Integer>();
        n10060020011.put("完成值", 156);
        n1006002001.put("10060020011", n10060020011);
        CellMap.put("1006002001", n1006002001);


        //1006002002 	房产经营市场占有率	经营指标	3	1006002
        HashMap<String, HashMap<String, Integer>> n1006002002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060020021 = new HashMap<String, Integer>();
        n10060020021.put("完成值", 161);
        n1006002002.put("10060020021", n10060020021);
        CellMap.put("1006002002", n1006002002);


        //1006002003 	控盘工作完成情况	经营指标	3	1006002
        HashMap<String, HashMap<String, Integer>> n1006002003 = new HashMap<String, HashMap<String, Integer>>();
//    	//s1
//    	HashMap<String,Integer> n10060020031 = new HashMap<String,Integer>();
//    	n10060020031.put("完成值", 163);
//    	n1006002003.put("10060020031", n10060020031);
//    	//s2
//    	HashMap<String,Integer> n10060020032 = new HashMap<String,Integer>();
//    	n10060020032.put("完成值", 164);
//    	n1006002003.put("10060020032", n10060020032);
//    	//s3
//    	HashMap<String,Integer> n10060020033 = new HashMap<String,Integer>();
//    	n10060020033.put("完成值", 165);
//    	n1006002003.put("10060020033", n10060020033);
//    	//s4
//    	HashMap<String,Integer> n10060020034 = new HashMap<String,Integer>();
//    	n10060020034.put("完成值", 166);
//    	n1006002003.put("10060020034", n10060020034);
        //全年
        HashMap<String, Integer> n10060020035 = new HashMap<String, Integer>();
        n10060020035.put("完成值", 167);
        n1006002003.put("10060020035", n10060020035);

        CellMap.put("1006002003", n1006002003);


        //1006003 	居者乐公司服务协作	经营指标	2	1006
        HashMap<String, HashMap<String, Integer>> n1006003 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060031 = new HashMap<String, Integer>();
        n10060031.put("完成值", 169);
        n10060031.put("指标单项得分", 174);
        n1006003.put("10060031", n10060031);
        CellMap.put("1006003", n1006003);

        //1007 	外拓收入	经营指标	1
        HashMap<String, HashMap<String, Integer>> n1007 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10071 = new HashMap<String, Integer>();
        n10071.put("完成值", 178);
        n10071.put("指标单项得分", 183);
        n10071.put("指标加权得分", 185);
        n1007.put("10071", n10071);
        CellMap.put("1007", n1007);


        //1008 	人均管理面积	效能指标	1
        HashMap<String, HashMap<String, Integer>> n1008 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10081 = new HashMap<String, Integer>();
        n10081.put("方阵序号", 192);
        n10081.put("指标单项得分", 193);
        n10081.put("指标加权得分", 195);
        n1008.put("10081", n10081);
        CellMap.put("1008", n1008);

        //1009 	元均产值	效能指标	1
        HashMap<String, HashMap<String, Integer>> n1009 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10091 = new HashMap<String, Integer>();
        n10091.put("完成值", 196);
        n10091.put("方阵序号", 202);
        n10091.put("指标单项得分", 203);
        n10091.put("指标加权得分", 205);
        n1009.put("10091", n10091);
        CellMap.put("1009", n1009);


        //1010 	社区智能化改造	加/减分项	1
        HashMap<String, HashMap<String, Integer>> n1010 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10101 = new HashMap<String, Integer>();
        n10101.put("指标单项得分", 211);
        n1010.put("10101", n10101);
        CellMap.put("1010", n1010);

        //1010001 	税前利润达标	加/减分项	2	1010
        HashMap<String, HashMap<String, Integer>> n1010001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10100011 = new HashMap<String, Integer>();
        n10100011.put("税前利润是否达标", 206);
        n1010001.put("10100011", n10100011);
        CellMap.put("1010001", n1010001);


        //1010002 	双执行完成项目数	加/减分项	2	1010
        HashMap<String, HashMap<String, Integer>> n1010002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10100021 = new HashMap<String, Integer>();
        n10100021.put("完成值", 207);
        n1010002.put("10100021", n10100021);
        CellMap.put("1010002", n1010002);


        //1010003 	iRBA实施完成项目数	加/减分项	2	1010
        HashMap<String, HashMap<String, Integer>> n1010003 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10100031 = new HashMap<String, Integer>();
        n10100031.put("完成值", 210);
        n1010003.put("10100031", n10100031);
        CellMap.put("1010003", n1010003);


        //1011 	品质红黄牌数	加/减分项	1
        HashMap<String, HashMap<String, Integer>> n1011 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10111 = new HashMap<String, Integer>();
        n10111.put("指标单项得分", 214);
        n1011.put("10111", n10111);
        CellMap.put("1011", n1011);


        //1011001 	品质黄牌	加/减分项	2	1011
        HashMap<String, HashMap<String, Integer>> n1011001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10110011 = new HashMap<String, Integer>();
        n10110011.put("完成值", 212);
        n1011001.put("10110011", n10110011);
        CellMap.put("1011001", n1011001);


        //1011002 	品质红牌	加/减分项	2	1011
        HashMap<String, HashMap<String, Integer>> n1011002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10110021 = new HashMap<String, Integer>();
        n10110021.put("完成值", 213);
        n1011002.put("10110021", n10110021);
        CellMap.put("1011002", n1011002);

        //1012 	入室盗窃案案发	加/减分项	1
        HashMap<String, HashMap<String, Integer>> n1012 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10121 = new HashMap<String, Integer>();
        n10121.put("指标单项得分", 220);
        n1012.put("10121", n10121);
        CellMap.put("1012", n1012);

        //1012001 	入室盗窃案案发数量	加/减分项	2	1012
        HashMap<String, HashMap<String, Integer>> n1012001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10120011 = new HashMap<String, Integer>();
        n10120011.put("完成值", 220);
        n1012001.put("10120011", n10120011);
        CellMap.put("1012001", n1012001);


        //1012002 	入室盗窃案导致人员伤亡案件数	加/减分项	2	1012
        HashMap<String, HashMap<String, Integer>> n1012002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10120021 = new HashMap<String, Integer>();
        n10120021.put("完成值", 220);
        n1012002.put("10120021", n10120021);
        CellMap.put("1012002", n1012002);


        //1012003 	期末接管户数	加/减分项	2	1012
        HashMap<String, HashMap<String, Integer>> n1012003 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10120031 = new HashMap<String, Integer>();
        n10120031.put("完成值", 217);
        n1012003.put("10120031", n10120031);
        CellMap.put("1012003", n1012003);


        //1012004 	折算任期户数	加/减分项	2	1012
        HashMap<String, HashMap<String, Integer>> n1012004 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10120041 = new HashMap<String, Integer>();
        n10120041.put("完成值", 218);
        n1012004.put("10120041", n10120041);
        CellMap.put("1012004", n1012004);


        //1012005 	入室盗窃案案发率	加/减分项	2	1012
        HashMap<String, HashMap<String, Integer>> n1012005 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10120051 = new HashMap<String, Integer>();
        n10120051.put("完成值", 219);
        n1012005.put("10120051", n10120051);
        CellMap.put("1012005", n1012005);


        //1013 	安全生产、消防责任事故	加/减分项	1
        HashMap<String, HashMap<String, Integer>> n1013 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10131 = new HashMap<String, Integer>();
        n10131.put("完成值", 221);
        n10131.put("指标单项得分", 222);
        n1013.put("10131", n10131);
        CellMap.put("1013", n1013);

        //1013001 	事故数量	加/减分项	2	1013
        HashMap<String, HashMap<String, Integer>> n1013001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10130011 = new HashMap<String, Integer>();
        n10130011.put("完成值", 221);
        n1013001.put("10130011", n10130011);
        CellMap.put("1013001", n1013001);


        //1014 	停车收费	加/减分项	1
        HashMap<String, HashMap<String, Integer>> n1014 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10141 = new HashMap<String, Integer>();
        n10141.put("指标单项得分", 227);
        n1014.put("10141", n10141);
        CellMap.put("1014", n1014);


        //1014001 	双百完成率（小区车辆授权管控完成率100%、进出车辆收费完成率100%）	加/减分项	2	1014
        HashMap<String, HashMap<String, Integer>> n1014001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10140011 = new HashMap<String, Integer>();
        n10140011.put("完成值", 224);
        n1014001.put("10140011", n10140011);
        CellMap.put("1014001", n1014001);


        //1014002 	停车收费收入	加/减分项	2	1014
        HashMap<String, HashMap<String, Integer>> n1014002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10140021 = new HashMap<String, Integer>();
        n10140021.put("完成值", 224);
        n1014002.put("10140021", n10140021);
        CellMap.put("1014002", n1014002);


        //1015 	媒体曝光或群诉	加/减分项	1
        HashMap<String, HashMap<String, Integer>> n1015 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10151 = new HashMap<String, Integer>();
        n10151.put("指标单项得分", 232);
        n1015.put("10151", n10151);
        CellMap.put("1015", n1015);


        //1015001 	未按标准流程妥善处理	加/减分项	2	1015
        HashMap<String, HashMap<String, Integer>> n1015001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10150011 = new HashMap<String, Integer>();
        n10150011.put("完成值", 228);
        n1015001.put("10150011", n10150011);
        CellMap.put("1015001", n1015001);


        //1015002 	地方媒体报道事件	加/减分项	2	1015
        HashMap<String, HashMap<String, Integer>> n1015002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10150021 = new HashMap<String, Integer>();
        n10150021.put("完成值", 229);
        n1015002.put("10150021", n10150021);
        CellMap.put("1015002", n1015002);


        //1015003 	中央媒体报道事件	加/减分项	2	1015
        HashMap<String, HashMap<String, Integer>> n1015003 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10150031 = new HashMap<String, Integer>();
        n10150031.put("完成值", 230);
        n1015003.put("10150031", n10150031);
        CellMap.put("1015003", n1015003);


        //1015004 	广泛媒体报道事件	加/减分项	2	1015
        HashMap<String, HashMap<String, Integer>> n1015004 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10150041 = new HashMap<String, Integer>();
        n10150041.put("完成值", 230);
        n1015004.put("10150041", n10150041);
        CellMap.put("1015004", n1015004);


        return CellMap;
    }


    private static HashMap<String, HashMap<String, HashMap<String, Integer>>> GetPerformanceTarget() {
        HashMap<String, HashMap<String, HashMap<String, Integer>>> pftg = new HashMap<String, HashMap<String, HashMap<String, Integer>>>();

        //1001 	大客户满意度	服务指标	1
        HashMap<String, HashMap<String, Integer>> n1001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10011 = new HashMap<String, Integer>();
        n10011.put("门槛值", 16);
        n10011.put("保底", 17);
        n10011.put("尖叫", 18);
        n10011.put("嚎叫", 19);
        n10011.put("是否考核", 21);
        n1001.put("10011", n10011);
        pftg.put("1001", n1001);

        //1002 	小业主满意率	服务指标	1
        HashMap<String, HashMap<String, Integer>> n1002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10021 = new HashMap<String, Integer>();
        n10021.put("是否考核", 36);
        n1002.put("10021", n10021);
        pftg.put("1002", n1002);


        //1002001 	综合满意率	服务指标	2	1002
        HashMap<String, HashMap<String, Integer>> n1002001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10020011 = new HashMap<String, Integer>();
        n10020011.put("门槛值", 24);
        n10020011.put("保底", 25);
        n10020011.put("尖叫", 26);
        n10020011.put("嚎叫", 27);
        n1002001.put("10020011", n10020011);
        pftg.put("1002001", n1002001);


        //1002002 	管家服务满意率	服务指标	2	1002
        HashMap<String, HashMap<String, Integer>> n1002002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10020021 = new HashMap<String, Integer>();
        n10020021.put("门槛值", 30);
        n10020021.put("保底", 31);
        n10020021.put("尖叫", 32);
        n10020021.put("嚎叫", 33);
        n1002002.put("10020021", n10020021);
        pftg.put("1002002", n1002002);


        //1003 	物业服务费收缴率	经营指标	1
        HashMap<String, HashMap<String, Integer>> n1003 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10031 = new HashMap<String, Integer>();
        n10031.put("是否考核", 108);
        n1003.put("10031", n10031);
        pftg.put("1003", n1003);


        //1003001 	综合收缴率	经营指标	2	1003
        HashMap<String, HashMap<String, Integer>> n1003001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10030011 = new HashMap<String, Integer>();
        n10030011.put("门槛值", 39);
        n10030011.put("保底", 40);
        n10030011.put("尖叫", 41);
        n10030011.put("嚎叫", 42);
        n1003001.put("10030011", n10030011);
        pftg.put("1003001", n1003001);


        //1003002 	已收楼收缴率（综合）	经营指标	2	1003
        HashMap<String, HashMap<String, Integer>> n1003002 = new HashMap<String, HashMap<String, Integer>>();
        //s1
//    	HashMap<String,Integer> n10030021 = new HashMap<String,Integer>();
//    	n10030021.put("门槛值", 45);
//    	n10030021.put("保底", 46);
//    	n10030021.put("尖叫", 47);
//    	n10030021.put("嚎叫", 48);
//    	n1003002.put("10030021",n10030021);
//    	//s2
//    	HashMap<String,Integer> n10030022 = new HashMap<String,Integer>();
//    	n10030022.put("门槛值", 51);
//    	n10030022.put("保底", 52);
//    	n10030022.put("尖叫", 53);
//    	n10030022.put("嚎叫", 54);
//    	n1003002.put("10030022",n10030022);
//    	//s3
//    	HashMap<String,Integer> n10030023 = new HashMap<String,Integer>();
//    	n10030023.put("门槛值", 57);
//    	n10030023.put("保底", 58);
//    	n10030023.put("尖叫", 59);
//    	n10030023.put("嚎叫", 60);
//    	n1003002.put("10030023",n10030023);
        //s4
        HashMap<String, Integer> n10030024 = new HashMap<String, Integer>();
        n10030024.put("门槛值", 63);
        n10030024.put("保底", 64);
        n10030024.put("尖叫", 65);
        n10030024.put("嚎叫", 66);
        n1003002.put("10030024", n10030024);

        pftg.put("1003002", n1003002);


        //1003003 	已收楼收缴率（外拓）	经营指标	2	1003
        HashMap<String, HashMap<String, Integer>> n1003003 = new HashMap<String, HashMap<String, Integer>>();
        //上半年外拓已收楼收缴率
//    	HashMap<String,Integer> n10030031 = new HashMap<String,Integer>();
//    	n10030031.put("门槛值", 69);
//    	n10030031.put("保底", 70);
//    	n10030031.put("尖叫", 71);
//    	n10030031.put("嚎叫", 72);
//    	n1003003.put("10030031",n10030031);
        //年度外拓已收楼收缴率
        HashMap<String, Integer> n10030032 = new HashMap<String, Integer>();
        n10030032.put("门槛值", 75);
        n10030032.put("保底", 76);
        n10030032.put("尖叫", 77);
        n10030032.put("嚎叫", 78);
        n1003003.put("10030032", n10030032);

        pftg.put("1003003", n1003003);


        //1004 	物业服务费欠费追缴率	经营指标	1
        HashMap<String, HashMap<String, Integer>> n1004 = new HashMap<String, HashMap<String, Integer>>();
        //s1
//    	HashMap<String,Integer> n10041 = new HashMap<String,Integer>();
//    	n10041.put("门槛值", 84);
//    	n10041.put("保底", 85);
//    	n10041.put("尖叫", 86);
//    	n10041.put("嚎叫", 87);
//    	n10041.put("是否考核", 108);
//    	n1004.put("10041",n10041);
//    	//s2
//    	HashMap<String,Integer> n10042 = new HashMap<String,Integer>();
//    	n10042.put("门槛值", 90);
//    	n10042.put("保底", 91);
//    	n10042.put("尖叫", 92);
//    	n10042.put("嚎叫", 93);
//    	n10042.put("是否考核", 108);
//    	n1004.put("10042",n10042);
//    	//s3
//    	HashMap<String,Integer> n10043 = new HashMap<String,Integer>();
//    	n10043.put("门槛值", 96);
//    	n10043.put("保底", 97);
//    	n10043.put("尖叫", 98);
//    	n10043.put("嚎叫", 99);
//    	n10043.put("是否考核", 108);
//    	n1004.put("10043",n10043);
//    	//s4
        HashMap<String, Integer> n10044 = new HashMap<String, Integer>();
        n10044.put("门槛值", 102);
        n10044.put("保底", 103);
        n10044.put("尖叫", 104);
        n10044.put("嚎叫", 105);
        n10044.put("是否考核", 108);
        n1004.put("10044", n10044);

        pftg.put("1004", n1004);


        //1005 	税前利润	经营指标	1
        HashMap<String, HashMap<String, Integer>> n1005 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10051 = new HashMap<String, Integer>();
        n10051.put("是否考核", 135);
        n1005.put("10051", n10051);
        pftg.put("1005", n1005);

        //1005001 	综合税前利润	经营指标	2	1005
        HashMap<String, HashMap<String, Integer>> n1005001 = new HashMap<String, HashMap<String, Integer>>();
        //上半年度综合税前利润
//    	HashMap<String,Integer> n10050011 = new HashMap<String,Integer>();
//    	n10050011.put("门槛值", 111);
//    	n10050011.put("保底", 112);
//    	n10050011.put("尖叫", 113);
//    	n10050011.put("嚎叫", 114);
//    	n1005001.put("10050011",n10050011);
        //年度综合税前利润
        HashMap<String, Integer> n10050012 = new HashMap<String, Integer>();
        n10050012.put("门槛值", 117);
        n10050012.put("保底", 118);
        n10050012.put("尖叫", 119);
        n10050012.put("嚎叫", 120);
        n1005001.put("10050012", n10050012);

        pftg.put("1005001", n1005001);


        //1005002 	社区经营服务（N）税前利润	经营指标	2	1005
        HashMap<String, HashMap<String, Integer>> n1005002 = new HashMap<String, HashMap<String, Integer>>();
        //上半年社区增值服务（N）税前利润
//    	HashMap<String,Integer> n10050021 = new HashMap<String,Integer>();
//    	n10050021.put("门槛值", 123);
//    	n10050021.put("保底", 124);
//    	n10050021.put("尖叫", 125);
//    	n10050021.put("嚎叫", 126);
//    	n1005002.put("10050021",n10050021);
        //年度社区增值服务（N）税前利润
        HashMap<String, Integer> n100500122 = new HashMap<String, Integer>();
        n100500122.put("门槛值", 129);
        n100500122.put("保底", 130);
        n100500122.put("尖叫", 131);
        n100500122.put("嚎叫", 132);
        n1005002.put("100500122", n100500122);

        pftg.put("1005002", n1005002);


        //1006 	社区经营服务	经营指标	1
        HashMap<String, HashMap<String, Integer>> n1006 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10061 = new HashMap<String, Integer>();
        n10061.put("是否考核", 176);
        n1006.put("10061", n10061);
        pftg.put("1006", n1006);


        //1006001 	社区增值服务	经营指标	2	1006
        HashMap<String, HashMap<String, Integer>> n1006001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060011 = new HashMap<String, Integer>();
        n1006001.put("10060011", n10060011);
        pftg.put("1006001", n1006001);

        //1006001001 	税前利润	经营指标	3	1006001
        HashMap<String, HashMap<String, Integer>> n1006001001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060010011 = new HashMap<String, Integer>();
        n10060010011.put("门槛值", 138);
        n10060010011.put("保底", 139);
        n10060010011.put("尖叫", 140);
        n10060010011.put("嚎叫", 141);
        n1006001001.put("10060010011", n10060010011);
        pftg.put("1006001001", n1006001001);


        //1006001002 	业务结构系数	经营指标	3	1006001
        HashMap<String, HashMap<String, Integer>> n1006001002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060010021 = new HashMap<String, Integer>();
        n10060010021.put("结构系数", 154);
        n1006001002.put("10060010021", n10060010021);
        pftg.put("1006001002", n1006001002);


        //1006001002001 	房屋配套	经营指标	4	1006001002
        HashMap<String, HashMap<String, Integer>> n1006001002001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060010020011 = new HashMap<String, Integer>();
        n10060010020011.put("保底", 143);
        n10060010020011.put("结构系数", 144);
        n1006001002001.put("10060010020011", n10060010020011);
        pftg.put("1006001002001", n1006001002001);


        //1006001002002 	生活团购	经营指标	4	1006001002
        HashMap<String, HashMap<String, Integer>> n1006001002002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060010020021 = new HashMap<String, Integer>();
        n10060010020021.put("保底", 146);
        n10060010020021.put("结构系数", 147);
        n1006001002002.put("10060010020021", n10060010020021);
        pftg.put("1006001002002", n1006001002002);


        //1006001002003 	社区广告	经营指标	4	1006001002
        HashMap<String, HashMap<String, Integer>> n1006001002003 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060010020031 = new HashMap<String, Integer>();
        n10060010020031.put("保底", 149);
        n10060010020031.put("结构系数", 150);
        n1006001002003.put("10060010020031", n10060010020031);
        pftg.put("1006001002003", n1006001002003);


        //1006001002004 	资源经营	经营指标	4	1006001002
        HashMap<String, HashMap<String, Integer>> n1006001002004 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060010020041 = new HashMap<String, Integer>();
        n10060010020041.put("保底", 149);
        n10060010020041.put("结构系数", 150);
        n1006001002004.put("10060010020041", n10060010020041);
        pftg.put("1006001002004", n1006001002004);


        //1006002 	房产租售服务	经营指标	2	1006


        //1006002001 	税前利润	经营指标	3	1006002
        HashMap<String, HashMap<String, Integer>> n1006002001 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060020011 = new HashMap<String, Integer>();
        n10060020011.put("门槛值", 157);
        n10060020011.put("保底", 158);
        n10060020011.put("尖叫", 159);
        n10060020011.put("嚎叫", 160);
        n1006002001.put("10060020011", n10060020011);
        pftg.put("1006002001", n1006002001);


        //1006002002 	房产经营市场占有率	经营指标	3	1006002
        HashMap<String, HashMap<String, Integer>> n1006002002 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060020021 = new HashMap<String, Integer>();
        n10060020021.put("门槛值", 162);
        n1006002002.put("10060020021", n10060020021);
        pftg.put("1006002002", n1006002002);


        //1006002003 	控盘工作完成情况	经营指标	3	1006002


        //1006003 	居者乐公司服务协作	经营指标	2	1006
        HashMap<String, HashMap<String, Integer>> n1006003 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10060031 = new HashMap<String, Integer>();
        n10060031.put("门槛值", 170);
        n10060031.put("保底", 171);
        n10060031.put("尖叫", 172);
        n10060031.put("嚎叫", 173);
        n1006003.put("10060031", n10060031);
        pftg.put("1006003", n1006003);


        //1007 	外拓收入	经营指标	1
        HashMap<String, HashMap<String, Integer>> n1007 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10071 = new HashMap<String, Integer>();
        n10071.put("门槛值", 179);
        n10071.put("保底", 180);
        n10071.put("尖叫", 181);
        n10071.put("嚎叫", 182);
        n10071.put("是否考核", 184);
        n1007.put("10071", n10071);
        pftg.put("1007", n1007);


        //1008 	人均管理面积	效能指标	1
        HashMap<String, HashMap<String, Integer>> n1008 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10081 = new HashMap<String, Integer>();
        n10081.put("门槛值", 187);
        n10081.put("保底", 188);
        n10081.put("尖叫", 190);
        n10081.put("嚎叫", 191);
        n10081.put("平均目标值", 189);
        n10081.put("是否考核", 194);
        n1008.put("10081", n10081);
        pftg.put("1008", n1008);


        //1009 	元均产值	效能指标	1
        HashMap<String, HashMap<String, Integer>> n1009 = new HashMap<String, HashMap<String, Integer>>();
        HashMap<String, Integer> n10091 = new HashMap<String, Integer>();
        n10091.put("门槛值", 197);
        n10091.put("保底", 198);
        n10091.put("尖叫", 200);
        n10091.put("嚎叫", 201);
        n10091.put("平均目标值", 199);
        n10091.put("是否考核", 204);
        n1009.put("10091", n10091);
        pftg.put("1009", n1009);


        //            	1010 	社区智能化改造	加/减分项	1
        //            	1010001 	税前利润达标	加/减分项	2	1010
        //            	1010002 	双执行完成项目数	加/减分项	2	1010
        //            	1010003 	iRBA实施完成项目数	加/减分项	2	1010
        //            	1011 	品质红黄牌数	加/减分项	1
        //            	1011001 	品质黄牌	加/减分项	2	1011
        //            	1011002 	品质红牌	加/减分项	2	1011
        //            	1012 	入室盗窃案案发	加/减分项	1
        //            	1012001 	入室盗窃案案发数量	加/减分项	2	1012
        //            	1012002 	入室盗窃案导致人员伤亡案件数	加/减分项	2	1012
        //            	1012003 	期末接管户数	加/减分项	2	1012
        //            	1012004 	折算任期户数	加/减分项	2	1012
        //            	1012005 	入室盗窃案案发率	加/减分项	2	1012
        //            	1013 	安全生产、消防责任事故	加/减分项	1
        //            	1013001 	事故数量	加/减分项	2	1013
        //            	1014 	停车收费	加/减分项	1
        //            	1014001 	双百完成率（小区车辆授权管控完成率100%、进出车辆收费完成率100%）	加/减分项	2	1014
        //            	1014002 	停车收费收入	加/减分项	2	1014
        //            	1015 	媒体曝光或群诉	加/减分项	1
        //            	1015001 	未按标准流程妥善处理	加/减分项	2	1015
        //            	1015002 	地方媒体报道事件	加/减分项	2	1015
        //            	1015003 	中央媒体报道事件	加/减分项	2	1015
        //            	1015004 	广泛媒体报道事件	加/减分项	2	1015
        return pftg;
    }


    private static HashMap<String, HashMap<String, String>> GetPerformanceFrequency() {
        HashMap<String, HashMap<String, String>> pff = new HashMap<String, HashMap<String, String>>();


        //1001 	大客户满意度	服务指标	1
        HashMap<String, String> n1001 = new HashMap<String, String>();
        n1001.put("考核频率", "月度、季度");
        n1001.put("权重", "0.15");
        pff.put("1001", n1001);
        //    	1002 	小业主满意率	服务指标	1
        //1002001 	综合满意率	服务指标	2	1002
        HashMap<String, String> n1002001 = new HashMap<String, String>();
        n1002001.put("考核频率", "月度");
        n1002001.put("权重", "0.2");
        pff.put("1002001", n1002001);
        //1002002 	管家服务满意率	服务指标	2	1002
        HashMap<String, String> n1002002 = new HashMap<String, String>();
        n1002002.put("考核频率", "月度");
        n1002002.put("权重", "0.05");
        pff.put("1002002", n1002002);
        //    	1003 	物业服务费收缴率	经营指标	1
        //1003001 	综合收缴率	经营指标	2	1003
        HashMap<String, String> n1003001 = new HashMap<String, String>();
        n1003001.put("考核频率", "年度");
        n1003001.put("权重", "0.02");
        pff.put("1003001", n1003001);
        //1003002 	已收楼收缴率（综合）	经营指标	2	1003
        HashMap<String, String> n1003002 = new HashMap<String, String>();
        n1003002.put("考核频率", "季度、年度");
        n1003002.put("权重", "0.065");
        pff.put("1003002", n1003002);
        //1003003 	已收楼收缴率（外拓）	经营指标	2	1003
        HashMap<String, String> n1003003 = new HashMap<String, String>();
        n1003003.put("考核频率", "半年度、年度");
        n1003003.put("权重", "0.015");
        pff.put("1003003", n1003003);
        //1004 	物业服务费欠费追缴率	经营指标	1
        HashMap<String, String> n1004 = new HashMap<String, String>();
        n1004.put("考核频率", "季度、年度");
        n1004.put("权重", "0.05");
        pff.put("1004", n1004);
        //1005 	税前利润	经营指标	1
        //1005001 	综合税前利润	经营指标	2	1005
        HashMap<String, String> n1005001 = new HashMap<String, String>();
        n1005001.put("考核频率", "半年度、年度");
        n1005001.put("权重", "0.07");
        pff.put("1005001", n1005001);
        //1005002 	社区经营服务（N）税前利润	经营指标	2	1005
        HashMap<String, String> n1005002 = new HashMap<String, String>();
        n1005002.put("考核频率", "半年度、年度");
        n1005002.put("权重", "0.03");
        pff.put("1005002", n1005002);
        //1006 	社区经营服务	经营指标	1
        //1006001 	社区增值服务	经营指标	2	1006
        HashMap<String, String> n1006001 = new HashMap<String, String>();
        n1006001.put("考核频率", "年度");
        n1006001.put("权重", "0.05");
        pff.put("1006001", n1006001);
        //1006001001 	税前利润	经营指标	3	1006001
        //1006001002 	业务结构系数	经营指标	3	1006001
        //1006001002001 	房屋配套	经营指标	4	1006001002
        //1006001002002 	生活团购	经营指标	4	1006001002
        //1006001002003 	社区广告	经营指标	4	1006001002
        //1006001002004 	资源经营	经营指标	4	1006001002
        //1006002 	房产租售服务	经营指标	2	1006
        //1006002001 	税前利润	经营指标	3	1006002
        HashMap<String, String> n1006002001 = new HashMap<String, String>();
        n1006002001.put("考核频率", "年度");
        n1006002001.put("权重", "0.03");
        pff.put("1006002001", n1006002001);
        //1006002002 	房产经营市场占有率	经营指标	3	1006002
        HashMap<String, String> n1006002002 = new HashMap<String, String>();
        n1006002002.put("考核频率", "年度");
        n1006002002.put("权重", "0.01");
        pff.put("1006002002", n1006002002);
        //1006002003 	控盘工作完成情况	经营指标	3	1006002
        HashMap<String, String> n1006002003 = new HashMap<String, String>();
        n1006002003.put("考核频率", "季度");
        n1006002003.put("权重", "0.01");
        pff.put("1006002003", n1006002003);
        //1006003 	居者乐公司服务协作	经营指标	2	1006
        HashMap<String, String> n1006003 = new HashMap<String, String>();
        n1006003.put("考核频率", "年度");
        n1006003.put("权重", "0.05");
        pff.put("1006003", n1006003);
        //1007 	外拓收入	经营指标	1
        HashMap<String, String> n1007 = new HashMap<String, String>();
        n1007.put("考核频率", "年度");
        n1007.put("权重", "0.1");
        pff.put("1007", n1007);
        //1008 	人均管理面积	效能指标	1
        HashMap<String, String> n1008 = new HashMap<String, String>();
        n1008.put("考核频率", "年度");
        n1008.put("权重", "0.05");
        pff.put("1008", n1008);
        //1009 	元均产值	效能指标	1
        HashMap<String, String> n1009 = new HashMap<String, String>();
        n1009.put("考核频率", "年度");
        n1009.put("权重", "0.05");
        pff.put("1009", n1009);
        return pff;
    }


    /**
     * 大客户满意度考核指标表格录入方法
     *
     * @param mf         excel文件
     * @param year       年度
     * @param quarter    季度
     * @param OperatorId 操作人ID
     * @Author Geoffrey
     * @Date 2018/10/10
     * @Update excel录入权重与考核频率动态获取
     */

    public void BigCustomerSatisfactionUpload(long elementId,MultipartFile mf, int year, int quarter, String OperatorId) {
        Workbook xwb = null;
            BufferedInputStream bf = null;
            Sheet sheet = null;
            String fileName = mf.getOriginalFilename();
            quarter = quarter > 4 ? 4 : quarter;

            List<BigCustomerSatisfaction> bigCustomerSatisfactions = new ArrayList<>(); //存放表单数据读取出的实体类对象
            try {
                bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);


            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空。");
                }
                for (int j = 0; j < 14; j++) {             //每一行一共13列
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }

                BigCustomerSatisfaction bi = new BigCustomerSatisfaction();
                bi.setHierarchyId(row.getCell(0).getStringCellValue());
                bi.setSecond_organization(row.getCell(1).getStringCellValue());
                bi.setThird_organization(row.getCell(2).getStringCellValue());
                bi.setS1(row.getCell(3).getStringCellValue());
                bi.setS2(row.getCell(4).getStringCellValue());
                bi.setS3(row.getCell(5).getStringCellValue());
                bi.setS4(row.getCell(6).getStringCellValue());
                bi.setAnnual(row.getCell(7).getStringCellValue());
                bi.setHrspp_threshold(row.getCell(8).getStringCellValue());
                bi.setHrspp_atLeast(row.getCell(9).getStringCellValue());
                bi.setHrspp_scream(row.getCell(10).getStringCellValue());
                bi.setHrspp_howl(row.getCell(11).getStringCellValue());
                bi.setIndividualScore(row.getCell(12).getStringCellValue());
                bi.setIs_check(row.getCell(13).getStringCellValue().equals("是") ? 1 : 0);

                bigCustomerSatisfactions.add(bi);
            }

            for (BigCustomerSatisfaction bigCustomerSatisfaction : bigCustomerSatisfactions) {

                String s1 = bigCustomerSatisfaction.getS1();
                String s2 = bigCustomerSatisfaction.getS2();
                String s3 = bigCustomerSatisfaction.getS3();
                String s4 = bigCustomerSatisfaction.getS4();
                String annual = bigCustomerSatisfaction.getAnnual();
                String individualScore = bigCustomerSatisfaction.getIndividualScore();

                String[] completes = {s1, s2, s3, s4, annual, individualScore};
                String complete = "-1";
                for (int i = 1; i < 5; i++) {
                    if (i == quarter) {  //只保留当前季度数据
                        complete = completes[i - 1];
                    }
                }


                //组装RecordPerformanceDto
                RecordPerformanceDto recordDto = new RecordPerformanceDto();
                recordDto.setHierachyId(bigCustomerSatisfaction.getHierarchyId());
                recordDto.setElementId(elementId);
                recordDto.setYear(year);
                recordDto.setQuarter(quarter);
                recordDto.setRate("月度、季度");
                recordDto.setWeight(0.15);
                recordDto.setIsExamine((short)bigCustomerSatisfaction.getIs_check());
                recordDto.setThreshold(bigCustomerSatisfaction.getHrspp_threshold());
                recordDto.setAt_Least(bigCustomerSatisfaction.getHrspp_atLeast());
                recordDto.setScream(bigCustomerSatisfaction.getHrspp_scream());
                recordDto.setHowl(bigCustomerSatisfaction.getHrspp_howl());
                recordDto.setComplete(StringUtil.isNotEmpty(complete) ? Float.parseFloat(complete) : -1F);
                recordDto.setYearly_score(StringUtil.isNotEmpty(completes[4]) ? Float.parseFloat(completes[4]) : -1F);
                recordDto.setScore(StringUtil.isNotEmpty(completes[5]) ? Float.parseFloat(completes[5]) : -1F);

                performanceRecordService.performanceRecord(recordDto);

            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("表格格式不对！");
        }
    }
    
    
    /**
     * 凤凰会
     */
    public void fenghuanghuiUpload(long elementId,MultipartFile mf, int year, int quarter, String OperatorId) {
        Workbook xwb = null;
        BufferedInputStream bf = null;
        Sheet sheet = null;
        String fileName = mf.getOriginalFilename();
        quarter = quarter > 4 ? 4 : quarter;

        List<Fenghuanghui> fenghuanghui = new ArrayList<>(); //存放表单数据读取出的实体类对象
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);


            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
//                if (row.getCell(0) == null) {
//                    throw new Exception("第" + i + "行，区域Id为空。");
//                }
                for (int j = 0; j < 14; j++) {             //每一行一共13列
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }

                Fenghuanghui bi = new Fenghuanghui();
                bi.setHierarchyId(row.getCell(0).getStringCellValue());
                bi.setSecond_organization(row.getCell(1).getStringCellValue());
                bi.setThird_organization(row.getCell(2).getStringCellValue());
                bi.setJiuyue(row.getCell(3).getStringCellValue());
                bi.setShiyue(row.getCell(4).getStringCellValue());
                bi.setShiyiyue(row.getCell(5).getStringCellValue());
                bi.setShieryue(row.getCell(6).getStringCellValue());
                bi.setHuoyue(row.getCell(7).getStringCellValue());
                bi.setJiajian(row.getCell(8).getStringCellValue());
                
                fenghuanghui.add(bi);
            }
            for (Fenghuanghui fenghuanghuiSatisfaction : fenghuanghui) {

                String s1 = fenghuanghuiSatisfaction.getJiuyue();
                String s2 = fenghuanghuiSatisfaction.getShiyue();
                String s3 = fenghuanghuiSatisfaction.getShiyiyue();
                String s4 = fenghuanghuiSatisfaction.getShieryue();
                String huoyue = fenghuanghuiSatisfaction.getHuoyue();
                String jiajian = fenghuanghuiSatisfaction.getJiajian();

                String[] completes = {s1, s2, s3, s4, huoyue, jiajian};
                float jiuyue=Float.parseFloat(s1);
                float shiyue=Float.parseFloat(s2);
                float shiyiyue=Float.parseFloat(s3);
                float shieryue=Float.parseFloat(s4);
                float huoyuelv=(jiuyue+shiyue+shiyiyue+shieryue)/4;
                float jiajianfen=0;
                
                if(0.32<=huoyuelv&&huoyuelv<=0.36){
                	jiajianfen=3;
                }else if(0.36<=huoyuelv&&huoyuelv<=0.4){
                	jiajianfen=4;
                }else if(huoyuelv>=0.4){
                	jiajianfen=5;
                }
                
                //组装RecordPerformanceDto
                RecordPerformanceDto recordDto = new RecordPerformanceDto();
                recordDto.setHierachyId(fenghuanghuiSatisfaction.getHierarchyId());
                recordDto.setElementId(elementId);
                recordDto.setYear(year);
                recordDto.setQuarter(quarter);
                recordDto.setRate("年度");
                recordDto.setYearly_score(StringUtil.isNotEmpty(completes[4]) ? Float.parseFloat(completes[4]) : -1F);
                recordDto.setScore(jiajianfen == 0 ? 0 : jiajianfen);
                recordDto.setComplete(Float.parseFloat(fenghuanghuiSatisfaction.getHuoyue()));
                performanceRecordService.performanceRecord(recordDto);

            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("表格格式不对！");
        }
    }
    
    /**
     * 示范项目
     */
    public void shifanUpload(long elementId,MultipartFile mf, int year, int quarter, String OperatorId) {
        Workbook xwb = null;
        BufferedInputStream bf = null;
        Sheet sheet = null;
        String fileName = mf.getOriginalFilename();
        quarter = quarter > 4 ? 4 : quarter;

        List<Shifan> Shifan = new ArrayList<>(); //存放表单数据读取出的实体类对象
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);


            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
//                if (row.getCell(0) == null) {
//                    throw new Exception("第" + i + "行，区域Id为空。");
//                }
                for (int j = 0; j < 14; j++) {             //每一行一共13列
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }

                Shifan bi = new Shifan();
                bi.setHierarchyId(row.getCell(0).getStringCellValue());
                bi.setSecond_organization(row.getCell(1).getStringCellValue());
                bi.setThird_organization(row.getCell(2).getStringCellValue());
                bi.setQuyu(row.getCell(3).getStringCellValue());
                bi.setJiajian(row.getCell(4).getStringCellValue());
                
                Shifan.add(bi);
            }
            float jiajianfen=0;//加减分
            for (Shifan shifanSatisfaction : Shifan) {
                if(shifanSatisfaction.getQuyu().equals("是")){
                	jiajianfen=1;
                }
                
                //组装RecordPerformanceDto
                RecordPerformanceDto recordDto = new RecordPerformanceDto();
                recordDto.setHierachyId(shifanSatisfaction.getHierarchyId());
                recordDto.setElementId(elementId);
                recordDto.setYear(year);
                recordDto.setQuarter(quarter);
                recordDto.setRate("年度");
                recordDto.setScore(jiajianfen == 0 ? 0 : jiajianfen);
                performanceRecordService.performanceRecord(recordDto);

            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("表格格式不对！");
        }
    }
    

    /**
     * 小业主满意度考核指标表格录入方法
     *
     * @param mf         excel文件
     * @param year       年度
     * @param quarter    季度
     * @param OperatorId 操作人ID
     * @Author Geoffrey
     * @Date 2018/6/28 19:31
     */

    public void SmallownersSatisfactionUpload(MultipartFile mf, int year, int quarter, String OperatorId) {
        Long elementId = 1002L;//大指标
        Long zhElementId = 1002001L;//综合满意率
        Long gjElementId = 1002002L;//管家服务满意率

        Workbook xwb = null;
        BufferedInputStream bf = null;
        Sheet sheet = null;
        String fileName = mf.getOriginalFilename();
        quarter = quarter > 4 ? 4 : quarter;
        List<SmallownersSatisfaction> smallownersSatisfactions = new ArrayList<>(); //存放表单数据读取出的实体类对象
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);


            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                Row row = sheet.getRow(i);

                if (row == null) {
                    break;
                }

//                if (row.getCell(0) == null) {
//                    throw new RuntimeException("第" + i + "行，区域Id为空。");
//                }
//                int rowCount = row.getLastCellNum();
//                if (rowCount > 17) {
//                    throw new RuntimeException("表格格式不对！");
//                }
                for (int j = 0; j < 17; j++) {
////                    if (row.getCell(j) == null) {
////                        throw new RuntimeException("第" + (i + 1) + "行，第" + (j + 1) + "列，数据为空");
////                    }

                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                SmallownersSatisfaction so = new SmallownersSatisfaction();
                so.setHierarchyId(row.getCell(0).getStringCellValue());
                so.setSecond_organization(row.getCell(1).getStringCellValue());
                so.setThird_organization(row.getCell(2).getStringCellValue());

                //综合满意度指标
                so.setCompre_investigation(row.getCell(3).getStringCellValue());
                so.setCompre_threshold(row.getCell(4).getStringCellValue());
                so.setCompre_atLeast(row.getCell(5).getStringCellValue());
                so.setCompre_scream(row.getCell(6).getStringCellValue());
                so.setCompre_howl(row.getCell(7).getStringCellValue());
                so.setCompre_score(row.getCell(8).getStringCellValue());
                //管家服务满意率指标
                so.setButler_investigation(row.getCell(9).getStringCellValue());
                so.setButler_threshold(row.getCell(10).getStringCellValue());
                so.setButler_atLeast(row.getCell(11).getStringCellValue());
                so.setButler_scream(row.getCell(12).getStringCellValue());
                so.setButler_howl(row.getCell(13).getStringCellValue());
                so.setButler_score(row.getCell(14).getStringCellValue());

                so.setIndividualScore(row.getCell(15).getStringCellValue());
                so.setIs_check(row.getCell(16).getStringCellValue().equals("是") ? 1 : 0);

                smallownersSatisfactions.add(so);
            }

            for (SmallownersSatisfaction s : smallownersSatisfactions) {

                String hierachyId = s.getHierarchyId();
                String compre_investigation = s.getCompre_investigation();//综合完成值
                String compre_score = s.getCompre_score();//综合细项得分
                String butler_investigation = s.getButler_investigation();//管家完成值
                String butler_score = s.getButler_score();//管家细项得分
                String individualScore = s.getIndividualScore();//总得分

                /*---------------------------综合满意率插入  start-----------------------------------------*/
                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setYear(year);
                performanceDto.setQuarter(quarter);
                performanceDto.setElementId(zhElementId);
                performanceDto.setThreshold(s.getCompre_threshold());
                performanceDto.setAt_Least(s.getCompre_atLeast());
                performanceDto.setScream(s.getCompre_scream());
                performanceDto.setHowl(s.getCompre_howl());
                performanceDto.setRate("月度、季度、年度");
                performanceDto.setIsExamine((short)s.getIs_check());
                performanceDto.setScore(StringUtil.isNotEmpty(compre_score) ? Float.parseFloat(compre_score) : -1F);
                performanceDto.setComplete(StringUtil.isNotEmpty(compre_investigation) ? Float.parseFloat(compre_investigation) : -1F);
                performanceRecordService.performanceRecord(performanceDto);
                /*---------------------------综合满意率插入  end-----------------------------------------*/

                /*---------------------------管家服务满意率插入  start-----------------------------------------*/
                performanceDto.setElementId(gjElementId);
                performanceDto.setThreshold(s.getButler_threshold());
                performanceDto.setAt_Least(s.getButler_atLeast());
                performanceDto.setScream(s.getButler_scream());
                performanceDto.setHowl(s.getButler_howl());
                performanceDto.setScore(StringUtil.isNotEmpty(butler_score) ? Float.parseFloat(butler_score) : -1F);
                performanceDto.setComplete(StringUtil.isNotEmpty(butler_investigation) ? Float.parseFloat(butler_investigation) : -1F);
                performanceRecordService.performanceRecord(performanceDto);
                /*---------------------------管家服务满意率插入  end-----------------------------------------*/

                /*-----------------------------总得分---------------------------------------------------*/
                performanceDto.setElementId(elementId);
                performanceDto.setThreshold(null);
                performanceDto.setAt_Least(null);
                performanceDto.setScream(null);
                performanceDto.setHowl(null);
                performanceDto.setWeight(0.25);
                performanceDto.setScore(StringUtil.isNotEmpty(individualScore) ? Float.parseFloat(individualScore) : -1F);
                performanceDto.setComplete(-1);
                performanceRecordService.performanceRecord(performanceDto);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }


    /**
     * 物业服务费收缴率考核指标表格录入方法
     *
     * @param mf         excel文件
     * @param year       年度
     * @param quarter    季度
     * @param OperatorId 操作人ID
     * @Author Geoffrey
     * @Date 2018/6/28 19:31
     */

    public void GetPropertyCostsUpload(MultipartFile mf, int year, int quarter, String OperatorId) {
        Long elementId = 1003L;
        Long zhElementId = 1003001L; //综合收缴率
        Long zhslElementId = 1003002L; //已收楼收缴率（综合）
        Long wtslElementId = 1003003L; //已收楼收缴率（外拓）

        Workbook xwb = null;
        BufferedInputStream bf = null;
        Sheet sheet = null;
        String fileName = mf.getOriginalFilename();

        quarter = quarter > 4 ? 4 : quarter;


        List<GetPropertyCosts> getPropertyCosts = new ArrayList<>(); //存放表单数据读取出的实体类对象
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);


            //excel表格数据收集(一行数据对应一个GetPropertyCosts实体)
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空。");
                }

//                int rowCount = row.getLastCellNum();
//                if (rowCount > 47) {
//                    throw new RuntimeException("表格格式不对!");
//                }
                for (int j = 0; j < 47; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                GetPropertyCosts pc = new GetPropertyCosts();
                pc.setHierarchyId(row.getCell(0).getStringCellValue());
                pc.setSecond_organization(row.getCell(1).getStringCellValue());
                pc.setThird_organization(row.getCell(2).getStringCellValue());

                //综合收缴率
                pc.setComplete_Value(row.getCell(3).getStringCellValue());
                pc.setThreshold(row.getCell(4).getStringCellValue());
                pc.setAtLeast(row.getCell(5).getStringCellValue());
                pc.setScream(row.getCell(6).getStringCellValue());
                pc.setHowl(row.getCell(7).getStringCellValue());
                pc.setScore(row.getCell(8).getStringCellValue());
                //S1
                pc.setS1_Complete_Value(row.getCell(9).getStringCellValue());
                pc.setS1_threshold(row.getCell(10).getStringCellValue());
                pc.setS1_atLeast(row.getCell(11).getStringCellValue());
                pc.setS1_scream(row.getCell(12).getStringCellValue());
                pc.setS1_howl(row.getCell(13).getStringCellValue());
                pc.setS1_score(row.getCell(14).getStringCellValue());
                //S2
                pc.setS2_Complete_Value(row.getCell(15).getStringCellValue());
                pc.setS2_threshold(row.getCell(16).getStringCellValue());
                pc.setS2_atLeast(row.getCell(17).getStringCellValue());
                pc.setS2_scream(row.getCell(18).getStringCellValue());
                pc.setS2_howl(row.getCell(19).getStringCellValue());
                pc.setS2_score(row.getCell(20).getStringCellValue());
                //S3
                pc.setS3_Complete_Value(row.getCell(21).getStringCellValue());
                pc.setS3_threshold(row.getCell(22).getStringCellValue());
                pc.setS3_atLeast(row.getCell(23).getStringCellValue());
                pc.setS3_scream(row.getCell(24).getStringCellValue());
                pc.setS3_howl(row.getCell(25).getStringCellValue());
                pc.setS3_score(row.getCell(26).getStringCellValue());
                //S4
                pc.setS4_Complete_Value(row.getCell(27).getStringCellValue());
                pc.setS4_threshold(row.getCell(28).getStringCellValue());
                pc.setS4_atLeast(row.getCell(29).getStringCellValue());
                pc.setS4_scream(row.getCell(30).getStringCellValue());
                pc.setS4_howl(row.getCell(31).getStringCellValue());
                pc.setS4_score(row.getCell(32).getStringCellValue());
                //外拓半年度
                pc.setHY_Complete_Value(row.getCell(33).getStringCellValue());
                pc.setHY_threshold(row.getCell(34).getStringCellValue());
                pc.setHY_atLeast(row.getCell(35).getStringCellValue());
                pc.setHY_scream(row.getCell(36).getStringCellValue());
                pc.setHY_howl(row.getCell(37).getStringCellValue());
                pc.setHY_score(row.getCell(38).getStringCellValue());

                //外拓年度
                pc.setAL_Complete_Value(row.getCell(39).getStringCellValue());
                pc.setAL_threshold(row.getCell(40).getStringCellValue());
                pc.setAL_atLeast(row.getCell(41).getStringCellValue());
                pc.setAL_scream(row.getCell(42).getStringCellValue());
                pc.setAL_howl(row.getCell(43).getStringCellValue());
                pc.setAL_score(row.getCell(44).getStringCellValue());


                pc.setIndividualScore(row.getCell(45).getStringCellValue());
                pc.setIs_check(row.getCell(46).getStringCellValue().equals("是") ? 1 : 0);

                getPropertyCosts.add(pc);
            }

            //遍历集合将实体对象插入数据库
            RecordPerformanceDto performanceDto = new RecordPerformanceDto();
            for (GetPropertyCosts propertyCost : getPropertyCosts) {

                String hierachyId = propertyCost.getHierarchyId();

                String IndividualScore = propertyCost.getIndividualScore();//指标单项总得分

                String[] thresholds = {propertyCost.getThreshold(), propertyCost.getS1_threshold(), propertyCost.getS2_threshold(), propertyCost.getS3_threshold(), propertyCost.getS4_threshold(), propertyCost.getHY_threshold(), propertyCost.getAL_threshold()};
                String[] atLasts = {propertyCost.getAtLeast(), propertyCost.getS1_atLeast(), propertyCost.getS2_atLeast(), propertyCost.getS3_atLeast(), propertyCost.getS4_atLeast(), propertyCost.getHY_atLeast(), propertyCost.getAL_atLeast()};
                String[] screams = {propertyCost.getScream(), propertyCost.getS1_scream(), propertyCost.getS2_scream(), propertyCost.getS3_scream(), propertyCost.getS4_scream(), propertyCost.getHY_scream(), propertyCost.getAL_scream()};
                String[] howls = {propertyCost.getHowl(), propertyCost.getS1_howl(), propertyCost.getS2_howl(), propertyCost.getS3_howl(), propertyCost.getS4_howl(), propertyCost.getHY_howl(), propertyCost.getAL_howl()};
                String[] completes = {propertyCost.getComplete_Value(), propertyCost.getS1_Complete_Value(), propertyCost.getS2_Complete_Value(), propertyCost.getS3_Complete_Value(), propertyCost.getS4_Complete_Value(), propertyCost.getHY_Complete_Value(), propertyCost.getAL_Complete_Value()};
                String[] scores = {propertyCost.getScore(), propertyCost.getS1_score(), propertyCost.getS2_score(), propertyCost.getS3_score(), propertyCost.getS4_score(), propertyCost.getHY_score(), propertyCost.getAL_score()};

                performanceDto.setHierachyId(hierachyId);
                performanceDto.setYear(year);
                performanceDto.setRate("季度、年度");
                performanceDto.setIsExamine((short)propertyCost.getIs_check());

                label:
                for (int i = 0; i < 7; i++) {
                    //S1-S4收缴率
                    switch (i) {
                        case 0: {  //年度综合收缴率
                            performanceDto.setElementId(zhElementId);
                            performanceDto.setQuarter(quarter);
                            break;
                        }
                        case 5: {//半年度外拓已收楼收缴率
                            if (quarter > 2) {
                                continue label;
                            }
                            performanceDto.setElementId(wtslElementId);
                            performanceDto.setQuarter(quarter);
                            break;
                        }
                        case 6: {//年度外拓已收楼收缴率
                            if (quarter <= 2) {
                                continue label;
                            }
                            performanceDto.setElementId(wtslElementId);
                            performanceDto.setQuarter(quarter);
                            break;
                        }
                        default: {
                            if (i != quarter) {
                                continue label;
                            }
                            performanceDto.setElementId(zhslElementId);
                            performanceDto.setQuarter(quarter);
                            break;
                        }
                    }

                    performanceDto.setThreshold(thresholds[i]);
                    performanceDto.setAt_Least(atLasts[i]);
                    performanceDto.setScream(screams[i]);
                    performanceDto.setHowl(howls[i]);
                    performanceDto.setComplete(StringUtil.isNotEmpty(completes[i]) ? Float.parseFloat(completes[i]) : -1F);
                    performanceDto.setScore(StringUtil.isNotEmpty(scores[i]) ? Float.parseFloat(scores[i]) : -1F);
                    performanceRecordService.performanceRecord(performanceDto);
                }
                performanceDto.setThreshold(null);
                performanceDto.setAt_Least(null);
                performanceDto.setScream(null);
                performanceDto.setHowl(null);

                performanceDto.setComplete(-1);
                performanceDto.setScore(StringUtil.isNotEmpty(IndividualScore) ? Float.parseFloat(IndividualScore) : -1F);
                //年度得分
                performanceDto.setElementId(elementId);
                performanceDto.setQuarter(quarter);
                performanceRecordService.performanceRecord(performanceDto);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("表格格式不对!");
        }
    }


    /**
     * 物业服务费欠费追缴率考核指标表格录入方法
     *
     * @param mf         excel文件
     * @param year       年度
     * @param quarter    季度
     * @param OperatorId 操作人ID
     * @Author Geoffrey
     * @Date 2018/10/10
     * @Update 修改权重及考核频率为动态获取
     */

    public void GetArrearsPropertyCostsUploadUpload(MultipartFile mf, int year, int quarter, String OperatorId) {
        Long elementId = 1004L;

        Workbook xwb = null;
        BufferedInputStream bf = null;
        Sheet sheet = null;
        String fileName = mf.getOriginalFilename();
        quarter = quarter > 4 ? 4 : quarter;

        List<GetArrearsPropertyCosts> arrearsPropertyCosts = new ArrayList<>(); //存放表单数据读取出的实体类对象
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);


            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new RuntimeException("第" + i + "行，区域Id为空。");
                }

//                int rowCount = row.getLastCellNum();
//                if (rowCount > 29) {
//                    throw new RuntimeException("表格格式不对!");
//                }
                try {

                    for (int j = 0; j < 29; j++) {
                        row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                        if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                            row.getCell(j).setCellValue("-1");
                        }
                    }
                } catch (NullPointerException e) {
                    e.printStackTrace();
                }
                GetArrearsPropertyCosts pc = new GetArrearsPropertyCosts();
                pc.setHierarchyId(row.getCell(0).getStringCellValue());
                pc.setSecond_organization(row.getCell(1).getStringCellValue());
                pc.setThird_organization(row.getCell(2).getStringCellValue());

                //S1
                pc.setS1_Complete_Value(row.getCell(3).getStringCellValue());
                pc.setS1_threshold(row.getCell(4).getStringCellValue());
                pc.setS1_atLeast(row.getCell(5).getStringCellValue());
                pc.setS1_scream(row.getCell(6).getStringCellValue());
                pc.setS1_howl(row.getCell(7).getStringCellValue());
                pc.setS1_score(row.getCell(8).getStringCellValue());
                //S2
                pc.setS2_Complete_Value(row.getCell(9).getStringCellValue());
                pc.setS2_threshold(row.getCell(10).getStringCellValue());
                pc.setS2_atLeast(row.getCell(11).getStringCellValue());
                pc.setS2_scream(row.getCell(12).getStringCellValue());
                pc.setS2_howl(row.getCell(13).getStringCellValue());
                pc.setS2_score(row.getCell(14).getStringCellValue());
                //S3
                pc.setS3_Complete_Value(row.getCell(15).getStringCellValue());
                pc.setS3_threshold(row.getCell(16).getStringCellValue());
                pc.setS3_atLeast(row.getCell(17).getStringCellValue());
                pc.setS3_scream(row.getCell(18).getStringCellValue());
                pc.setS3_howl(row.getCell(19).getStringCellValue());
                pc.setS3_score(row.getCell(20).getStringCellValue());
                //S4
                pc.setS4_Complete_Value(row.getCell(21).getStringCellValue());
                pc.setS4_threshold(row.getCell(22).getStringCellValue());
                pc.setS4_atLeast(row.getCell(23).getStringCellValue());
                pc.setS4_scream(row.getCell(24).getStringCellValue());
                pc.setS4_howl(row.getCell(25).getStringCellValue());
                pc.setS4_score(row.getCell(26).getStringCellValue());

                pc.setIndividualScore(row.getCell(27).getStringCellValue());
                pc.setIs_check(row.getCell(28).getStringCellValue().equals("是") ? 1 : 0);

                arrearsPropertyCosts.add(pc);
            }

            //遍历实体集合，将实体存入数据库
            RecordPerformanceDto performanceDto = new RecordPerformanceDto();
            for (GetArrearsPropertyCosts propertyCost : arrearsPropertyCosts) {

                String hierachyId = propertyCost.getHierarchyId();
                String IndividualScore = propertyCost.getIndividualScore(); //单项指标得分

                String[] thresholds = {propertyCost.getS1_threshold(), propertyCost.getS2_threshold(), propertyCost.getS3_threshold(), propertyCost.getS4_threshold()};
                String[] atLasts = {propertyCost.getS1_atLeast(), propertyCost.getS2_atLeast(), propertyCost.getS3_atLeast(), propertyCost.getS4_atLeast()};
                String[] screams = {propertyCost.getS1_scream(), propertyCost.getS2_scream(), propertyCost.getS3_scream(), propertyCost.getS4_scream()};
                String[] howls = {propertyCost.getS1_howl(), propertyCost.getS2_howl(), propertyCost.getS3_howl(), propertyCost.getS4_howl()};
                String[] completes = {propertyCost.getS1_Complete_Value(), propertyCost.getS2_Complete_Value(), propertyCost.getS3_Complete_Value(), propertyCost.getS4_Complete_Value()};
                //各季度细项指标得分
                String[] scores = {propertyCost.getS1_score(), propertyCost.getS2_score(), propertyCost.getS3_score(), propertyCost.getS4_score()};


                performanceDto.setElementId(elementId);
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setYear(year);
                performanceDto.setRate("季度、年度");
                performanceDto.setIsExamine((short)propertyCost.getIs_check());
                performanceDto.setWeight(0.05);

                for (int i = 0; i < 4; i++) {

                    if ((i + 1) != quarter) {//如果选择录入的季度非当前季度 跳过
                        continue;
                    }
                    performanceDto.setQuarter(quarter);
                    performanceDto.setThreshold(String.valueOf(thresholds[i]));
                    performanceDto.setAt_Least(String.valueOf(atLasts[i]));
                    performanceDto.setScream(String.valueOf(screams[i]));
                    performanceDto.setHowl(String.valueOf(howls[i]));
                    performanceDto.setComplete(StringUtil.isNotEmpty(completes[i]) ? Float.parseFloat(completes[i]) : -1F);
                    performanceDto.setYearly_score(StringUtil.isNotEmpty(scores[i]) ? Float.parseFloat(scores[i]) : -1F);
                    performanceDto.setScore(StringUtil.isNotEmpty(IndividualScore) ? Float.parseFloat(IndividualScore) : -1F);
                    performanceRecordService.performanceRecord(performanceDto);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 税前利润考核指标表格录入方法
     *
     * @param mf         excel文件
     * @param year       年度
     * @param quarter    季度
     * @param OperatorId 操作人ID
     * @Author Geoffrey
     * @Date 2018/6/28 19:31
     */

    public void PretaxProfitUpload(MultipartFile mf, int year, int quarter, String OperatorId) {
        Long elementId = 1005L;
        Long zhElementId = 1005001L; //综合税前利润
        Long sqElementId = 1005002L; //社区经营服务（N）税前利润


        Workbook xwb = null;
        BufferedInputStream bf = null;
        Sheet sheet = null;
        String fileName = mf.getOriginalFilename();

        List<ProfitBeforeTax> profitBeforeTaxes = new ArrayList<>(); //存放表单数据读取出的实体类对象
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);


            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
//                if (row.getCell(0) == null) {
//                    throw new Exception("第" + i + "行，区域Id为空。");
//                }

//                int rowCount = row.getLastCellNum();
//                if (rowCount > 29) {
//                    throw new RuntimeException("表格格式不对!");
//                }

                for (int j = 0; j < 29; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                ProfitBeforeTax pbt = new ProfitBeforeTax();
                pbt.setHierarchyId(row.getCell(0).getStringCellValue());
                pbt.setSecond_organization(row.getCell(1).getStringCellValue());
                pbt.setThird_organization(row.getCell(2).getStringCellValue());

                //半年度综合税前利润
                pbt.setHY_Complete_Value(row.getCell(3).getStringCellValue());
                pbt.setHY_threshold(row.getCell(4).getStringCellValue());
                pbt.setHY_atLeast(row.getCell(5).getStringCellValue());
                pbt.setHY_scream(row.getCell(6).getStringCellValue());
                pbt.setHY_howl(row.getCell(7).getStringCellValue());
                pbt.setHY_score(row.getCell(8).getStringCellValue());
                //年度综合税前利润
                pbt.setAL_Complete_Value(row.getCell(9).getStringCellValue());
                pbt.setAL_threshold(row.getCell(10).getStringCellValue());
                pbt.setAL_atLeast(row.getCell(11).getStringCellValue());
                pbt.setAL_scream(row.getCell(12).getStringCellValue());
                pbt.setAL_howl(row.getCell(13).getStringCellValue());
                pbt.setAL_score(row.getCell(14).getStringCellValue());
                //半年度社区增值服务税前利润
                pbt.setHYC_Complete_Value(row.getCell(15).getStringCellValue());
                pbt.setHYC_threshold(row.getCell(16).getStringCellValue());
                pbt.setHYC_atLeast(row.getCell(17).getStringCellValue());
                pbt.setHYC_scream(row.getCell(18).getStringCellValue());
                pbt.setHYC_howl(row.getCell(19).getStringCellValue());
                pbt.setHYC_score(row.getCell(20).getStringCellValue());
                //年度社区增值服务税前利润
                pbt.setALC_Complete_Value(row.getCell(21).getStringCellValue());
                pbt.setALC_threshold(row.getCell(22).getStringCellValue());
                pbt.setALC_atLeast(row.getCell(23).getStringCellValue());
                pbt.setALC_scream(row.getCell(24).getStringCellValue());
                pbt.setALC_howl(row.getCell(25).getStringCellValue());
                pbt.setALC_score(row.getCell(26).getStringCellValue());

                pbt.setIndividualScore(row.getCell(27).getStringCellValue());
                pbt.setIs_check(row.getCell(28).getStringCellValue().equals("是") ? 1 : 0);

                profitBeforeTaxes.add(pbt);
            }

            //遍历集合将实体对象插入数据库中
            for (ProfitBeforeTax profitBeforeTax : profitBeforeTaxes) {

                String hierachyId = profitBeforeTax.getHierarchyId();

                String IndividualScore = profitBeforeTax.getIndividualScore();

                String[] thresholds = {profitBeforeTax.getHY_threshold(), profitBeforeTax.getAL_threshold(), profitBeforeTax.getHYC_threshold(), profitBeforeTax.getALC_threshold()};
                String[] atLasts = {profitBeforeTax.getHY_atLeast(), profitBeforeTax.getAL_atLeast(), profitBeforeTax.getHYC_atLeast(), profitBeforeTax.getALC_atLeast()};
                String[] screams = {profitBeforeTax.getHY_scream(), profitBeforeTax.getAL_scream(), profitBeforeTax.getHYC_scream(), profitBeforeTax.getALC_scream()};
                String[] howls = {profitBeforeTax.getHY_howl(), profitBeforeTax.getAL_howl(), profitBeforeTax.getHYC_howl(), profitBeforeTax.getALC_howl()};
                String[] completes = {profitBeforeTax.getHY_Complete_Value(), profitBeforeTax.getAL_Complete_Value(), profitBeforeTax.getHYC_Complete_Value(), profitBeforeTax.getALC_Complete_Value()};
                String[] scores = {profitBeforeTax.getHY_score(), profitBeforeTax.getAL_score(), profitBeforeTax.getHYC_score(), profitBeforeTax.getALC_score()};


                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setYear(year);
                performanceDto.setRate("半年度、年度");

                for (int i = 0; i < 4; i++) {

                    if (i % 2 == 0) { // 0,2 上半年度的
                        if (quarter >= 2) {
                            continue;
                        }
                    } else {
                        if (quarter < 2) {
                            continue;
                        }
                    }

                    if (i <= 1) {
                        performanceDto.setElementId(zhElementId);
                    } else {
                        performanceDto.setElementId(sqElementId);
                    }
                    performanceDto.setQuarter(quarter);

                    performanceDto.setThreshold(thresholds[i]);
                    performanceDto.setAt_Least(atLasts[i]);
                    performanceDto.setScream(screams[i]);
                    performanceDto.setHowl(howls[i]);
                    performanceDto.setIsExamine((short)profitBeforeTax.getIs_check());
                    performanceDto.setComplete(StringUtil.isNotEmpty(completes[i]) ? Float.parseFloat(completes[i]) : -1F);
                    performanceDto.setScore(StringUtil.isNotEmpty(scores[i]) ? Float.parseFloat(scores[i]) : -1F);
                    performanceRecordService.performanceRecord(performanceDto);

                }

                performanceDto.setElementId(elementId);
                performanceDto.setQuarter(quarter);
                performanceDto.setThreshold(null);
                performanceDto.setAt_Least(null);
                performanceDto.setScream(null);
                performanceDto.setHowl(null);

                performanceDto.setComplete(-1);
                performanceDto.setScore(StringUtil.isNotEmpty(IndividualScore) ? Float.parseFloat(IndividualScore) : -1F);
                performanceDto.setWeight(0.1);
                performanceDto.setIsExamine((short)profitBeforeTax.getIs_check());
                performanceRecordService.performanceRecord(performanceDto);

            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("表格格式不对！");
        }
    }


    /**
     * 外拓收入考核指标表格录入方法
     *
     * @param mf         excel文件
     * @param year       年度
     * @param quarter    季度
     * @param operatorId 操作人ID
     * @author Max Date:2018/06/30
     * @update Wyman Date:2018/10/10 修改权重值和考核频率值动态获取
     */
    public void outreachRevenueUpload(MultipartFile mf, int year, int quarter, String operatorId) {
        Long elementId = 1007L;//外拓收入的ElementId
        Workbook xwb = null;
        BufferedInputStream bf;
        Sheet sheet;
        String fileName = mf.getOriginalFilename();


        List<OutreachRevenue> outreachRevenues = new ArrayList<>();
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel 2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);//获得第一个sheet，默认每个excel只有一个sheet
            //开始遍历excel里面所有的数据，正确的数据从第7行开始
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //每次遍历的临时存储
                OutreachRevenue outreachRevenue = new OutreachRevenue();
                //得到遍历的当前行
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空");
                }
                //区域Id
                for (int j = 0; j < 10; j++) {//一共十列
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }

                //分别存储每行数据，存入JavaBean里
                outreachRevenue.setHierarchyId(row.getCell(0).getStringCellValue());//设置区域名称
                outreachRevenue.setSecond_organization(row.getCell(1).getStringCellValue());//二级组织
                outreachRevenue.setThird_organization(row.getCell(2).getStringCellValue());//三级组织
                outreachRevenue.setRealIncome(row.getCell(3).getStringCellValue());//外拓收入实际值
                outreachRevenue.setThresholdTarget(row.getCell(4).getStringCellValue());//门槛值
                outreachRevenue.setAtLeastTarget(row.getCell(5).getStringCellValue());//保底值
                outreachRevenue.setScreamTarget(row.getCell(6).getStringCellValue());//尖叫值
                outreachRevenue.setHowlTarget(row.getCell(7).getStringCellValue());//嚎叫值
                outreachRevenue.setIndividualScore(row.getCell(8).getStringCellValue());// 指标单项得分
                outreachRevenue.setIs_check(row.getCell(9).getStringCellValue().equals("是") ? 1 : 0);//是否考核

                //保存
                outreachRevenues.add(outreachRevenue);
            }

            //遍历要保存的数据库分别存放进入target和score里
            for (OutreachRevenue outreach : outreachRevenues) {

                String hierachyId = outreach.getHierarchyId();

                RecordPerformanceDto performanceDto = new RecordPerformanceDto();

                performanceDto.setYear(year);
                performanceDto.setQuarter(quarter);
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setElementId(elementId);
                performanceDto.setRate("年度");
                performanceDto.setWeight(0.1);
                performanceDto.setIsExamine((short)outreach.getIs_check());
                performanceDto.setThreshold(outreach.getThresholdTarget());//门槛值
                performanceDto.setAt_Least(outreach.getAtLeastTarget());//保底值
                performanceDto.setScream(outreach.getScreamTarget());//尖叫值
                performanceDto.setHowl(outreach.getHowlTarget());//嚎叫值
                performanceDto.setComplete(Float.valueOf(outreach.getRealIncome()) == null ? 0 : Float.valueOf(outreach.getRealIncome()));
                performanceDto.setScore(Float.valueOf(outreach.getIndividualScore()) == null ? 0 : Float.valueOf(outreach.getIndividualScore()));
                performanceRecordService.performanceRecord(performanceDto);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 人均管理面积表格录入方法
     *
     * @param mf         excel文件
     * @param year       年度
     * @param quarter    季度
     * @param operatorId 操作人ID
     * @author Max Date:2018/06/30
     */
    public void permanagementareaUpload(MultipartFile mf, int year, int quarter, String operatorId) {
        Long elementId = 1008L;//人均管理面积的ElementId
        Workbook xwb = null;
        BufferedInputStream bf;
        Sheet sheet;
        String fileName = mf.getOriginalFilename();


        List<PerManagementArea> perManagementAreas = new ArrayList<>();
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel 2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);//获得第一个sheet，默认每个excel只有一个sheet
            //开始遍历excel里面所有的数据，正确的数据从第7行开始
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //每次遍历的临时存储
                PerManagementArea perManagementArea = new PerManagementArea();
                //得到遍历的当前行
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空");
                }
                //区域Id
                //一共十二列
                for (int j = 0; j < 4; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                for (int j = 10; j < 12; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                //分别存储每行数据，存入JavaBean里
                perManagementArea.setHierarchyId(row.getCell(0).getStringCellValue());//设置区域名称
                perManagementArea.setSecond_organization(row.getCell(1).getStringCellValue());//二级组织
                perManagementArea.setThird_organization(row.getCell(2).getStringCellValue());//三级组织
                perManagementArea.setArea_RealValue(row.getCell(3).getStringCellValue());//人均管理面积实际值
                perManagementArea.setIndividualScore(row.getCell(10).getStringCellValue());//指标单项得分
                perManagementArea.setIs_check(row.getCell(11).getStringCellValue().equals("是") ? 1 : 0);//是否考核
                //保存
                perManagementAreas.add(perManagementArea);
            }

            //遍历要保存的数据库分别存放进入target和score里
            for (PerManagementArea perma : perManagementAreas) {

                String hierachyId = perma.getHierarchyId();
                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setElementId(elementId);
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setYear(year);
                performanceDto.setQuarter(quarter);
                performanceDto.setWeight(0.05);
                performanceDto.setRate("年度");
                performanceDto.setScore(Float.valueOf(perma.getIndividualScore()));
                if (perma.getArea_RealValue() != null) {
                    try {
                        performanceDto.setComplete(Float.valueOf(perma.getArea_RealValue()));//设置外拓收入实际值
                    } catch (Exception e) {
                        logger.error("=====ExcelAnalysis=====permanagementareaUpload=====complete:" + perma.getArea_RealValue());
                    }
                }
                performanceRecordService.performanceRecord(performanceDto);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 元均产值考核指标表格录入方法
     *
     * @param mf         excel文件
     * @param year       年度
     * @param quarter    季度
     * @param operatorId 操作人ID
     * @author Max Date:2018/06/30
     * @update Wyman Date 2018/10/10 修改权重和考核频率动态获取
     */
    public void yuanAverageValueUpload(MultipartFile mf, int year, int quarter, String operatorId) {
        Long elementId = 1009L;//元均产值的ElementId
        Workbook xwb = null;
        BufferedInputStream bf;
        Sheet sheet;
        String fileName = mf.getOriginalFilename();

        List<YuanAverageValue> yuanAverageValues = new ArrayList<>();
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel 2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);//获得第一个sheet，默认每个excel只有一个sheet
            //开始遍历excel里面所有的数据，正确的数据从第7行开始
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //每次遍历的临时存储
                YuanAverageValue yuanAverageValue = new YuanAverageValue();
                //得到遍历的当前行
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空");
                }
                //区域Id
                //一共11列
                for (int j = 0; j < 4; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);

                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                for (int j = 10; j < 12; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                //分别存储每行数据，存入JavaBean里
                yuanAverageValue.setHierarchyId(row.getCell(0).getStringCellValue());//设置区域名称
                yuanAverageValue.setSecond_organization(row.getCell(1).getStringCellValue());//二级组织
                yuanAverageValue.setThird_organization(row.getCell(2).getStringCellValue());//三级组织
                yuanAverageValue.setYuan_RealValue(row.getCell(3).getStringCellValue());//元均产值：实际值
                yuanAverageValue.setIndividualScore(row.getCell(10).getStringCellValue());// 指标单项得分
                yuanAverageValue.setIs_check(row.getCell(11).getStringCellValue().equals("是") ? 1 : 0);//是否考核

                //保存
                yuanAverageValues.add(yuanAverageValue);
            }

            //遍历要保存的数据库分别存放进入target和score里
            for (YuanAverageValue yunav : yuanAverageValues) {

                String hierachyId = yunav.getHierarchyId();

                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setYear(year);
                performanceDto.setQuarter(quarter);
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setElementId(elementId);
                performanceDto.setRate("年度");
                performanceDto.setIsExamine((short)yunav.getIs_check());
                performanceDto.setWeight(0.05);
                performanceDto.setComplete(yunav.getYuan_RealValue() == null ? -1 : Float.valueOf(yunav.getYuan_RealValue()));
                performanceDto.setScore(yunav.getIndividualScore() == null ? -1 : Float.valueOf(yunav.getYuan_RealValue()));
                performanceRecordService.performanceRecord(performanceDto);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 社区智能化改造考核指标表格录入方法
     *
     * @param mf         excel文件
     * @param year       年度
     * @param quarter    季度
     * @param operatorId 操作人ID
     * @author Max Date:2018/06/30
     */
    public void communityITTransforUpload(MultipartFile mf, int year, int quarter, String operatorId) {
        long elementIdSqznh = 1010;//社区智能化改造id
        long elementIdSqlr = 1010001;//税前利润达标id
        long elementIdSzxwc = 1010002;//双执行完成项目数id
        long elementIdsswc = 1010003;//iRBA实施完成项目数id

        Workbook xwb = null;
        BufferedInputStream bf;
        Sheet sheet;
        String fileName = mf.getOriginalFilename();


        List<CommunityITTransfor> communityITTransforList = new ArrayList<>();
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel 2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);//获得第一个sheet，默认每个excel只有一个sheet
            //开始遍历excel里面所有的数据，正确的数据从第7行开始
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //每次遍历的临时存储
                CommunityITTransfor communityITTransfor = new CommunityITTransfor();
                //得到遍历的当前行
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空");
                }
                //区域Id
                for (int j = 0; j < 9; j++) {//一共9列
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                //分别存储每行数据，存入JavaBean里
                communityITTransfor.setHierarchyId(row.getCell(0).getStringCellValue());//设置区域名称
                communityITTransfor.setSecond_organization(row.getCell(1).getStringCellValue());//二级组织
                communityITTransfor.setThird_organization(row.getCell(2).getStringCellValue());//三级组织
                communityITTransfor.setIs_Standard(row.getCell(3).getStringCellValue().equals("是") ? "1" : "0");//税前利润达标 是或者否
                //双执行完成项目数
                if (row.getCell(4).getStringCellValue() != null && (!row.getCell(4).getStringCellValue().equals(""))) {
                    try {
                        communityITTransfor.setPriject_Count(Float.parseFloat(row.getCell(4).getStringCellValue()));
                    } catch (Exception e) {
                        communityITTransfor.setPriject_Count(0.0f);
                        logger.error("=====ExcelAnalysis=====communityITTransforUpload=====Priject_Count:" + row.getCell(4).getStringCellValue());
                    }
                } else {
                    communityITTransfor.setPriject_Count(0.0f);
                }
                //双执行完成目标值
                if (row.getCell(5).getStringCellValue() != null) {
                    if (row.getCell(5).getStringCellValue().equals("/")) {
                        communityITTransfor.setComple_Value("0");
                    } else {
                        communityITTransfor.setComple_Value(row.getCell(5).getStringCellValue());
                    }
                } else {
                    communityITTransfor.setComple_Value("0");
                }
                if (row.getCell(6).getStringCellValue() != null && (!row.getCell(6).getStringCellValue().equals(""))) {
                    try {
                        communityITTransfor.setComple_Rate(Float.parseFloat(row.getCell(6).getStringCellValue()));//双执行完成率
                    } catch (Exception e) {
                        communityITTransfor.setComple_Rate(0f);
                        logger.error("=====ExcelAnalysis=====communityITTransforUpload=====Comple_Rate:" + row.getCell(6).getStringCellValue());
                    }
                } else {
                    communityITTransfor.setComple_Rate(0f);
                }
                if (row.getCell(7).getStringCellValue() != null && (!row.getCell(7).getStringCellValue().equals(""))) {
                    try {
                        communityITTransfor.setiRBA_Count(Float.parseFloat(row.getCell(7).getStringCellValue()));// iRBA实施完成项目数
                    } catch (Exception e) {
                        communityITTransfor.setiRBA_Count(0f);
                        logger.error("=====ExcelAnalysis=====communityITTransforUpload=====iRBA_Count:" + row.getCell(7).getStringCellValue());
                    }
                } else {
                    communityITTransfor.setiRBA_Count(0f);
                }
                if (row.getCell(8).getStringCellValue() != null && (!row.getCell(8).getStringCellValue().equals(""))) {
                    try {
                        communityITTransfor.setPlus_OR_Less(Float.parseFloat(row.getCell(8).getStringCellValue()));// 加减分
                    } catch (Exception e) {
                        communityITTransfor.setPlus_OR_Less(0f);
                        logger.error("=====ExcelAnalysis=====communityITTransforUpload=====Plus_OR_Less:" + row.getCell(8).getStringCellValue());
                    }
                } else {
                    communityITTransfor.setPlus_OR_Less(0f);
                }
                //保存
                communityITTransforList.add(communityITTransfor);
            }

            //指标季度
            String thisQuarter = String.valueOf(quarter);//按照季度指标

            //遍历要保存的数据库分别存放进入target和score里
            for (CommunityITTransfor communitytt : communityITTransforList) {

                String hierachyId = communitytt.getHierarchyId();

                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setYear(year);
                performanceDto.setQuarter(quarter);
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setElementId(elementIdSqznh);//社区智能化改造
                performanceDto.setRate("年度");
                performanceDto.setIsExamine((short)1);
                performanceRecordService.performanceRecord(performanceDto);

                performanceDto.setElementId(elementIdSqznh);//社区智能化改造id
                performanceDto.setScore(communitytt.getPlus_OR_Less());
                performanceRecordService.performanceRecord(performanceDto);

                //税前利润达标
                performanceDto.setElementId(elementIdSqlr);
                performanceDto.setComplete(communitytt.getIs_Standard() == null ? -1 : Float.valueOf(communitytt.getIs_Standard()));
                performanceRecordService.performanceRecord(performanceDto);

                //双执行完成
                performanceDto.setElementId(elementIdSzxwc);
                performanceDto.setHowl(communitytt.getComple_Value() == null ? "" : String.valueOf(communitytt.getComple_Value()));
                performanceDto.setComplete(communitytt.getPriject_Count());//双执行完成项目数
                performanceDto.setScore(communitytt.getComple_Rate());//双执行完成率
                performanceRecordService.performanceRecord(performanceDto);

                //设置iRBA项目数
                performanceDto.setElementId(elementIdsswc);
                performanceDto.setHowl(communitytt.getiRBA_Count() == null?"":String.valueOf(communitytt.getiRBA_Count()));
                performanceRecordService.performanceRecord(performanceDto);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 社区经营服务考核指标表格录入方法
     *
     * @param mf         excel文件
     * @param year       年度
     * @param quarter    季度
     * @param operatorId 操作人ID
     * @author Max Date:2018/06/30
     * @Update Wyman 修改动态权重值，考核频率值没改 2018/10/10
     */
    public void communityManageUpload(MultipartFile mf, int year, int quarter, String operatorId) {
        Long elementIdSqjyff = 1006L;//社区经营服务的ElementId
        Long elementSqzzfw = 1006001L;//社区增值服务
        Long elementSqzzsq = 1006001001L;//社区增值税前
        Long elementFwpt = 1006001002001L;//房屋配套
        Long elementShtg = 1006001002002L;//生活团购
        Long elementSqgg = 1006001002003L;//社区广告
        Long elementZyjy = 1006001002004L;//资源经营
        Long elementYwjg = 1006001002L;//业务结构系数
        Long elementFwsq = 1006002001L;//房屋税前利润
        Long elementFcjysc = 1006002002L;//房产经营市场占有率
        Long elementKpgz = 1006002003L;//控盘工作完成情况
        Long elementFczs = 1006002L;//房产租售服务
        Long elementJzlgs = 1006003L;//居者乐公司服务


        Workbook xwb = null;
        BufferedInputStream bf;
        Sheet sheet;
        String fileName = mf.getOriginalFilename();


        List<CommunityManagement> communityManagementList = new ArrayList<>();
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel 2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);//获得第一个sheet，默认每个excel只有一个sheet
            //开始遍历excel里面所有的数据，正确的数据从第7行开始
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //每次遍历的临时存储
                CommunityManagement communityManagement = new CommunityManagement();
                //得到遍历的当前行
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空");
                }
                //区域Id
                for (int j = 0; j < 43; j++) {//一共43列
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                //分别存储每行数据，存入JavaBean里
                communityManagement.setHierarchyId(row.getCell(0).getStringCellValue());//设置区域名称
                //二级组织
                //三级组织
                //---------------社区增值税前利润目标值
                communityManagement.setCvapp_actual(row.getCell(3).getStringCellValue());//社区增值税前利润:实际值
                communityManagement.setCvapp_threshold(row.getCell(4).getStringCellValue());//社区增值税前利润: 门槛值
                communityManagement.setCvapp_atLeast(row.getCell(5).getStringCellValue());//社区增值税前利润: 保底
                communityManagement.setCvapp_scream(row.getCell(6).getStringCellValue());//社区增值税前利润: 尖叫
                communityManagement.setCvapp_howl(row.getCell(7).getStringCellValue());//社区增值税前利润: 嚎叫
                //---------------业务结构系数
                //-----房屋配套
                communityManagement.setAccommodationActual(row.getCell(8).getStringCellValue());//房屋配套实际值
                communityManagement.setAccommodationTarget(row.getCell(9).getStringCellValue());//房屋配套保底目标
                communityManagement.setAccommodationRatio(row.getCell(10).getStringCellValue());//房屋配套结构系数
                //-----生活团购
                communityManagement.setGroupBuyingActual(row.getCell(11).getStringCellValue());//生活团购实际值
                communityManagement.setGroupBuyingTarget(row.getCell(12).getStringCellValue());//生活团购保底目标
                communityManagement.setGroupBuyingRatio(row.getCell(13).getStringCellValue());//生活团购结构系数
                //-----社区广告
                communityManagement.setAdvertisementActual(row.getCell(14).getStringCellValue());//社区广告实际值
                communityManagement.setAdvertisementTarget(row.getCell(15).getStringCellValue());//社区广告保底目标
                communityManagement.setAdvertisementRatio(row.getCell(16).getStringCellValue());//社区广告结构系数
                //-----资源经营
                communityManagement.setResourceManagementActual(row.getCell(17).getStringCellValue());//资源经营实际值
                communityManagement.setResourceManagementTarget(row.getCell(18).getStringCellValue());//资源经营保底目标
                communityManagement.setResourceManagementRatio(row.getCell(19).getStringCellValue());//资源经营结构系数
                //-------------
                communityManagement.setStructulRatio(row.getCell(20).getStringCellValue());//业务结构系数
                communityManagement.setCva_score(row.getCell(21).getStringCellValue());//细项得分
                //---------------房屋租售服务
                //-----房屋租售税前利润
                communityManagement.setHrspp_actual(row.getCell(22).getStringCellValue());//房屋租售税前利润: 实际值
                communityManagement.setHrspp_threshold(row.getCell(23).getStringCellValue());//房屋租售税前利润: 门槛值
                communityManagement.setHrspp_atLeast(row.getCell(24).getStringCellValue());//房屋租售税前利润: 保底
                communityManagement.setHrspp_scream(row.getCell(25).getStringCellValue());//房屋租售税前利润: 尖叫
                communityManagement.setHrspp_howl(row.getCell(26).getStringCellValue());//房屋租售税前利润: 嚎叫
                //-----市场占有率实际值
                communityManagement.setMo_actual(row.getCell(27).getStringCellValue());//市场占有率实际值
                communityManagement.setMo_target(row.getCell(28).getStringCellValue());//市场占有率目标值
                //-----控盘得分
                communityManagement.setS1(row.getCell(29).getStringCellValue());//第一季度
                communityManagement.setS2(row.getCell(30).getStringCellValue());//第二季度
                communityManagement.setS3(row.getCell(31).getStringCellValue());//第三季度
                communityManagement.setS4(row.getCell(32).getStringCellValue());//第四季度
                communityManagement.setAnnual(row.getCell(33).getStringCellValue());//年度
                //-------------
                communityManagement.setHrs_score(row.getCell(34).getStringCellValue());//细项得分
                //---------------居者乐公司服务协作
                communityManagement.setJzl_actual(row.getCell(35).getStringCellValue());//居者乐公司服务协作: 实际值
                communityManagement.setJzl_threshold(row.getCell(36).getStringCellValue());//居者乐公司服务协作: 门槛值
                communityManagement.setJzl_atLeast(row.getCell(37).getStringCellValue());//居者乐公司服务协作: 保底
                communityManagement.setJzl_scream(row.getCell(38).getStringCellValue());//居者乐公司服务协作: 尖叫
                communityManagement.setJzl_howl(row.getCell(39).getStringCellValue());//居者乐公司服务协作: 嚎叫
                communityManagement.setJzl_score(row.getCell(40).getStringCellValue());//居者乐公司服务协作: 细项得分
                communityManagement.setTotalScore(row.getCell(43).getStringCellValue());//指标单项得分
                communityManagement.setIsCheck(row.getCell(44).getStringCellValue().equals("是") ? "1" : "0");//是否考核
                
                communityManagement.setLrdb(row.getCell(41).getStringCellValue());//整体利润是否达标
                communityManagement.setFwzzdf(row.getCell(42).getStringCellValue());//房屋租售最终得分
                
                //保存
                communityManagementList.add(communityManagement);
            }

            //遍历要保存的数据库分别存放进入target和score里
            for (CommunityManagement communitym : communityManagementList) {
                String hierachyId = communitym.getHierarchyId();
                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                //社区增值税钱利润实际值
                //设置performanceTarget要保存的数据
                //设置年/季/区/考核指标
                performanceDto.setYear(year);
                //targetSqzzsq.setQuarterly("6");//年度指标
                performanceDto.setQuarter(quarter);//按照季度指标来
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setElementId(elementSqzzsq);
                performanceDto.setThreshold(communitym.getCvapp_threshold());//社区增值税前利润: 门槛值
                performanceDto.setAt_Least(communitym.getCvapp_atLeast());//社区增值税前利润: 保底
                performanceDto.setScream(communitym.getCvapp_scream());//社区增值税前利润: 尖叫
                performanceDto.setHowl(communitym.getCvapp_howl());//社区增值税前利润: 嚎叫
                ////////////////计算社区增值税前利润得分////////////////
                String temp_score_sqzzsq = "-1";
                //实际值  门槛值  保底  尖叫  嚎叫
                if ((!communitym.getCvapp_actual().equals("-1")) && (!communitym.getCvapp_threshold().equals("-1")) &&
                        (!communitym.getCvapp_atLeast().equals("-1")) && (!communitym.getCvapp_scream().equals("-1")) &&
                        (!communitym.getCvapp_howl().equals("-1"))) {
                    try {
                        temp_score_sqzzsq = Calculate.InsertionMethod(Double.valueOf(communitym.getCvapp_actual()),
                                Double.valueOf(communitym.getCvapp_threshold()), Double.valueOf(communitym.getCvapp_atLeast()),
                                Double.valueOf(communitym.getCvapp_scream()), Double.valueOf(communitym.getCvapp_howl()), 1);
                    } catch (Exception e) {
                    }
                }
                /////////////////////////////////////////////////////////;
                try {
                    performanceDto.setComplete(Float.valueOf(communitym.getCvapp_actual()) == null ? -1 : Float.valueOf(communitym.getCvapp_actual()));//社区增值税前利润： 实际值
                } catch (Exception e) {
                    performanceDto.setComplete(-1);//社区增值税前利润： 实际值
                }
                try {
                    performanceDto.setScore(Float.valueOf(temp_score_sqzzsq));
                } catch (Exception e) {
                    performanceDto.setScore(-1);
                }
                performanceRecordService.performanceRecord(performanceDto);

                //----------业务结构系数
                //-----房屋配套
                //设置年/季/区/考核指标
                performanceDto.setElementId(elementFwpt);
                performanceDto.setHowl(null);
                performanceDto.setThreshold(null);
                performanceDto.setScream(null);
                performanceDto.setAt_Least(communitym.getAccommodationTarget());//房屋配套保底目标
                performanceDto.setComplete(Float.valueOf(communitym.getAccommodationActual()) == null ? -1 : Float.valueOf(communitym.getAccommodationActual()));//房屋配套实际值
                performanceDto.setScore(Float.valueOf(communitym.getAccommodationRatio()) == null ? -1 : Float.valueOf(communitym.getAccommodationRatio()));//房屋配套结构系数
                performanceRecordService.performanceRecord(performanceDto);

                //-----生活团购
                performanceDto.setElementId(elementShtg);
                performanceDto.setAt_Least(communitym.getGroupBuyingTarget() == null ? "-1" : communitym.getGroupBuyingTarget());//生活团购保底目标performanceDto.setComplete(Float.valueOf(communitym.getGroupBuyingActual()));//生活团购实际值
                performanceDto.setScore(Float.valueOf(communitym.getGroupBuyingRatio()) == null ? -1 : Float.valueOf(communitym.getGroupBuyingRatio()));//生活团购结构系数
                performanceRecordService.performanceRecord(performanceDto);

                //-----社区广告
                performanceDto.setElementId(elementSqgg);
                performanceDto.setAt_Least(communitym.getAdvertisementTarget());//社区广告保底目标
                performanceDto.setComplete(Float.valueOf(communitym.getAdvertisementActual()) == null ? -1 : Float.valueOf(communitym.getAdvertisementActual()));//社区广告实际值
                performanceDto.setScore(Float.valueOf(communitym.getAdvertisementRatio()) == null ? -1 : Float.valueOf(communitym.getAdvertisementRatio()));//社区广告结构系数
                performanceRecordService.performanceRecord(performanceDto);

                //-----资源经营
                performanceDto.setElementId(elementZyjy);
                performanceDto.setAt_Least(communitym.getResourceManagementTarget());//资源经营实际值
                //资源经营实际值
                performanceDto.setComplete(Float.valueOf(communitym.getResourceManagementActual()) == null ? -1 : Float.valueOf(communitym.getResourceManagementActual()));//资源经营实际值
                //资源经营结构系数
                performanceDto.setScore(Float.valueOf(communitym.getResourceManagementRatio()) == null ? -1 : Float.valueOf(communitym.getResourceManagementRatio()));
                performanceRecordService.performanceRecord(performanceDto);

                //----------业务结构
                performanceDto.setElementId(elementYwjg);
                String struct_radio = communitym.getStructulRatio();
                float struct;
                if (struct_radio.equals("-1")) {
                    struct = -1.0f;
                } else {
                    struct = (float) new BigDecimal(struct_radio).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
                }
                performanceDto.setAt_Least(String.valueOf(struct));//业务结构系数
                performanceDto.setScore(struct);
                performanceDto.setComplete(struct);
                performanceRecordService.performanceRecord(performanceDto);

                //----------社区增值服务
                performanceDto.setElementId(elementSqzzfw);
                performanceDto.setScore(Float.valueOf(communitym.getCva_score()) == null ? -1 : Float.valueOf(communitym.getCva_score()));//细项得分
                performanceDto.setComplete(-1);

                //-----房屋税前利润
                performanceDto.setElementId(elementFwsq);
                performanceDto.setThreshold(communitym.getHrspp_threshold());//房屋租售税前利润: 门槛值
                performanceDto.setAt_Least(communitym.getHrspp_atLeast());//房屋租售税前利润: 保底
                performanceDto.setScream(communitym.getHrspp_scream());//房屋租售税前利润: 尖叫
                performanceDto.setHowl(communitym.getHrspp_howl());//房屋租售税前利润: 嚎叫
                ////////////////计算房屋租售税前利润得分////////////////
                String temp_score_Fwsq = "-1";
                //实际值  门槛值  保底  尖叫  嚎叫
                if ((!communitym.getHrspp_actual().equals("-1")) && (!communitym.getHrspp_threshold().equals("-1")) &&
                        (!communitym.getHrspp_atLeast().equals("-1")) && (!communitym.getHrspp_scream().equals("-1")) &&
                        (!communitym.getHrspp_howl().equals("-1"))) {
                    try {
                        temp_score_Fwsq = Calculate.InsertionMethod(Double.valueOf(communitym.getHrspp_actual()),
                                Double.valueOf(communitym.getHrspp_threshold()), Double.valueOf(communitym.getHrspp_atLeast()),
                                Double.valueOf(communitym.getHrspp_scream()), Double.valueOf(communitym.getHrspp_howl()), 1);
                    } catch (Exception e) {
                    }
                }
                ///////////////////////////////////////////////////////
                performanceDto.setComplete(Float.valueOf(communitym.getHrspp_actual()) == null ? -1 : Float.valueOf(communitym.getHrspp_actual()));//房屋租售税前利润: 实际值
                performanceDto.setScore(Float.valueOf(temp_score_Fwsq) == null ? -1 : Float.valueOf(temp_score_Fwsq));
                performanceRecordService.performanceRecord(performanceDto);

                //-----------市场占有率
                performanceDto.setElementId(elementFcjysc);
                double score = Calculate.bazaars(communitym.getMo_actual(), communitym.getMo_target());
                performanceDto.setComplete(Float.valueOf(communitym.getMo_actual()) == null ? -1 : Float.valueOf(communitym.getMo_actual()));//市场占有率实际值
                performanceDto.setScore((float) score);
                performanceDto.setThreshold(null);
                performanceDto.setHowl(null);
                performanceDto.setAt_Least(null);
                performanceDto.setScream(null);
                performanceRecordService.performanceRecord(performanceDto);

                //-----------控盘得分
                String[] scores = {communitym.getS1(), communitym.getS2(), communitym.getS3(), communitym.getS4()};
                performanceDto.setElementId(elementKpgz);

                for (int i = 1; i < 5; i++) {
                    performanceDto.setQuarter(quarter);//年度指标
                    if (i != quarter) {
                        continue;
                    }
                    performanceDto.setComplete(Float.parseFloat(StringUtil.isBlankOrEmpty(scores[i - 1]) ? "-1" : scores[i - 1]));
                }

                ////设置年度
                performanceDto.setQuarter(quarter);//年度指标
                performanceDto.setScore(Float.valueOf(communitym.getAnnual()) == null ? -1 : Float.valueOf(communitym.getAnnual()));//年度
                performanceRecordService.performanceRecord(performanceDto);

                //----------房屋租售服务
                performanceDto.setElementId(elementFczs);
                performanceDto.setScore(Float.valueOf(communitym.getHrs_score()) == null ? -1 : Float.valueOf(communitym.getHrs_score()));//房屋租售服务 细项得分
                performanceDto.setComplete(-1);
                performanceRecordService.performanceRecord(performanceDto);

                //居者乐公司服务
                performanceDto.setElementId(elementJzlgs);
                performanceDto.setComplete(Float.valueOf(communitym.getJzl_actual()) == null ? -1 : Float.valueOf(communitym.getJzl_actual()));//居者乐公司服务协作: 实际值
                performanceDto.setScore(Float.valueOf(communitym.getJzl_score()) == null ? -1 : Float.valueOf(communitym.getJzl_score()));//居者乐公司服务协作: 得分
                //居者乐公司服务协作
                performanceDto.setThreshold(communitym.getJzl_threshold());//居者乐公司服务协作: 门槛值
                performanceDto.setAt_Least(communitym.getJzl_atLeast());//居者乐公司服务协作: 保底
                performanceDto.setScream(communitym.getJzl_scream());//居者乐公司服务协作: 尖叫
                performanceDto.setHowl(communitym.getJzl_howl());//居者乐公司服务协作: 嚎叫
                performanceRecordService.performanceRecord(performanceDto);

                //-----------------社区经营服务
                performanceDto.setElementId(elementIdSqjyff);
                performanceDto.setIsExamine(Short.parseShort(communitym.getIsCheck()));//是否考核
                performanceDto.setWeight(0.15);
                performanceDto.setThreshold(null);
                performanceDto.setScream(null);
                performanceDto.setAt_Least(null);
                performanceDto.setHowl(null);
                performanceDto.setScore(Float.valueOf(communitym.getTotalScore()) == null ? -1 : Float.valueOf(communitym.getTotalScore()));//指标单项得分
                performanceDto.setComplete(-1);
                
                performanceDto.setLrdb(communitym.getLrdb()); //整体利润是否达标
                performanceDto.setFwzzdf(communitym.getFwzzdf());//房屋租售最终得分
                performanceRecordService.performanceRecord(performanceDto);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * @Author: Create by white
     * @Description: 品质红黄牌excel导入实现
     * @Date: 2018-06-30 12:56
     * @Params: [multipartFile, year, quarterly, OperatorId]
     * @Return: void
     * @Throws:
     */
    public void cardsUpload(MultipartFile multipartFile, int year, String quarterly, String OperatorId) {
        //指标id 1011表示品质红黄牌
        long elementId = 1011;
        long elementId1 = 1011001;
        long elementId2 = 1011002;
//        quarterly = "6";//考核频率为年度对应“6”
        //创建工作簿
        Workbook workbook = null;
        BufferedInputStream bis = null;
        //创建sheet
        Sheet sheet = null;
        //获取文件原名称
        String fileName = multipartFile.getOriginalFilename();

        //创建list用于存放实体对象
        List<QualityOFRYCards> qualityOFRYCardsList = new ArrayList<>();
        try {
            bis = new BufferedInputStream(multipartFile.getInputStream());
            //判断文件的扩展名是xls还是xlsx
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                workbook = new HSSFWorkbook(bis);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                workbook = new XSSFWorkbook(bis);
            }
            //获取工作簿的第一个sheet
            sheet = workbook.getSheetAt(0);

            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //创建品质红黄牌数，用于拼接每一行的数据
                QualityOFRYCards qualityOFRYCards = new QualityOFRYCards();
                Row row = sheet.getRow(i);
                //如果获取的行是空对象，跳出循环
                if (row == null) {
                    break;
                } else {
//                    System.out.println("第" + i + "行不为空");
                }
                //判断区域id是否为空
                if (row.getCell(0) == null) {
                    System.out.println("第" + i + "行，区域Id为空。");
                    break;
//                    throw new Exception("第" + i + "行，区域Id为空。");
                }
                //每行总共6列
                for (int j = 0; j < 6; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                qualityOFRYCards.setHierarchyId(row.getCell(0).getStringCellValue());
                qualityOFRYCards.setSecond_organization(row.getCell(1).getStringCellValue());
                qualityOFRYCards.setThird_organization(row.getCell(2).getStringCellValue());
                qualityOFRYCards.setYellowcards(row.getCell(3).getStringCellValue());//品质黄牌
                qualityOFRYCards.setRedcards(row.getCell(4).getStringCellValue());//品质红牌
                qualityOFRYCards.setPlus_OR_Less(row.getCell(5).getStringCellValue());//加减分
                qualityOFRYCards.setQuarter(quarterly);
                qualityOFRYCards.setYear(String.valueOf(year));
                //将拼接到的qualityOFRYCards添加到list中
                qualityOFRYCardsList.add(qualityOFRYCards);
            }
            //以下步骤操作进行入库和更新操作
            for (QualityOFRYCards qualityOFRYCards1 : qualityOFRYCardsList) {

                String hierachyId = qualityOFRYCards1.getHierarchyId();

                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setElementId(elementId);
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setYear(year);
                performanceDto.setQuarter(Integer.parseInt(quarterly));

                //加减分
                if ((!qualityOFRYCards1.getPlus_OR_Less().equals("")) && qualityOFRYCards1.getPlus_OR_Less() != null) {
                    try {
                        performanceDto.setScore(Float.valueOf(qualityOFRYCards1.getPlus_OR_Less()));
                    } catch (Exception e) {
                        logger.error("=====ExcelAnalysis=====cardsUpload=====complete:" + qualityOFRYCards1.getPlus_OR_Less());
                    }
                }
                performanceRecordService.performanceRecord(performanceDto);

                //查找黄牌的分数的记录是否存在，存在则更新，不存在则插入
                performanceDto.setElementId(elementId1);
                performanceDto.setScore(0);
                if ((!qualityOFRYCards1.getYellowcards().equals("")) && qualityOFRYCards1.getYellowcards() != null) {
                    try {
                        performanceDto.setComplete(Float.valueOf(qualityOFRYCards1.getYellowcards()));
                    } catch (Exception e) {
                        logger.error("=====ExcelAnalysis=====cardsUpload=====complete:" + qualityOFRYCards1.getYellowcards());
                    }
                }
                performanceRecordService.performanceRecord(performanceDto);

                //查找红牌的分数的记录是否存在，存在则更新，不存在则插入
                performanceDto.setElementId(elementId2);
                performanceDto.setScore(0);
                if ((!qualityOFRYCards1.getYellowcards().equals("")) && qualityOFRYCards1.getYellowcards() != null) {
                    try {
                        performanceDto.setComplete(Float.valueOf(qualityOFRYCards1.getRedcards()));
                    } catch (Exception e) {
                        logger.error("=====ExcelAnalysis=====cardsUpload=====complete:" + qualityOFRYCards1.getRedcards());
                    }
                }
                performanceRecordService.performanceRecord(performanceDto);

                performanceDto.setIsExamine((short)1);
                performanceDto.setRate("");
                performanceDto.setElementId(elementId);
                performanceRecordService.performanceRecord(performanceDto);
            }
        } catch (Exception e) {
            e.printStackTrace();
//            System.out.println("服务出现异常");
        }

    }


    /**
     * @Author: Create by white
     * @Description: 入室盗窃案案发率excel导入实现
     * @Date: 2018-06-30 19:28
     * @Params: [multipartFile, year, quarterly, OperatorId]
     * @Return: void
     * @Throws:
     */
    public void burglaryUpload(MultipartFile multipartFile, int year, String quarterly, String OperatorId) {
        //指标id 入室盗窃案案发率
        long elementId = 1012;
        long elementId1 = 1012001;//入室盗窃案发数量
        long elementId2 = 1012002; //导致人员伤亡案件数
        long elementId3 = 1012003;//期末接管户数
        long elemnetId4 = 1012004;//折算任期户数
        long elementId5 = 1012005;//入室盗窃案发率

//        quarterly = "6";//考核频率为年度对应“6”
        //创建工作簿
        Workbook workbook = null;
        BufferedInputStream bis = null;
        //创建sheet
        Sheet sheet = null;
        //获取文件原名称
        String fileName = multipartFile.getOriginalFilename();


        List<BurglaryIncident> burglaryIncidentList = new ArrayList<>();
        try {
            bis = new BufferedInputStream(multipartFile.getInputStream());
            //判断文件的扩展名是xls还是xlsx
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                workbook = new HSSFWorkbook(bis);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                workbook = new XSSFWorkbook(bis);
            }
            //获取工作簿的第一个sheet
            sheet = workbook.getSheetAt(0);

            //循环遍历每一行的数据
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //创建入室盗窃案实体，用于拼接每一行的数据
                BurglaryIncident burglaryIncident = new BurglaryIncident();
                Row row = sheet.getRow(i);
                //如果获取的行是空对象，跳出循环
                if (row == null) {
                    break;
                } else {
                    int r = i + 1;
//                    System.out.println("第" + r + "行不为空");
                }
                //判断区域id是否为空
                if (row.getCell(0) == null) {
                    System.out.println("第" + i + "行，区域Id为空。");
                    break;
//                    throw new Exception("第" + i + "行，区域Id为空。");
                }
                //每行总共9列
                for (int j = 0; j < 9; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                burglaryIncident.setHierarchyId(row.getCell(0).getStringCellValue());
                burglaryIncident.setSecond_organization(row.getCell(1).getStringCellValue());
                burglaryIncident.setThird_organization(row.getCell(2).getStringCellValue());
                burglaryIncident.setBurglaryIncident_Count(row.getCell(3).getStringCellValue());
                burglaryIncident.setHurt_OR_Dead(row.getCell(4).getStringCellValue());
                burglaryIncident.setFinal_Count(row.getCell(5).getStringCellValue());
                burglaryIncident.setCal_Count(row.getCell(6).getStringCellValue());
                burglaryIncident.setRate(row.getCell(7).getStringCellValue());
                burglaryIncident.setPlus_OR_Less(row.getCell(8).getStringCellValue());
                //将拼接到的对象burglaryIncident添加到list中
                burglaryIncidentList.add(burglaryIncident);
            }
            //以下步骤用于入库和更新操作
            for (BurglaryIncident burglaryIncident1 : burglaryIncidentList) {

                String hierachyId = burglaryIncident1.getHierarchyId();
                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setYear(year);
                performanceDto.setQuarter(Integer.parseInt(quarterly));
                performanceDto.setElementId(elementId);
                if (burglaryIncident1.getPlus_OR_Less() != null && (!burglaryIncident1.getPlus_OR_Less().equals(""))) {
                    try {
                        performanceDto.setScore(Float.valueOf(burglaryIncident1.getPlus_OR_Less()));
                    } catch (Exception e) {
                        performanceDto.setScore(0);
                    }
                } else {
                    performanceDto.setScore(0);
                }
                //加减分插入与更新
                performanceRecordService.performanceRecord(performanceDto);

                //入室盗窃案发数量 插入与更新
                performanceDto.setScore(0);
                performanceDto.setElementId(elementId1);
                if (burglaryIncident1.getBurglaryIncident_Count() != null && (!burglaryIncident1.getBurglaryIncident_Count().equals(""))) {
                    try {
                        performanceDto.setComplete(Float.valueOf(burglaryIncident1.getBurglaryIncident_Count()));
                    } catch (Exception e) {
                        performanceDto.setComplete(0);
                    }
                } else {
                    performanceDto.setComplete(0);
                }
                performanceRecordService.performanceRecord(performanceDto);

                //入室盗窃案导致人员伤亡案件数 插入与更新
                performanceDto.setElementId(elementId2);
                if (burglaryIncident1.getHurt_OR_Dead() != null && (!burglaryIncident1.getHurt_OR_Dead().equals(""))) {
                    try {
                        performanceDto.setComplete(Float.valueOf(burglaryIncident1.getHurt_OR_Dead()));
                    } catch (Exception e) {
                        performanceDto.setComplete(0);
                    }
                } else {
                    performanceDto.setComplete(0);
                }
                performanceRecordService.performanceRecord(performanceDto);

                //期末接管户数 插入与更新
                performanceDto.setElementId(elementId3);
                if (burglaryIncident1.getFinal_Count() != null && (!burglaryIncident1.getFinal_Count().equals(""))) {
                    try {
                        performanceDto.setComplete(Float.valueOf(burglaryIncident1.getFinal_Count()));
                    } catch (Exception e) {
                        performanceDto.setComplete(0);
                    }
                } else {
                    performanceDto.setComplete(0);
                }
                performanceRecordService.performanceRecord(performanceDto);

                //折算任期户数 插入于更新
                performanceDto.setElementId(elemnetId4);
                if (burglaryIncident1.getCal_Count() != null && (!burglaryIncident1.getCal_Count().equals(""))) {
                    try {
                        performanceDto.setComplete(Float.valueOf(burglaryIncident1.getCal_Count()));
                    } catch (Exception e) {
                        performanceDto.setComplete(0);
                    }
                } else {
                    performanceDto.setComplete(0);
                }
                performanceRecordService.performanceRecord(performanceDto);

                //入室盗窃案案发率 插入与更新
                performanceDto.setElementId(elementId5);
                if (burglaryIncident1.getRate() != null && (!burglaryIncident1.getRate().equals(""))) {
                    try {
                        performanceDto.setComplete(Float.parseFloat(burglaryIncident1.getRate()));
                    } catch (Exception e) {
                        performanceDto.setComplete(0);
                    }
                } else {
                    performanceDto.setComplete(0);
                }
                performanceRecordService.performanceRecord(performanceDto);

                performanceDto.setElementId(elementId);
                performanceDto.setIsExamine((short)1);
                performanceDto.setRate("年度");
                performanceRecordService.performanceRecord(performanceDto);

            }
        } catch (Exception e) {
            e.printStackTrace();
//            System.out.println("服务出项异常");
        }

    }

    /**
     * @Author: Create by white
     * @Description: 消防责任事故excel导入接口实现
     * @Date: 2018-06-30 19:31
     * @Params: [multipartFile, year, quarterly, OperatorId]
     * @Return: void
     * @Throws:
     */
    public void accidentsUpload(MultipartFile multipartFile, int year, String quarterly, String OperatorId) {
        //指标id 消防责任事故
        long elementId = 1013;
//        long elementId1 = 1013001;

//        quarterly = "6";//考核频率为年度对应“6”
        //创建工作簿
        Workbook workbook = null;
        BufferedInputStream bis = null;
        //创建sheet
        Sheet sheet = null;
        //获取文件原名称
        String fileName = multipartFile.getOriginalFilename();

        List<Accidents> accidentsList = new ArrayList<>();
        try {
            bis = new BufferedInputStream(multipartFile.getInputStream());
            //判断文件的扩展名是xls还是xlsx
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                workbook = new HSSFWorkbook(bis);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                workbook = new XSSFWorkbook(bis);
            }
            //获取工作簿的第一个sheet
            sheet = workbook.getSheetAt(0);

            //循环遍历每一行的数据
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //创建消防责任事故实体，用于拼接每一行的数据
                Accidents accidents = new Accidents();
                Row row = sheet.getRow(i);
                //如果获取的行是空对象，跳出循环
                if (row == null) {
                    break;
                } else {
                    int r = i + 1;
//                    System.out.println("第" + r + "行不为空");
                }
                //判断区域id是否为空
                if (row.getCell(0) == null) {
                    System.out.println("第" + i + "行，区域Id为空。");
                    break;
//                    throw new Exception("第" + i + "行，区域Id为空。");
                }
                //每行总共5列
                for (int j = 0; j < 5; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                accidents.setHierarchyId(row.getCell(0).getStringCellValue());
                accidents.setHierarchyname(row.getCell(1).getStringCellValue());
                accidents.setSecond_organization(row.getCell(1).getStringCellValue());
                accidents.setThird_organization(row.getCell(2).getStringCellValue());
                accidents.setCount(row.getCell(3).getStringCellValue());
                accidents.setPlus_OR_Less(row.getCell(4).getStringCellValue());
                accidents.setQuarter(quarterly);
                accidents.setYear(String.valueOf(year));
                accidentsList.add(accidents);
            }
            //以下操作是入库与更新操作
            for (Accidents accidents1 : accidentsList) {

                String hierachyId = accidents1.getHierarchyId();

                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setYear(year);
                performanceDto.setQuarter(Integer.parseInt(quarterly));
                performanceDto.setElementId(elementId);
                performanceDto.setIsExamine((short)1);
                performanceDto.setRate("年度");
                performanceRecordService.performanceRecord(performanceDto);

                if (accidents1.getPlus_OR_Less() != null || (!accidents1.getPlus_OR_Less().equals(""))) {
                    try {
                        performanceDto.setScore(Float.valueOf(accidents1.getPlus_OR_Less()));
                    } catch (Exception e) {
                        performanceDto.setScore(0);
                    }
                } else {
                    performanceDto.setScore(0);
                }
                if (accidents1.getCount() != null || (!accidents1.getCount().equals(""))) {
                    try {
                        performanceDto.setComplete(Float.valueOf(accidents1.getCount()));
                    } catch (Exception e) {
                        performanceDto.setComplete(0);
                    }
                } else {
                    performanceDto.setComplete(0);
                }
                performanceRecordService.performanceRecord(performanceDto);
            }
        } catch (Exception e) {
            e.printStackTrace();
//            System.out.println("服务出现异常");
        }

    }

    /**
     * @Author: Create by white
     * @Description: 停车收费excel接口导入具体实现
     * @Date: 2018-06-30 19:36
     * @Params: [multipartFile, year, quarterly, OperatorId]
     * @Return: void
     * @Throws:
     */
    public void parkingCostUpload(MultipartFile multipartFile, int year, String quarterly, String OperatorId) {

        //指标id 即停车收费
        long elementId = 1014;
        long elementId1 = 1014001;//停车收费双百目标应实施数 停车收费双百目标已实施数
        long elementId2 = 1014002;//停车收费收入目标值  停车收费收入实际值
//        quarterly = "6";//考核频率为年度对应“6”

        //创建工作簿
        Workbook workbook = null;
        BufferedInputStream bis = null;
        //创建sheet
        Sheet sheet = null;
        //获取文件原名称
        String fileName = multipartFile.getOriginalFilename();


        List<ParkingCost> parkingCostList = new ArrayList<>();
        try {
            bis = new BufferedInputStream(multipartFile.getInputStream());
            //判断文件的扩展名是xls还是xlsx
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                workbook = new HSSFWorkbook(bis);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                workbook = new XSSFWorkbook(bis);
            }
            //获取工作簿的第一个sheet
            sheet = workbook.getSheetAt(0);

            //循环遍历每一行的数据
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //创建消防责任事故实体，用于拼接每一行的数据
                ParkingCost parkingCost = new ParkingCost();
                Row row = sheet.getRow(i);
                //如果获取的行是空对象，跳出循环
                if (row == null) {
                    break;
                } else {
                    int r = i + 1;
//                    System.out.println("第" + r + "行不为空");
                }
                //判断区域id是否为空
                if (row.getCell(0) == null) {
                    System.out.println("第" + i + "行，区域Id为空。");
                    break;
//                    throw new Exception("第" + i + "行，区域Id为空。");
                }
                //每行总共8列
                for (int j = 0; j < 8; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                parkingCost.setHierarchyId(row.getCell(0).getStringCellValue());
                parkingCost.setSecond_organization(row.getCell(1).getStringCellValue());
                parkingCost.setThird_organization(row.getCell(2).getStringCellValue());
                //parkingCost.setShould_Count(row.getCell(3).getStringCellValue() == "" ? "0" : row.getCell(3).getStringCellValue());
                parkingCost.setShould_Count(row.getCell(3).getStringCellValue());
                parkingCost.setDone_Count(row.getCell(4).getStringCellValue());
                parkingCost.setRealIncome(row.getCell(5).getStringCellValue());
                parkingCost.setPointIncome(row.getCell(6).getStringCellValue());
                if (row.getCell(7).getStringCellValue() != null && (!row.getCell(7).getStringCellValue().equals(""))) {
                    try {
                        parkingCost.setPlus_OR_Less(Integer.parseInt(row.getCell(7).getStringCellValue()));
                    } catch (NumberFormatException e) {
                        parkingCost.setPlus_OR_Less(0);
                    }

                }
                parkingCost.setQuarter(quarterly);
                parkingCost.setYear(year);
                parkingCostList.add(parkingCost);
            }

            //以下是停车收费的入库与更新操作
            for (ParkingCost parkingCost1 : parkingCostList) {

                String hierachyId = parkingCost1.getHierarchyId();

                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setYear(year);
                performanceDto.setQuarter(Integer.parseInt(quarterly));
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setElementId(elementId);
                performanceDto.setRate("年度");
                performanceDto.setIsExamine((short)1);

                if (parkingCost1.getDone_Count() != null && (!parkingCost1.getDone_Count().equals(""))) {
                    try {
                        performanceDto.setScore(parkingCost1.getPlus_OR_Less());
                    } catch (Exception e) {
                        performanceDto.setScore(0);
                    }
                }
                performanceRecordService.performanceRecord(performanceDto);

                //停车收费双百目标已实施数
                performanceDto.setScore(0);
                performanceDto.setElementId(elementId1);
                if (parkingCost1.getDone_Count() != null && (!parkingCost1.getDone_Count().equals(""))) {
                    try {
                        performanceDto.setComplete(Float.parseFloat(String.valueOf(parkingCost1.getDone_Count())));
                    } catch (Exception e) {
                        performanceDto.setComplete(0);
                    }
                }
                //停车收费双百目标应实施数  插入与更新
                if (parkingCost1.getShould_Count() != null && (!parkingCost1.getShould_Count().equals("")) && (!parkingCost1.getShould_Count().equals("/"))) {
                    performanceDto.setHowl(parkingCost1.getShould_Count());
                }

                performanceRecordService.performanceRecord(performanceDto);

                //停车收费收入实际值
                performanceDto.setElementId(elementId2);
                if (parkingCost1.getRealIncome() != null && (!parkingCost1.getRealIncome().equals(""))) {
                    try {
                        performanceDto.setComplete(Float.parseFloat(parkingCost1.getRealIncome()));
                    } catch (Exception e) {
                        performanceDto.setComplete(0);
                    }
                }

                //停车收费收入目标值 插入与更新
                if (parkingCost1.getPointIncome() != null && (!parkingCost1.getPointIncome().equals("")) && (!parkingCost1.getPointIncome().equals("/"))) {
                    performanceDto.setHowl(parkingCost1.getPointIncome());
                }
                performanceRecordService.performanceRecord(performanceDto);

            }

        } catch (Exception e) {
            e.printStackTrace();
//            System.out.println("服务出现异常");
        }

    }

    /**
     * @Author: Create by white
     * @Description: 媒体曝光或群诉excel导入具体实现
     * @Date: 2018-06-30 19:39
     * @Params: [multipartFile, year, quarterly, OperatorId]
     * @Return: void
     * @Throws:
     */
    public void negativeEffectiveUplaod(MultipartFile multipartFile, int year, String quarterly, String OperatorId) {
        //指标id 即媒体曝光或群诉
        long elementId = 1015;
        long elementId1 = 1015001;//未按标准流程妥善处理
        long elementId2 = 1015002;//地方媒体报道事件
        long elementId3 = 1015003;//中央媒体报道事件
        long elementId4 = 1015004;//广泛媒体报道事件

//        quarterly = "6";//考核频率为年度对应“6”
        //创建工作簿
        Workbook workbook = null;
        BufferedInputStream bis = null;
        //创建sheet
        Sheet sheet = null;
        //获取文件原名称
        String fileName = multipartFile.getOriginalFilename();


        List<NegativeEffective> negativeEffectiveList = new ArrayList<>();
        try {
            bis = new BufferedInputStream(multipartFile.getInputStream());
            //判断文件的扩展名是xls还是xlsx
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                workbook = new HSSFWorkbook(bis);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                workbook = new XSSFWorkbook(bis);
            }
            //获取工作簿的第一个sheet
            sheet = workbook.getSheetAt(0);

            //循环遍历每一行的数据
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //创建媒体曝光或群诉实体，用于拼接每一行的数据
                NegativeEffective negativeEffective = new NegativeEffective();
                Row row = sheet.getRow(i);
                //如果获取的行是空对象，跳出循环
                if (row == null) {
                    break;
                } else {
                    int r = i + 1;
//                    System.out.println("第" + r + "行不为空");
                }
                //判断区域id是否为空
                if (row.getCell(0) == null) {
                    System.out.println("第" + i + "行，区域Id为空。");
                    break;
//                    throw new Exception("第" + i + "行，区域Id为空。");
                }
                //每行总共5列
                for (int j = 0; j < 8; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                negativeEffective.setHierarchyId(row.getCell(0).getStringCellValue());
                negativeEffective.setSecond_organization(row.getCell(1).getStringCellValue());
                negativeEffective.setThird_organization(row.getCell(2).getStringCellValue());
                negativeEffective.setYear(year);
                negativeEffective.setQuarter(quarterly);
                negativeEffective.setOutStandard(row.getCell(3).getStringCellValue());
                negativeEffective.setLocation(row.getCell(4).getStringCellValue());
                negativeEffective.setCenter(row.getCell(5).getStringCellValue());
                negativeEffective.setSpread(row.getCell(6).getStringCellValue());
                negativeEffective.setPlus_OR_Less(row.getCell(7).getStringCellValue());
                negativeEffectiveList.add(negativeEffective);
            }
            for (NegativeEffective negativeEffective1 : negativeEffectiveList) {

                String hierachyId = negativeEffective1.getHierarchyId();
                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setElementId(elementId);
                performanceDto.setYear(year);
                performanceDto.setQuarter(Integer.parseInt(quarterly));
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setIsExamine((short)1);
                performanceDto.setRate("年度");
                performanceDto.setScore(negativeEffective1.getPlus_OR_Less() == null ? 0 : Float.parseFloat(negativeEffective1.getPlus_OR_Less()));
                performanceRecordService.performanceRecord(performanceDto);

                //未按标准流程妥善处理 插入与更新
                performanceDto.setScore(0);
                performanceDto.setElementId(elementId1);
                performanceDto.setComplete(Float.valueOf(negativeEffective1.getOutStandard()));
                performanceRecordService.performanceRecord(performanceDto);

                //地方媒体报道事件 插入于更新
                performanceDto.setElementId(elementId2);
                performanceDto.setComplete(Float.valueOf(negativeEffective1.getLocation()));
                performanceRecordService.performanceRecord(performanceDto);

                //中央媒体报道事件 插入与更新
                performanceDto.setElementId(elementId3);
                performanceDto.setComplete(Float.valueOf(negativeEffective1.getCenter()));
                performanceRecordService.performanceRecord(performanceDto);

                //广泛媒体报道事件 插入与更新
                performanceDto.setElementId(elementId4);
                performanceDto.setComplete(Float.valueOf(negativeEffective1.getSpread()));
                performanceRecordService.performanceRecord(performanceDto);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 城市指标--业主满意率 Excel上传
     * @param mf
     * @param year
     * @param quarter
     * @param OperatorId
     * @Author Wyman
     * @Update 新增城市公司分类，根据类型获得权重值
     */
    public void OwnersSatisfactionUpload(MultipartFile mf, int year, int quarter, String OperatorId){
        Long elementId = 1016L;
        Workbook wb = null;
        BufferedInputStream bis = null;
        Sheet sheet = null;
        String fileName = mf.getOriginalFilename();
        quarter = quarter > 4 ? 4 : quarter;

        //权重值
        double weight = 0;

        List<OwnersSatisfaction> ownersSatisfactionList = new ArrayList<>();//存放表单数据读取出的实体类对象
        try {
            bis = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                wb = new HSSFWorkbook(bis);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                wb = new XSSFWorkbook(bis);
            }
            sheet = wb.getSheetAt(0);

            for(int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++){
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空。");
                }
                for(int j = 0; j < 10; j++) {
                    Cell cell = row.getCell(j);
                    if( cell == null){
                        cell = row.createCell(j);
                    }
                    cell.setCellType(CellType.STRING);
                    if (cell.getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(cell.getStringCellValue())) {
                        cell.setCellValue("-1");
                    }
                }

                OwnersSatisfaction os = new OwnersSatisfaction();
                os.setHierarchyId(row.getCell(0).getStringCellValue());
                os.setSecond_organization(row.getCell(1).getStringCellValue());
                os.setThird_organization(row.getCell(2).getStringCellValue());
                os.setInvestigation(row.getCell(3).getStringCellValue());
                os.setThreshold(row.getCell(4).getStringCellValue());
                os.setAtLeast(row.getCell(5).getStringCellValue());
                os.setScream(row.getCell(6).getStringCellValue());
                os.setHowl(row.getCell(7).getStringCellValue());
                os.setIndividualScore(row.getCell(8).getStringCellValue());
                os.setIs_check(row.getCell(9).getStringCellValue().equals("是") ? 1 : 0);

                ownersSatisfactionList.add(os);

            }

            for(OwnersSatisfaction os : ownersSatisfactionList){

                //////加判断
                //1.门槛值有&&保底值有 2.门槛值无且保底值有的情况 门槛值才是保底值的80%
                if((os.getThreshold() != null && os.getAtLeast() != null) || (os.getThreshold() == null && os.getAtLeast() != null)){
                    double d = Float.parseFloat(os.getAtLeast()) * 0.8;
                    String atLeast = String.valueOf(d < 0 ? -1 : d);
                    os.setThreshold(atLeast);
                }

                //获得类型对应的权重和考核频率值
                String hierarchyId = os.getHierarchyId();
                String type = performanceAreaService.getSubTypeByHierachyId(hierarchyId);
                switch (type){
                    case "单一业主项目":
                        weight = 0.3;
                        break;
                    case "多业主第一年":
                        weight = 0.5;
                        break;
                    case "多业主第二年":
                        weight = 0.4;
                        break;
                }

                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setElementId(elementId);
                performanceDto.setHierachyId(hierarchyId);
                performanceDto.setYear(year);
                performanceDto.setQuarter(quarter);
                performanceDto.setThreshold(os.getThreshold());
                performanceDto.setAt_Least(os.getAtLeast());
                performanceDto.setHowl(os.getHowl());
                performanceDto.setScream(os.getScream());
                performanceDto.setIsExamine((short) os.getIs_check());
                performanceDto.setWeight(weight);
                String complete = os.getInvestigation();
                String score = os.getIndividualScore();
                performanceDto.setComplete(StringUtil.isNotEmpty(complete) ? Float.parseFloat(complete) : -1F);
                performanceDto.setScore(StringUtil.isNotEmpty(score) ? Float.parseFloat(score) : -1F);
                performanceRecordService.performanceRecord(performanceDto);
            }
        }catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("表格格式不对！");
        }
    }

    /**
     * 城市指标--物业服务费收缴率 Excel上传
     * @param mf
     * @param year
     * @param quarter
     * @param OperatorId
     * @Author Wyman
     */
    public void CityPropertyCollectionRateUpload(MultipartFile mf, int year, int quarter, String OperatorId){
        Long elementId1 = 1017L;
        Long elementId2 = 1017001L;
        Long elementId3 = 1017002L;

        Workbook wb = null;
        BufferedInputStream bis = null;
        Sheet sheet = null;
        String fileName = mf.getOriginalFilename();
        quarter = quarter > 4 ? 4 : quarter;

        //权重值
        double weight = 0;

        List<CityPropertyCollectionRate> cityPropertyCollectionRates = new ArrayList<>();//存放表单数据读取出的实体类对象

        try {
            bis = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                wb = new HSSFWorkbook(bis);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                wb = new XSSFWorkbook(bis);
            }
            sheet = wb.getSheetAt(0);

            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空。");
                }

                for (int j = 0; j < 35; j++) {
                    Cell cell = row.getCell(j);
                    if(cell == null){
                        cell = row.createCell(j);
                    }
                    cell.setCellType(CellType.STRING);
                    if (cell.getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(cell.getStringCellValue())) {
                        cell.setCellValue("-1");
                    }
                }
                CityPropertyCollectionRate c = new CityPropertyCollectionRate();
                //综合收缴率
                c.setHierarchyId(row.getCell(0).getStringCellValue());
                c.setSecond_organization(row.getCell(1).getStringCellValue());
                c.setThird_organization(row.getCell(2).getStringCellValue());
                c.setCompre_complete(row.getCell(3).getStringCellValue());
                c.setCompre_threshold(row.getCell(4).getStringCellValue());
                c.setCompre_atLeast(row.getCell(5).getStringCellValue());
                c.setCompre_scream(row.getCell(6).getStringCellValue());
                c.setCompre_howl(row.getCell(7).getStringCellValue());
                c.setCompre_score(row.getCell(8).getStringCellValue());
                //S1
                c.setS1_complete(row.getCell(9).getStringCellValue());
                c.setS1_threshold(row.getCell(10).getStringCellValue());
                c.setS1_atLeast(row.getCell(11).getStringCellValue());
                c.setS1_scream(row.getCell(12).getStringCellValue());
                c.setS1_howl(row.getCell(13).getStringCellValue());
                c.setS1_score(row.getCell(14).getStringCellValue());
                //S2
                c.setS2_complete(row.getCell(15).getStringCellValue());
                c.setS2_threshold(row.getCell(16).getStringCellValue());
                c.setS2_atLeast(row.getCell(17).getStringCellValue());
                c.setS2_scream(row.getCell(18).getStringCellValue());
                c.setS2_howl(row.getCell(19).getStringCellValue());
                c.setS2_score(row.getCell(20).getStringCellValue());
                //S3
                c.setS3_complete(row.getCell(21).getStringCellValue());
                c.setS3_threshold(row.getCell(22).getStringCellValue());
                c.setS3_atLeast(row.getCell(23).getStringCellValue());
                c.setS3_scream(row.getCell(24).getStringCellValue());
                c.setS3_howl(row.getCell(25).getStringCellValue());
                c.setS3_score(row.getCell(26).getStringCellValue());
                //S4
                c.setS4_complete(row.getCell(27).getStringCellValue());
                c.setS4_threshold(row.getCell(28).getStringCellValue());
                c.setS4_atLeast(row.getCell(29).getStringCellValue());
                c.setS4_scream(row.getCell(30).getStringCellValue());
                c.setS4_howl(row.getCell(31).getStringCellValue());
                c.setS4_score(row.getCell(32).getStringCellValue());
                c.setIndividualScore(row.getCell(33).getStringCellValue());
                c.setIs_check(row.getCell(34).getStringCellValue().equals("是") ? 1 : 0);

                cityPropertyCollectionRates.add(c);
            }


            for(CityPropertyCollectionRate c : cityPropertyCollectionRates) {

                String IndividualScore = c.getIndividualScore();

                String[] thresholds = {c.getCompre_threshold(), c.getS1_threshold(), c.getS2_threshold(), c.getS3_threshold(), c.getS4_threshold()};
                String[] atLasts = {c.getCompre_atLeast(), c.getS1_atLeast(), c.getS2_atLeast(), c.getS3_atLeast(), c.getS4_atLeast()};
                String[] screams = {c.getCompre_scream(), c.getS1_scream(), c.getS2_scream(), c.getS3_scream(), c.getS4_scream()};
                String[] howls = {c.getCompre_howl(), c.getS1_howl(), c.getS2_howl(), c.getS3_howl(), c.getS4_howl()};
                String[] completes = {c.getCompre_complete(), c.getS1_complete(), c.getS2_complete(), c.getS3_complete(), c.getS4_complete()};
                String[] scores = {c.getCompre_score(), c.getS1_score(), c.getS2_score(), c.getS3_score(), c.getS4_score()};

                //根据城市公司id获取值
                String hierachyId = c.getHierarchyId();
                String type = performanceAreaService.getSubTypeByHierachyId(hierachyId);
                switch (type){
                    case "单一业主项目":
                        weight = 0.2;
                        break;
                    case "多业主第一年":
                        weight = 0.2;
                        break;
                    case "多业主第二年":
                        weight = 0.2;
                        break;
                }

                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                //首先插入年度 年度只需要指标得分值和是否审核值
                performanceDto.setElementId(elementId1);
                performanceDto.setHierachyId(hierachyId);
                performanceDto.setYear(year);
                performanceDto.setQuarter(quarter);
                performanceDto.setIsExamine((short) c.getIs_check());
                performanceDto.setWeight(weight);
                performanceDto.setComplete(-1);
                performanceDto.setScore(Float.parseFloat(IndividualScore));
                performanceRecordService.performanceRecord(performanceDto);

                for (int i = 0; i < 5; i++) {
                    //S1-S4收缴率
                    switch (i) {
                        case 0: {  //年度综合收缴率
                            performanceDto.setElementId(elementId2);
                            performanceDto.setQuarter(quarter);
                            performanceDto.setThreshold(thresholds[i]);
                            performanceDto.setAt_Least(atLasts[i]);
                            performanceDto.setScream(screams[i]);
                            performanceDto.setHowl(howls[i]);
                            performanceDto.setComplete(StringUtil.isNotEmpty(completes[i]) ? Float.parseFloat(completes[i]) : -1F);
                            performanceDto.setScore(StringUtil.isNotEmpty(scores[i]) ? Float.parseFloat(scores[i]) : -1F);
                            performanceRecordService.performanceRecord(performanceDto);

                            break;
                        }
                        default: {
                            if (i != quarter) {
                                continue;
                            }
                            performanceDto.setElementId(elementId3);
                            performanceDto.setQuarter(quarter);
                            performanceDto.setThreshold(thresholds[i]);
                            performanceDto.setAt_Least(atLasts[i]);
                            performanceDto.setScream(screams[i]);
                            performanceDto.setHowl(howls[i]);
                            performanceDto.setComplete(StringUtil.isNotEmpty(completes[i]) ? Float.parseFloat(completes[i]) : -1F);
                            performanceDto.setScore(StringUtil.isNotEmpty(scores[i]) ? Float.parseFloat(scores[i]) : -1F);
                            performanceRecordService.performanceRecord(performanceDto);
                            break;
                        }
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException("表格格式不对！");
        }




    }

    /**
     * 城市指标--物业服务费欠费追缴率 Excel上传
     * @param mf
     * @param year
     * @param quarter
     * @param OperatorId
     * @Author Wyman
     */
    public void CityPropertyArrearsRecoveryRateUpload(MultipartFile mf, int year, int quarter, String OperatorId){
        Long elementId = 1018L;
        Workbook wb = null;
        BufferedInputStream bis = null;
        Sheet sheet = null;
        String fileName = mf.getOriginalFilename();
        quarter = quarter > 4 ? 4 : quarter;

        //门槛值
        double weight = 0;

        List<CityPropertyArrearsRecoveryRate> cityPropertyArrearsRecoveryRates = new ArrayList<>();//存放表单数据读取出的实体类对象

        try {
            bis = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                wb = new HSSFWorkbook(bis);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                wb = new XSSFWorkbook(bis);
            }
            sheet = wb.getSheetAt(0);

            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，城市公司Id为空。");
                }

                for (int j = 0; j < 29; j++) {
                    Cell cell = row.getCell(j);
                    if( cell == null){//单元格为空时
                        cell = row.createCell(j);
                    }
                    cell.setCellType(CellType.STRING);
                    if (cell.getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(cell.getStringCellValue())) {
                        cell.setCellValue("-1");
                    }
                }
                CityPropertyArrearsRecoveryRate c = new CityPropertyArrearsRecoveryRate();
                c.setHierarchyId(row.getCell(0).getStringCellValue());
                c.setSecond_organization(row.getCell(1).getStringCellValue());
                c.setThird_organization(row.getCell(2).getStringCellValue());
                //S1
                c.setS1_complete(row.getCell(3).getStringCellValue());
                c.setS1_threshold(row.getCell(4).getStringCellValue());
                c.setS1_atLeast(row.getCell(5).getStringCellValue());
                c.setS1_scream(row.getCell(6).getStringCellValue());
                c.setS1_howl(row.getCell(7).getStringCellValue());
                c.setS1_score(row.getCell(8).getStringCellValue());
                //S2
                c.setS2_complete(row.getCell(9).getStringCellValue());
                c.setS2_threshold(row.getCell(10).getStringCellValue());
                c.setS2_atLeast(row.getCell(11).getStringCellValue());
                c.setS2_scream(row.getCell(12).getStringCellValue());
                c.setS2_howl(row.getCell(13).getStringCellValue());
                c.setS2_score(row.getCell(14).getStringCellValue());
                //S3
                c.setS3_complete(row.getCell(15).getStringCellValue());
                c.setS3_threshold(row.getCell(16).getStringCellValue());
                c.setS3_atLeast(row.getCell(17).getStringCellValue());
                c.setS3_scream(row.getCell(18).getStringCellValue());
                c.setS3_howl(row.getCell(19).getStringCellValue());
                c.setS3_score(row.getCell(20).getStringCellValue());
                //S4
                c.setS4_complete(row.getCell(21).getStringCellValue());
                c.setS4_threshold(row.getCell(22).getStringCellValue());
                c.setS4_atLeast(row.getCell(23).getStringCellValue());
                c.setS4_scream(row.getCell(24).getStringCellValue());
                c.setS4_howl(row.getCell(25).getStringCellValue());
                c.setS4_score(row.getCell(26).getStringCellValue());

                c.setIndividualScore(row.getCell(27).getStringCellValue());
                c.setIs_check(row.getCell(28).getStringCellValue().equals("是") ? 1 : 0);

                cityPropertyArrearsRecoveryRates.add(c);
            }

            for(CityPropertyArrearsRecoveryRate crarr : cityPropertyArrearsRecoveryRates){


                String IndividualScore = crarr.getIndividualScore();

                String[] thresholds = { crarr.getS1_threshold(), crarr.getS2_threshold(), crarr.getS3_threshold(), crarr.getS4_threshold()};
                String[] atLasts = { crarr.getS1_atLeast(), crarr.getS2_atLeast(), crarr.getS3_atLeast(), crarr.getS4_atLeast()};
                String[] screams = { crarr.getS1_scream(), crarr.getS2_scream(), crarr.getS3_scream(), crarr.getS4_scream()};
                String[] howls = { crarr.getS1_howl(), crarr.getS2_howl(), crarr.getS3_howl(), crarr.getS4_howl()};
                String[] completes = { crarr.getS1_complete(), crarr.getS2_complete(), crarr.getS3_complete(), crarr.getS4_complete()};
                //String[] scores = { crarr.getS1_score(), crarr.getS2_score(), crarr.getS3_score(), crarr.getS4_score()};

                //根据城市公司id获取类型
                String hierarchyId = crarr.getHierarchyId();
                String type = performanceAreaService.getSubTypeByHierachyId(hierarchyId);
                switch (type){
                    case "单一业主项目":
                        weight = 0.3;
                        break;
                    case "多业主第一年":
                        weight = 0.1;
                        break;
                    case "多业主第二年":
                        weight = 0.2;
                        break;
                }

                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setHierachyId(hierarchyId);
                performanceDto.setElementId(elementId);
                performanceDto.setYear(year);
                performanceDto.setQuarter(quarter);
                performanceDto.setIsExamine((short) crarr.getIs_check());
                performanceDto.setWeight(weight);

                for(int i = 0; i < 4; i++){//S1-S4
                    if((i+1) != quarter){
                        continue;
                    }
                    performanceDto.setThreshold(thresholds[i]);
                    performanceDto.setAt_Least(atLasts[i]);
                    performanceDto.setScream(screams[i]);
                    performanceDto.setHowl(howls[i]);
                    performanceDto.setComplete(StringUtil.isNotEmpty(completes[i]) ? Float.parseFloat(completes[i]) : -1F);
                    performanceDto.setScore(StringUtil.isNotEmpty(IndividualScore) ? Float.parseFloat(IndividualScore) : -1F);
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException("表格格式不对！");
        }
    }

    /**
     * 城市公司—-社区经营税前利润
     * @param mf excel文件
     * @param year 年度
     * @param quarter 季度
     * @param operatorId 操作人ID
     * @author Max Date:2018/09/07
     */
    public void communityProfixUpload(MultipartFile mf, int year, int quarter, String operatorId) {
        long elementId=1020;//社区经营税前利润
        Workbook xwb = null;
        BufferedInputStream bf;
        Sheet sheet;
        String fileName = mf.getOriginalFilename();

        //权重值
        double weight = 0;

        List<CommunityProfix> communityProfixList = new ArrayList<>();//存储从excel得到的数据

        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel 2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);//获得第一个sheet，每个模板第一个sheet为要上传数据的模板
            //开始遍历excel里面所有的数据，正确的数据从第7行开始
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //每次遍历的临时存储
                CommunityProfix communityProfix=new CommunityProfix();
                //得到遍历的当前行
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空");
                }
                for (int j = 0; j < 10; j++) {//一共10列
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }
                //遍历每行的数据，存入JavaBean里
                communityProfix.setHierarchyId(row.getCell(0).getStringCellValue());//设置区域名称
                communityProfix.setSecond_organization(row.getCell(1).getStringCellValue());//二级组织
                communityProfix.setThird_organization(row.getCell(2).getStringCellValue());//三级组织
                communityProfix.setComplete(row.getCell(3).getStringCellValue());//完成值
                communityProfix.setThresholdTarget(row.getCell(4).getStringCellValue());//门槛
                communityProfix.setAtLeastTarget(row.getCell(5).getStringCellValue());//保底
                communityProfix.setScreamTarget(row.getCell(6).getStringCellValue());//尖叫
                communityProfix.setHowlTarget(row.getCell(7).getStringCellValue());//嚎叫
                communityProfix.setIndividualScore(row.getCell(8).getStringCellValue());//指标单项得分
                communityProfix.setIsCheck(row.getCell(9).getStringCellValue().equals("是") ? "1" : "0");//是否考核

                communityProfixList.add(communityProfix);
            }

            //遍历数据分别存入score和target表
            for(CommunityProfix communityProfix:communityProfixList){

                //根据城市公司id获取类型
                String hierarchyId = communityProfix.getHierarchyId();
                String type = performanceAreaService.getSubTypeByHierachyId(hierarchyId);
                switch (type){
                    case "单一业主项目":
                        weight = 0.3;
                        break;
                    case "多业主第一年":
                        weight = 0.1;
                        break;
                    case "多业主第二年":
                        weight = 0.2;
                        break;
                }

                RecordPerformanceDto performanceDto = new RecordPerformanceDto();
                performanceDto.setElementId(elementId);
                performanceDto.setYear(year);
                performanceDto.setQuarter(quarter);
                performanceDto.setHierachyId(hierarchyId);
                performanceDto.setRate("年度");
                performanceDto.setWeight(weight);
                performanceDto.setIsExamine(Short.parseShort(communityProfix.getIsCheck()));
                performanceDto.setComplete(StringUtil.isNotEmpty(communityProfix.getComplete()) ? Float.parseFloat(communityProfix.getComplete()) : -1F);
                performanceDto.setScore(StringUtil.isNotEmpty(communityProfix.getIndividualScore()) ? Float.parseFloat(communityProfix.getIndividualScore()) : -1F);
                performanceRecordService.performanceRecord(performanceDto);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 城市指标—主营税前利润
     * @param mf excel文件
     * @param year 年度
     * @param quarter 季度
     * @param operatorId 操作人ID
     * @author Max Date:2018/09/07
     */
    public void PrincipalProfitUpload(MultipartFile mf, int year, int quarter, String operatorId) {
        long elementId = 1019;
        long zhElementId = 1019001L; //综合税前利润
        long sqElementId = 1019002L; //社区经营服务（N）税前利润

        Workbook xwb = null;
        BufferedInputStream bf = null;
        Sheet sheet = null;
        String fileName = mf.getOriginalFilename();

        //权重值
        double weight = 0;

        List<PrincipalProfit> principalProfitList = new ArrayList<>(); //存放数据
        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);


            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                Row row = sheet.getRow(i);
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空。");
                }

                for (int j = 0; j < 29; j++) {
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }

                PrincipalProfit principalProfit = new PrincipalProfit();
                principalProfit.setHierarchyId(row.getCell(0).getStringCellValue());
                principalProfit.setSecond_organization(row.getCell(1).getStringCellValue());
                principalProfit.setThird_organization(row.getCell(2).getStringCellValue());

                //半年度综合税前利润
                principalProfit.setHyComplete(row.getCell(3).getStringCellValue());//完成值
                principalProfit.setHyThreshold(row.getCell(4).getStringCellValue());//门槛值
                principalProfit.setHyAtLeast(row.getCell(5).getStringCellValue());//保底
                principalProfit.setHyScream(row.getCell(6).getStringCellValue());//尖叫
                principalProfit.setHyHowl(row.getCell(7).getStringCellValue());//嚎叫
                principalProfit.setHyScore(row.getCell(8).getStringCellValue());//细项得分
                //年度综合税前利润
                principalProfit.setAlComplete(row.getCell(9).getStringCellValue());//完成值
                principalProfit.setAlThreshold(row.getCell(10).getStringCellValue());//门槛值
                principalProfit.setAlAtLeast(row.getCell(11).getStringCellValue());//保底
                principalProfit.setAlScream(row.getCell(12).getStringCellValue());//尖叫
                principalProfit.setAlHowl(row.getCell(13).getStringCellValue());//嚎叫
                principalProfit.setAlScore(row.getCell(14).getStringCellValue());//细项得分
                //半年度社区增值服务税前利润
                principalProfit.setHycComplete(row.getCell(15).getStringCellValue());//完成值
                principalProfit.setHycThreshold(row.getCell(16).getStringCellValue());//门槛值
                principalProfit.setHycAtLeast(row.getCell(17).getStringCellValue());//保底
                principalProfit.setHycScream(row.getCell(18).getStringCellValue());//尖叫
                principalProfit.setHycHowl(row.getCell(19).getStringCellValue());//嚎叫
                principalProfit.setHycScore(row.getCell(20).getStringCellValue());//细项得分
                //年度社区增值服务税前利润
                principalProfit.setAlcComplete(row.getCell(21).getStringCellValue());//完成值
                principalProfit.setAlcThreshold(row.getCell(22).getStringCellValue());//门槛值
                principalProfit.setAlcAtLeast(row.getCell(23).getStringCellValue());//保底
                principalProfit.setAlcScream(row.getCell(24).getStringCellValue());//尖叫
                principalProfit.setAlcHowl(row.getCell(25).getStringCellValue());//嚎叫
                principalProfit.setAlcScore(row.getCell(26).getStringCellValue());//细项得分

                principalProfit.setIndividualscore(row.getCell(27).getStringCellValue());
                principalProfit.setIsCheck(row.getCell(28).getStringCellValue().equals("是") ? "1" : "0");

                principalProfitList.add(principalProfit);
            }

            for (PrincipalProfit principalProfit : principalProfitList) {

                RecordPerformanceDto performanceDto = new RecordPerformanceDto();

                String IndividualScore = principalProfit.getIndividualscore();

                String[] thresholds = {principalProfit.getHyThreshold(), principalProfit.getAlThreshold(), principalProfit.getHycThreshold(), principalProfit.getAlcThreshold()};
                String[] atLasts = {principalProfit.getHyAtLeast(), principalProfit.getAlAtLeast(), principalProfit.getHycAtLeast(), principalProfit.getAlcAtLeast()};
                String[] screams = {principalProfit.getHyScream(), principalProfit.getAlScream(), principalProfit.getHycScream(), principalProfit.getAlcScream()};
                String[] howls = {principalProfit.getHyHowl(), principalProfit.getAlHowl(), principalProfit.getHycHowl(), principalProfit.getAlcHowl()};
                String[] completes = {principalProfit.getHyComplete(), principalProfit.getAlComplete(), principalProfit.getHycComplete(), principalProfit.getAlcComplete()};
                String[] scores = {principalProfit.getHyScore(), principalProfit.getAlScore(), principalProfit.getHycScore(), principalProfit.getAlcScore()};

                //根据城市公司id获取类型
                String hierarchyId = principalProfit.getHierarchyId();
                String type = performanceAreaService.getSubTypeByHierachyId(hierarchyId);

                performanceDto.setHierachyId(hierarchyId);
                performanceDto.setYear(year);
                switch (type){
                    case "单一业主项目":
                        weight = 0.1;
                        break;
                    case "多业主第一年":
                        weight = 0.1;
                        break;
                    case "多业主第二年":
                        weight = 0.1;
                        break;
                }

                for (int i = 0; i < 4; i++) {
                    if (i % 2 == 0) { // 0,2 上半年度的
                        if (quarter >= 2) {
                            continue;
                        }
                    } else {
                        if (quarter < 2) {
                            continue;
                        }
                    }

                    if (i <= 1) {
                        performanceDto.setElementId(zhElementId);
                    } else {
                        performanceDto.setElementId(sqElementId);
                    }
                    performanceDto.setQuarter(quarter);
                    performanceDto.setThreshold(thresholds[i]);
                    performanceDto.setAt_Least(atLasts[i]);
                    performanceDto.setScream(screams[i]);
                    performanceDto.setHowl(howls[i]);
                    performanceDto.setIsExamine(Short.parseShort(principalProfit.getIsCheck()));
                    performanceDto.setWeight(weight);
                    performanceDto.setComplete(StringUtil.isNotEmpty(completes[i]) ? Float.parseFloat(completes[i]) : -1F);
                    performanceDto.setScore(StringUtil.isNotEmpty(scores[i]) ? Float.parseFloat(scores[i]) : -1F);
                    performanceRecordService.performanceRecord(performanceDto);
                }

                //年度得分
                performanceDto.setThreshold(null);
                performanceDto.setAt_Least(null);
                performanceDto.setScream(null);
                performanceDto.setHowl(null);

                performanceDto.setComplete(-1);
                performanceDto.setScore(StringUtil.isNotEmpty(IndividualScore) ? Float.parseFloat(IndividualScore) : -1F);
                performanceRecordService.performanceRecord(performanceDto);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("表格格式不对！");
        }
    }

    /**
     * 非指标—利润规模
     * @param mf excel文件
     * @param year 年度
     * @param quarter 季度
     * @param operatorId 操作人ID
     * @author Max Date:2018/09/10
     */
    public void profitScaleControllerUpload(MultipartFile mf, int year, int quarter, String operatorId) {
        long elementId=999;//利润规模

        Workbook xwb = null;
        BufferedInputStream bf;
        Sheet sheet;
        String fileName = mf.getOriginalFilename();

        List<ProfitScale> profitScales = new ArrayList<>();//存储从excel得到的数据

        try {
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel 2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }

            sheet = xwb.getSheetAt(0);//获得第一个sheet，每个模板第一个sheet为要上传数据的模板

            //开始遍历excel里面所有的数据，正确的数据从第7行开始
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //每次遍历的临时存储
                ProfitScale profitScale = new ProfitScale();

                Row row = sheet.getRow(i);//得到遍历的当前行
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空");
                }

                for (int j = 0; j < 4; j++) {//一共4列
                    row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellType(CellType.STRING);
                    if (row.getCell(j).getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(row.getCell(j).getStringCellValue())) {
                        row.getCell(j).setCellValue("-1");
                    }
                }

                //遍历每行的数据，存入JavaBean里
                profitScale.setHierarchyId(row.getCell(0).getStringCellValue());//设置区域名称
                profitScale.setSecond_organization(row.getCell(1).getStringCellValue());//二级组织
                profitScale.setThird_organization(row.getCell(2).getStringCellValue());//三级组织
                profitScale.setProScale(row.getCell(3).getStringCellValue());//利润规模

                profitScales.add(profitScale);
            }

            //遍历数据分别存入score表
            for(ProfitScale profitScale:profitScales){

                String hierachyId = profitScale.getHierarchyId();
                long recordId;
                String scope = StringUtil.isNotEmpty(profitScale.getProScale())?profitScale.getProScale():"0";

                PerformanceRecord record = performanceRecordService.getRecordSelective(elementId,year,quarter,hierachyId);
                if(record != null){
                    recordId = record.getRecordId();
                    performanceRecordService.updateScope(scope,recordId);
                }else{
                    record = new PerformanceRecord(hierachyId,elementId,year,quarter);
                    record.setScope(scope);
                    performanceRecordService.insertPerformanceRecord(record);
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 月度城市公司Excel上传
     */
    public void monthlyPerformanceUpload(MultipartFile mf,long elementId,int year,int month,String operatorId) throws Exception {

        Workbook wb = null;//存放Excel对象
        BufferedInputStream bis;
        Sheet sheet;//存放第一张单
        String fileName = mf.getOriginalFilename();

        List<PerformanceMonthly> pms = new ArrayList<>();//存储从Excel得到的数据
        try{
            bis = new BufferedInputStream(mf.getInputStream());//将文件转换成流

            if(fileName.endsWith("xls")){   //Excel 2003
                wb = new HSSFWorkbook(bis);
            }else if(fileName.endsWith("xlsx")){ // Excel 2007/2010
                wb = new XSSFWorkbook(bis);
            }

            sheet = wb.getSheetAt(0);//获得第一张Sheet工作表

            Row r=sheet.getRow(1);//得到第二行
            Cell c=r.getCell(0);//得到第一列
            c.setCellType(CellType.STRING);
            if(!c.getStringCellValue().equals("城市公司编号")){
                throw new Exception();
            }

            //遍历Excel里的所有数据
            for(int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++){

                PerformanceMonthly performanceMonthly = new PerformanceMonthly();

                //得到当前行
                Row row = sheet.getRow(i);
                if(row == null){//判断当前行是否为空
                    break;
                }
                if(row.getCell(0) == null){//判断是否有城市公司Id
                    throw new Exception("第" + i + "行，城市公司Id为空");
                }

                for(int j = 0; j < 5; j++){//一共5列
                    Cell cell = row.getCell(j);
                    if(cell == null){
                        cell = row.createCell(j);
                    }
                    cell.setCellType(CellType.STRING);
                    if(cell.getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(cell.getStringCellValue())){
                        cell.setCellValue("-1");
                    }
                }
                //遍历每行的数据存到javabean中
                performanceMonthly.setHierarchyId(row.getCell(0).getStringCellValue());
                performanceMonthly.setComplete(row.getCell(3).getStringCellValue());
                performanceMonthly.setAnnualTarget(row.getCell(4).getStringCellValue());

                pms.add(performanceMonthly);
            }

            //遍历集合，存入月度表总
            for(PerformanceMonthly pm : pms){
                pm.setElementId(elementId);//设置指标编号
                pm.setYear(year);//年份
                pm.setMonth(month);//月份

                double complete = -1; //完成值默认值
                double annualTarget = -1; // 年度目标值默认值
                double completeRate = -1; //完成率默认值

                if(!StringUtil.isBlankOrEmpty(pm.getComplete())){
                    complete = Double.parseDouble(pm.getComplete());
                    if(complete < 0 && complete != -1){
                        throw new RuntimeException("完成值不能小于0");
                    }
                }

                if(!StringUtil.isBlankOrEmpty(pm.getAnnualTarget())){
                    annualTarget = Double.parseDouble(pm.getAnnualTarget());
                    if(annualTarget < 0 && annualTarget != -1){
                        throw new RuntimeException("年度目标值不能小于0");
                    }
                }

                //计算完成率
                if(complete != -1 && annualTarget != -1){
                    completeRate = Arith.div(complete,annualTarget,6);
                }

                PerformanceMonthly rperformanceMonthly = performanceMonthlyService.getSelect(pm);
                if(rperformanceMonthly == null){//新增记录
                    pm.setComplete(String.valueOf(complete));
                    pm.setAnnualTarget(String.valueOf(annualTarget));
                    pm.setCompleteRate(String.valueOf(completeRate));
                    pm.setCreatedDate(new Date());
                    pm.setCreatedBy(operatorId);
                    performanceMonthlyService.insertSelective(pm);
                }else{//更新记录
                    rperformanceMonthly.setComplete(String.valueOf(complete));
                    rperformanceMonthly.setAnnualTarget(String.valueOf(annualTarget));
                    rperformanceMonthly.setCompleteRate(String.valueOf(completeRate));
                    rperformanceMonthly.setUpdateDate(new Date());
                    rperformanceMonthly.setUpdateBy(operatorId);
                    performanceMonthlyService.updateByPrimaryKeySelective(rperformanceMonthly);
                }
            }

        }catch (Exception e){
            throw e;
        }
    }

    /**
     * 月度—区域
     * @param mf 文件
     * @param elementId 指标名称
     * @param year 年
     * @param month 月
     * @param operatorId 操作人id
     */
    public void regionMonthlyUpload(MultipartFile mf,long elementId,int year,int month,String operatorId) throws Exception{
        Workbook xwb = null;
        BufferedInputStream bf;
        Sheet sheet;
        String fileName = mf.getOriginalFilename();

        List<AllMonth> allMonths=new ArrayList<>();//存储从excel得到的数据

        try{
            bf = new BufferedInputStream(mf.getInputStream());
            if (fileName.endsWith("xls")) {     //Excel 2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }

            sheet = xwb.getSheetAt(0);//获得第一个sheet，每个模板第一个sheet为要上传数据的模板

            Row r=sheet.getRow(1);//得到第二行
            Cell c=r.getCell(0);//得到第一列
            c.setCellType(CellType.STRING);
            if(!c.getStringCellValue().equals("区域编号")){
                throw new Exception();
            }

            //开始遍历excel里面所有的数据，正确的数据从第7行开始
            for (int i = 6; i <= sheet.getPhysicalNumberOfRows(); i++) {
                //每次遍历的临时存储
                AllMonth allMonth = new AllMonth();

                Row row = sheet.getRow(i);//得到遍历的当前行
                if (row == null) {
                    break;
                }
                if (row.getCell(0) == null) {
                    throw new Exception("第" + i + "行，区域Id为空");
                }

                for(int j = 0; j < 5; j++){//一共5列
                    Cell cell = row.getCell(j);
                    if(cell == null){
                        cell = row.createCell(j);
                    }
                    cell.setCellType(CellType.STRING);
                    if(cell.getStringCellValue().equals("/") || StringUtil.isBlankOrEmpty(cell.getStringCellValue())){
                        cell.setCellValue("-1");
                    }
                }

                //遍历每行的数据，存入JavaBean里
                allMonth.setHierarchyId(row.getCell(0).getStringCellValue());//设置区域名称
                allMonth.setSecond_organization(row.getCell(1).getStringCellValue());//二级组织
                allMonth.setThird_organization(row.getCell(2).getStringCellValue());//三级组织
                allMonth.setComplete(row.getCell(3).getStringCellValue());//完成值
                allMonth.setAnnualTarget(row.getCell(4).getStringCellValue());//年度目标

                allMonths.add(allMonth);
            }

            for(AllMonth allMonth:allMonths){

                double compelete = -1;//完成值
                double annualTarget = -1;//目标值
                double completeRate = -1;//完成率

                //完成值
                if (StringUtil.isNotEmpty(allMonth.getComplete())) {
                    try {
                        compelete = Double.parseDouble(allMonth.getComplete());
                    } catch (NumberFormatException e) {
                        compelete = -1;
                    }
                }

                //目标值
                if (StringUtil.isNotEmpty(allMonth.getAnnualTarget())) {
                    try {
                        annualTarget = Double.parseDouble(allMonth.getAnnualTarget());
                    } catch (NumberFormatException e) {
                        annualTarget = -1;
                    }
                }

                //计算完成率
                if (compelete != -1 & annualTarget != -1) {
                    completeRate = Arith.div(compelete, annualTarget, 6);
                }

                //进入数据库
                //查询Performancce_monthly数据
                PerformanceMonthly performanceMonthly = new PerformanceMonthly();
                performanceMonthly.setYear(year);//年
                performanceMonthly.setMonth(month);//月
                performanceMonthly.setHierarchyId(allMonth.getHierarchyId());//区域
                performanceMonthly.setElementId(elementId);//指标
                PerformanceMonthly pValue = performanceMonthlyService.getSelect(performanceMonthly);//查询
                if (pValue != null) {
                    pValue.setComplete(String.valueOf(compelete));//完成值
                    pValue.setAnnualTarget(String.valueOf(annualTarget));//目标值
                    pValue.setCompleteRate(String.valueOf(completeRate));//完成率
                    pValue.setUpdateBy(operatorId);
                    pValue.setUpdateDate(new Date());
                    //执行更新操作
                    performanceMonthlyService.updateByPrimaryKeySelective(pValue);
                } else {
                    performanceMonthly.setComplete(String.valueOf(compelete));//完成值
                    performanceMonthly.setAnnualTarget(String.valueOf(annualTarget));//目标值
                    performanceMonthly.setCompleteRate(String.valueOf(completeRate));//完成率
                    performanceMonthly.setCreatedBy(operatorId);
                    performanceMonthly.setCreatedDate(new Date());
                    //执行插入操作
                    performanceMonthlyService.insertSelective(performanceMonthly);
                }
            }
        } catch (Exception e) {
            throw e;
        }
    }


    public void excelToObject(MultipartFile mf, String fileName, String OperatorId) {
        Workbook xwb = null;
        BufferedInputStream bf = null;
        Sheet sheet = null;


        //区域接管面积 PerformanceEnv
        HashMap<String, PerformanceEnv> oldPerformanceEnv = new HashMap<String, PerformanceEnv>();
        ArrayList<PerformanceEnv> newPerformanceEnv = new ArrayList<PerformanceEnv>();
        ArrayList<PerformanceEnv> uPerformanceEnv = new ArrayList<PerformanceEnv>();
        //目标
        HashMap<String, HashMap<String, PerformanceTarget>> oldPerformanceTarget = new HashMap<String, HashMap<String, PerformanceTarget>>();
        ArrayList<PerformanceTarget> newPerformanceTarget = new ArrayList<PerformanceTarget>();
        ArrayList<PerformanceTarget> uPerformanceTarget = new ArrayList<PerformanceTarget>();
        //值
        HashMap<String, HashMap<String, PerformanceScore>> oldPerformanceScore = new HashMap<String, HashMap<String, PerformanceScore>>();
        ArrayList<PerformanceScore> newPerformanceScore = new ArrayList<PerformanceScore>();
        ArrayList<PerformanceScore> uPerformanceScore = new ArrayList<PerformanceScore>();
        //平均分
        HashMap<String, PerformanceStatistics> oldPerformanceStatistics = new HashMap<String, PerformanceStatistics>();
        HashMap<String, PerformanceStatistics> PerformanceStatisticsMap = new HashMap<String, PerformanceStatistics>();
        ArrayList<PerformanceStatistics> newPerformanceStatistics = new ArrayList<PerformanceStatistics>();
        ArrayList<PerformanceStatistics> uPerformanceStatistics = new ArrayList<PerformanceStatistics>();

        try {
            //File file = new File("/Users/king/git/2018年1月.xlsx");
            //FileInputStream in_file = new FileInputStream(file);
            bf = new BufferedInputStream(mf.getInputStream());
            //fileName = file.getName();

            String year = fileName.split("年")[0];
//            String month = (fileName.split("年")[1]).split("季度")[0];
            String quarterly = (fileName.split("年")[1]).split("季度")[0];


//            if(fileName.endsWith("xls")){     //Excel&nbsp;2003
//            	xwb = new HSSFWorkbook(in_file);
//            }else if(fileName.endsWith("xlsx")){    // Excel 2007/2010
//            	xwb = new XSSFWorkbook(in_file);
//            }

            if (fileName.endsWith("xls")) {     //Excel&nbsp;2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) {    // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);


            //区域接管面积
            List<PerformanceEnv> PerformanceEnvlist = performanceEnvService.selectPerformanceOrgan();
            if (PerformanceEnvlist != null) {
                for (PerformanceEnv pt : PerformanceEnvlist) {
                    oldPerformanceEnv.put(pt.getHierarchyId(), pt);
                }
            }


            //目标
            PerformanceTarget spt = new PerformanceTarget();
            spt.setYear(Integer.parseInt(year));
//            spt.setMonth(Integer.parseInt(month));
            spt.setQuarterly(quarterly);
            List<PerformanceTarget> PerformanceTargetlist = performanceTargetService.selectList(spt);
            if (PerformanceTargetlist != null) {
                for (PerformanceTarget pt : PerformanceTargetlist) {
                    HashMap<String, PerformanceTarget> hm = new HashMap<String, PerformanceTarget>();
                    if (oldPerformanceTarget.containsKey(pt.getHierarchyId()))
                        hm = oldPerformanceTarget.get(pt.getHierarchyId());
                    hm.put(String.valueOf(pt.getElementId()), pt);
                    oldPerformanceTarget.put(pt.getHierarchyId(), hm);
                }
            }


            //值
            PerformanceScore sps = new PerformanceScore();
            sps.setYear(Integer.parseInt(year));
//            sps.setMonth(Integer.parseInt(month));
            sps.setQuarterly(quarterly);
            sps.setScore(Float.NaN);
            List<PerformanceScore> PerformanceScorelist = performanceScoreService.selectList(sps);
            if (PerformanceScorelist != null) {
                for (PerformanceScore pt : PerformanceScorelist) {
                    HashMap<String, PerformanceScore> hm = new HashMap<String, PerformanceScore>();
                    if (oldPerformanceScore.containsKey(pt.getHierarchyId()))
                        hm = oldPerformanceScore.get(pt.getHierarchyId());
                    hm.put(String.valueOf(pt.getElementId()), pt);
                    oldPerformanceScore.put(pt.getHierarchyId(), hm);
                }
            }


            //平均分
            PerformanceStatistics spfs = new PerformanceStatistics();
            spfs.setYear(Integer.parseInt(year));
//            spfs.setMonth(Integer.parseInt(month));
            spfs.setQuarter(quarterly);
            for (PerformanceStatistics pt : performanceStatisticsService.selectList(spfs)) {
                oldPerformanceStatistics.put(String.valueOf(pt.getElementId()), pt);
            }


            for (int i = 8; i <= sheet.getPhysicalNumberOfRows(); i++) {
                Row row = sheet.getRow(i);
                if (row == null)
                    break;
                if (row.getCell(0) == null)
                    throw new Exception("第" + i + "行，区域Id为空。");

                //区域Id
                row.getCell(0).setCellType(CellType.STRING);
                String regionid = row.getCell(0).getStringCellValue();

                //区域接管面积 PerformanceEnv
                PerformanceEnv oldPerformanceEnv1 = new PerformanceEnv();
                if (oldPerformanceEnv.containsKey(regionid)) {
                    oldPerformanceEnv1 = oldPerformanceEnv.get(regionid);
                }

                //目标
                HashMap<String, PerformanceTarget> oldPerformanceTarget1 = new HashMap<String, PerformanceTarget>();
                if (oldPerformanceTarget.containsKey(regionid)) {
                    oldPerformanceTarget1 = oldPerformanceTarget.get(regionid);
                }

                //值
                HashMap<String, PerformanceScore> oldPerformanceScore1 = new HashMap<String, PerformanceScore>();
                if (oldPerformanceScore.containsKey(regionid)) {
                    oldPerformanceScore1 = oldPerformanceScore.get(regionid);
                }


                //区域接管面积
                PerformanceEnv penv = new PerformanceEnv();
                penv.setHierarchyId(regionid);
                //接管面积
                if (row.getCell(2) != null && row.getCell(2).getCellTypeEnum() == CellType.NUMERIC) {
                    penv.setSquare(String.valueOf(row.getCell(2).getNumericCellValue()));
                }
                //利润规模
                if (row.getCell(3) != null && row.getCell(3).getCellTypeEnum() == CellType.NUMERIC) {
                    penv.setScope(String.valueOf(row.getCell(3).getNumericCellValue()));
                }

                penv.setHierarchyId(regionid);
                penv.setHierarchyName(row.getCell(1).getStringCellValue());

                if (oldPerformanceEnv1 != null && oldPerformanceEnv1.getEnvId() != null) {
                    penv.setEnvId(oldPerformanceEnv1.getEnvId());
                    //private Date updateDate;	//更新日期
                    penv.setUpdateDate(new Date());
                    //private String updateBy;	//更新人
                    penv.setUpdateBy(OperatorId);
                    uPerformanceEnv.add(penv);
                } else {
                    //private Date createdDate;	//创建日期
                    penv.setCreatedDate(new Date());
                    //private String createdBy;	//创建人
                    penv.setCreatedBy(OperatorId);
                    //private Date updateDate;	//更新日期
                    penv.setUpdateDate(new Date());
                    //private String updateBy;	//更新人
                    penv.setUpdateBy(OperatorId);
                    newPerformanceEnv.add(penv);
                }

                //总指标平均分
                PerformanceStatistics psts = new PerformanceStatistics();
                if (PerformanceStatisticsMap.containsKey("0")) {
                    psts = PerformanceStatisticsMap.get("0");
                } else {
                    psts.setQuarter(quarterly);
                    psts.setYear(Integer.valueOf(year));
                    psts.setElementId((long) 0);
                }
                Float avgScore = Float.parseFloat(String.valueOf(row.getCell(5).getNumericCellValue()));
                Float actualAvgScore = Float.parseFloat(String.valueOf(row.getCell(8).getNumericCellValue()));
                psts.setAverageScore(psts.getAverageScore() == Float.NaN ? avgScore : (psts.getAverageScore() * (i - 8) + avgScore) / (i - 7));
                psts.setActualAverageScore(psts.getActualAverageScore() == Float.NaN ? actualAvgScore : (psts.getActualAverageScore() * (i - 8) + actualAvgScore) / (i - 7));
                PerformanceStatisticsMap.put("0", psts);


                //目标
                for (String key : PerformanceTarget.keySet()) {
                    HashMap<String, HashMap<String, Integer>> pt = PerformanceTarget.get(key);
                    int total = pt.size();
                    int index = 0;
                    for (String key1 : pt.keySet()) {
                        ++index;
                        HashMap<String, Integer> pt1 = pt.get(key1);
                        PerformanceTarget npt = new PerformanceTarget();
                        //private Long targetId;	//目标编号
                        //private Long elementId;	//指标编号
                        npt.setElementId(Long.parseLong(key));
                        //private String thresholdTarget;	//门槛值目标值
                        if (pt1.containsKey("门槛值") && row.getCell(pt1.get("门槛值")) != null && row.getCell(pt1.get("门槛值")).getCellTypeEnum() == CellType.NUMERIC) {
                            npt.setThresholdTarget(String.valueOf(row.getCell(pt1.get("门槛值")).getNumericCellValue()));
                        }
                        //private String atLeastTarget;	//保底目标值
                        if (pt1.containsKey("保底") && row.getCell(pt1.get("保底")) != null && row.getCell(pt1.get("保底")).getCellTypeEnum() == CellType.NUMERIC) {
                            npt.setAtLeastTarget(String.valueOf(row.getCell(pt1.get("保底")).getNumericCellValue()));
                        }
                        //private String screamTarget;	//尖叫目标值
                        if (pt1.containsKey("尖叫") && row.getCell(pt1.get("尖叫")) != null && row.getCell(pt1.get("尖叫")).getCellTypeEnum() == CellType.NUMERIC) {
                            npt.setScreamTarget(String.valueOf(row.getCell(pt1.get("尖叫")).getNumericCellValue()));
                        }
                        //private String howlTarget;	//嚎叫目标值
                        if (pt1.containsKey("嚎叫") && row.getCell(pt1.get("嚎叫")) != null && row.getCell(pt1.get("嚎叫")).getCellTypeEnum() == CellType.NUMERIC) {
                            npt.setHowlTarget(String.valueOf(row.getCell(pt1.get("嚎叫")).getNumericCellValue()));
                        }
                        //private String hierarchy;	//层级（区域/项目）
                        npt.setHierarchy("区域");
                        //private String hierarchyId;	//层级id
                        npt.setHierarchyId(regionid);


                        if (PerformanceFrequency.containsKey(key)) {
                            //private String frequency;	//考核频率
                            npt.setFrequency(PerformanceFrequency.get(key).get("考核频率"));
                            //private Integer weight;	//权重
                            npt.setWeight(Double.parseDouble(PerformanceFrequency.get(key).get("权重")));
                        }


                        //private Integer year;	//年份
                        npt.setYear(Integer.parseInt(year));
                        //private Integer month;	//月份
                        //if(total == 1)
                        {
//            				npt.setMonth(Integer.parseInt(month));
                            npt.setQuarterly(quarterly);
                        }

                        //private String isCheck;	//是否考核
                        if (pt1.containsKey("是否考核") && row.getCell(pt1.get("是否考核")) != null) {
                            row.getCell(pt1.get("是否考核")).setCellType(CellType.STRING);
                            npt.setIsCheck(String.valueOf(row.getCell(pt1.get("是否考核")).getStringCellValue()));
                        }

                        if (oldPerformanceTarget1.containsKey(key)) {
                            npt.setTargetId(oldPerformanceTarget1.get(key).getTargetId());
                            //private Date updateDate;	//更新日期
                            npt.setUpdateDate(new Date());
                            //private String updateBy;	//更新人
                            npt.setUpdateBy(OperatorId);
                            uPerformanceTarget.add(npt);
                        } else {
                            //private Date createdDate;	//创建日期
                            npt.setCreatedDate(new Date());
                            //private String createdBy;	//创建人
                            npt.setCreatedBy(OperatorId);
                            //private Date updateDate;	//更新日期
                            npt.setUpdateDate(new Date());
                            //private String updateBy;	//更新人
                            npt.setUpdateBy(OperatorId);
                            newPerformanceTarget.add(npt);
                        }
                    }
                }


                //总分
                PerformanceScore totalScore = new PerformanceScore();
                totalScore.setElementId((long) 0);
                totalScore.setHierarchyId(regionid);
                totalScore.setScore(Float.parseFloat(String.valueOf(row.getCell(5).getNumericCellValue())));
                totalScore.setActualScore(Float.parseFloat(String.valueOf(row.getCell(8).getNumericCellValue())));
                totalScore.setYear(Integer.valueOf(year));
//            	totalScore.setMonth(Integer.valueOf(month));
                totalScore.setQuarterly(quarterly);
                if (oldPerformanceScore1.containsKey("0")) {
                    totalScore.setScoreId(oldPerformanceScore1.get("0").getScoreId());
                    //private Date updateDate;	//更新日期
                    totalScore.setUpdateDate(new Date());
                    //private String updateBy;	//更新人
                    totalScore.setUpdateBy(OperatorId);
                    uPerformanceScore.add(totalScore);
                } else {
                    //private Date createdDate;	//创建日期
                    totalScore.setCreatedDate(new Date());
                    //private String createdBy;	//创建人
                    totalScore.setCreatedBy(OperatorId);
                    //private Date updateDate;	//更新日期
                    totalScore.setUpdateDate(new Date());
                    //private String updateBy;	//更新人
                    totalScore.setUpdateBy(OperatorId);
                    newPerformanceScore.add(totalScore);
                }
                //总指标目标——用于保存
                PerformanceTarget totalTarget = new PerformanceTarget();
//				totalTarget.setMonth(Integer.valueOf(month));
                totalTarget.setQuarterly(quarterly);
                totalTarget.setYear(Integer.valueOf(year));
                totalTarget.setElementId((long) 0);
                totalTarget.setHierarchyId(regionid);
                if (oldPerformanceTarget1.containsKey("0")) {
                    totalTarget.setTargetId(oldPerformanceTarget1.get("0").getTargetId());
                    //private Date updateDate;	//更新日期
                    totalTarget.setUpdateDate(new Date());
                    //private String updateBy;	//更新人
                    totalTarget.setUpdateBy(OperatorId);
                    uPerformanceTarget.add(totalTarget);
                } else {
                    //private Date createdDate;	//创建日期
                    totalTarget.setCreatedDate(new Date());
                    //private String createdBy;	//创建人
                    totalTarget.setCreatedBy(OperatorId);
                    //private Date updateDate;	//更新日期
                    totalTarget.setUpdateDate(new Date());
                    //private String updateBy;	//更新人
                    totalTarget.setUpdateBy(OperatorId);
                    newPerformanceTarget.add(totalTarget);
                }


                for (String key : PerformanceScore.keySet()) {
                    HashMap<String, HashMap<String, Integer>> pfs = PerformanceScore.get(key);
                    int total = pfs.size();
                    int index = 0;
                    for (String key1 : pfs.keySet()) {
                        ++index;

                        HashMap<String, Integer> pt1 = pfs.get(key1);
                        PerformanceScore npfs = new PerformanceScore();
                        //private Long scoreId;	//得分编号
                        //private Long elementId;	//指标编号
                        npfs.setElementId(Long.parseLong(key));
                        //private Integer score;	//二级指标为细项得分，一级为单项得分
                        if (pt1.containsKey("指标单项得分") && row.getCell(pt1.get("指标单项得分")) != null && row.getCell(pt1.get("指标单项得分")).getCellTypeEnum() == CellType.NUMERIC) {
                            //row.getCell(pt1.get("指标单项得分")).setCellType(CellType.STRING);
                            npfs.setScore(Float.parseFloat(String.valueOf(row.getCell(pt1.get("指标单项得分")).getNumericCellValue())));


                            PerformanceStatistics pfsi = new PerformanceStatistics();

                            if (PerformanceStatisticsMap.containsKey(key)) {
                                pfsi = PerformanceStatisticsMap.get(key);
                            }

                            //private Long elementId;	//指标编号
                            pfsi.setElementId(Long.parseLong(key));
                            //private Integer year;	//年份
                            pfsi.setYear(Integer.parseInt(year));
                            //private Integer month;	//月份
//                			pfsi.setMonth(Integer.parseInt(month));
                            pfsi.setQuarter(quarterly);

                            //private Integer quarterly;	//季度


                            //private float averageScore;	//平均分
                            pfsi.setAverageScore(pfsi.getAverageScore() == Float.NaN ? npfs.getScore() : (pfsi.getAverageScore() * (i - 8) + npfs.getScore()) / (i - 7));

                            PerformanceStatisticsMap.put(key, pfsi);

                        }
                        //private Integer actualScore;	//加权得分
                        if (pt1.containsKey("指标加权得分") && row.getCell(pt1.get("指标加权得分")) != null && row.getCell(pt1.get("指标加权得分")).getCellTypeEnum() == CellType.NUMERIC) {
                            npfs.setActualScore(Float.parseFloat(String.valueOf(row.getCell(pt1.get("指标加权得分")).getNumericCellValue())));
                        }

                        //private BigDecimal complete;	//完成值
                        if (pt1.containsKey("完成值") && row.getCell(pt1.get("完成值")) != null && row.getCell(pt1.get("完成值")).getCellTypeEnum() == CellType.NUMERIC) {
                            npfs.setComplete(Float.parseFloat((String.valueOf(row.getCell(pt1.get("完成值")).getNumericCellValue()))));
                        }
                        //private String type;	//数值，百分比型
                        if (npfs.getComplete() != Float.NaN) {
                            npfs.setType(Math.abs(npfs.getComplete()) >= 0 ? "数值" : "百分比型");
                        }
                        //private Integer squareNo;	//方阵序号
                        if (pt1.containsKey("方阵序号") && row.getCell(pt1.get("方阵序号")) != null) {
                            npfs.setSquareNo((String.valueOf(row.getCell(pt1.get("方阵序号")).getStringCellValue())));
                        }
                        //private Integer year;	//年份
                        npfs.setYear(Integer.parseInt(year));

                        //int Quarterly = Integer.parseInt(key1.substring(key1.length() - 1));

                        //private Integer month;	//月份
                        //if(total == 1)
                        {
//            				npfs.setMonth(Integer.parseInt(month));
                            npfs.setQuarterly(quarterly);
                        }
                        //private Integer quarterly;	//季度
//            			else if(total == 2)
//            			{
//            				npfs.setYearly_score(Quarterly);
//            			}
//            			else
//            			{
//            				if(Quarterly < 5)
//            				{
//            					npfs.setQuarterly(index);
//            				}
//            				else
//            				{
//            					npfs.setYearly_score(2);
//            				}
//
//            			}
                        //private String hierarchy;	//层级（区域/项目）
                        npfs.setHierarchy("区域");
                        //private String hierarchyId;	//层级id
                        npfs.setHierarchyId(regionid);

                        if (oldPerformanceScore1.containsKey(key)) {
                            npfs.setScoreId(oldPerformanceScore1.get(key).getScoreId());
                            //private Date updateDate;	//更新日期
                            npfs.setUpdateDate(new Date());
                            //private String updateBy;	//更新人
                            npfs.setUpdateBy(OperatorId);
                            uPerformanceScore.add(npfs);
                        } else {
                            //private Date createdDate;	//创建日期
                            npfs.setCreatedDate(new Date());
                            //private String createdBy;	//创建人
                            npfs.setCreatedBy(OperatorId);
                            //private Date updateDate;	//更新日期
                            npfs.setUpdateDate(new Date());
                            //private String updateBy;	//更新人
                            npfs.setUpdateBy(OperatorId);
                            newPerformanceScore.add(npfs);
                        }
                    }
                }

            }

            //平均分
            if (PerformanceStatisticsMap.size() > 0) {
                for (String key : PerformanceStatisticsMap.keySet()) {
                    PerformanceStatistics pts = PerformanceStatisticsMap.get(key);
                    if (oldPerformanceStatistics.containsKey(key)) {
                        pts.setStatisticsId(oldPerformanceStatistics.get(key).getStatisticsId());
                        //private Date updateDate;	//更新日期
                        pts.setUpdateDate(new Date());
                        //private String updateBy;	//更新人
                        pts.setUpdateBy(OperatorId);
                        uPerformanceStatistics.add(pts);
                    } else {
                        //private Date createdDate;	//创建日期
                        pts.setCreatedDate(new Date());
                        //private String createdBy;	//创建人
                        pts.setCreatedBy(OperatorId);
                        //private Date updateDate;	//更新日期
                        pts.setUpdateDate(new Date());
                        //private String updateBy;	//更新人
                        pts.setUpdateBy(OperatorId);
                        newPerformanceStatistics.add(pts);
                    }
                }
            }

            //区域接管面积
            if (newPerformanceEnv.size() > 0)
                performanceEnvService.insertEnvList(newPerformanceEnv);
            if (uPerformanceEnv.size() > 0)
                performanceEnvService.updateEnvList(uPerformanceEnv);
            //目标
            if (newPerformanceTarget.size() > 0)
                performanceTargetService.insertTargetList(newPerformanceTarget);
            if (uPerformanceTarget.size() > 0)
                performanceTargetService.updateTargetList(uPerformanceTarget);

            //值
            if (newPerformanceScore.size() > 0)
                performanceScoreService.insertScoreList(newPerformanceScore);
            if (uPerformanceScore.size() > 0)
                performanceScoreService.updateScoreList(uPerformanceScore);
            //平均分
            if (newPerformanceStatistics.size() > 0)
                performanceStatisticsService.insertStatisticsList(newPerformanceStatistics);
            if (uPerformanceStatistics.size() > 0)
                performanceStatisticsService.updateStatisticsList(uPerformanceStatistics);
        } catch (Exception e) {
            e.printStackTrace();
            e.getMessage();
            throw new RuntimeException(e);
        }


    }


    public static void main(String[] args) {
        try {
            //            File file = new File("E:\\123.xlsx");
            //            FileInputStream in_file = new FileInputStream(file);
            ExcelAnalysis exa = new ExcelAnalysis();
            exa.excelToObject(null, "123.xlsx", "12345678");
        } catch (Exception e) {

        }
    }

}
