package cn.com.countrygarden.bi.main.controller.performance.indicators;

import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.exception.ServiceException;
import cn.com.countrygarden.bi.main.model.AccessToken;
import cn.com.countrygarden.bi.main.model.performance.*;
import cn.com.countrygarden.bi.main.service.AccessTokenService;
import cn.com.countrygarden.bi.main.service.performance.PerformanceEnvService;
import cn.com.countrygarden.bi.main.service.performance.PerformanceScoreService;
import cn.com.countrygarden.bi.main.util.Calculate;

import cn.com.countrygarden.bi.main.util.ExcelAnalysis;
import cn.com.countrygarden.bi.main.util.PerformancePower;
import cn.com.countrygarden.bi.main.util.erp.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

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

//物业服务费收缴率1003 综合收缴率:1003001  已收楼收缴率（综合）:1003002 已收楼收缴率（外拓）:1003003

/**
 * 物业服务费收缴率
 *
 * @author zhaolie
 * @date 2018年6月12日
 */
@Controller("GetPropertyCostsController")
@RequestMapping("/GetPropertyCostsController")
public class GetPropertyCostsController {
    @Autowired
    private cn.com.countrygarden.bi.main.service.performance.PerformanceTargetService PerformanceTargetService;
    @Autowired
    private PerformanceEnvService performanceEnvService;
    @Autowired
    private PerformanceScoreService performanceScoreService;

    @Autowired
    private AccessTokenService accessTokenService;

    @Autowired
    private ExcelAnalysis ea;

    @Autowired
    private  PerformancePower performancePower;

    private static final Logger LOGGER = LoggerFactory.getLogger(GetPropertyCostsController.class);

