package com.rf.psychological.scale.resultBusiness.scaleResult;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.rf.psychological.utils.Constant;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @description 舒伯职业价值观量表
 */
public class WVIScale extends BaseScale {
    public WVIScale(JSONArray jsonArray, JSONObject resultJson) {
        super(jsonArray, resultJson);
    }

    public JSONObject scaleCalculate() throws Exception {
        //利他主义
        int scoreA = 0;
        //美的追求
        int scoreB = 0;
        //创造发明
        int scoreC = 0;
        //智力激发
        int scoreD = 0;
        //独立自主
        int scoreE = 0;
        //成就满足
        int scoreF = 0;
        //声望地位
        int scoreG = 0;
        //管理权力
        int scoreH = 0;
        //经济报酬
        int scoreI = 0;
        //安全稳定
        int scoreJ = 0;
        //工作环境
        int scoreK = 0;
        //上司关系
        int scoreL = 0;
        //同事关系
        int scoreM = 0;
        //多样变化
        int scoreN = 0;
        //生活方式
        int scoreO = 0;

        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObject1 = jsonArray.getJSONObject(i);
            if ((i + 1) % 15 == 1) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreA += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreA += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreA += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreA += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreA += 5;
                }
            } else if ((i + 1) % 15 == 2) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreB += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreB += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreB += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreB += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreB += 5;
                }
            } else if ((i + 1) % 15 == 3) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreC += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreC += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreC += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreC += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreC += 5;
                }
            } else if ((i + 1) % 15 == 4) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreD += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreD += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreD += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreD += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreD += 5;
                }
            } else if ((i + 1) % 15 == 5) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreE += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreE += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreE += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreE += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreE += 5;
                }
            } else if ((i + 1) % 15 == 6) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreF += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreF += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreF += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreF += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreF += 5;
                }
            } else if ((i + 1) % 15 == 7) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreG += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreG += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreG += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreG += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreG += 5;
                }
            } else if ((i + 1) % 15 == 8) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreH += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreH += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreH += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreH += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreH += 5;
                }
            } else if ((i + 1) % 15 == 9) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreI += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreI += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreI += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreI += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreI += 5;
                }
            } else if ((i + 1) % 15 == 10) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreJ += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreJ += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreJ += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreJ += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreJ += 5;
                }
            } else if ((i + 1) % 15 == 11) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreK += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreK += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreK += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreK += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreK += 5;
                }
            } else if ((i + 1) % 15 == 12) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreL += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreL += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreL += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreL += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreL += 5;
                }
            } else if ((i + 1) % 15 == 13) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreM += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreM += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreM += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreM += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreM += 5;
                }
            } else if ((i + 1) % 15 == 14) {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreN += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreN += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreN += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreN += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreN += 5;
                }
            } else {
                if (jsonObject1.getString("checkItems").equals("1")) {
                    scoreO += 1;
                } else if (jsonObject1.getString("checkItems").equals("2")) {
                    scoreO += 2;
                } else if (jsonObject1.getString("checkItems").equals("3")) {
                    scoreO += 3;
                } else if (jsonObject1.getString("checkItems").equals("4")) {
                    scoreO += 4;
                } else if (jsonObject1.getString("checkItems").equals("5")) {
                    scoreO += 5;
                }
            }
        }
        //得分列表
        Map<String, String> resultMap = new LinkedHashMap<>();
        resultMap.put("利他主义分数", String.valueOf(scoreA));
        resultMap.put("美的追求分数", String.valueOf(scoreB));
        resultMap.put("创造发明分数", String.valueOf(scoreC));
        resultMap.put("智力激发分数", String.valueOf(scoreD));
        resultMap.put("独立自主分数", String.valueOf(scoreE));
        resultMap.put("成就满足分数", String.valueOf(scoreF));
        resultMap.put("声望地位分数", String.valueOf(scoreG));
        resultMap.put("管理权力分数", String.valueOf(scoreH));
        resultMap.put("经济报酬分数", String.valueOf(scoreI));
        resultMap.put("安全稳定分数", String.valueOf(scoreJ));
        resultMap.put("工作环境分数", String.valueOf(scoreK));
        resultMap.put("上司关系分数", String.valueOf(scoreL));
        resultMap.put("同事关系分数", String.valueOf(scoreM));
        resultMap.put("多样变化分数", String.valueOf(scoreN));
        resultMap.put("生活方式分数", String.valueOf(scoreO));

        resultJson.put("利他主义分数", String.valueOf(scoreA));
        resultJson.put("美的追求分数", String.valueOf(scoreB));
        resultJson.put("创造发明分数", String.valueOf(scoreC));
        resultJson.put("智力激发分数", String.valueOf(scoreD));
        resultJson.put("独立自主分数", String.valueOf(scoreE));
        resultJson.put("成就满足分数", String.valueOf(scoreF));
        resultJson.put("声望地位分数", String.valueOf(scoreG));
        resultJson.put("管理权力分数", String.valueOf(scoreH));
        resultJson.put("经济报酬分数", String.valueOf(scoreI));
        resultJson.put("安全稳定分数", String.valueOf(scoreJ));
        resultJson.put("工作环境分数", String.valueOf(scoreK));
        resultJson.put("上司关系分数", String.valueOf(scoreL));
        resultJson.put("同事关系分数", String.valueOf(scoreM));
        resultJson.put("多样变化分数", String.valueOf(scoreN));
        resultJson.put("生活方式分数", String.valueOf(scoreO));


        List<Map<String, String>> resultMapList = new ArrayList<>();
        resultMapList.add(resultMap);

        JSONObject returnJson = new JSONObject(true);
        returnJson.put("resultMapList", resultMapList);
        returnJson.put("scaleName", Constant.SHEET_NAME_WVI);
        returnJson.put("resultJson", resultJson);

        return returnJson;
    }
}
