소스 검색

Merge branch 'dev' of trick9191/wlyy2.0 into dev

trick9191 5 년 전
부모
커밋
ba30abc3f5

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyUserAnswerDao.java

@ -14,4 +14,7 @@ public interface SurveyUserAnswerDao extends PagingAndSortingRepository<WlyySurv
    List<WlyySurveyUserAnswerDO> findBySurveyTempCodeAndPatient(String surveyTempCode,String patient);
    List<WlyySurveyUserAnswerDO> findByTempQuestionCode(String tempQuestionCode);
    List<WlyySurveyUserAnswerDO> findBytempOptionCode(String tempOptionCode);
}

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyUserDao.java

@ -4,8 +4,12 @@ import com.yihu.jw.entity.hospital.survey.WlyySurveyUserDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2019/9/6.
 */
public interface SurveyUserDao extends PagingAndSortingRepository<WlyySurveyUserDO, String>, JpaSpecificationExecutor<WlyySurveyUserDO> {
    List<WlyySurveyUserDO> findBySurveyTempCodeAndStatus(String surveyTempCode,Integer status);
}

+ 183 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/survey/service/SurveyService.java

@ -10,6 +10,8 @@ import com.yihu.jw.restmodel.hospital.consult.WlyyHospitalSysDictVO;
import com.yihu.jw.restmodel.hospital.survey.*;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.PercentageUtil;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
@ -473,6 +475,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
     */
    public List<Map<String,Object>> findDeptBySurvey(String tempId){
        String sql ="SELECT " +
                " d.survey_temp_code AS surveyTempCode," +
                " d.dept, " +
                " d.dept_name AS deptName " +
                " FROM " +
@ -514,4 +517,184 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        List<WlyySurveyUserAnswerDO> list = surveyUserAnswerDao.findBySurveyTempCodeAndPatient(tempId,patient);
        return list;
    }
    /**
     * 查询问题情况
     * @param tempId
     * @return
     */
    public WlyySurveyTemplateVO findSurveyTemplateResult(String tempId) {
        WlyySurveyTemplateDO templateDO = surveyTemplateDao.findOne(tempId);
        WlyySurveyTemplateVO templateVO = convertToModel(templateDO,WlyySurveyTemplateVO.class);
        templateVO.setLabels(findSurveyTemplateLabel(tempId));
        templateVO.setInsplabels(findSurveyInspTemplateLabel(tempId));
        //查询所有答题过的用户,计算答题总数
        List<WlyySurveyUserDO> surveyUsers = surveyUserDao.findBySurveyTempCodeAndStatus(templateVO.getId(),1);
        Integer total =0;
        if(surveyUsers!=null&&surveyUsers.size()>0){
            total = surveyUsers.size();
        }
        List<WlyySurveyTemplateQuestionDO> tqDOs = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(tempId,"1");
        if(tqDOs!=null&&tqDOs.size()>0){
            //设置问题
            List<WlyySurveyTemplateQuestionVO> tqVOs = new ArrayList<>();
            convertToModels(tqDOs,tqVOs,WlyySurveyTemplateQuestionVO.class);
            templateVO.setTemplateQuestionVOs(tqVOs);
            //设置选项
            for(WlyySurveyTemplateQuestionVO tq:tqVOs){
                List<WlyySurveyTemplateOptionDO> optionDOs  = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getId(),"1");
                List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
                convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
                /**
                 * 统计每个选项选择的百分比
                 */
                if(optionVOs!=null&&optionVOs.size()>0){
                    for(WlyySurveyTemplateOptionVO vo:optionVOs){
                        Integer answerCount =0;
                        List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getId());
                        if(answerDOs!=null&&answerDOs.size()>0){
                            answerCount = answerDOs.size();
                        }
                        vo.setPercentage(PercentageUtil.bs(answerCount,total)+"%");
                    }
                }
                tq.setOptionVOs(optionVOs);
            }
        }
        return templateVO;
    }
    /**
     * 综合查询问题答案
     * @param comment
     * @param content
     * @param tempQuestionCode
     * @param tempOptionCode
     * @param page
     * @param size
     * @return
     */
    public MixEnvelop findQuestionInfoList(String comment, String content, String tempQuestionCode,String tempOptionCode,Integer page,Integer size){
        String totalSql ="SELECT " +
                " COUNT(1) AS total" +
                " FROM " +
                " wlyy_survey_user_answer t " +
                " WHERE 1=1";
        if(StringUtils.isNotBlank(comment)){
            totalSql += " AND t.comment like '%"+comment+"%' ";
        }
        if(StringUtils.isNotBlank(content)){
            totalSql += " AND t.content  like '%"+content+"%'";
        }
        if(StringUtils.isNotBlank(tempQuestionCode)){
            totalSql += " AND t.temp_question_code ='"+tempQuestionCode+"'";
        }
        if(StringUtils.isNotBlank(tempOptionCode)){
            totalSql += " AND t.temp_option_code ='"+tempOptionCode+"'";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
        }
        String sql = "SELECT " +
                " t.id, " +
                " t.survey_temp_code AS surveyTempCode, " +
                " t.temp_question_code AS tempQuestionCode, " +
                " t.question_type AS questionType, " +
                " t.temp_option_code AS tempOptionCode, " +
                " t.comment, " +
                " t.content, " +
                " t.patient," +
                " t.patient_name AS patientName," +
                " t.score," +
                " t.create_time AS createTime" +
                " FROM " +
                " wlyy_survey_user_answer t ";
        if(StringUtils.isNotBlank(comment)){
            sql += " AND t.comment like '%"+comment+"%' ";
        }
        if(StringUtils.isNotBlank(content)){
            sql += " AND t.content  like '%"+content+"%'";
        }
        if(StringUtils.isNotBlank(tempQuestionCode)){
            sql += " AND t.temp_question_code ='"+tempQuestionCode+"'";
        }
        if(StringUtils.isNotBlank(tempOptionCode)){
            sql += " AND t.temp_option_code ='"+tempOptionCode+"'";
        }
        sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
        List<WlyySurveyUserAnswerDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyUserAnswerDO.class));
        return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
    }
    /**
     * 查询
     * @param title
     * @param page
     * @param size
     * @return
     */
    public MixEnvelop findAnswerList(String title,Integer page,Integer size){
        String totalSql ="SELECT " +
                " COUNT(1) AS total" +
                " FROM " +
                " wlyy_survey_user t " +
                " WHERE 1=1";
        if(StringUtils.isNotBlank(title)){
            totalSql += " AND t.title like '%"+title+"%' ";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
        }
        String sql = "SELECT " +
                " t.id, " +
                " t.survey_temp_code AS surveyTempCode, " +
                " t.survey_temp_title AS surveyTempTitle, " +
                " t.patient," +
                " t.patient_name AS patientName," +
                " t.score," +
                " t.dept," +
                " t.dept_name AS deptName," +
                " t.doctor," +
                " t.doctor_name AS doctorName," +
                " t.status," +
                " t.end_time AS endTime," +
                " t.create_time AS createTime," +
                " p.idcard" +
                " FROM " +
                " wlyy_survey_user t " +
                " JOIN base_patient p ON t.patient = p.id " +
                " WHERE 1=1 ";
        if(StringUtils.isNotBlank(title)){
            sql += " AND t.title like '%"+title+"%' ";
        }
        sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
        List<WlyySurveyUserVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyUserVO.class));
        if(list!=null&&list.size()>0){
            for(WlyySurveyUserVO vo :list){
                vo.setAge(IdCardUtil.getAgeForIdcard(vo.getIdcard()));
            }
        }
        return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
    }
}

