From d2c59eb8ffdd7fa0793c57af6bbe7b70b3b3838e Mon Sep 17 00:00:00 2001 From: zhangxb Date: Thu, 18 Aug 2022 09:48:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?YCHZ-325-zhangxianbo-=E3=80=90=E8=AF=84?= =?UTF-8?q?=E4=BB=B7=E7=B3=BB=E7=BB=9F=E3=80=91=E5=AF=B9=E6=8E=A5=E9=97=AE?= =?UTF-8?q?=E5=8D=B7=E7=AD=94=E5=8D=B7=E6=8E=A5=E5=8F=A3=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/net/diaowen/common/utils/testOK.java | 18 + .../question/ResponseController.java | 135 +++- .../diaowen/estimate/entity/SurveyAnswer.java | 719 +++++++++++------- .../estimate/service/SurveyAnswerManager.java | 2 +- .../service/impl/SurveyAnswerManagerImpl.java | 114 ++- 5 files changed, 681 insertions(+), 307 deletions(-) create mode 100644 src/main/java/net/diaowen/common/utils/testOK.java diff --git a/src/main/java/net/diaowen/common/utils/testOK.java b/src/main/java/net/diaowen/common/utils/testOK.java new file mode 100644 index 0000000..02de991 --- /dev/null +++ b/src/main/java/net/diaowen/common/utils/testOK.java @@ -0,0 +1,18 @@ +package net.diaowen.common.utils; + +import java.util.regex.Pattern; + +public class testOK { + public static boolean checkDateFormat(String timeStr){ + String rexp = "^((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29))\\s+([0-1]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$"; + return Pattern.matches(rexp, timeStr); + } + public static void main(String[] args) + { + String timeStr = "2021-08-17 13:47:28"; + + boolean test = checkDateFormat(timeStr); + System.out.println(test); + } + +} diff --git a/src/main/java/net/diaowen/estimate/controller/question/ResponseController.java b/src/main/java/net/diaowen/estimate/controller/question/ResponseController.java index 46cc69c..90cfc03 100644 --- a/src/main/java/net/diaowen/estimate/controller/question/ResponseController.java +++ b/src/main/java/net/diaowen/estimate/controller/question/ResponseController.java @@ -35,7 +35,10 @@ import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; +import java.util.regex.Pattern; /** * 答卷 action @@ -49,6 +52,8 @@ import java.util.*; @RequestMapping("/api/dwsurvey/anon/response") public class ResponseController { private static final long serialVersionUID = -2289729314160067840L; + //private static String DATE_REGEX = "^([1-9]\\d{3}-)(([0]{0,1}[1-9]-)|([1][0-2]-))(([0-3]{0,1}[0-9]))$"; + private static String DATE_REGEX = "^((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29))\\s+([0-1]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$"; @Autowired private SurveyAnswerManager surveyAnswerManager; @Autowired @@ -73,8 +78,15 @@ public class ResponseController { ,String hospitalNumber ,String inspectNumber ,String source - ,String sourceNumber, - String answerId + ,String sourceNumber + ,String orgName + ,String orgCode + ,String estimateTemplateName + ,String estimateDate + ,String estimatePerson + ,String estimateScore + ,String estimateStatus + ,String answerId ) throws Exception { return saveSurvey(request,response ,siteUrl @@ -86,7 +98,15 @@ public class ResponseController { ,hospitalNumber ,inspectNumber ,source - ,sourceNumber, answerId); + ,sourceNumber + ,orgName + ,orgCode + ,estimateTemplateName + ,estimateDate + ,estimatePerson + ,estimateScore + ,estimateStatus + , answerId); } @RequestMapping("/saveMobile.do") @@ -100,7 +120,15 @@ public class ResponseController { ,String hospitalNumber ,String inspectNumber ,String source - ,String sourceNumber) throws Exception { + ,String sourceNumber + ,String orgName + ,String orgCode + ,String estimateTemplateName + ,String estimateDate + ,String estimatePerson + ,String estimateScore + ,String estimateStatus + ) throws Exception { return saveSurvey(request,response ,siteUrl ,surveyId @@ -111,7 +139,15 @@ public class ResponseController { ,hospitalNumber ,inspectNumber ,source - ,sourceNumber,null); + ,sourceNumber + ,orgName + ,orgCode + ,estimateTemplateName + ,estimateDate + ,estimatePerson + ,estimateScore + ,estimateStatus + ,null); } public String saveSurvey(HttpServletRequest request,HttpServletResponse response @@ -124,12 +160,34 @@ public class ResponseController { ,String hospitalNumber ,String inspectNumber ,String source - ,String sourceNumber,String answerId + ,String sourceNumber + ,String orgName + ,String orgCode + ,String estimateTemplateName + ,String estimateDate + ,String estimatePerson + ,String estimateScore + ,String estimateStatus + ,String answerId ) throws Exception { SurveyDirectory directory = null; try { directory = directoryManager.getSurvey(surveyId); + SurveyAnswer entity=new SurveyAnswer(); + + entity.setBusinessTypeId(directory.getBusinessTypeId()); + + if(StringUtils.isNotEmpty(answerId)) + { + entity.setAnswerId(answerId); + } + else + { + entity.setAnswerId(directory.getId()); + } + + entity.setAnswerId(surveyId); if(StringUtils.isNotEmpty(estimateName)) { entity.setEstimateName(estimateName); @@ -162,6 +220,71 @@ public class ResponseController { { entity.setSourceNumber(sourceNumber); } + + if(StringUtils.isNotEmpty(orgName)) + { + entity.setOrgName(orgName); + } + + if(StringUtils.isNotEmpty(orgCode)) + { + entity.setOrgCode(orgCode); + } + + if(StringUtils.isNotEmpty(estimateTemplateName)) + { + entity.setEstimateTemplateName(estimateTemplateName); + } + else + { + entity.setEstimateTemplateName(directory.getSurveyName()); + } + + if(StringUtils.isNotEmpty(sourceNumber)) + { + entity.setSourceNumber(sourceNumber); + } + + if(StringUtils.isNotEmpty(estimateDate)) + { + boolean matches = Pattern.matches(DATE_REGEX, estimateDate); + Date _date = new Date(); + if(matches == true){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //设置日期格式转的严谨性 + sdf.setLenient(false); + try { + _date = sdf.parse(estimateDate); + } catch (ParseException e) { + _date = new Date(); + } + } + entity.setEstimateDate(_date); + } + else + { + entity.setEstimateDate(new Date()); + } + + if(StringUtils.isNotEmpty(estimatePerson)) + { + entity.setEstimatePerson(estimatePerson); + } + + if(StringUtils.isNotEmpty(estimateScore)) + { + entity.setEstimateScore(estimateScore); + } + + if(StringUtils.isNotEmpty(estimateStatus)) + { + entity.setEstimateStatus(estimateStatus); + } + else + { + entity.setEstimateStatus("0"); + } + AnswerCheckData answerCheckData = answerCheckData(request,directory, true, entity); if(!answerCheckData.isAnswerCheck()) return answerRedirect(siteUrl,directory,answerCheckData.getAnswerCheckCode()); diff --git a/src/main/java/net/diaowen/estimate/entity/SurveyAnswer.java b/src/main/java/net/diaowen/estimate/entity/SurveyAnswer.java index bab6546..9bb2b1a 100644 --- a/src/main/java/net/diaowen/estimate/entity/SurveyAnswer.java +++ b/src/main/java/net/diaowen/estimate/entity/SurveyAnswer.java @@ -8,291 +8,458 @@ import javax.persistence.Table; import javax.persistence.Transient; import net.diaowen.common.base.entity.IdEntity; + /** * 具体的一次调查 - * @author keyuan * + * @author keyuan + *

* https://github.com/wkeyuan/DWSurvey * http://dwsurvey.net */ @Entity -@Table(name="t_survey_answer") -public class SurveyAnswer extends IdEntity{ - //问卷ID - private String surveyId; - //回答者ID - private String userId; - //回答时间 - private Date bgAnDate; - //回答时间 - private Date endAnDate=new Date(); - //用时 - private Float totalTime; - //回答者IP - private String ipAddr; - //回答者是详细地址 - private String addr; - //回答者城市 - private String city; - //回答者MAC - private String pcMac; - //回答的题数 - private Integer quNum; - - /** 回复的此条数据统计信息 **/ - - /** 数据--完成情况 是否全部题都回答 **/ - //是否完成 1完成 - private Integer isComplete; - //回答的题数 - private Integer completeNum; - //回答的题项目数 ---- 表示有些题下面会有多重回答 - private Integer completeItemNum; - - /** 数据--有效情况 根据设计问卷时指定的必填项 **/ - //是否是有效数据 1有效 - private Integer isEffective; - - /** 数据--审核情况 **/ - //审核状态 0未处理 1通过 2不通过 - private Integer handleState=0; - - /** 不同来源数据 **/ - //数据来源 0网调 1录入数据 2移动数据 3导入数据 - private Integer dataSource=0; - - - public String getSurveyName() { - return surveyName; - } - - public void setSurveyName(String surveyName) { - this.surveyName = surveyName; - } - - //问卷ID - @Transient - private String surveyName; - /** - * 评价人姓名 - */ - @Column(name = "estimate_name") - private String estimateName; - - /** - * 评价人性别 - */ - @Column(name = "estimate_gender") - private String estimateGender; - /** - * 评价人年龄 - */ - @Column(name = "estimate_age") - private String estimateAge; - - /** - * 门诊号 - */ - @Column(name = "outpatient_number") - private String outpatientNumber; - - /** - * 住院号 - */ - @Column(name = "hospital_number") - private String hospitalNumber; - - - - /** - * 检查号 - */ - @Column(name = "inspect_number") - private String inspectNumber; - - /** - * 来源 - */ - @Column(name = "source") - private String source; - - /** - * 来源编号 - */ - @Column(name = "source_number") - private String sourceNumber; - - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } - - public String getSourceNumber() { - return sourceNumber; - } - - public void setSourceNumber(String sourceNumber) { - this.sourceNumber = sourceNumber; - } - - public String getEstimateName() { - return estimateName; - } - - public void setEstimateName(String estimateName) { - this.estimateName = estimateName; - } - - public String getEstimateGender() { - return estimateGender; - } - - public void setEstimateGender(String estimateGender) { - this.estimateGender = estimateGender; - } - - public String getEstimateAge() { - return estimateAge; - } - - public void setEstimateAge(String estimateAge) { - this.estimateAge = estimateAge; - } - - public String getOutpatientNumber() { - return outpatientNumber; - } - - public void setOutpatientNumber(String outpatientNumber) { - this.outpatientNumber = outpatientNumber; - } - - public String getHospitalNumber() { - return hospitalNumber; - } - - public void setHospitalNumber(String hospitalNumber) { - this.hospitalNumber = hospitalNumber; - } - - public String getInspectNumber() { - return inspectNumber; - } - - public void setInspectNumber(String inspectNumber) { - this.inspectNumber = inspectNumber; - } - - public String getSurveyId() { - return surveyId; - } - public void setSurveyId(String surveyId) { - this.surveyId = surveyId; - } - public Date getBgAnDate() { - return bgAnDate; - } - public void setBgAnDate(Date bgAnDate) { - this.bgAnDate = bgAnDate; - } - public Date getEndAnDate() { - return endAnDate; - } - public void setEndAnDate(Date endAnDate) { - this.endAnDate = endAnDate; - } - public String getIpAddr() { - return ipAddr; - } - public void setIpAddr(String ipAddr) { - this.ipAddr = ipAddr; - } - public Integer getQuNum() { - return quNum; - } - public void setQuNum(Integer quNum) { - this.quNum = quNum; - } - public Float getTotalTime() { - return totalTime; - } - public void setTotalTime(Float totalTime) { - this.totalTime = totalTime; - } - public String getPcMac() { - return pcMac; - } - public void setPcMac(String pcMac) { - this.pcMac = pcMac; - } - public String getAddr() { - return addr; - } - public void setAddr(String addr) { - this.addr = addr; - } - public String getCity() { - return city; - } - public void setCity(String city) { - this.city = city; - } - public Integer getIsComplete() { - return isComplete; - } - public void setIsComplete(Integer isComplete) { - this.isComplete = isComplete; - } - public Integer getCompleteNum() { - return completeNum; - } - public void setCompleteNum(Integer completeNum) { - this.completeNum = completeNum; - } - public Integer getIsEffective() { - return isEffective; - } - public void setIsEffective(Integer isEffective) { - this.isEffective = isEffective; - } - public Integer getHandleState() { - return handleState; - } - public void setHandleState(Integer handleState) { - this.handleState = handleState; - } - public Integer getDataSource() { - return dataSource; - } - public void setDataSource(Integer dataSource) { - this.dataSource = dataSource; - } - public Integer getCompleteItemNum() { - return completeItemNum; - } - public void setCompleteItemNum(Integer completeItemNum) { - this.completeItemNum = completeItemNum; - } - public String getUserId() { - return userId; - } - public void setUserId(String userId) { - this.userId = userId; - } - - private SurveyDirectory surveyDirectory; - @Transient - public SurveyDirectory getSurveyDirectory() { - return surveyDirectory; - } - public void setSurveyDirectory(SurveyDirectory surveyDirectory) { - this.surveyDirectory = surveyDirectory; - } +@Table(name = "t_survey_answer") +public class SurveyAnswer extends IdEntity { + //问卷ID + private String surveyId; + //回答者ID + private String userId; + //回答时间 + private Date bgAnDate; + //回答时间 + private Date endAnDate = new Date(); + //用时 + private Float totalTime; + //回答者IP + private String ipAddr; + //回答者是详细地址 + private String addr; + //回答者城市 + private String city; + //回答者MAC + private String pcMac; + //回答的题数 + private Integer quNum; + + /** 回复的此条数据统计信息 **/ + + /** + * 数据--完成情况 是否全部题都回答 + **/ + //是否完成 1完成 + private Integer isComplete; + //回答的题数 + private Integer completeNum; + //回答的题项目数 ---- 表示有些题下面会有多重回答 + private Integer completeItemNum; + + /** + * 数据--有效情况 根据设计问卷时指定的必填项 + **/ + //是否是有效数据 1有效 + private Integer isEffective; + + /** + * 数据--审核情况 + **/ + //审核状态 0未处理 1通过 2不通过 + private Integer handleState = 0; + + /** + * 不同来源数据 + **/ + //数据来源 0网调 1录入数据 2移动数据 3导入数据 + private Integer dataSource = 0; + + //问卷ID + @Transient + private String surveyName; + /** + * 评价人姓名 + */ + @Column(name = "estimate_name") + private String estimateName; + + /** + * 评价人性别 + */ + @Column(name = "estimate_gender") + private String estimateGender; + /** + * 评价人年龄 + */ + @Column(name = "estimate_age") + private String estimateAge; + + /** + * 门诊号 + */ + @Column(name = "outpatient_number") + private String outpatientNumber; + + /** + * 住院号 + */ + @Column(name = "hospital_number") + private String hospitalNumber; + + + /** + * 检查号 + */ + @Column(name = "inspect_number") + private String inspectNumber; + + /** + * 来源 + */ + @Column(name = "source") + private String source; + + /** + * 来源编号 + */ + @Column(name = "source_number") + private String sourceNumber; + + @Column(name = "business_type_id") + private String businessTypeId; + + + /** + * 机构名称 + */ + @Column(name = "org_name") + private String orgName; + + /** + * 机构名称 + */ + @Column(name = "org_code") + private String orgCode; + + /** + * 评价模板 + */ + @Column(name = "estimate_template_name") + private String estimateTemplateName; + + /** + * 评价时间 + */ + @Column(name = "estimate_date") + private Date estimateDate; + + /** + * 评价人员 + */ + @Column(name = "estimate_person") + private String estimatePerson; + + /** + * 评分 + */ + @Column(name = "estimate_score") + private String estimateScore; + + + /** + * 评分 + */ + @Column(name = "estimate_status") + private String estimateStatus; + + /** + * 评分 + */ + @Column(name = "answer_id") + private String answerId; + + + public String getEstimateTemplateName() { + return estimateTemplateName; + } + + public void setEstimateTemplateName(String estimateTemplateName) { + this.estimateTemplateName = estimateTemplateName; + } + + public String getSurveyName() { + return surveyName; + } + + public void setSurveyName(String surveyName) { + this.surveyName = surveyName; + } + + public String getOrgCode() { + return orgCode; + } + + public void setOrgCode(String orgCode) { + this.orgCode = orgCode; + } + + public Date getEstimateDate() { + return estimateDate; + } + + public void setEstimateDate(Date estimateDate) { + this.estimateDate = estimateDate; + } + + public String getEstimatePerson() { + return estimatePerson; + } + + public void setEstimatePerson(String estimatePerson) { + this.estimatePerson = estimatePerson; + } + + public String getEstimateScore() { + return estimateScore; + } + + public void setEstimateScore(String estimateScore) { + this.estimateScore = estimateScore; + } + + public String getEstimateStatus() { + return estimateStatus; + } + + public void setEstimateStatus(String estimateStatus) { + this.estimateStatus = estimateStatus; + } + + public String getAnswerId() { + return answerId; + } + + public void setAnswerId(String answerId) { + this.answerId = answerId; + } + + public String getBusinessTypeId() { + return businessTypeId; + } + + public void setBusinessTypeId(String businessTypeId) { + this.businessTypeId = businessTypeId; + } + + public String getOrgName() { + return orgName; + } + + public void setOrgName(String orgName) { + this.orgName = orgName; + } + + + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getSourceNumber() { + return sourceNumber; + } + + public void setSourceNumber(String sourceNumber) { + this.sourceNumber = sourceNumber; + } + + public String getEstimateName() { + return estimateName; + } + + public void setEstimateName(String estimateName) { + this.estimateName = estimateName; + } + + public String getEstimateGender() { + return estimateGender; + } + + public void setEstimateGender(String estimateGender) { + this.estimateGender = estimateGender; + } + + public String getEstimateAge() { + return estimateAge; + } + + public void setEstimateAge(String estimateAge) { + this.estimateAge = estimateAge; + } + + public String getOutpatientNumber() { + return outpatientNumber; + } + + public void setOutpatientNumber(String outpatientNumber) { + this.outpatientNumber = outpatientNumber; + } + + public String getHospitalNumber() { + return hospitalNumber; + } + + public void setHospitalNumber(String hospitalNumber) { + this.hospitalNumber = hospitalNumber; + } + + public String getInspectNumber() { + return inspectNumber; + } + + public void setInspectNumber(String inspectNumber) { + this.inspectNumber = inspectNumber; + } + + public String getSurveyId() { + return surveyId; + } + + public void setSurveyId(String surveyId) { + this.surveyId = surveyId; + } + + public Date getBgAnDate() { + return bgAnDate; + } + + public void setBgAnDate(Date bgAnDate) { + this.bgAnDate = bgAnDate; + } + + public Date getEndAnDate() { + return endAnDate; + } + + public void setEndAnDate(Date endAnDate) { + this.endAnDate = endAnDate; + } + + public String getIpAddr() { + return ipAddr; + } + + public void setIpAddr(String ipAddr) { + this.ipAddr = ipAddr; + } + + public Integer getQuNum() { + return quNum; + } + + public void setQuNum(Integer quNum) { + this.quNum = quNum; + } + + public Float getTotalTime() { + return totalTime; + } + + public void setTotalTime(Float totalTime) { + this.totalTime = totalTime; + } + + public String getPcMac() { + return pcMac; + } + + public void setPcMac(String pcMac) { + this.pcMac = pcMac; + } + + public String getAddr() { + return addr; + } + + public void setAddr(String addr) { + this.addr = addr; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public Integer getIsComplete() { + return isComplete; + } + + public void setIsComplete(Integer isComplete) { + this.isComplete = isComplete; + } + + public Integer getCompleteNum() { + return completeNum; + } + + public void setCompleteNum(Integer completeNum) { + this.completeNum = completeNum; + } + + public Integer getIsEffective() { + return isEffective; + } + + public void setIsEffective(Integer isEffective) { + this.isEffective = isEffective; + } + + public Integer getHandleState() { + return handleState; + } + + public void setHandleState(Integer handleState) { + this.handleState = handleState; + } + + public Integer getDataSource() { + return dataSource; + } + + public void setDataSource(Integer dataSource) { + this.dataSource = dataSource; + } + + public Integer getCompleteItemNum() { + return completeItemNum; + } + + public void setCompleteItemNum(Integer completeItemNum) { + this.completeItemNum = completeItemNum; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + private SurveyDirectory surveyDirectory; + @Transient + public SurveyDirectory getSurveyDirectory() { + return surveyDirectory; + } + public void setSurveyDirectory(SurveyDirectory surveyDirectory) { + this.surveyDirectory = surveyDirectory; + } } diff --git a/src/main/java/net/diaowen/estimate/service/SurveyAnswerManager.java b/src/main/java/net/diaowen/estimate/service/SurveyAnswerManager.java index 69c89f6..793a24d 100644 --- a/src/main/java/net/diaowen/estimate/service/SurveyAnswerManager.java +++ b/src/main/java/net/diaowen/estimate/service/SurveyAnswerManager.java @@ -37,7 +37,7 @@ public interface SurveyAnswerManager extends BaseService{ * @param surveyIds * @return */ - public Page answerPage(Page page, String[] surveyIds,String startToEndDate); + public Page answerPage(Page page, String[] surveyIds,Map params); public void deleteData(String[] ids); diff --git a/src/main/java/net/diaowen/estimate/service/impl/SurveyAnswerManagerImpl.java b/src/main/java/net/diaowen/estimate/service/impl/SurveyAnswerManagerImpl.java index 30fd462..6186bae 100644 --- a/src/main/java/net/diaowen/estimate/service/impl/SurveyAnswerManagerImpl.java +++ b/src/main/java/net/diaowen/estimate/service/impl/SurveyAnswerManagerImpl.java @@ -591,9 +591,28 @@ public class SurveyAnswerManagerImpl extends * 取一份卷子回答的数据 */ @Override - public Page answerPage(Page page,String[] surveyIds, String startToEndDate){ + public Page answerPage(Page page,String[] surveyIds, Map params){ //Restrictions.between("bgAnDate",) + List listCriterion = new ArrayList<>(); + Criterion cri1 = null; + Criterion cri2 = null; Criterion cri3 = null; + Criterion cri4 = null; + Criterion cri5 = null; + Criterion cri6 = null; + Criterion cri7 = null; + Criterion cri8 = null; + + if(surveyIds.length > 0) { + cri1 = Restrictions.in("surveyId", surveyIds); + cri2 = Restrictions.lt("handleState", 2); + } + else + { + cri2 = Restrictions.lt("handleState", 2); + } + + String startToEndDate = params.get("startToEndDate"); if(StringUtils.isNotEmpty(startToEndDate)) { String [] bgAnDate = startToEndDate.split(",",-1); @@ -613,33 +632,80 @@ public class SurveyAnswerManagerImpl extends } } } - - if(surveyIds.length>0) { - Criterion cri1 = Restrictions.in("surveyId", surveyIds); - Criterion cri2 = Restrictions.lt("handleState", 2); - page.setOrderBy("endAnDate"); - page.setOrderDir("desc"); - if(cri3 == null) { - page = findPage(page, cri1, cri2); - } - else - { - page = findPage(page, cri1, cri2, cri3); - } - } - else + String startToEndEstimateDate = params.get("startToEndEstimateDate"); + if(StringUtils.isNotEmpty(startToEndEstimateDate)) { - Criterion cri2 = Restrictions.lt("handleState", 2); - page.setOrderBy("endAnDate"); - page.setOrderDir("desc"); - if(cri3 == null) { - page = findPage(page, cri2); - } - else + String [] bgAnDate = startToEndEstimateDate.split(",",-1); + if(bgAnDate.length>=2) { - page = findPage(page, cri2,cri3); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date startDate = null; + Date endDate = null; + try { + startDate = df.parse(bgAnDate[0]+" 00:00:00"); + endDate = df.parse(bgAnDate[1]+" 23:59:59"); + } catch (ParseException e) { + e.printStackTrace(); + } + if((startDate!=null) && (endDate!=null)) { + cri4 = Restrictions.between("estimateDate", startDate, endDate); + } } } + + String businessId = params.get("businessId"); + if(StringUtils.isNotEmpty(businessId)) { + cri5 = Restrictions.eq("businessTypeId", businessId); + } + + String surveyId = params.get("surveyId"); + if(StringUtils.isNotEmpty(surveyId)) { + cri6 = Restrictions.eq("surveyId", surveyId); + } + + String orgCode = params.get("orgCode"); + if(StringUtils.isNotEmpty(orgCode)) { + cri7 = Restrictions.eq("orgCode", orgCode); + } + + String estimateStatus = params.get("estimateStatus"); + if(StringUtils.isNotEmpty(estimateStatus)) { + cri8 = Restrictions.eq("estimateStatus", estimateStatus); + } + + if (cri1 != null) { + listCriterion.add(cri1); + } + if (cri2 != null) { + listCriterion.add(cri2); + } + if (cri3 != null) { + listCriterion.add(cri3); + } + + if (cri4 != null) { + listCriterion.add(cri4); + } + if (cri5 != null) { + listCriterion.add(cri5); + } + if (cri6 != null) { + listCriterion.add(cri6); + } + if (cri7 != null) { + listCriterion.add(cri7); + } + if (cri8 != null) { + listCriterion.add(cri8); + } + + Criterion [] criterions = listCriterion.toArray(new Criterion[listCriterion.size()]); + + page.setOrderBy("endAnDate"); + page.setOrderDir("desc"); + + page=findPage(page, criterions); + return page; } -- Gitee From a19e52bd66d87a2a5c56188c3338decf93e9255d Mon Sep 17 00:00:00 2001 From: kingchenglee <34094793@qq.com> Date: Thu, 18 Aug 2022 09:48:42 +0800 Subject: [PATCH 2/3] =?UTF-8?q?YCHZ-323-=E3=80=90=E8=AF=84=E4=BB=B7?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E3=80=91=E7=B3=BB=E7=BB=9F=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=BA=E6=9E=84=E7=AE=A1=E7=90=86=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/sys/SysOrgController.java | 31 ++++++++ .../net/diaowen/estimate/dao/SysOrgDao.java | 7 ++ .../estimate/dao/impl/SysOrgDaoImpl.java | 10 +++ .../net/diaowen/estimate/entity/SysOrg.java | 70 +++++++++++++++++++ .../estimate/service/SysOrgManager.java | 12 ++++ .../service/impl/SysOrgManagerImpl.java | 42 +++++++++++ 6 files changed, 172 insertions(+) create mode 100644 src/main/java/net/diaowen/estimate/controller/sys/SysOrgController.java create mode 100644 src/main/java/net/diaowen/estimate/dao/SysOrgDao.java create mode 100644 src/main/java/net/diaowen/estimate/dao/impl/SysOrgDaoImpl.java create mode 100644 src/main/java/net/diaowen/estimate/entity/SysOrg.java create mode 100644 src/main/java/net/diaowen/estimate/service/SysOrgManager.java create mode 100644 src/main/java/net/diaowen/estimate/service/impl/SysOrgManagerImpl.java diff --git a/src/main/java/net/diaowen/estimate/controller/sys/SysOrgController.java b/src/main/java/net/diaowen/estimate/controller/sys/SysOrgController.java new file mode 100644 index 0000000..4c79151 --- /dev/null +++ b/src/main/java/net/diaowen/estimate/controller/sys/SysOrgController.java @@ -0,0 +1,31 @@ +package net.diaowen.estimate.controller.sys; + +import net.diaowen.common.base.entity.User; +import net.diaowen.common.plugs.httpclient.PageResult; +import net.diaowen.common.plugs.httpclient.ResultUtils; +import net.diaowen.common.plugs.page.Page; +import net.diaowen.estimate.entity.SysOrg; +import net.diaowen.estimate.service.SysOrgManager; +import net.diaowen.estimate.service.UserManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/api/dwsurvey/app/org") +public class SysOrgController { + + @Autowired + private SysOrgManager sysOrgManager; + + @RequestMapping(value = "/list.do", method = RequestMethod.GET) + @ResponseBody + public PageResult list(PageResult pageResult,String orgName) { + Page page = ResultUtils.getPageByPageResult(pageResult); + page = sysOrgManager.findPage(page, orgName); + pageResult = ResultUtils.getPageResultByPage(page, pageResult); + return pageResult; + } +} diff --git a/src/main/java/net/diaowen/estimate/dao/SysOrgDao.java b/src/main/java/net/diaowen/estimate/dao/SysOrgDao.java new file mode 100644 index 0000000..1f0e33b --- /dev/null +++ b/src/main/java/net/diaowen/estimate/dao/SysOrgDao.java @@ -0,0 +1,7 @@ +package net.diaowen.estimate.dao; + +import net.diaowen.common.dao.BaseDao; +import net.diaowen.estimate.entity.SysOrg; + +public interface SysOrgDao extends BaseDao { +} diff --git a/src/main/java/net/diaowen/estimate/dao/impl/SysOrgDaoImpl.java b/src/main/java/net/diaowen/estimate/dao/impl/SysOrgDaoImpl.java new file mode 100644 index 0000000..e335413 --- /dev/null +++ b/src/main/java/net/diaowen/estimate/dao/impl/SysOrgDaoImpl.java @@ -0,0 +1,10 @@ +package net.diaowen.estimate.dao.impl; + +import net.diaowen.common.dao.BaseDaoImpl; +import net.diaowen.estimate.dao.SysOrgDao; +import net.diaowen.estimate.entity.SysOrg; +import org.springframework.stereotype.Repository; + +@Repository +public class SysOrgDaoImpl extends BaseDaoImpl implements SysOrgDao { +} diff --git a/src/main/java/net/diaowen/estimate/entity/SysOrg.java b/src/main/java/net/diaowen/estimate/entity/SysOrg.java new file mode 100644 index 0000000..6c05266 --- /dev/null +++ b/src/main/java/net/diaowen/estimate/entity/SysOrg.java @@ -0,0 +1,70 @@ +package net.diaowen.estimate.entity; + +import net.diaowen.common.base.entity.IdEntity; + +import javax.persistence.Entity; +import javax.persistence.Table; +import java.util.Date; + +/** + * 机构管理 + */ +@Entity +@Table(name = "t_sys_org") +public class SysOrg extends IdEntity { + + private String orgName; + private String orgCode; + private String parentOrgCode; + private String status; + private Date createTime = new Date(); + private String createBy; + + public String getOrgName() { + return orgName; + } + + public void setOrgName(String orgName) { + this.orgName = orgName; + } + + public String getOrgCode() { + return orgCode; + } + + public void setOrgCode(String orgCode) { + this.orgCode = orgCode; + } + + public String getParentOrgCode() { + return parentOrgCode; + } + + public void setParentOrgCode(String parentOrgCode) { + this.parentOrgCode = parentOrgCode; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } +} diff --git a/src/main/java/net/diaowen/estimate/service/SysOrgManager.java b/src/main/java/net/diaowen/estimate/service/SysOrgManager.java new file mode 100644 index 0000000..dbcdca8 --- /dev/null +++ b/src/main/java/net/diaowen/estimate/service/SysOrgManager.java @@ -0,0 +1,12 @@ +package net.diaowen.estimate.service; + +import net.diaowen.common.base.entity.User; +import net.diaowen.common.plugs.page.Page; +import net.diaowen.common.service.BaseService; +import net.diaowen.estimate.entity.SysOrg; + +public interface SysOrgManager extends BaseService { + + public Page findPage(Page page, String orgName); + +} diff --git a/src/main/java/net/diaowen/estimate/service/impl/SysOrgManagerImpl.java b/src/main/java/net/diaowen/estimate/service/impl/SysOrgManagerImpl.java new file mode 100644 index 0000000..ffd4b1f --- /dev/null +++ b/src/main/java/net/diaowen/estimate/service/impl/SysOrgManagerImpl.java @@ -0,0 +1,42 @@ +package net.diaowen.estimate.service.impl; + + +import net.diaowen.common.plugs.page.Page; +import net.diaowen.common.service.BaseServiceImpl; +import net.diaowen.estimate.dao.SysOrgDao; +import net.diaowen.estimate.entity.SysOrg; +import net.diaowen.estimate.service.SysOrgManager; +import org.apache.commons.lang3.StringUtils; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Restrictions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class SysOrgManagerImpl extends BaseServiceImpl implements SysOrgManager { + + @Autowired + private SysOrgDao sysOrgDao; + + @Override + public void setBaseDao() { + this.baseDao = sysOrgDao; + } + + @Override + public Page findPage(Page page, String orgName) { + List criterions = new ArrayList(); + if (StringUtils.isNotEmpty(orgName)) { + criterions.add(Restrictions.like("orgName", "%" + orgName + "%")); + } + criterions.add(Restrictions.in("status", 1)); + if (StringUtils.isEmpty(page.getOrderBy())) { + page.setOrderBy("createTime"); + page.setOrderDir("desc"); + } + return super.findPageByCri(page, criterions); + } +} -- Gitee From 8bfcc5ff61f1f9f95e5c9255a6d5d95780fa9c90 Mon Sep 17 00:00:00 2001 From: zhangxb Date: Fri, 19 Aug 2022 09:38:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?YCHZ-32-zhangxianbo-=E3=80=90=E8=AF=84?= =?UTF-8?q?=E4=BB=B7=E7=B3=BB=E7=BB=9F=E3=80=91=E6=A3=80=E6=9F=A5=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=BB=A1=E8=B6=B3=E6=9C=BA=E6=9E=84=20?= =?UTF-8?q?=E7=AD=94=E5=8D=B7=E6=97=B6=E9=97=B4=20=E7=8A=B6=E6=80=81=20?= =?UTF-8?q?=E6=9C=BA=E6=9E=84=20=E4=B8=9A=E5=8A=A1=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../question/ResponseController.java | 25 +++++++- .../survey/MySurveyAnswerController.java | 59 ++++++++++++++++--- 2 files changed, 75 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/diaowen/estimate/controller/question/ResponseController.java b/src/main/java/net/diaowen/estimate/controller/question/ResponseController.java index 90cfc03..e330702 100644 --- a/src/main/java/net/diaowen/estimate/controller/question/ResponseController.java +++ b/src/main/java/net/diaowen/estimate/controller/question/ResponseController.java @@ -15,7 +15,10 @@ import net.diaowen.estimate.config.DWSurveyConfig; import net.diaowen.estimate.entity.*; import net.diaowen.estimate.service.SurveyAnswerManager; import net.diaowen.estimate.service.SurveyDirectoryManager; +import net.diaowen.estimate.service.SysOrgManager; import org.apache.commons.lang.StringUtils; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; @@ -64,6 +67,10 @@ public class ResponseController { private AccountManager accountManager; @Autowired private ImageCaptchaService imageCaptchaService; + + @Autowired + private SysOrgManager sysOrgManager; + // @Autowired // private SurveyAnswerLogManager surveyAnswerLogManager; @@ -288,6 +295,9 @@ public class ResponseController { AnswerCheckData answerCheckData = answerCheckData(request,directory, true, entity); if(!answerCheckData.isAnswerCheck()) return answerRedirect(siteUrl,directory,answerCheckData.getAnswerCheckCode()); + + checkOrcreateSysOrg(orgCode,orgName,estimatePerson); + answerSurvey(request,surveyId,entity); answerAfterUpData(request,response,surveyId,entity.getId()); return answerRedirect(siteUrl,directory,6, entity.getId()); @@ -296,7 +306,20 @@ public class ResponseController { return answerRedirect(siteUrl,directory,5); } } - + public void checkOrcreateSysOrg(String orgCode,String orgName,String createBy){ + Criterion cri = Restrictions.eq("orgCode",orgCode); + List listSysOrg = sysOrgManager.findList(cri); + if((null== listSysOrg) || (listSysOrg.size()==0)) + { + SysOrg sysOrg = new SysOrg(); + sysOrg.setOrgCode(orgCode); + sysOrg.setOrgName(orgName); + sysOrg.setCreateBy(createBy); + sysOrg.setCreateTime(new Date()); + sysOrg.setStatus("0"); + sysOrgManager.save(sysOrg); + } + } public AnswerCheckData answerCheckData(HttpServletRequest request, SurveyDirectory directory,boolean isSubmit,SurveyAnswer entity) { AnswerCheckData answerCheckData = new AnswerCheckData(); String surveyId = directory.getId(); diff --git a/src/main/java/net/diaowen/estimate/controller/survey/MySurveyAnswerController.java b/src/main/java/net/diaowen/estimate/controller/survey/MySurveyAnswerController.java index 66c7f1c..4e9fc8a 100644 --- a/src/main/java/net/diaowen/estimate/controller/survey/MySurveyAnswerController.java +++ b/src/main/java/net/diaowen/estimate/controller/survey/MySurveyAnswerController.java @@ -9,13 +9,11 @@ import net.diaowen.common.plugs.page.Page; import net.diaowen.common.utils.UserAgentUtils; import net.diaowen.common.utils.ZipUtil; import net.diaowen.estimate.config.DWSurveyConfig; -import net.diaowen.estimate.entity.AnUplodFile; -import net.diaowen.estimate.entity.Question; -import net.diaowen.estimate.entity.SurveyAnswer; -import net.diaowen.estimate.entity.SurveyDirectory; +import net.diaowen.estimate.entity.*; import net.diaowen.estimate.service.AnUploadFileManager; import net.diaowen.estimate.service.SurveyAnswerManager; import net.diaowen.estimate.service.SurveyDirectoryManager; +import net.diaowen.estimate.service.SysOrgManager; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -27,6 +25,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -43,6 +42,9 @@ public class MySurveyAnswerController { @Autowired private AnUploadFileManager anUploadFileManager; + @Autowired + private SysOrgManager sysOrgManager; + /** * 获取答卷列表 * @@ -50,7 +52,11 @@ public class MySurveyAnswerController { */ @RequestMapping(value = "/list.do", method = RequestMethod.GET) @ResponseBody - public PageResult survey(HttpServletRequest request, PageResult pageResult, String businessId, String surveyId, String ipAddr, String city, Integer isEffective, String startToEndDate) { + public PageResult survey(HttpServletRequest request, PageResult pageResult, + String businessId, String surveyId, String ipAddr + , String city, Integer isEffective + , String startToEndEstimateDate,String orgCode ,String estimateStatus + , String startToEndDate) { UserAgentUtils.userAgent(request); User user = accountManager.getCurUser(); if (user != null) { @@ -67,7 +73,15 @@ public class MySurveyAnswerController { } else { surveyIds = surveyDirectoryManager.getSurveyByType(businessId).stream().map(SurveyDirectory::getId).toArray(String[]::new); } - page = surveyAnswerManager.answerPage(page, surveyIds, startToEndDate); + Map params = new HashMap<>(); + params.put("startToEndDate",startToEndDate); + params.put("businessId",businessId); + params.put("surveyId",surveyId); + params.put("startToEndEstimateDate",startToEndEstimateDate); + params.put("orgCode",orgCode); + params.put("estimateStatus",estimateStatus); + + page = surveyAnswerManager.answerPage(page, surveyIds, params); } pageResult = ResultUtils.getPageResultByPage(page, pageResult); } @@ -82,7 +96,11 @@ public class MySurveyAnswerController { */ @RequestMapping(value = "/listAll.do", method = RequestMethod.GET) @ResponseBody - public PageResult surveyAll(HttpServletRequest request, PageResult pageResult, String businessId, String surveyId, String ipAddr, String city, Integer isEffective, String startToEndDate) { + public PageResult surveyAll(HttpServletRequest request, PageResult pageResult, + String businessId, String surveyId, String ipAddr + ,String city, Integer isEffective + , String startToEndEstimateDate,String orgCode ,String estimateStatus + ,String startToEndDate) { UserAgentUtils.userAgent(request); Page page = ResultUtils.getPageByPageResult(pageResult); @@ -101,7 +119,15 @@ public class MySurveyAnswerController { } else { surveyIds = surveyDirectoryManager.getSurveyByType(businessId).stream().map(SurveyDirectory::getId).toArray(String[]::new); } - page = surveyAnswerManager.answerPage(page, surveyIds, startToEndDate); + Map params = new HashMap<>(); + params.put("startToEndDate",startToEndDate); + params.put("businessId",businessId); + params.put("surveyId",surveyId); + params.put("startToEndEstimateDate",startToEndEstimateDate); + params.put("orgCode",orgCode); + params.put("estimateStatus",estimateStatus); + + page = surveyAnswerManager.answerPage(page, surveyIds, params); List surveyAnswers = page.getResult(); for (int i = 0; i < surveyAnswers.size(); i++) { @@ -214,5 +240,22 @@ public class MySurveyAnswerController { return null; } + /** + * 拉取组织无条件列表 + * @return + * @throws Exception + */ + @RequestMapping(value = "/orgSimpleList.do", method = RequestMethod.GET) + @ResponseBody + public HttpResult getOrgSimpleList() throws Exception { + try { + List listSysOrg = sysOrgManager.findList(); + + return HttpResult.SUCCESS(listSysOrg); + } catch (Exception e) { + e.printStackTrace(); + } + return HttpResult.FAILURE(); + } } -- Gitee