Trick пре 5 година
родитељ
комит
9ae03fafa0

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

@ -0,0 +1,16 @@
package com.yihu.jw.hospital.survey.dao;
import com.yihu.jw.entity.hospital.survey.WlyySurveyDeptDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyInspLabelInfoDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2019/9/12.
 */
public interface SurveyDeptDao extends PagingAndSortingRepository<WlyySurveyDeptDO, String>, JpaSpecificationExecutor<WlyySurveyDeptDO> {
    List<WlyySurveyDeptDO> findBySurveyTempCode(String surveyTempCode);
}

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

@ -1,11 +1,17 @@
package com.yihu.jw.hospital.survey.dao;
import com.yihu.jw.entity.hospital.survey.WlyySurveyInspLabelInfoDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyUserAnswerDO;
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 SurveyUserAnswerDao extends PagingAndSortingRepository<WlyySurveyUserAnswerDO, String>, JpaSpecificationExecutor<WlyySurveyUserAnswerDO> {
    List<WlyySurveyUserAnswerDO> findBySurveyTempCodeAndPatient(String surveyTempCode,String patient);
}

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

@ -18,6 +18,7 @@ import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.nativejdbc.OracleJdbc4NativeJdbcExtractor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -52,6 +53,12 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    private SurveyLabelInfoDao surveyLabelInfoDao;
    @Autowired
    private SurveyInspLabelInfoDao surveyInspLabelInfoDao;
    @Autowired
    private SurveyDeptDao surveyDeptDao;
    @Autowired
    private SurveyUserDao surveyUserDao;
    @Autowired
    private SurveyUserAnswerDao surveyUserAnswerDao;
    /**
     * 查询字典
     * 1.surveyLabel;2.surveyScreenLabel
@ -414,4 +421,97 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        return true;
    }
    //=======================调查问卷发送=====================
    /**
     * 保存问卷科室关系
     * @param tempId
     * @param sdJsons
     * @return
     * @throws Exception
     */
    public Boolean saveSurveyDept(String tempId,String sdJsons)throws Exception{
        //删除之前关系
        List<WlyySurveyDeptDO> dels = surveyDeptDao.findBySurveyTempCode(tempId);
        if(dels!=null&&dels.size()>0){
            surveyDeptDao.delete(dels);
        }
        if(StringUtils.isNotBlank(sdJsons)){
            List<WlyySurveyDeptDO> list = EntityUtils.jsonToList(sdJsons,WlyySurveyDeptDO.class);
            if(list!=null&&list.size()>0){
                surveyDeptDao.save(list);
            }
        }
        return true;
    }
    /**
     * 查询科室下问卷列表
     * @param dept
     * @return
     */
    public List<Map<String,Object>> findSurveyByDept(String dept){
        String sql = "SELECT " +
                " t.id, " +
                " t.title, " +
                " t.template_comment AS templateComment " +
                " FROM " +
                " wlyy_survey_template t " +
                " JOIN wlyy_survey_dept d ON t.id = d.survey_temp_code " +
                " WHERE " +
                " d.dept = '"+dept+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    /**
     * 查询问卷下科室
     * @param tempId
     * @return
     */
    public List<Map<String,Object>> findDeptBySurvey(String tempId){
        String sql ="SELECT " +
                " d.dept, " +
                " d.dept_name AS deptName " +
                " FROM " +
                " wlyy_survey_template t " +
                " JOIN wlyy_survey_dept d ON t.id = d.survey_temp_code " +
                " WHERE " +
                " t.id = '"+tempId+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    /**
     *
     * @param suJson
     * @param suaJsons
     * @return
     * @throws Exception
     */
    public Boolean saveSurveyAnswer(String suJson,String suaJsons)throws Exception{
        WlyySurveyUserDO surveyUserDO = objectMapper.readValue(suJson,WlyySurveyUserDO.class);
        surveyUserDao.save(surveyUserDO);
        //删除问题答案
        List<WlyySurveyUserAnswerDO> dels = surveyUserAnswerDao.findBySurveyTempCodeAndPatient(surveyUserDO.getSurveyTempCode(),surveyUserDO.getPatient());
        if(dels!=null&&dels.size()>0){
            surveyUserAnswerDao.delete(dels);
        }
        //保存答案
        if(StringUtils.isNotBlank(suaJsons)){
            List<WlyySurveyUserAnswerDO> answerDOs = EntityUtils.jsonToList(suaJsons,WlyySurveyUserAnswerDO.class);
            surveyUserAnswerDao.save(answerDOs);
        }
        return true;
    }
    public List<WlyySurveyUserAnswerDO> findAnswerBySurveyTempCode(String patient,String tempId){
        List<WlyySurveyUserAnswerDO> list = surveyUserAnswerDao.findBySurveyTempCodeAndPatient(tempId,patient);
        return list;
    }
}

+ 54 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyDeptDO.java

@ -0,0 +1,54 @@
package com.yihu.jw.entity.hospital.survey;
import com.yihu.jw.entity.IntegerIdentityEntity;
import org.springframework.beans.factory.annotation.Autowired;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Trick on 2019/9/12.
 */
@Entity
@Table(name = "wlyy_survey_dept")
public class WlyySurveyDeptDO extends IntegerIdentityEntity {
    /**
     * 问卷模板关系表
     */
    private String surveyTempCode;
    /**
     * 问卷部门
     */
    private String dept;
    /**
     * 问卷部门名称
     */
    private String deptCode;
    public String getSurveyTempCode() {
        return surveyTempCode;
    }
    public void setSurveyTempCode(String surveyTempCode) {
        this.surveyTempCode = surveyTempCode;
    }
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    public String getDeptCode() {
        return deptCode;
    }
    public void setDeptCode(String deptCode) {
        this.deptCode = deptCode;
    }
}