Browse Source

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

wangzhinan 4 years ago
parent
commit
fc5cf6065e

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

@ -15,5 +15,4 @@ public interface SurveyTemplateOptionDao extends PagingAndSortingRepository<Wlyy
    List<WlyySurveyTemplateOptionDO> findByQuestionCodeAndDelOrderBySortAsc(String questionCode,String templateCode,String del);
    List<WlyySurveyTemplateOptionDO> findByTemplateCodeAndDelOrderBySortAsc(String templateCode,String del);
}

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

@ -15,6 +15,6 @@ public interface SurveyUserDao extends PagingAndSortingRepository<WlyySurveyUser
    List<WlyySurveyUserDO> findBySurveyTempCodeAndStatus(String surveyTempCode,Integer status);
    @Query("from WlyySurveyUserDO c WHERE c.surveyTempCode = ?1 and c.patient =?2 and c.status =1 and c.createTime >= ?3")
    List<WlyySurveyUserDO> findBySurvey(String surveyTempCode,String patient,Date createTime);
    @Query("from WlyySurveyUserDO c WHERE c.surveyTempCode = ?1 and c.patient =?2 and c.status =1 ")
    List<WlyySurveyUserDO> findBySurvey(String surveyTempCode,String patient);
}

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

@ -21,6 +21,7 @@ import com.yihu.jw.utils.EntityUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.apache.xpath.operations.Bool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -29,10 +30,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by Trick on 2019/9/6
@ -287,7 +285,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
            totalSql += " AND i.label_code ='"+label+"'";
        }
        if (StringUtils.isNoneBlank(creater)){
            totalSql +=" AND  t.creater = '"+creater+"' ";
            totalSql +=" AND  t.creater_code = '"+creater+"' ";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
@ -397,15 +395,19 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
            //设置问题
            List<WlyySurveyTemplateQuestionVO> tqVOs = new ArrayList<>();
            convertToModels(tqDOs,tqVOs,WlyySurveyTemplateQuestionVO.class);
            templateVO.setTemplateQuestionVOs(tqVOs);
            //设置选项
            for(WlyySurveyTemplateQuestionVO tq:tqVOs){
                List<WlyySurveyTemplateOptionDO> optionDOs  = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getId(),tq.getTemplateCode(),"1");
                List<WlyySurveyTemplateOptionDO> optionDOs  = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getCode(),tq.getTemplateCode(),"1");
                List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
                convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
                for (WlyySurveyTemplateOptionVO optionVO:optionVOs){
                    optionVO.setId(optionVO.getCode());
                }
                tq.setOptionVOs(optionVOs);
                tq.setId(tq.getCode());
            }
            templateVO.setTemplateQuestionVOs(tqVOs);
        }
        return templateVO;
    }
