package com.rf.psychological.rest; import com.alibaba.fastjson.JSONObject; import com.rf.psychological.base.rest.BaseController; import com.rf.psychological.dao.model.AnswerEntity; import com.rf.psychological.dao.model.DimensionEntity; import com.rf.psychological.scale.dao.model.MBTIResultDetail; import com.rf.psychological.scale.dao.model.ScaleEntity; import com.rf.psychological.scale.dao.model.ScaleMarksEntity; import com.rf.psychological.scale.dao.model.SubjectEntity; import com.rf.psychological.scale.service.*; import com.rf.psychological.security.DESede; import com.rf.psychological.utils.ExcelUtil; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.List; /** * @author zzf * @description:控制器 * @date 2021/1/18 19:19 */ @Slf4j @RestController @RequestMapping("/device") @Api(tags = "设备信息") public class DeviceController extends BaseController { @Autowired private SubjectService subjectService; @Autowired private ScaleService scaleService; @Autowired private AnswerService answerService; @Autowired private ScaleMarksService scaleMarksService; @Autowired private DimensionService dimensionService; @Autowired private MBTIResultDetailService detailService; /** * APP查找服务器使用 * @return */ @RequestMapping("/hello") public String hello(){ System.out.println("hello"); return "hello"; } @GetMapping("/updateItem") public void updateItem(String fileName,String flag){ File file = new File("C:\\Users\\Administrator\\Desktop\\"+fileName+".xlsx"); try { List>> datas = ExcelUtil.getBankListByExcelSheet(new FileInputStream(file.getAbsolutePath()), file.getName()); List scaleEntities = scaleService.getScaleByFlag(flag); List> an = datas.get(1); for (ScaleEntity scaleEntity : scaleEntities) { log.info("------" + scaleEntity.getCheckItems()); String no = scaleEntity.getQuestionNo(); String item = null; for (List objects : an) { if (objects.get(0).equals(no)) { if (StringUtils.isEmpty(item)) { item = objects.get(1).toString(); } else { item = item + ";" + objects.get(1).toString(); } } } scaleEntity.setCheckItems(item); if (item != null){ scaleService.saveScale(scaleEntity); } log.info("------" + scaleEntity.toString()); } }catch (Exception e){ e.printStackTrace(); } } @GetMapping("/updateAnswer") public void updateAnswer(String fileName,String flag){ File file = new File("C:\\Users\\Administrator\\Desktop\\"+fileName+".xlsx"); try { List>> datas = ExcelUtil.getBankListByExcelSheet(new FileInputStream(file.getAbsolutePath()), file.getName()); List answerEntities = answerService.getAnswerByFlag(flag); List> answerObj = datas.get(1); for (int i =0;i>> datas = ExcelUtil.getBankListByExcelSheet(new FileInputStream(file.getAbsolutePath()), file.getName()); List scaleEntities = scaleMarksService.getScaleMarksByFlag("20210820143117"); List> an = datas.get(2); for (int i = 0;i{ // ScaleMarksEntity entity = new ScaleMarksEntity(); // entity.setName("总分"); // entity.setScoreStart(item.get(1).toString()); // entity.setScoreEnd(item.get(2).toString()); // entity.setSymptom(item.get(3).toString()); // entity.setImprovementSuggestions(item.get(4).toString()); // entity.setIsTotalScoreExplain("是"); // entity.setNameExplain("无"); // entity.setStandardDeviation("无"); // entity.setScoringType("0"); // entity.setFlag("20210820143117"); // entity.setSuggestion("无"); // entity.setReference("无"); // scaleMarksService.saveScaleMarks(entity); // // log.info(entity.toString()); // }); // for (int i =0;i>> datas = ExcelUtil.getBankListByExcelSheet(new FileInputStream(file.getAbsolutePath()), file.getName()); List scaleMarksEntities = scaleMarksService.getScaleMarksByFlag(flag); List> markObj = datas.get(2); for (int i =0;i>> datas = ExcelUtil.getBankListByExcelSheet(new FileInputStream(file.getAbsolutePath()), file.getName()); List> markObj = datas.get(1); for (int i =0;i objects = markObj.get(i); MBTIResultDetail detail = new MBTIResultDetail(); detail.setFlag(objects.get(0).toString()); detail.setConclusion(objects.get(1).toString()); detail.setCharacteristic(objects.get(2).toString()); detail.setEvaluate(objects.get(3).toString()); detail.setRepresentative(objects.get(4).toString()); detail.setPursuit(objects.get(5).toString()); detail.setAdvantage(objects.get(6).toString()); detail.setDisadvantages(objects.get(7).toString()); detail.setRecommendation(objects.get(8).toString()); detail.setSuggest(objects.get(9).toString()); detail.setRevered(objects.get(10).toString()); log.info(detail.toString()); //detailService.save(detail); } }catch (Exception e){ e.printStackTrace(); } } }