    @ResponseBody
    @RequestMapping(value = "/showPropertyCosts", method = {RequestMethod.POST, RequestMethod.GET})
    public Object showPropertyCosts(@RequestParam(value = "pageSize") int pageSize, @RequestParam(value = "pageCurr") int pageCurr, @RequestParam(value = "years") int year
            , @RequestParam(value = "quarterly") String quarterly) {
        Map<String, Object> returnMap = new HashMap<>();
        long elementId1 = 1003;//物业服务费收缴率1003 id 写死
        long elementId2 = 1003001;//综合收缴率 写死
        long elementId3 = 1003002;//综合已收楼收缴率
        long elementId4 = 1003003;//已收楼收缴率(外拓)id 写死

        List<GetPropertyCosts> returnList = new ArrayList<GetPropertyCosts>();//初始化list 用来存东西

        PerformanceScore score = new PerformanceScore();//分数
        PerformanceScore sValue = new PerformanceScore();

        PerformanceTarget target = new PerformanceTarget();//目标值
        PerformanceTarget tValue = new PerformanceTarget();//目标值中间量

        try {

            List<PerformanceEnv> envList = performanceEnvService.selectPerformanceOrgan();
            int count = envList.size();
            int start = (pageCurr - 1) * pageSize;
            int end = pageCurr * pageSize;
            envList = envList.subList(start < 0 ? 0 : start, end >= count ? count : end);

            //查询多少条数据是录入的
            PerformanceScore performanceScore = new PerformanceScore();
            performanceScore.setYear(year);//年
            performanceScore.setQuarterly(quarterly);//季度
            performanceScore.setElementId(elementId1);
            int vacancy = count - performanceScoreService.getTotalPage(performanceScore).getTotalPage();//空缺，还有多少个区域指标没填
            if (vacancy < 0) {
                vacancy = 0;
            }
            List<String> vacancyHierarchyName = performanceEnvService.selectNotInName(performanceScore);

            //遍历  插入到bean
            for (PerformanceEnv performanceEnv : envList) {
                GetPropertyCosts g = new GetPropertyCosts();//bean
                ////////////下面设置区域的 中文名
                String hierarchyId = performanceEnv.getHierarchyId();
                g.setHierarchyId(hierarchyId);
                g.setThird_organization(performanceEnv.getHierarchyName());//插入区域名字
                g.setSecond_organization(performanceEnv.getHierarchyName());//插入区域名字
                g.setYear(String.valueOf(year));
                g.setQuarter(quarterly);

                //综合收缴率
                target.setElementId(elementId2);//综合的id
                target.setHierarchyId(performanceEnv.getHierarchyId());//设置区域id
                target.setYear(year);//设置年份
                target.setQuarterly(quarterly);//设置季度
                tValue = PerformanceTargetService.getNewByHierarchyId(target);//查询改id 该区域，该年度，该季度的数据
                if (tValue != null) {
                    g.setThreshold(tValue.getThresholdTarget());//bean插入门槛
                    g.setAtLeast(tValue.getAtLeastTarget());//bean插入低保
                    g.setScream(tValue.getScreamTarget());//bean插入尖叫
                    g.setHowl((tValue.getHowlTarget()));//bean插入嚎叫
                }

                //////////////////////////////////////////查询该区域，该id，该年度，该季度的得分
                score.setElementId(elementId2);//设置 id给得分
                score.setHierarchyId(g.getHierarchyId());//区域id给得分
                score.setYear(year);//设置年份
                score.setQuarterly(quarterly);//设置季度
                sValue = performanceScoreService.getscoreByHierarchyId(score);//查询这个区域的得分
                if (sValue != null) {
                    g.setComplete_Value(String.valueOf(sValue.getComplete()));//完成值插入
                    g.setScore(String.valueOf(sValue.getScore()));//细项得分
                }
                ////////////////////////////////////综合满意率数据填好
                //以下是综合已收楼收缴率

                target.setElementId(elementId3);//指标id
                score.setElementId(elementId3);//设置 id给得分


                //S1-S4综合收缴率
                //@Author:Geoffrey
                //[start]
                for (int j = 1; j < 5; j++) {
                    target.setQuarterly(String.valueOf(j));
                    score.setQuarterly(String.valueOf(j));//季度

                    tValue = PerformanceTargetService.getNewByHierarchyId(target);//查出该id，该区域，该年度，该年份的目标值
                    sValue = performanceScoreService.getscoreByHierarchyId(score);//查询这个区域的得分
                    if (tValue != null && sValue != null) {
                        if (j == 1) {
                            g.setS1_threshold(tValue.getThresholdTarget());//插入门槛
                            g.setS1_atLeast(tValue.getAtLeastTarget());//插入低保
                            g.setS1_scream(tValue.getScreamTarget());//插入尖叫
                            g.setS1_howl(tValue.getHowlTarget());//插入嚎叫
                            g.setS1_Complete_Value(String.valueOf(sValue.getComplete())); //完成值
                            g.setS1_score(String.valueOf(sValue.getScore()));//得分
                        }
                        if (j == 2) {
                            g.setS2_threshold(tValue.getThresholdTarget());//插入门槛
                            g.setS2_atLeast(tValue.getAtLeastTarget());//插入低保
                            g.setS2_scream(tValue.getScreamTarget());//插入尖叫
                            g.setS2_howl(tValue.getHowlTarget());//插入嚎叫
                            g.setS2_Complete_Value(String.valueOf(sValue.getComplete())); //完成值
                            g.setS2_score(String.valueOf(sValue.getScore()));//得分
                        }
                        if (j == 3) {
                            g.setS3_threshold(tValue.getThresholdTarget());//插入门槛
                            g.setS3_atLeast(tValue.getAtLeastTarget());//插入低保
                            g.setS3_scream(tValue.getScreamTarget());//插入尖叫
                            g.setS3_howl(tValue.getHowlTarget());//插入嚎叫
                            g.setS3_Complete_Value(String.valueOf(sValue.getComplete())); //完成值
                            g.setS3_score(String.valueOf(sValue.getScore()));//得分
                        }
                        if (j == 4) {
                            g.setS4_threshold(tValue.getThresholdTarget());//插入门槛
                            g.setS4_atLeast(tValue.getAtLeastTarget());//插入低保
                            g.setS4_scream(tValue.getScreamTarget());//插入尖叫
                            g.setS4_howl(tValue.getHowlTarget());//插入嚎叫
                            g.setS4_Complete_Value(String.valueOf(sValue.getComplete())); //完成值
                            g.setS4_score(String.valueOf(sValue.getScore()));//得分
                        }
                    }
                }
                //[end]

                //修改外拓年度半年度展示  12季度展示到半年度，年度部分为空；34季度展示到年度，半年度部分展示2季度数据
                //[start]
                if (Integer.parseInt(quarterly) <= 2) {
                    //查询半年度的数据  外拓
                    score.setElementId(elementId4);//设置 id给得分
                    score.setQuarterly(quarterly);//季度
                    sValue = performanceScoreService.getscoreByHierarchyId(score);//查询这个区域的得分

                    target.setElementId(elementId4);
                    target.setQuarterly(quarterly);//季度
                    tValue = PerformanceTargetService.getNewByHierarchyId(target);
                    if (tValue != null) {
                        g.setHY_threshold(tValue.getThresholdTarget());//门槛
                        g.setHY_atLeast(tValue.getAtLeastTarget());//保底
                        g.setHY_scream(tValue.getScreamTarget());//尖叫
                        g.setHY_howl(tValue.getHowlTarget());//傲叫

                        g.setAL_threshold(tValue.getThresholdTarget());//门槛
                        g.setAL_atLeast(tValue.getAtLeastTarget());//保底
                        g.setAL_scream(tValue.getScreamTarget());//尖叫
                        g.setAL_howl(tValue.getHowlTarget());//傲叫
                    }
                    //给半年的入分
                    if (sValue != null) {
                        g.setHY_Complete_Value(String.valueOf(sValue.getComplete()));
                        g.setHY_score(String.valueOf(sValue.getScore()));

                        g.setAL_Complete_Value(String.valueOf(sValue.getComplete()));
                        g.setAL_score(String.valueOf(sValue.getScore()));
                    }
                } else {
                    //查询半年度的数据  外拓
                    score.setElementId(elementId4);//设置 id给得分
                    score.setQuarterly("2");//季度
                    sValue = performanceScoreService.getscoreByHierarchyId(score);//查询这个区域的得分


                    target.setElementId(elementId4);
                    target.setQuarterly("2");//季度
                    tValue = PerformanceTargetService.getNewByHierarchyId(target);
                    if (tValue != null) {
                        g.setHY_threshold(tValue.getThresholdTarget());//门槛
                        g.setHY_atLeast(tValue.getAtLeastTarget());//保底
                        g.setHY_scream(tValue.getScreamTarget());//尖叫
                        g.setHY_howl(tValue.getHowlTarget());//傲叫
                    }
                    //给半年的入分
                    if (sValue != null) {
                        g.setHY_Complete_Value(String.valueOf(sValue.getComplete()));
                        g.setHY_score(String.valueOf(sValue.getScore()));
                    }


                    //年度外拓收缴率
                    score.setElementId(elementId4);//设置 id给得分
                    score.setQuarterly(quarterly);//设置全年的
                    sValue = performanceScoreService.getscoreByHierarchyId(score);//查询这个区域的得分

                    target.setElementId(elementId4);
                    target.setQuarterly(quarterly);//季度
                    tValue = PerformanceTargetService.getNewByHierarchyId(target);

                    if (tValue != null) {
                        g.setAL_threshold(tValue.getThresholdTarget());//门槛
                        g.setAL_atLeast(tValue.getAtLeastTarget());//保底
                        g.setAL_scream(tValue.getScreamTarget());//尖叫
                        g.setAL_howl(tValue.getHowlTarget());//傲叫
                    }

                    if (sValue != null) {
                        g.setAL_Complete_Value(String.valueOf(sValue.getComplete()));
                        g.setAL_score(String.valueOf(sValue.getScore()));
                    }
                }
                //[end]

                //////////////查询单项指标得分
                score.setElementId(elementId1);//设置id拿得分
                score.setQuarterly(quarterly);//季度
                sValue = performanceScoreService.getscoreByHierarchyId(score);//查询这个区域的得分
                if (sValue != null) {
                    g.setIndividualScore(String.valueOf(sValue.getScore()));
                }

                //////////////////是否考核

                target.setElementId(elementId1);
                target.setQuarterly(quarterly);
                tValue = PerformanceTargetService.getNewByHierarchyId(target);
                if (tValue != null) {
                    g.setIs_check(tValue.getIsCheck().equals("1") ? 1 : 0);
                } else {
                    g.setIs_check(1);
                }
                ////////////////////////////////////////
                returnList.add(g);
            }

            returnMap.put("totalPage", count);
            returnMap.put("list", returnList);
            returnMap.put("vacancy", vacancy);
            returnMap.put("vacancyHierarchyName", vacancyHierarchyName);//无指标区域名称
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Response.response(returnMap);

    }

    /**
     * 重构物业服务收缴率自动计算方法
     *
     * @ModifiedBy Geoffrey
     * @Date 2018/7/8 21:35
     */

    @ResponseBody
    @RequestMapping(value = "/showPropertyCostsCal", method = {RequestMethod.POST, RequestMethod.GET})
    public Object showPropertyCostsCal(@RequestBody List<GetPropertyCosts> GetPropertyCosts) {
        Map<String, Object> resultMap = new HashMap<>();
        List<GetPropertyCosts> resultList = new ArrayList<>();

        long elementId1 = 1003;//物业服务费收缴率1003 id 写死
        long elementId2 = 1003001;//综合收缴率 写死
        long elementId3 = 1003002;//综合已收楼收缴率
        long elementId4 = 1003003;//已收楼收缴率(外拓)id 写死
        PerformanceScore score = new PerformanceScore();//初始化分数对象,查询和插入使用
        PerformanceScore sValue = new PerformanceScore();//查询结果和更新对象使用
        PerformanceTarget target = new PerformanceTarget();
        PerformanceTarget tValue = new PerformanceTarget();

        for (GetPropertyCosts propertyCost : GetPropertyCosts) {

            String hierarchyId = propertyCost.getHierarchyId();
            String year = propertyCost.getYear();
            String quarter = propertyCost.getQuarter();

            //综合收缴率
            double complete = -1;   // 完成值
            double threshold = -1;  // 门槛值
            double atLeast = -1;    // 保底
            double scream = -1;     // 尖叫
            double howl = -1;       // 嚎叫


            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 = {"-1", "-1", "-1", "-1", "-1", "-1", "-1"};

            score.setHierarchyId(hierarchyId);//按这个区域插
            score.setYear(Integer.parseInt(year));//按年度

            target.setHierarchyId(hierarchyId);
            target.setYear(Integer.valueOf(year));

            //用来从switch中跳出循环的标记,java goto不能用 = =,
            label:
            for (int i = 0; i < 7; i++) {       //综合、S1-S4、两个外拓 一共7个,除了指标编号、季度有区别，其他的没啥区别

                switch (i) {
                    case 0: {           //综合
                        score.setElementId(elementId2);
                        target.setElementId(elementId2);
                        score.setQuarterly(quarter);
                        target.setQuarterly(quarter);
                        break;
                    }
                      /*
                    这个外拓收入的处理逻辑是这样的:
                    1、2季度的，更新到半年度的地方，也就是element_id = 1003003  quarter = 1 or 2;
                    1、2、3、4季度的更新到年度的地方                    */
                    case 5: {           //外拓半年
                        String q = String.valueOf(quarter);
                        if (Integer.parseInt(quarter) > 2) {
                            q = "2";
                        }
                        score.setElementId(elementId4);
                        target.setElementId(elementId4);
                        score.setQuarterly(q);
                        target.setQuarterly(q);
                        break;
                    }
                    case 6: {           //外拓年度
                        score.setElementId(elementId4);
                        target.setElementId(elementId4);
                        score.setQuarterly(quarter);
                        target.setQuarterly(quarter);
                        break;
                    }
                    default: {          //S1-S4
                        score.setElementId(elementId3);
                        target.setElementId(elementId3);
                        score.setQuarterly(String.valueOf(i));
                        target.setQuarterly(String.valueOf(i));
                        break;
                    }
                }

                if (!StringUtil.isBlankOrEmpty(completes[i])) {
                    try {
                        complete = Double.parseDouble(completes[i]);    // 完成值
                        atLeast = Double.parseDouble(atLasts[i]);       //  保底
                        scream = Double.parseDouble(screams[i]);        // :尖叫
                        howl = Double.parseDouble(howls[i]);            // :嚎叫
                    } catch (NumberFormatException e) {
                        //输入数据有误 直接return error不合适，计算成0值返回，各目标值初始化为-1
                        LOGGER.error("目标值输入有误：{},{},{},{}", completes[i], atLasts[i], screams[i], howls[i]);
                    }

                    // 计算出细项目得分综合收费，放入数组中，不设置门槛值
                    scores[i] = Calculate.InsertionMethod(complete, -1, atLeast, scream, howl, 1);

                    //插入计算的数据，和实际值
                    sValue = performanceScoreService.getscoreByHierarchyId(score);//查询有没有这条记录
                    if (sValue != null) {
                        sValue.setComplete((float) complete);//插入实际值：就是完成值
                        sValue.setScore(Float.parseFloat(scores[i])); //综合收缴率细项得分
                        performanceScoreService.updateScoreSelective(sValue);
                    } else {
                        score.setComplete((float) complete);//插入实际值：就是完成值
                        score.setScore(Float.parseFloat(scores[i])); //综合收缴率细项得分
                        performanceScoreService.insertScoreSelective(score);

                    }

                    //更新目标值
                    tValue = PerformanceTargetService.getByHierarchyId(target);
                    if (tValue != null) {
                        tValue.setThresholdTarget(String.valueOf(atLeast));  //没有门槛值，门槛值跟保底值相等
                        tValue.setAtLeastTarget(String.valueOf(atLeast));
                        tValue.setScreamTarget(String.valueOf(scream));
                        tValue.setHowlTarget(String.valueOf(howl));
                        PerformanceTargetService.updateTargetSelective(tValue);
                    } else {
                        target.setThresholdTarget(String.valueOf(atLeast));  //没有门槛值，门槛值跟保底值相等
                        target.setAtLeastTarget(String.valueOf(atLeast));
                        target.setScreamTarget(String.valueOf(scream));
                        target.setHowlTarget(String.valueOf(howl));
                        PerformanceTargetService.insertTargetSelective(target);
                    }
                }
            }

            String ZH_score = scores[0];
            //综合收缴率:细项目得分
            String S1_score = scores[1];
            // S1综合已收楼缴率:细项目得分
            String S2_score = scores[2];
            // S2综合已收楼缴率:细项目得分
            String S3_score = scores[3];
            // S3综合已收楼缴率:细项目得分
            String S4_score = scores[4];
            // S4综合已收楼缴率:细项目得分
            String HY_score = scores[5];
            // 上半年外拓已收楼收缴率:细项目得分
            String AL_score = scores[6];
            // 年度外拓已收楼收缴率:细项目得分
            String IndividualScore = "-1";     //指标总得分


            propertyCost.setScore(ZH_score);
            propertyCost.setS1_score(S1_score);
            propertyCost.setS2_score(S2_score);
            propertyCost.setS3_score(S3_score);
            propertyCost.setS4_score(S4_score);
            propertyCost.setHY_score(HY_score);
            propertyCost.setAL_score(AL_score);



            //////////////根据权重计算年度（外拓值）
            ////////计算指标单项得分
            IndividualScore = Calculate.getCostIndividualScore(ZH_score, S1_score, S2_score, S3_score, S4_score, HY_score);


            //以下插入计算结果，先查询是否存在同样数据是的update，否则insert
            score.setElementId(elementId1);//按这个指标插入
            score.setQuarterly(quarter);//第几季度

            score.setScore(-1);
            score.setComplete(-1);
            sValue = performanceScoreService.getscoreByHierarchyId(score);//查询有没有这条记录
            if (sValue != null) {
                sValue.setScore(Float.parseFloat(IndividualScore));//插入的细项得分
                performanceScoreService.updateScoreSelective(sValue);
            } else {
                score.setScore(Float.parseFloat(IndividualScore));//插入的细项得分
                performanceScoreService.insertScoreSelective(score);
            }
            target.setElementId(elementId1);
            target.setQuarterly(quarter);

            target.setThresholdTarget(null);
            target.setAtLeastTarget(null);
            target.setScreamTarget(null);
            target.setHowlTarget(null);
            tValue = PerformanceTargetService.getNewByHierarchyId(target);
            if (tValue != null) {

                tValue.setIsCheck(String.valueOf(propertyCost.getIs_check()));
                PerformanceTargetService.updateTargetSelective(tValue);
            } else {
                tValue.setWeight(0.1);
                target.setIsCheck(String.valueOf(propertyCost.getIs_check()));
                PerformanceTargetService.insertTargetSelective(target);
            }
            //回传计算后的值
            propertyCost.setIndividualScore(IndividualScore);
        }
        resultMap.put("list", GetPropertyCosts);
        List<PerformanceEnv> envList = performanceEnvService.selectPerformanceOrgan();
        int count = envList.size();
        PerformanceScore performanceScore = new PerformanceScore();
        performanceScore.setYear(Integer.parseInt(GetPropertyCosts.get(0).getYear()));//年
        performanceScore.setQuarterly(GetPropertyCosts.get(0).getQuarter());//季度
        performanceScore.setElementId(elementId1);
        int vacancy = count - performanceScoreService.getTotalPage(performanceScore).getTotalPage();//空缺，还有多少个区域指标没填
        if (vacancy < 0) {
            vacancy = 0;
        }
        performanceScoreService.saveQuartlyAverageScoreAndSumScore(Integer.parseInt(GetPropertyCosts.get(0).getYear()), Integer.parseInt(GetPropertyCosts.get(0).getQuarter()));
        resultMap.put("vacancy", vacancy);//设置空缺数据
        List<String> vacancyHierarchyName = performanceEnvService.selectNotInName(performanceScore);
        resultMap.put("vacancyHierarchyName", vacancyHierarchyName);//无指标区域名称
        return Response.response(resultMap);
    }


    @ResponseBody
    @RequestMapping(value = "/upload", produces = "application/json;charset=utf-8", method = RequestMethod.POST)
    public Result upload(@RequestParam(value = "year") int year, @RequestParam(value = "quarter") int quarter,
                         @RequestParam(value = "name") String name,
                         @RequestParam(value = "uploadfile", required = true) MultipartFile multipartFile,
                         HttpServletRequest request, HttpServletResponse response) throws ServiceException {
        String accessToken = request.getParameter("AccessToken");
        AccessToken token = accessTokenService.findByToken(accessToken);
        if (multipartFile == null) {
            return Response.responseFail("请选择需要上传的文件");
        } else if (name == null) {
            return Response.responseFail("请输入文件名");
        }
        CommonsMultipartFile commonsMultipartFile = (CommonsMultipartFile) multipartFile;
        if (commonsMultipartFile.isEmpty()) {
            return Response.responseFail("上传文件为空文件");
        }
        String fileName = commonsMultipartFile.getOriginalFilename();
        if (fileName.indexOf(".xlsx") <= 0 || fileName.indexOf(".xls") <= 0) {
            return Response.responseFail("上传文件应为excel文件格式为：xlsx 或 xls");
        }
        if (!fileName.contains("收缴率")) {
            return Response.responseFail("请选择正确的文件！");
        }
        try {
            ea.GetPropertyCostsUpload(multipartFile, year, quarter, token.getUserCode());
            performanceScoreService.saveQuartlyAverageScoreAndSumScore(year, quarter);
            return Response.response("导入成功");
        } catch (Exception e) {
            return Response.responseFail(e.getMessage());
        }

    }

    /**
     * 查询和更新解锁状态，handle=1表示查询，handle=2表示更新
     *
     * @param requestMap json
     * @return Object
     * @author Max
     */
    @ResponseBody
    @RequestMapping(value = "/judgeLock")
    public Object judgeLock(@RequestBody Map<String, Object> requestMap, HttpServletRequest request) {
        String elementId = "1003";//物业服务费收缴率1003
        return Response.response(performancePower.getUserPower(elementId,requestMap,request));
    }
}