|
@@ -54,286 +54,6 @@ public class ScaleResultController extends BaseController {
|
|
String fileName = userName+ Constant.SPLIT_CHAR+userBirthday+Constant.SPLIT_CHAR+userSex+Constant.SPLIT_CHAR+testTime;
|
|
String fileName = userName+ Constant.SPLIT_CHAR+userBirthday+Constant.SPLIT_CHAR+userSex+Constant.SPLIT_CHAR+testTime;
|
|
JSONArray jsonArray = jsonObject.getJSONArray("data");
|
|
JSONArray jsonArray = jsonObject.getJSONArray("data");
|
|
List<Map<String,String>> resultMapList = null;
|
|
List<Map<String,String>> resultMapList = null;
|
|
- //艾森克
|
|
|
|
- if(Constant.QUEST_TYPE_ASK.equals(type)){
|
|
|
|
- int scoreE=0;
|
|
|
|
- int scoreN=0;
|
|
|
|
- int scoreP=0;
|
|
|
|
- int scoreL=0;
|
|
|
|
- for(int i=0;i<jsonArray.size();i++){
|
|
|
|
- JSONObject jsonObject1 = jsonArray.getJSONObject(i);
|
|
|
|
- if(jsonObject1.getString("scale").equals(Constant.SCALE_TYPE_E)&&jsonObject1.getString("checkItems").equals(Constant.YES)){
|
|
|
|
- scoreE +=1;
|
|
|
|
- }else if(jsonObject1.getString("scale").equals(Constant.SCALE_TYPE_N)&&jsonObject1.getString("checkItems").equals(Constant.YES)){
|
|
|
|
- scoreN +=1;
|
|
|
|
- }else if(jsonObject1.getString("scale").equals(Constant.SCALE_TYPE_P)&&jsonObject1.getString("checkItems").equals(Constant.YES)){
|
|
|
|
- scoreP +=1;
|
|
|
|
- }else if(jsonObject1.getString("scale").equals(Constant.SCALE_TYPE_L)&&jsonObject1.getString("checkItems").equals(Constant.YES)){
|
|
|
|
- scoreL +=1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //答题结果列表
|
|
|
|
- List<ASKEntity> dataList= jsonArray.toJavaList(ASKEntity.class);
|
|
|
|
- //得分列表
|
|
|
|
- Map<String,String> resultMap = new LinkedHashMap<>();
|
|
|
|
- resultMap.put("分量E得分",String.valueOf(scoreE));
|
|
|
|
- resultMap.put("分量N得分",String.valueOf(scoreN));
|
|
|
|
- resultMap.put("分量P得分",String.valueOf(scoreP));
|
|
|
|
- resultMap.put("分量L得分",String.valueOf(scoreL));
|
|
|
|
- System.out.println("分量E得分:"+scoreE+";分量N得分:"+scoreN+";分量P得分:"+scoreP+";分量L得分:"+scoreL);
|
|
|
|
- fileName = fileName+"-"+Constant.SHEET_NAME_ASK+".xlsx";
|
|
|
|
- resultMapList = new ArrayList<>();
|
|
|
|
- resultMapList.add(resultMap);
|
|
|
|
-// 导出文件
|
|
|
|
- ExcelUtil.createExcelFile(ASKEntity.class,dataList,resultMapList,new ExcelClass().contentExcel(Constant.QUEST_TYPE_ASK),fileName,Constant.SHEET_NAME_ASK);
|
|
|
|
- //匹兹堡睡眠质量指数
|
|
|
|
- }else if(Constant.QUEST_TYPE_POMS.equals(type)){
|
|
|
|
- int [] scores= {0,0,0,0,0,0,0,0};
|
|
|
|
- for (int i=0;i<jsonArray.size();i++) {
|
|
|
|
- JSONObject jsonObject1= jsonArray.getJSONObject(i);
|
|
|
|
- int model = jsonObject1.getIntValue("type");
|
|
|
|
- String checked = jsonObject1.getString("checked");
|
|
|
|
- if(checked.equals("几乎没有")){
|
|
|
|
-
|
|
|
|
- }else if (checked.equals("有点")){
|
|
|
|
- scores[model-1] +=1;
|
|
|
|
- }else if (checked.equals("适中")){
|
|
|
|
- scores[model-1] +=2;
|
|
|
|
- }else if (checked.equals("相当多")){
|
|
|
|
- scores[model-1] +=3;
|
|
|
|
- }else if (checked.equals("⾮常多")){
|
|
|
|
- scores[model-1] +=4;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //TMD(情绪纷乱的总分)=5个消极的情绪得分之和减去两个积极情绪(精⼒,⾃尊感)得分之和+100
|
|
|
|
- scores[7]=scores[0]+scores[1]+scores[2]+scores[3]+scores[5]-scores[4]-scores[6]+100;
|
|
|
|
- System.out.println("POMS得分:"+scores.toString());
|
|
|
|
- fileName = fileName+"-"+Constant.SHEET_NAME_POMS+".xlsx";
|
|
|
|
- Map<String,String> resultMap = new LinkedHashMap<>();
|
|
|
|
- resultMap.put("紧张",String.valueOf(scores[0]));
|
|
|
|
- resultMap.put("愤怒",String.valueOf(scores[1]));
|
|
|
|
- resultMap.put("疲劳",String.valueOf(scores[2]));
|
|
|
|
- resultMap.put("抑郁",String.valueOf(scores[3]));
|
|
|
|
- resultMap.put("精力",String.valueOf(scores[4]));
|
|
|
|
- resultMap.put("慌乱",String.valueOf(scores[5]));
|
|
|
|
- resultMap.put("自我情绪相关",String.valueOf(scores[6]));
|
|
|
|
- resultMap.put("总分",String.valueOf(scores[7]));
|
|
|
|
- resultMapList = new ArrayList<>();
|
|
|
|
- resultMapList.add(resultMap);
|
|
|
|
- ExcelUtil.createExcelFile(POMSEntity.class,jsonArray.toJavaList(POMSEntity.class),resultMapList,new ExcelClass().contentExcel(Constant.QUEST_TYPE_POMS),fileName,Constant.SHEET_NAME_POMS);
|
|
|
|
- //症状自评
|
|
|
|
- }else if(Constant.QUEST_TYPE_AVAI.equals(type)){
|
|
|
|
- int score = 0 ;
|
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
- JSONObject jsonObject1 = jsonArray.getJSONObject(i);
|
|
|
|
- score += jsonObject1.getInteger("checked");
|
|
|
|
- }
|
|
|
|
- //平均分保留两位小数
|
|
|
|
- double avgScore = new BigDecimal((double)score/(double)jsonArray.size()).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
|
|
|
- System.out.println("总得分:"+score+";平均得分:"+avgScore);
|
|
|
|
- fileName = fileName+"-"+Constant.SHEET_NAME_AVAI+".xlsx";
|
|
|
|
- Map<String,String> resultMap = new LinkedHashMap<>();
|
|
|
|
- resultMap.put("总得分",String.valueOf(score));
|
|
|
|
- resultMap.put("平均得分",String.valueOf(avgScore));
|
|
|
|
- resultMapList = new ArrayList<>();
|
|
|
|
- resultMapList.add(resultMap);
|
|
|
|
- ExcelUtil.createExcelFile(AviationEntity.class,jsonArray.toJavaList(AviationEntity.class),resultMapList,new ExcelClass().contentExcel(Constant.QUEST_TYPE_AVAI),fileName,Constant.SHEET_NAME_AVAI);
|
|
|
|
- //社会支持评定量表
|
|
|
|
- }else if (Constant.QUEST_TYPE_SUPP.equals(type)){
|
|
|
|
- //总分
|
|
|
|
- int sumScore = 0;
|
|
|
|
- //主管得分
|
|
|
|
- int chargeScore = 0;
|
|
|
|
- //客观得分
|
|
|
|
- int impersonalityScore = 0;
|
|
|
|
- //利用度
|
|
|
|
- int utilizationScore = 0;
|
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
- JSONObject jsonObject1 = jsonArray.getJSONObject(i);
|
|
|
|
- String checked = jsonObject1.getString("checked");
|
|
|
|
- if(i==0||(i>=2&&i<=5)||(i==8)){
|
|
|
|
- if(checked.contains("(1)")){
|
|
|
|
- sumScore += 1 ;
|
|
|
|
- chargeScore +=1;
|
|
|
|
- }else if(checked.contains("(2)")){
|
|
|
|
- sumScore += 2 ;
|
|
|
|
- chargeScore += 2;
|
|
|
|
- }else if(checked.contains("(3)")){
|
|
|
|
- sumScore += 3 ;
|
|
|
|
- chargeScore+= 3;
|
|
|
|
- }else if(checked.contains("(4)")){
|
|
|
|
- sumScore += 4 ;
|
|
|
|
- chargeScore+=4;
|
|
|
|
- }
|
|
|
|
- }else if(i==1){
|
|
|
|
- if(checked.contains("(1)")){
|
|
|
|
- impersonalityScore +=1;
|
|
|
|
- sumScore += 1 ;
|
|
|
|
- }else if(checked.contains("(2)")){
|
|
|
|
- impersonalityScore+=2;
|
|
|
|
- sumScore += 2 ;
|
|
|
|
- }else if(checked.contains("(3)")){
|
|
|
|
- impersonalityScore+=3;
|
|
|
|
- sumScore += 3 ;
|
|
|
|
- }else if(checked.contains("(4)")){
|
|
|
|
- impersonalityScore+=4;
|
|
|
|
- sumScore += 4 ;
|
|
|
|
- }
|
|
|
|
- }else if(i==6||i==7){
|
|
|
|
- if(checked.equals("无任何来源")){
|
|
|
|
-
|
|
|
|
- }else {
|
|
|
|
- String [] strings= checked.replace("[","").replace("]","").split(",");
|
|
|
|
- int length = strings.length;
|
|
|
|
- sumScore += length;
|
|
|
|
- impersonalityScore +=length;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }else if(i==9||i==10){
|
|
|
|
- if(checked.contains("(1)")){
|
|
|
|
-
|
|
|
|
- }else if(checked.contains("(2)")){
|
|
|
|
- impersonalityScore += checked.split(";").length;
|
|
|
|
- sumScore += checked.split(";").length;;
|
|
|
|
- }
|
|
|
|
- }else {
|
|
|
|
- if(checked.contains("(1)")){
|
|
|
|
- utilizationScore +=1;
|
|
|
|
- sumScore += 1 ;
|
|
|
|
- }else if(checked.contains("(2)")){
|
|
|
|
- utilizationScore+=2;
|
|
|
|
- sumScore += 2 ;
|
|
|
|
- }else if(checked.contains("(3)")){
|
|
|
|
- utilizationScore+=3;
|
|
|
|
- sumScore += 3 ;
|
|
|
|
- }else if(checked.contains("(4)")){
|
|
|
|
- utilizationScore+=4;
|
|
|
|
- sumScore += 4 ;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- System.out.println("总分:"+sumScore+";客观得分:"+impersonalityScore+";主观得分:"+chargeScore+";支持的利用度:"+utilizationScore);
|
|
|
|
- fileName=fileName+"-"+Constant.SHEET_NAME_SUPP+".xlsx";
|
|
|
|
- Map<String,String> resultMap = new LinkedHashMap<>();
|
|
|
|
- resultMap.put("客观得分",String.valueOf(impersonalityScore));
|
|
|
|
- resultMap.put("主观得分",String.valueOf(chargeScore));
|
|
|
|
- resultMap.put("支持的利用度",String.valueOf(utilizationScore));
|
|
|
|
- resultMap.put("总分",String.valueOf(sumScore));
|
|
|
|
- resultMapList = new ArrayList<>();
|
|
|
|
- resultMapList.add(resultMap);
|
|
|
|
- ExcelUtil.createExcelFile(SupportEntity.class,jsonArray.toJavaList(SupportEntity.class),resultMapList,new ExcelClass().contentExcel(Constant.QUEST_TYPE_SUPP),fileName,Constant.SHEET_NAME_SUPP);
|
|
|
|
- //抑郁焦虑压力表
|
|
|
|
- }else if (Constant.QUEST_TYPE_DEPR.equals(type)){
|
|
|
|
- //压力的分 焦虑得分 抑郁得分
|
|
|
|
- int [] score = {0,0,0};
|
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
- JSONObject jsonObject1 = jsonArray.getJSONObject(i);
|
|
|
|
- String checked = jsonObject1.getString("checked");
|
|
|
|
- int model = jsonObject1.getIntValue("type");
|
|
|
|
- if(checked.equals("非常符合")){
|
|
|
|
- score[model-1] += 3;
|
|
|
|
- }else if(checked.equals("大部分符合")){
|
|
|
|
- score[model-1] += 2;
|
|
|
|
- }else if(checked.equals("小部分符合")){
|
|
|
|
- score[model-1] +=1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- System.out.println("压力得分:"+score[0]+";焦虑得分:"+score[1]+";抑郁得分:"+score[2]);
|
|
|
|
- fileName=fileName+"-"+Constant.SHEET_NAME_DEPR+".xlsx";
|
|
|
|
- Map<String,String> resultMap = new LinkedHashMap<>();
|
|
|
|
- resultMap.put("压力指数",String.valueOf(score[0]));
|
|
|
|
- resultMap.put("焦虑指数",String.valueOf(score[1]));
|
|
|
|
- resultMap.put("抑郁指数",String.valueOf(score[2]));
|
|
|
|
- resultMapList = new ArrayList<>();
|
|
|
|
- resultMapList.add(resultMap);
|
|
|
|
- ExcelUtil.createExcelFile(DepressEntity.class,jsonArray.toJavaList(DepressEntity.class),resultMapList,new ExcelClass().contentExcel(Constant.QUEST_TYPE_DEPR),fileName,Constant.SHEET_NAME_DEPR);
|
|
|
|
- //正性负性情绪量表
|
|
|
|
- }else if (Constant.QUEST_TYPE_MOOD.equals(type)){
|
|
|
|
- //反向情绪 正向情绪
|
|
|
|
- int [] score = {0,0};
|
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
- JSONObject jsonObject1 = jsonArray.getJSONObject(i);
|
|
|
|
- int model = jsonObject1.getIntValue("type");
|
|
|
|
- String checked = jsonObject1.getString("checked");
|
|
|
|
- if(checked.equals("几乎没有")){
|
|
|
|
- score[model] += 1;
|
|
|
|
- }else if(checked.equals("比较少")){
|
|
|
|
- score[model] += 2;
|
|
|
|
- }else if(checked.equals("中等程度")){
|
|
|
|
- score[model] += 3;
|
|
|
|
- }else if(checked.equals("比较多")){
|
|
|
|
- score[model] += 4;
|
|
|
|
- }else if(checked.equals("及其多")){
|
|
|
|
- score[model] += 5;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- System.out.println("负向情绪得分:"+score[0]+";正向情绪得分:"+score[1]);
|
|
|
|
- fileName=fileName+"-"+Constant.SHEET_NAME_MOOD+".xlsx";
|
|
|
|
- Map<String,String> resultMap = new LinkedHashMap<>();
|
|
|
|
- resultMap.put("负向情绪得分",String.valueOf(score[0]));
|
|
|
|
- resultMap.put("正向情绪得分",String.valueOf(score[1]));
|
|
|
|
- resultMapList = new ArrayList<>();
|
|
|
|
- resultMapList.add(resultMap);
|
|
|
|
- ExcelUtil.createExcelFile(MoodEntity.class,jsonArray.toJavaList(MoodEntity.class),resultMapList,new ExcelClass().contentExcel(Constant.QUEST_TYPE_MOOD),fileName,Constant.SHEET_NAME_MOOD);
|
|
|
|
- }else if(Constant.QUEST_TYPE_LIFE.equals(type)){
|
|
|
|
- int score = 0;
|
|
|
|
- List<LifeEntity> dataList = jsonArray.toJavaList(LifeEntity.class);
|
|
|
|
- for (LifeEntity lifeEntity:dataList) {
|
|
|
|
- score = score + lifeEntity.getScore()*Integer.parseInt(lifeEntity.getChecked());
|
|
|
|
- }
|
|
|
|
- Map<String,String> resultMap = new LinkedHashMap<>();
|
|
|
|
- resultMap.put("总分",String.valueOf(score));
|
|
|
|
- fileName = fileName+"-"+Constant.SHEET_NAME_LIFE+".xlsx";
|
|
|
|
- resultMapList = new ArrayList<>();
|
|
|
|
- resultMapList.add(resultMap);
|
|
|
|
- ExcelUtil.createExcelFile(LifeEntity.class,dataList,resultMapList,new ExcelClass().contentExcel(Constant.QUEST_TYPE_LIFE),fileName,Constant.SHEET_NAME_LIFE);
|
|
|
|
- }else if (Constant.QUEST_TYPE_CATTELL.equals(type)){
|
|
|
|
- List<CattellEntity>dataList = jsonArray.toJavaList(CattellEntity.class);
|
|
|
|
- Map<String,String> resultMap = new LinkedHashMap<>();
|
|
|
|
- //第1、2、187 题不参与计算
|
|
|
|
- for (int i =2;i<dataList.size()-1;i++) {
|
|
|
|
- CattellEntity cattellEntity = dataList.get(i);
|
|
|
|
- int no = cattellEntity.getNo();
|
|
|
|
- resultMap.put("因素B得分",String.valueOf(0));
|
|
|
|
- String factor = cattellEntity.getType();
|
|
|
|
- String checked = cattellEntity.getChecked();
|
|
|
|
- int score = 0;
|
|
|
|
- //B因素一下选项加1分,其他选项均为0分:28.B 53.B 54.B 77.C 78.B 102.C 103.B 127.C 128.B 152.B 153.C 177.A 178.A
|
|
|
|
- if(factor.equals("B")){
|
|
|
|
- if(((no == 28||no == 53 || no ==54 || no ==78||no ==103 ||no == 128 || no == 152 )&&checked.equals("B"))||((no == 77 || no ==102 || no ==127 || no == 153)&&checked.equals("C"))||((no == 177 || no == 178)&& checked.equals("A"))){
|
|
|
|
- score = 1;
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- if(checked.equals("B")){
|
|
|
|
- score =1;
|
|
|
|
- }else{
|
|
|
|
- if(no ==3 || no ==4 || no == 7 || no == 13 || no == 17 || no == 18 || no == 20 || no == 21 || no == 25 || no == 30 || no == 33 || (no >= 36&&no<=40)|| no == 42 || no == 43 || (no>=46 && no <= 50) || no == 52 || no == 55 || no == 56 || no == 58 || no == 59
|
|
|
|
- || no == 65 || (no >= 69 && no <= 74)|| no == 88 || no == 91 || (no >= 98 && no <= 101) || no == 104|| no == 105 || (no >= 107 && no <= 119)|| no == 124 || no == 126 ||(no>=129&&no<=134)
|
|
|
|
- || no == 136 || no == 138 || no == 140 || no == 142 || no == 143 || (no>=145 && no <= 150)|| no == 155 || no == 156 || no == 160 || no ==163 || no ==164
|
|
|
|
- || (no>=167 && no <= 169) || no == 171 || no == 173 || no == 174 || no == 176 || no>=179){
|
|
|
|
- if(checked.equals("A")){
|
|
|
|
- score = 2;
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- if(checked.equals("C")){
|
|
|
|
- score = 2;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- String key = "因素"+factor+"得分";
|
|
|
|
- if(resultMap.get(key)==null){
|
|
|
|
- resultMap.put(key,String.valueOf(score));
|
|
|
|
- }else {
|
|
|
|
- resultMap.put(key,String.valueOf(Integer.parseInt(resultMap.get("因素B得分")+score)));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- fileName = fileName+"-"+Constant.SHEET_NAME_CATTELL+".xlsx";
|
|
|
|
- resultMapList = new ArrayList<>();
|
|
|
|
- resultMapList.add(resultMap);
|
|
|
|
- ExcelUtil.createExcelFile(CattellEntity.class,dataList,resultMapList,new ExcelClass().contentExcel(Constant.QUEST_TYPE_CATTELL),fileName,Constant.SHEET_NAME_CATTELL);
|
|
|
|
- }
|
|
|
|
return success("success","完成");
|
|
return success("success","完成");
|
|
}
|
|
}
|
|
|
|
|