@ -433,7 +435,13 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    public Boolean saveSurveyTemplate(String tempJson,String tempQJson,String tempOpJson,String labelJson,String labelInspJson)throws Exception{
        WlyySurveyTemplateDO temp = objectMapper.readValue(tempJson,WlyySurveyTemplateDO.class);
        String doctor = temp.getCreaterCode();
        if (StringUtils.isNotEmpty(temp.getId())){
            WlyySurveyTemplateDO templateDO = surveyTemplateDao.findOne(temp.getId());
            if(null!=templateDO){
                temp.setCreater(templateDO.getCreater());
                temp.setCreaterCode(templateDO.getCreaterCode());
            }
        }
        temp = surveyTemplateDao.save(temp);
        //删除原有问题
        List<WlyySurveyTemplateQuestionDO> questionDODels = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
@ -443,6 +451,11 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        //新增问题
        if(StringUtils.isNotBlank(tempQJson)){
            List<WlyySurveyTemplateQuestionDO> questions = EntityUtils.jsonToList(tempQJson, WlyySurveyTemplateQuestionDO.class);
            for (WlyySurveyTemplateQuestionDO wlyySurveyTemplateQuestionDO:questions){
                wlyySurveyTemplateQuestionDO.setTemplateCode(temp.getId());
                wlyySurveyTemplateQuestionDO.setCode(wlyySurveyTemplateQuestionDO.getId());
                wlyySurveyTemplateQuestionDO.setId(UUID.randomUUID().toString());
            }
            surveyTemplateQuestionDao.save(questions);
        }
@ -455,6 +468,11 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        //保存新问题选项
        if(StringUtils.isNotBlank(tempOpJson)){
            List<WlyySurveyTemplateOptionDO> options = EntityUtils.jsonToList(tempOpJson, WlyySurveyTemplateOptionDO.class);
            for (WlyySurveyTemplateOptionDO wlyySurveyTemplateOptionDO:options){
                wlyySurveyTemplateOptionDO.setTemplateCode(temp.getId());
                wlyySurveyTemplateOptionDO.setCode(wlyySurveyTemplateOptionDO.getId());
                wlyySurveyTemplateOptionDO.setId(UUID.randomUUID()+"");
            }
            surveyTemplateOptionDao.save(options);
        }
@ -580,7 +598,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        if(result!=null&&result.size()>0){
            for(Map<String,Object> map:result){
                String tempId = (String)map.get("id");
                List<WlyySurveyUserDO> list = surveyUserDao.findBySurvey(tempId,patient, DateUtil.strToDate(DateUtil.dateToStr(new Date(),"yyyy-MM-dd")));
                List<WlyySurveyUserDO> list = surveyUserDao.findBySurvey(tempId,patient);
                if(list!=null&&list.size()>0){
                    map.put("isAnswer",true);
                }else{
@ -635,6 +653,9 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
            List<WlyySurveyUserAnswerDO> answerDOs = EntityUtils.jsonToList(suaJsons,WlyySurveyUserAnswerDO.class);
            for(WlyySurveyUserAnswerDO answerDO : answerDOs){
                answerDO.setSurverUserId(surveyUserDO.getId());
                /*WlyySurveyTemplateOptionDO surveyTemplateOptionDO = surveyTemplateOptionDao.findOne(answerDO.getTempOptionCode());
                answerDO.setTempQuestionCode(surveyTemplateOptionDO.getQuestionCode());
                answerDO.setTempOptionCode(surveyTemplateOptionDO.getCode());*/
            }
            surveyUserAnswerDao.save(answerDOs);
            BasePatientBusinessDO basePatientBusinessDO = basePatientBusinessDao.findByDoctorPatientRelationCode(surveyUserDO.getPatient(),surveyUserDO.getSurveyTempCode(),surveyUserDO.getDoctor());
@ -654,9 +675,11 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        if(StringUtils.isNotBlank(surverUserId)){
            list = surveyUserAnswerDao.findBySurverUserId(surverUserId);
        }else{
            List<WlyySurveyUserDO> surveys = surveyUserDao.findBySurvey(tempId,patient, DateUtil.strToDate(DateUtil.dateToStr(new Date(),"yyyy-MM-dd")));
            List<WlyySurveyUserDO> surveys = surveyUserDao.findBySurvey(tempId,patient);
            System.out.println(surveys);
            if(surveys!=null&&surveys.size()>0){
                WlyySurveyUserDO wlyySurveyUserDO = surveys.get(0);
                System.out.println(wlyySurveyUserDO);
                list = surveyUserAnswerDao.findBySurverUserId(wlyySurveyUserDO.getId());
            }
        }
@ -680,7 +703,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
            templateVO.setVisitDeptName(doctor.getVisitDeptName());
        }
        //查询所有答题过的用户,计算答题总数
        List<WlyySurveyUserDO> surveyUsers = surveyUserDao.findBySurveyTempCodeAndStatus(templateVO.getId(),1);
        List<WlyySurveyUserDO> surveyUsers = surveyUserDao.findBySurveyTempCodeAndStatus(tempId,1);
        Integer total =0;
        if(surveyUsers!=null&&surveyUsers.size()>0){
            total = surveyUsers.size();
@ -692,15 +715,14 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
            //设置问题
            List<WlyySurveyTemplateQuestionVO> tqVOs = new ArrayList<>();
            convertToModels(tqDOs,tqVOs,WlyySurveyTemplateQuestionVO.class);
            templateVO.setTemplateQuestionVOs(tqVOs);
            //设置选项
            for(WlyySurveyTemplateQuestionVO tq:tqVOs){
                List<WlyySurveyTemplateOptionDO> optionDOs  = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getId(),tq.getTemplateCode(),"1");
                List<WlyySurveyTemplateOptionDO> optionDOs  = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getCode(),tq.getTemplateCode(),"1");
                List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
                convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
                int tpCount = 0;
                List<WlyySurveyUserAnswerDO> answerQuestionDOs = surveyUserAnswerDao.findByTempQuestionCodeDistinctPatient(tq.getId(),tempId);
                List<WlyySurveyUserAnswerDO> answerQuestionDOs = surveyUserAnswerDao.findByTempQuestionCodeDistinctPatient(tq.getCode(),tempId);
                if(answerQuestionDOs!=null&&answerQuestionDOs.size()>0){
                    tpCount = answerQuestionDOs.size();
                }
@ -711,17 +733,19 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                if(optionVOs!=null&&optionVOs.size()>0){
                    for(WlyySurveyTemplateOptionVO vo:optionVOs){
                        Integer answerCount =0;
                        List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getId(),vo.getTemplateCode());
                        List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getCode(),vo.getTemplateCode());
                        if(answerDOs!=null&&answerDOs.size()>0){
                            answerCount = answerDOs.size();
                        }
                        vo.setPercentage(PercentageUtil.bs(answerCount,total)+"%");
                        vo.setOptCount(answerCount);
                        vo.setId(vo.getCode());
                    }
                }
                tq.setOptionVOs(optionVOs);
                tq.setId(tq.getCode());
            }
            templateVO.setTemplateQuestionVOs(tqVOs);
        }
        return templateVO;
    }
