From f44ac34e2c09c374aa428af66ba7d7aafd0e6614 Mon Sep 17 00:00:00 2001 From: keyuan Date: Mon, 26 Apr 2021 10:39:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=94=E5=8D=B7=E9=87=8F=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/survey/MyCollectAction.java | 18 ++-- .../action/survey/MySurveyAction.java | 7 +- .../action/survey/MySurveyAnswerAction.java | 21 +++-- .../action/survey/SurveyReportAction.java | 26 +++--- .../com/key/dwsurvey/dao/SurveyAnswerDao.java | 3 + .../dao/impl/SurveyAnswerDaoImpl.java | 91 ++++++++++--------- .../dwsurvey/service/SurveyAnswerManager.java | 22 +++-- .../service/impl/SurveyAnswerManagerImpl.java | 30 ++++++ 8 files changed, 136 insertions(+), 82 deletions(-) diff --git a/src/main/java/com/key/dwsurvey/action/survey/MyCollectAction.java b/src/main/java/com/key/dwsurvey/action/survey/MyCollectAction.java index 2cb382c..7602a07 100755 --- a/src/main/java/com/key/dwsurvey/action/survey/MyCollectAction.java +++ b/src/main/java/com/key/dwsurvey/action/survey/MyCollectAction.java @@ -4,6 +4,7 @@ import com.key.common.base.entity.User; import com.key.common.base.service.AccountManager; import com.key.common.utils.web.Struts2Utils; import com.key.dwsurvey.entity.SurveyDirectory; +import com.key.dwsurvey.service.SurveyAnswerManager; import com.key.dwsurvey.service.SurveyDirectoryManager; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.*; @@ -29,27 +30,29 @@ import javax.servlet.http.HttpServletRequest; @Result(name=MyCollectAction.SHARE,location="/WEB-INF/page/content/diaowen-collect/collect_2.jsp",type=Struts2Utils.DISPATCHER) }) public class MyCollectAction extends ActionSupport{ - + protected final static String COLLECT1="collect1"; protected final static String IFRAME="iframe"; protected final static String SITECOMP="sitecomp"; protected final static String WEIXIN="weixin"; protected final static String SHARE="share"; - + private String surveyId; @Autowired private SurveyDirectoryManager surveyDirectoryManager; @Autowired private AccountManager accountManager; + @Autowired + private SurveyAnswerManager surveyAnswerManager; + - @Override public String execute() throws Exception { HttpServletRequest request=Struts2Utils.getRequest(); String tabId=request.getParameter("tabId"); String baseUrl = ""; - baseUrl = request.getScheme() +"://" + request.getServerName() + baseUrl = request.getScheme() +"://" + request.getServerName() + (request.getServerPort() == 80 ? "" : ":" +request.getServerPort()) + request.getContextPath(); @@ -57,6 +60,7 @@ public class MyCollectAction extends ActionSupport{ User user=accountManager.getCurUser(); if(user!=null){ + surveyAnswerManager.upAnCount(surveyId); SurveyDirectory surveyDirectory=surveyDirectoryManager.getSurveyByUser(surveyId, user.getId()); if(surveyDirectory!=null){ request.setAttribute("survey", surveyDirectory); @@ -74,7 +78,7 @@ public class MyCollectAction extends ActionSupport{ } return null; } - + public String getSurveyId() { return surveyId; } @@ -82,6 +86,6 @@ public class MyCollectAction extends ActionSupport{ public void setSurveyId(String surveyId) { this.surveyId = surveyId; } - - + + } diff --git a/src/main/java/com/key/dwsurvey/action/survey/MySurveyAction.java b/src/main/java/com/key/dwsurvey/action/survey/MySurveyAction.java index 2a86f88..e7b2887 100755 --- a/src/main/java/com/key/dwsurvey/action/survey/MySurveyAction.java +++ b/src/main/java/com/key/dwsurvey/action/survey/MySurveyAction.java @@ -6,6 +6,7 @@ import com.key.common.base.service.AccountManager; import com.key.common.utils.web.JsonDateValueProcessor; import com.key.common.utils.web.Struts2Utils; import com.key.dwsurvey.entity.SurveyDirectory; +import com.key.dwsurvey.service.SurveyAnswerManager; import com.key.dwsurvey.service.SurveyDirectoryManager; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; @@ -15,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Date; +import java.util.List; /** * 我的问卷 action @@ -37,6 +39,8 @@ public class MySurveyAction extends CrudActionSupport{ private SurveyDirectoryManager surveyDirectoryManager; @Autowired private AccountManager accountManager; + @Autowired + private SurveyAnswerManager surveyAnswerManager; @Override public String list() throws Exception { @@ -45,7 +49,8 @@ public class MySurveyAction extends CrudActionSupport{ if(surveyState==null||"".equals(surveyState)){ entity.setSurveyState(null); } - page=surveyDirectoryManager.findByUser(page,entity); + page = surveyDirectoryManager.findByUser(page,entity); + page.setResult(surveyAnswerManager.upAnCounts(page.getResult())); return SUCCESS; } diff --git a/src/main/java/com/key/dwsurvey/action/survey/MySurveyAnswerAction.java b/src/main/java/com/key/dwsurvey/action/survey/MySurveyAnswerAction.java index 5006329..091c834 100644 --- a/src/main/java/com/key/dwsurvey/action/survey/MySurveyAnswerAction.java +++ b/src/main/java/com/key/dwsurvey/action/survey/MySurveyAnswerAction.java @@ -41,27 +41,28 @@ public class MySurveyAnswerAction extends ActionSupport{ private SurveyDirectoryManager directoryManager; @Autowired private AccountManager accountManager; - + protected final static String RESPONSE_ANSWER = "responseAnswer"; - + private Page page=new Page(); private String surveyId; - + @Override public String execute() throws Exception { HttpServletRequest request=Struts2Utils.getRequest(); User user=accountManager.getCurUser(); if(user!=null){ + surveyAnswerManager.upAnCount(surveyId); SurveyDirectory survey=directoryManager.getSurveyByUser(surveyId, user.getId()); if(survey!=null){ page=surveyAnswerManager.answerPage(page, surveyId); request.setAttribute("survey", survey); } } - + return SUCCESS; } - + public String responseAnswer() throws Exception { HttpServletRequest request=Struts2Utils.getRequest(); String answerId=request.getParameter("answerId"); @@ -85,8 +86,8 @@ public class MySurveyAnswerAction extends ActionSupport{ } return RESPONSE_ANSWER; } - - + + public String delete() throws Exception { HttpServletRequest request=Struts2Utils.getRequest(); HttpServletResponse response=Struts2Utils.getResponse(); @@ -115,7 +116,7 @@ public class MySurveyAnswerAction extends ActionSupport{ response.getWriter().write(result); return null; } - + public String exportXLS() throws Exception{ HttpServletRequest request=Struts2Utils.getRequest(); HttpServletResponse response=Struts2Utils.getResponse(); @@ -134,7 +135,7 @@ public class MySurveyAnswerAction extends ActionSupport{ } return null; } - + public Page getPage() { return page; } @@ -150,5 +151,5 @@ public class MySurveyAnswerAction extends ActionSupport{ public void setSurveyId(String surveyId) { this.surveyId = surveyId; } - + } diff --git a/src/main/java/com/key/dwsurvey/action/survey/SurveyReportAction.java b/src/main/java/com/key/dwsurvey/action/survey/SurveyReportAction.java index 7c22410..cb8072e 100755 --- a/src/main/java/com/key/dwsurvey/action/survey/SurveyReportAction.java +++ b/src/main/java/com/key/dwsurvey/action/survey/SurveyReportAction.java @@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse; import com.key.dwsurvey.entity.Question; import com.key.dwsurvey.entity.SurveyStats; +import com.key.dwsurvey.service.SurveyAnswerManager; import com.key.dwsurvey.service.SurveyDirectoryManager; import com.key.dwsurvey.service.SurveyStatsManager; import com.key.dwsurvey.entity.SurveyDirectory; @@ -35,27 +36,30 @@ import com.opensymphony.xwork2.ActionSupport; }) @AllowedMethods({"defaultReport","lineChart","pieChart","chartData"}) public class SurveyReportAction extends ActionSupport{ - + protected final static String DEFAULT_REPORT="default_report"; protected final static String LINE_CHART="line_chart"; protected final static String PIE_CHART="pie_chart"; - + @Autowired private SurveyStatsManager surveyStatsManager; @Autowired private SurveyDirectoryManager directoryManager; @Autowired private AccountManager accountManager; - + @Autowired + private SurveyAnswerManager surveyAnswerManager; + private SurveyStats surveyStats = new SurveyStats(); private SurveyDirectory directory = new SurveyDirectory(); - + private String surveyId; - + public String defaultReport() throws Exception { // 得到频数分析数据 User user = accountManager.getCurUser(); if(user!=null){ + surveyAnswerManager.upAnCount(surveyId); directory=directoryManager.getSurveyByUser(surveyId, user.getId()); if(directory!=null){ List questions = surveyStatsManager.findFrequency(directory); @@ -64,7 +68,7 @@ public class SurveyReportAction extends ActionSupport{ } return DEFAULT_REPORT; } - + public String lineChart() throws Exception { User user = accountManager.getCurUser(); if(user!=null){ @@ -76,7 +80,7 @@ public class SurveyReportAction extends ActionSupport{ } return LINE_CHART; } - + public String pieChart() throws Exception { User user = accountManager.getCurUser(); if(user!=null){ @@ -88,7 +92,7 @@ public class SurveyReportAction extends ActionSupport{ } return PIE_CHART; } - + //取得某一题的统计数据 public String chartData() throws Exception { HttpServletResponse response=Struts2Utils.getResponse(); @@ -103,11 +107,11 @@ public class SurveyReportAction extends ActionSupport{ } return null; } - + public SurveyStats getSurveyStats() { return surveyStats; } - + public SurveyDirectory getDirectory() { return directory; } @@ -119,5 +123,5 @@ public class SurveyReportAction extends ActionSupport{ public void setSurveyId(String surveyId) { this.surveyId = surveyId; } - + } diff --git a/src/main/java/com/key/dwsurvey/dao/SurveyAnswerDao.java b/src/main/java/com/key/dwsurvey/dao/SurveyAnswerDao.java index c52a321..e53c93a 100755 --- a/src/main/java/com/key/dwsurvey/dao/SurveyAnswerDao.java +++ b/src/main/java/com/key/dwsurvey/dao/SurveyAnswerDao.java @@ -12,4 +12,7 @@ public interface SurveyAnswerDao extends BaseDao{ Map> quMaps); public SurveyStats surveyStatsData(SurveyStats surveyStats); + + public Long countResult(String surveyId); + } diff --git a/src/main/java/com/key/dwsurvey/dao/impl/SurveyAnswerDaoImpl.java b/src/main/java/com/key/dwsurvey/dao/impl/SurveyAnswerDaoImpl.java index 73e0d46..6428bac 100755 --- a/src/main/java/com/key/dwsurvey/dao/impl/SurveyAnswerDaoImpl.java +++ b/src/main/java/com/key/dwsurvey/dao/impl/SurveyAnswerDaoImpl.java @@ -5,7 +5,10 @@ import java.util.Map; import com.key.dwsurvey.dao.SurveyAnswerDao; import com.key.dwsurvey.service.SurveyStatsManager; +import org.hibernate.Criteria; import org.hibernate.Session; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; @@ -41,34 +44,36 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple @Autowired private SurveyStatsManager surveyStatsManager; - + @Override public void saveAnswer(SurveyAnswer surveyAnswer, Map> quMaps) { Date curDate=new Date(); - + Session session=this.getSession(); //保存答案信息 String surveyId=surveyAnswer.getSurveyId(); // Survey survey=(Survey) session.get(Survey.class, surveyId); SurveyDirectory survey=(SurveyDirectory) session.get(SurveyDirectory.class, surveyId); -// System.out.println("survey:"+survey); + + /* Integer answerNum = survey.getAnswerNum(); if(answerNum==null){ answerNum=0; } survey.setAnswerNum(answerNum+1); session.update(survey);//更新回答数 + */ int surveyQuAnItemNum=survey.getAnItemLeastNum();//可以回答的最少项目数 - + surveyAnswer.setBgAnDate(curDate); surveyAnswer.setEndAnDate(new Date()); - + //计算答卷用时 long time=surveyAnswer.getEndAnDate().getTime()-surveyAnswer.getBgAnDate().getTime(); surveyAnswer.setTotalTime(Float.parseFloat(time/(60*60)+"")); session.save(surveyAnswer); - + int anCount=0; //保存答案 //是非题 @@ -101,11 +106,11 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple //评分题 Map scoreMaps=quMaps.get("scoreMaps"); anCount+=saveScoreMaps(surveyAnswer,scoreMaps,session); - + //排序题 quOrderMaps Map quOrderMaps=quMaps.get("quOrderMaps"); anCount+=saveQuOrderMaps(surveyAnswer,quOrderMaps,session); - + //矩阵单选题 Map chehRadioMaps=quMaps.get("chenRadioMaps"); anCount+=saveChenRadioMaps(surveyAnswer,chehRadioMaps,session); @@ -118,11 +123,11 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple //复合矩阵单选题 Map compChehRadioMaps=quMaps.get("compChenRadioMaps"); anCount+=saveCompChehRadioMaps(surveyAnswer,compChehRadioMaps,session); - + //矩阵填空题 Map chenScoreMaps=quMaps.get("chenScoreMaps"); anCount+=saveChenScoreMaps(surveyAnswer,chenScoreMaps,session); - + //保存anCount surveyAnswer.setCompleteItemNum(anCount); int isComplete=0; @@ -136,7 +141,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple } surveyAnswer.setIsEffective(isEffective); session.save(surveyAnswer); - + //更新统计状态 SurveyStats surveyStats=surveyStatsManager.findBySurvey(surveyId); if(surveyStats!=null){ @@ -150,7 +155,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple surveyStats.setSurveyId(surveyId); surveyStatsManager.save(surveyStats); } - + } /** @@ -162,7 +167,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple */ private int saveChenScoreMaps(SurveyAnswer surveyAnswer, Map chenScoreMaps, Session session) { - + String surveyId=surveyAnswer.getSurveyId(); String surveyAnswerId=surveyAnswer.getId(); int answerQuCount=0; @@ -190,7 +195,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple Map quOrderMaps, Session session) { String surveyId=surveyAnswer.getSurveyId(); String surveyAnswerId=surveyAnswer.getId(); - + int answerQuCount=0; if(quOrderMaps!=null){ for (String key : quOrderMaps.keySet()) { @@ -212,7 +217,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple Map compChenRadioMaps, Session session) { String surveyId=surveyAnswer.getSurveyId(); String surveyAnswerId=surveyAnswer.getId(); - + int answerQuCount=0; if(compChenRadioMaps!=null){ for (String key : compChenRadioMaps.keySet()) { @@ -236,7 +241,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple private int saveChenFbkMaps(SurveyAnswer surveyAnswer, Map chenFbkMaps, Session session) { - + String surveyId=surveyAnswer.getSurveyId(); String surveyAnswerId=surveyAnswer.getId(); int answerQuCount=0; @@ -262,10 +267,10 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple private int saveChenCheckboxMaps(SurveyAnswer surveyAnswer, Map chenCheckboxMaps, Session session) { - + String surveyId=surveyAnswer.getSurveyId(); String surveyAnswerId=surveyAnswer.getId(); - + int answerQuCount=0; if(chenCheckboxMaps!=null){ for (String key : chenCheckboxMaps.keySet()) { @@ -289,15 +294,14 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple /** * 保存矩阵单选题 * @param surveyAnswer - * @param chehRadioMaps * @param session */ private int saveChenRadioMaps(SurveyAnswer surveyAnswer, Map chenRadioMaps, Session session) { - + String surveyId=surveyAnswer.getSurveyId(); String surveyAnswerId=surveyAnswer.getId(); - + int answerQuCount=0; if(chenRadioMaps!=null){ for (String key : chenRadioMaps.keySet()) { @@ -324,7 +328,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple Map scoreMaps, Session session) { String surveyId=surveyAnswer.getSurveyId(); String surveyAnswerId=surveyAnswer.getId(); - + int answerQuCount=0; if(scoreMaps!=null){ for (String key : scoreMaps.keySet()) { @@ -352,7 +356,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple Map enumMaps, Session session) { String surveyId=surveyAnswer.getSurveyId(); String surveyAnswerId=surveyAnswer.getId(); - + int answerQuCount=0; for (String key : enumMaps.keySet()) { answerQuCount++; @@ -369,7 +373,6 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple /** * 保存判断题答案 - * @param exambatchUser * @param anAnswerMaps * @param session */ @@ -377,7 +380,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple Map anAnswerMaps,Session session) { String surveyId=surveyAnswer.getSurveyId(); String surveyAnswerId=surveyAnswer.getId(); - + int answerQuCount=0; for (String key : anAnswerMaps.keySet()) { answerQuCount++; @@ -391,7 +394,6 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple /** * 保存单项填空题答案 - * @param exambatchUser * @param fillMaps * @param session */ @@ -412,7 +414,6 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple /** * 保存多选题答案 - * @param exambatchUser * @param checkboxMaps * @param session */ @@ -420,7 +421,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple Map checkboxMaps,Session session) { String surveyId=surveyAnswer.getSurveyId(); String surveyAnswerId=surveyAnswer.getId(); - + int answerQuCount=0; if (checkboxMaps!=null) for (String key : checkboxMaps.keySet()) { @@ -437,8 +438,6 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple } /** * 保存复合多选题答案 - * @param exambatchUser - * @param checkboxMaps * @param session */ private int saveCompAnCheckboxMaps(SurveyAnswer surveyAnswer, @@ -465,7 +464,6 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple /** * 保存多项填空题答案 - * @param exambatchUser * @param dfillMaps * @param session */ @@ -473,7 +471,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple Map dfillMaps,Session session) { String surveyId=surveyAnswer.getSurveyId(); String surveyAnswerId=surveyAnswer.getId(); - + int answerQuCount=0; for (String key : dfillMaps.keySet()) { String quId=key; @@ -494,7 +492,6 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple /** * 保存单选题答案 - * @param exambatchUser * @param radioMaps * @param session */ @@ -535,13 +532,12 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple AnRadio anRadio=new AnRadio(surveyId,surveyAnswerId,quId,quItemId); anRadio.setOtherText(othertext); session.save(anRadio); - } + } return answerQuCount; } - + /** * 保存是非题答案 - * @param exambatchUser * @param yesnoMaps * @param session */ @@ -558,7 +554,7 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple } return answerQuCount; } - + public SurveyStats surveyStatsData(SurveyStats surveyStats){ try{ StringBuffer sqlBuf=new StringBuffer("select MIN(bg_an_date) firstDate,MAX(bg_an_date) lastDate,count(id) anCount,min(total_time) minTime,avg(total_time) avgTime, "); @@ -569,36 +565,36 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple sqlBuf.append("count(case when handle_state =2 then handle_state end) handle2, "); sqlBuf.append("count(case when data_source =0 then data_source end) datasource0, "); sqlBuf.append("count(case when data_source =1 then data_source end) datasource1, "); - + sqlBuf.append("count(case when data_source =2 then data_source end) datasource2, "); sqlBuf.append("count(case when data_source =3 then data_source end) datasource3 "); sqlBuf.append("from t_survey_answer where survey_id=? "); Object[] objects = (Object[]) this.getSession().createSQLQuery(sqlBuf.toString()).setString(0, surveyStats.getSurveyId()).uniqueResult(); - + surveyStats.setFirstAnswer((Date)objects[0]); surveyStats.setLastAnswer((Date)objects[1]); surveyStats.setAnswerNum(Integer.parseInt(objects[2].toString())); String minTime=objects[3].toString(); - + int minIndex=minTime.indexOf("."); if(minIndex>0){ minTime=minTime.substring(0,minIndex); } surveyStats.setAnMinTime(Integer.parseInt(minTime));//Min Time - + String avgTime=objects[4].toString(); int avgIndex=avgTime.indexOf("."); if(avgIndex>0){ avgTime=avgTime.substring(0,avgIndex); } surveyStats.setAnAvgTime(Integer.parseInt(avgTime));//Avg Time - + surveyStats.setCompleteNum(Integer.parseInt(objects[5].toString())); surveyStats.setEffectiveNum(Integer.parseInt(objects[6].toString())); surveyStats.setUnHandleNum(Integer.parseInt(objects[7].toString())); surveyStats.setHandlePassNum(Integer.parseInt(objects[8].toString())); surveyStats.setHandleUnPassNum(Integer.parseInt(objects[9].toString())); - + surveyStats.setOnlineNum(Integer.parseInt(objects[10].toString())); surveyStats.setInputNum(Integer.parseInt(objects[11].toString())); surveyStats.setMobileNum(Integer.parseInt(objects[12].toString())); @@ -609,4 +605,13 @@ public class SurveyAnswerDaoImpl extends BaseDaoImpl imple // 0网调 1录入数据 2移动数据 3导入数据 return surveyStats; } + + @Override + public Long countResult(String surveyId) { + Criterion cri1 = Restrictions.eq("surveyId",surveyId); + Criterion cri2=Restrictions.eq("isEffective", 1); + Criteria c = createCriteria(cri1,cri2); + return countCriteriaResult(c); + } + } diff --git a/src/main/java/com/key/dwsurvey/service/SurveyAnswerManager.java b/src/main/java/com/key/dwsurvey/service/SurveyAnswerManager.java index dbf5662..efe9430 100755 --- a/src/main/java/com/key/dwsurvey/service/SurveyAnswerManager.java +++ b/src/main/java/com/key/dwsurvey/service/SurveyAnswerManager.java @@ -6,10 +6,7 @@ import java.util.Map; import com.key.common.base.entity.User; import com.key.common.plugs.page.Page; import com.key.common.service.BaseService; -import com.key.dwsurvey.entity.Question; -import com.key.dwsurvey.entity.SurveyAnswer; -import com.key.dwsurvey.entity.SurveyDetail; -import com.key.dwsurvey.entity.SurveyStats; +import com.key.dwsurvey.entity.*; import javax.servlet.http.HttpServletRequest; @@ -25,19 +22,19 @@ public interface SurveyAnswerManager extends BaseService{ public void saveAnswer(SurveyAnswer surveyAnswer, Map> quMaps); public List findAnswerDetail(SurveyAnswer answer); - + public List answersByIp(String surveyId, String ip); - + public SurveyAnswer getTimeInByIp(SurveyDetail surveyDetail, String ip); - + public Long getCountByIp(String surveyId, String ip); public String exportXLS(String surveyId,String savePath); - + public SurveyStats surveyStatsData(SurveyStats surveyStats); - + public Page joinSurvey(Page page, User user) ; - + /** * 取出某份问卷的答卷数据 * @param page @@ -46,4 +43,9 @@ public interface SurveyAnswerManager extends BaseService{ */ public Page answerPage(Page page,String surveyId); + public List upAnCounts(List result); + + public Integer upAnCount(SurveyDirectory directory); + + public Integer upAnCount(String directoryId); } diff --git a/src/main/java/com/key/dwsurvey/service/impl/SurveyAnswerManagerImpl.java b/src/main/java/com/key/dwsurvey/service/impl/SurveyAnswerManagerImpl.java index 8f8990b..0afa268 100755 --- a/src/main/java/com/key/dwsurvey/service/impl/SurveyAnswerManagerImpl.java +++ b/src/main/java/com/key/dwsurvey/service/impl/SurveyAnswerManagerImpl.java @@ -833,5 +833,35 @@ public class SurveyAnswerManagerImpl extends super.delete(t); } + @Transactional + public List upAnCounts(List result) { + if(result!=null){ + for (SurveyDirectory survey:result) { + upAnCount(survey); + } + } + return result; + } + @Transactional + public Integer upAnCount(SurveyDirectory directory) { + if(directory!=null){ + Long answerCount = surveyAnswerDao.countResult(directory.getId()); + if(answerCount!=null){ + directory.setAnswerNum(answerCount.intValue()); + directoryManager.saveByAdmin(directory); + return directory.getAnswerNum(); + } + } + return 0; + } + + @Transactional + public Integer upAnCount(String directoryId) { + if(directoryId!=null){ + SurveyDirectory surveyDirectory = directoryManager.get(directoryId); + return upAnCount(surveyDirectory); + } + return 0; + } }