修改答卷数统计方式

This commit is contained in:
wkeyuan 2021-12-31 10:34:41 +08:00
parent 50edd3eda7
commit 47b2c0deab
4 changed files with 29 additions and 10 deletions

View File

@ -20,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Controller
@ -50,7 +52,7 @@ public class MySurveyController {
if(user!=null){
Page page = ResultUtils.getPageByPageResult(pageResult);
page = surveyDirectoryManager.findByUser(page,surveyName, surveyState);
// page.setResult(surveyAnswerManager.upAnCounts(page.getResult()));
page.setResult(surveyAnswerManager.upAnQuNum(page.getResult()));
pageResult = ResultUtils.getPageResultByPage(page,pageResult);
}
return pageResult;
@ -70,6 +72,7 @@ public class MySurveyController {
if(user!=null){
surveyStatsManager.findBySurvey(id);
SurveyDirectory survey = surveyDirectoryManager.findUniqueBy(id);
survey = surveyAnswerManager.upAnQuNum(survey);
return HttpResult.SUCCESS(survey);
}else{
return HttpResult.buildResult(HttpStatus.NOLOGIN);

View File

@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
@ -34,14 +35,13 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl<SurveyAnswer, String> imple
Session session=this.getSession();
//保存答案信息
String surveyId=surveyAnswer.getSurveyId();
// Survey survey=(Survey) session.get(Survey.class, surveyId);
SurveyDirectory survey=(SurveyDirectory) session.get(SurveyDirectory.class, surveyId);
Integer answerNum = survey.getAnswerNum();
if(answerNum==null){
answerNum=0;
}
survey.setAnswerNum(answerNum+1);
session.update(survey);//更新回答数
// Integer answerNum = survey.getAnswerNum();
// if(answerNum==null){
// answerNum=0;
// }
// survey.setAnswerNum(answerNum+1);
// session.update(survey);//更新回答数
int surveyQuAnItemNum=survey.getAnItemLeastNum();//可以回答的最少项目数
// surveyAnswer.setBgAnDate(curDate);
@ -457,4 +457,5 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl<SurveyAnswer, String> imple
}
return countCriteriaResult(c);
}
}

View File

@ -46,4 +46,10 @@ public interface SurveyAnswerManager extends BaseService<SurveyAnswer, String>{
public void deleteData(String[] ids);
public int getquestionAnswer(String surveyAnswerId, Question question);
public SurveyDirectory upAnQuNum(String surveyId);
public SurveyDirectory upAnQuNum(SurveyDirectory surveyDirectory);
public List<SurveyDirectory> upAnQuNum(List<SurveyDirectory> result);
}

View File

@ -575,7 +575,7 @@ public class SurveyAnswerManagerImpl extends
}
@Transactional
public SurveyDirectory upAnQuNum(SurveyDirectory survey){
public SurveyDirectory upAnQuNum(SurveyDirectory survey) {
Long answerCount = surveyAnswerDao.countResult(survey.getId());
if(answerCount!=null){
survey.setAnswerNum(answerCount.intValue());
@ -584,6 +584,16 @@ public class SurveyAnswerManagerImpl extends
return survey;
}
@Override
public List<SurveyDirectory> upAnQuNum(List<SurveyDirectory> result) {
if(result!=null){
for (SurveyDirectory survey:result) {
upAnQuNum(survey);
}
}
return result;
}
@Transactional
@Override
public void deleteData(String[] ids) {
@ -679,5 +689,4 @@ public class SurveyAnswerManagerImpl extends
super.delete(t);
}
}