@ -904,4 +928,5 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        String response = HttpClientUtil.postBody(imAddr, params);
        return response;
    }
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyTemplateOptionDO.java

@ -15,6 +15,7 @@ import javax.persistence.Table;
public class WlyySurveyTemplateOptionDO  {
    private String id;
    private String code;
    private String templateCode;//模板编码',
    private String questionCode;//模板问题编码',关联wlyy_survey_template_question
    private String content;//选项内容',
@ -115,4 +116,12 @@ public class WlyySurveyTemplateOptionDO  {
    public void setHaveComment(Integer haveComment) {
        this.haveComment = haveComment;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyTemplateQuestionDO.java

@ -17,6 +17,7 @@ import java.util.Date;
public class WlyySurveyTemplateQuestionDO {
    private String id;
    private String code;//问题id
    private String title;//问题标题',
    private String questionComment;//问题说明(可为null)',
    private Integer questionType;//问题类型(0单选 1多选 2问答)',
@ -41,6 +42,14 @@ public class WlyySurveyTemplateQuestionDO {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getTitle() {
        return title;
    }

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

@ -9,7 +9,8 @@ import io.swagger.annotations.ApiModelProperty;
 */
@ApiModel(value = "WlyySurveyTemplateOptionVO", description = "问卷调查模板问题选项")
public class WlyySurveyTemplateOptionVO extends UuidIdentityVO {
    @ApiModelProperty(value = "业务id", example = "模块1")
    private String code;//模板编码',
    @ApiModelProperty(value = "模板编码", example = "模块1")
    private String templateCode;//模板编码',
    @ApiModelProperty(value = "模板问题编码", example = "模块1")
@ -132,4 +133,12 @@ public class WlyySurveyTemplateOptionVO extends UuidIdentityVO {
    public void setOptCount(Integer optCount) {
        this.optCount = optCount;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
}

+ 10 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/survey/WlyySurveyTemplateQuestionVO.java

@ -13,7 +13,8 @@ import java.util.List;
 */
@ApiModel(value = "WlyySurveyTemplateQuestionVO", description = "问卷调查模板问题")
public class WlyySurveyTemplateQuestionVO extends UuidIdentityVO {
    @ApiModelProperty(value = "问题id", example = "模块1")
    private String code;//问题id
    @ApiModelProperty(value = "问题标题", example = "模块1")
    private String title;//问题标题',
    @ApiModelProperty(value = "问题说明(可为null)", example = "模块1")
@ -46,6 +47,14 @@ public class WlyySurveyTemplateQuestionVO extends UuidIdentityVO {
    @ApiModelProperty(value = "选项问题答题人数", example = "模块1")
    private Integer tqCount;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getTitle() {
        return title;
    }