+ 36 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyUserDO.java

@ -18,6 +18,10 @@ public class WlyySurveyUserDO extends UuidIdentityEntity {
    private String surveyTempTitle;//模板标题
    private String patient;//患者ID',
    private String patientName;//
    private String dept;//部门
    private String deptName;//部门名称
    private String doctor;  //医生
    private String doctorName;//医生名称
    private Integer status;//是否已答(0未答 1已答 2放弃)',
    private Date endTime;//完成时间(放弃时间)',
    private Date createTime;//调查时间(居民接受时间)',
@ -79,4 +83,36 @@ public class WlyySurveyUserDO extends UuidIdentityEntity {
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
}

+ 3 - 3
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/survey/WlyySurveyQuestionsOptionVO.java

@ -15,7 +15,7 @@ public class WlyySurveyQuestionsOptionVO extends UuidIdentityVO {
    @ApiModelProperty(value = "选项内容", example = "模块1")
    private String content;//选项内容',
    @ApiModelProperty(value = "是否有备注,0没有,1有", example = "模块1")
    private String haveComment;
    private Integer haveComment;
    @ApiModelProperty(value = "选项说明是否必填(0否 1是)", example = "模块1")
    private Integer isRequired;//选项说明是否必填(0否 1是)',
    @ApiModelProperty(value = "单题内排序", example = "模块1")
@ -63,11 +63,11 @@ public class WlyySurveyQuestionsOptionVO extends UuidIdentityVO {
        this.del = del;
    }
    public String getHaveComment() {
    public Integer getHaveComment() {
        return haveComment;
    }
    public void setHaveComment(String haveComment) {
    public void setHaveComment(Integer haveComment) {
        this.haveComment = haveComment;
    }
}

+ 11 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/survey/WlyySurveyTemplateOptionVO.java

@ -31,6 +31,9 @@ public class WlyySurveyTemplateOptionVO extends UuidIdentityVO {
    @ApiModelProperty(value = "单题内排序", example = "模块1")
    private Integer sort;//单题内排序',
    @ApiModelProperty(value = "百分比", example = "模块1")
    private String percentage;
    public String getTemplateCode() {
        return templateCode;
    }
@ -110,4 +113,12 @@ public class WlyySurveyTemplateOptionVO extends UuidIdentityVO {
    public void setHaveComment(String haveComment) {
        this.haveComment = haveComment;
    }
    public String getPercentage() {
        return percentage;
    }
    public void setPercentage(String percentage) {
        this.percentage = percentage;
    }
}

+ 145 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/survey/WlyySurveyUserVO.java

@ -0,0 +1,145 @@
package com.yihu.jw.restmodel.hospital.survey;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * Created by Trick on 2019/9/17.
 */
@ApiModel(value = "WlyySurveyUserVO", description = "问卷调查")
public class WlyySurveyUserVO extends UuidIdentityVO {
    @ApiModelProperty(value = "问卷模板编码", example = "模块1")
    private String surveyTempCode;//问卷模板编码',
    @ApiModelProperty(value = "模板标题", example = "模块1")
    private String surveyTempTitle;//模板标题
    @ApiModelProperty(value = "患者ID", example = "模块1")
    private String patient;//患者ID',
    @ApiModelProperty(value = "患者", example = "模块1")
    private String patientName;//
    @ApiModelProperty(value = "部门", example = "模块1")
    private String dept;//部门
    @ApiModelProperty(value = "部门名称", example = "模块1")
    private String deptName;//部门名称
    @ApiModelProperty(value = "医生", example = "模块1")
    private String doctor;  //医生
    @ApiModelProperty(value = "医生名称", example = "模块1")
    private String doctorName;//医生名称
    @ApiModelProperty(value = "是否已答", example = "模块1")
    private Integer status;//是否已答(0未答 1已答 2放弃)',
    @ApiModelProperty(value = "完成时间", example = "模块1")
    private Date endTime;//完成时间(放弃时间)',
    @ApiModelProperty(value = "调查时间", example = "模块1")
    private Date createTime;//调查时间(居民接受时间)',
    @ApiModelProperty(value = "身份证", example = "模块1")
    private String idcard;
    @ApiModelProperty(value = "年龄", example = "模块1")
    private Integer age;
    public String getSurveyTempCode() {
        return surveyTempCode;
    }
    public void setSurveyTempCode(String surveyTempCode) {
        this.surveyTempCode = surveyTempCode;
    }
    public String getSurveyTempTitle() {
        return surveyTempTitle;
    }
    public void setSurveyTempTitle(String surveyTempTitle) {
        this.surveyTempTitle = surveyTempTitle;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
}

+ 29 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/PercentageUtil.java

@ -0,0 +1,29 @@
package com.yihu.jw.util.common;
import java.math.BigDecimal;
/**
 * Created by Trick on 2019/9/17.
 */
public class PercentageUtil {
    /**
     * 求百分比
     * @param a
     * @param b
     * @return
     */
    public static double bs(int a, int b) {
        if(b==0||a==0){
            return 0;
        }
        return ((new BigDecimal((float) a / b).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100);
    }
//    public static void main(String[] args) {
//        double v = bs(0,545);
//        String str = v+"%";
//        System.out.println(str);
//    }
}