Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

chenweida 8 years ago
parent
commit
44a14feb5d

+ 22 - 18
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultDao.java

@ -9,28 +9,32 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.consult.Consult;
public interface ConsultDao extends PagingAndSortingRepository<Consult, Long>, JpaSpecificationExecutor<Consult> {
public interface ConsultDao extends PagingAndSortingRepository<Consult, Long>, JpaSpecificationExecutor<Consult> {
	
	Consult findByCode(String code);
	// 查询患者咨询记录
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.symptoms like ?2 order by a.czrq desc")
	Page<Object> findByPatient(String patient,String title, Pageable pageRequest);
    Consult findByCode(String code);
	// 查询患者咨询记录
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1'and a.symptoms like ?2 order by a.czrq desc")
	Page<Object> findByPatient(String patient,String title, long id, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, Pageable pageRequest);
	// 查询患者咨询记录
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' order by a.czrq desc")
	Page<Object> findByPatient(String patient, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1'and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, long id, Pageable pageRequest);
	// 查询患者咨询记录
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1'order by a.czrq desc")
	Page<Object> findByPatient(String patient, long id, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' order by a.czrq desc")
    Page<Object> findByPatient(String patient, Pageable pageRequest);
	@Query("select count(a) from Consult a,ConsultTeamDoctor b  where a.code = b.consult and a.patient=?1 and b.to=?2 and b.from is null")
	Integer findByPatient(String patientCode,String doctorCode);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1'order by a.czrq desc")
    Page<Object> findByPatient(String patient, long id, Pageable pageRequest);
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.adminTeamId,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and b.adminTeamId = ?2 and a.del = '1' order by a.czrq desc")
	Page<Object> findByPatientAndTeam(String patient,Long team, Pageable pageRequest);
    @Query("select count(a) from Consult a,ConsultTeamDoctor b  where a.code = b.consult and a.patient=?1 and b.to=?2 and b.from is null")
    Integer findByPatient(String patientCode, String doctorCode);
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.adminTeamId,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and b.adminTeamId = ?2 and a.del = '1' order by a.czrq desc")
    Page<Object> findByPatientAndTeam(String patient, Long team, Pageable pageRequest);
    //获取咨询的状态
    @Query("select a.type from Consult a,ConsultTeam b where a.code = b.consult and a.code = ?1 ")
    int findTypeByCode(String code);
}
}

+ 12 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateOptionsDao.java

@ -11,11 +11,21 @@ import java.util.List;
 * Created by Reece on 2017/3/10.
 * Created by Reece on 2017/3/10.
 */
 */
public interface SurveyTemplateOptionsDao extends PagingAndSortingRepository<SurveyTemplateOptions, Long> {
public interface SurveyTemplateOptionsDao extends PagingAndSortingRepository<SurveyTemplateOptions, Long> {
    @Query("select t from  SurveyTemplateOptions t where  t.templateQuestionCode = ?1 and t.templateCode = ?2 ")
    @Query("select t from  SurveyTemplateOptions t where  t.templateQuestionCode = ?1 and t.templateCode = ?2 and t.del = 1 ")
    List<SurveyTemplateOptions> findById(String qstcode, String tempCode);
    List<SurveyTemplateOptions> findById(String qstcode, String tempCode);
    @Modifying
    @Modifying
    @Query("update SurveyTemplateOptions t set t.haveComment=?4,t.content=?5," +
    @Query("update SurveyTemplateOptions t set t.haveComment=?4,t.content=?5," +
            "t.questionCodeNext=?6,t.isRequired=?7,t.sort=?8 where  t.templateQuestionCode = ?1 and t.templateCode = ?2 and t.code=?3")
            "t.questionCodeNext=?6,t.isRequired=?7,t.sort=?8 where  t.templateQuestionCode = ?2 and t.templateCode = ?1 and t.code=?3")
    int modifyOption(String tempCode, String qstcode, String optcode, Integer haveCommment, String content, String nextCode, Integer isRequired, Integer sort);
    int modifyOption(String tempCode, String qstcode, String optcode, Integer haveCommment, String content, String nextCode, Integer isRequired, Integer sort);
    /**
     * 修改选项状态(删除)
     * @param tempCode
     * @param qstcode
     * @param optcode
     */
    @Modifying
    @Query("update SurveyTemplateOptions t set t.del = 0 where  t.templateQuestionCode = ?2 and t.templateCode = ?1 and t.code=?3")
    void modifyOption(String tempCode, String qstcode, String optcode);
}
}

+ 10 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateQuestionsDao.java

@ -11,7 +11,7 @@ import java.util.List;
 * Created by Reece on 2017/3/10.
 * Created by Reece on 2017/3/10.
 */
 */
public interface SurveyTemplateQuestionsDao extends PagingAndSortingRepository<SurveyTemplateQuestions, Long> {
public interface SurveyTemplateQuestionsDao extends PagingAndSortingRepository<SurveyTemplateQuestions, Long> {
    @Query("select  t from SurveyTemplateQuestions t where t.templateCode = ?1 ")
    @Query("select  t from SurveyTemplateQuestions t where t.templateCode = ?1 and t.del = 1 ")
    List<SurveyTemplateQuestions> findById(String tempCode);
    List<SurveyTemplateQuestions> findById(String tempCode);
    @Query("select  t from SurveyTemplateQuestions t where t.templateCode = ?1 and t.code = ?2 ")
    @Query("select  t from SurveyTemplateQuestions t where t.templateCode = ?1 and t.code = ?2 ")
@ -25,4 +25,13 @@ public interface SurveyTemplateQuestionsDao extends PagingAndSortingRepository<S
            "t.isRequired=?6,t.minNum=?7,t.maxNum=?8,t.sort=?9,t.questionCodeNext=?10  where t.templateCode = ?1 and t.code = ?2 ")
            "t.isRequired=?6,t.minNum=?7,t.maxNum=?8,t.sort=?9,t.questionCodeNext=?10  where t.templateCode = ?1 and t.code = ?2 ")
    int modifyQuestion(String tempCode, String qstCode, String qstTitle, String qstComment, Integer qstType,
    int modifyQuestion(String tempCode, String qstCode, String qstTitle, String qstComment, Integer qstType,
                        Integer isRequired, Integer minNum, Integer maxNum, Integer sort, String next);
                        Integer isRequired, Integer minNum, Integer maxNum, Integer sort, String next);
    /**
     * 修改模板问题状态(删除)
     * @param tempCode
     * @param qstCode
     */
    @Modifying
    @Query("update SurveyTemplateQuestions t set t.del = 0  where t.templateCode = ?1 and t.code = ?2 ")
    void modifyQuestion(String tempCode, String qstCode);
}
}

+ 4 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -1649,7 +1649,7 @@ public class ConsultTeamService extends ConsultService {
     * @param type 1患者 2医生
     * @param type 1患者 2医生
     * @throws Exception
     * @throws Exception
     */
     */
    public void famousConsult(ConsultTeam ct, String uid, String type) throws Exception {
    public JSONObject famousConsult(ConsultTeam ct, String uid, String type) throws Exception {
        // 设置患者信息
        // 设置患者信息
        ct.setPatient(uid);
        ct.setPatient(uid);
        String senderId = "";
        String senderId = "";
@ -1721,9 +1721,12 @@ public class ConsultTeamService extends ConsultService {
        }
        }
        //设置消息ID
        //设置消息ID
        ct.setStartMsgId(obj.getString("start_msg_id"));
        ct.setStartMsgId(obj.getString("start_msg_id"));
        JSONObject object = ImUtill.getTopic(ct.getConsult());
        JSONArray array = new JSONArray(object.get("data").toString());
        consultTeamDao.save(ct);  // 保存医生咨询信息
        consultTeamDao.save(ct);  // 保存医生咨询信息
        consultTeamDoctorDao.save(cd);
        consultTeamDoctorDao.save(cd);
        consultDao.save(consult);
        consultDao.save(consult);
        return array.getJSONObject(0);
    }
    }

+ 10 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

@ -256,6 +256,14 @@ public class FamilyMemberService extends BaseService {
        if (fmt != null) {
        if (fmt != null) {
            memberDao.delete(fmt);
            memberDao.delete(fmt);
        }
        }
        //删除微信模板临时表
        List<PatientFamilyTemp> patientFamilyTemps = patientFamilyTempDao.findByDealerAndPatient(member,patient);
        if(patientFamilyTemps!=null&&patientFamilyTemps.size()>0){
            for(PatientFamilyTemp temp : patientFamilyTemps){
                patientFamilyTempDao.delete(temp);
            }
        }
        return 1;
        return 1;
    }
    }
@ -683,7 +691,7 @@ public class FamilyMemberService extends BaseService {
                    if(StringUtils.isNotBlank(p.getOpenid())){
                    if(StringUtils.isNotBlank(p.getOpenid())){
                        //发送添加成功消息模板
                        //发送添加成功消息模板
                        JSONObject json = new JSONObject();
                        JSONObject json = new JSONObject();
                        json.put("first", p.getName() + ",您好!添加家人"+m.getName()+"申请成功。");
                        json.put("first", p.getName() + ",您好!"+m.getName()+"已加入到您的家庭成员。");
                        json.put("keyword1", "添加家人申请成功");
                        json.put("keyword1", "添加家人申请成功");
                        json.put("keyword2", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                        json.put("keyword2", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
//                        json.put("keyword3", m.getName());
//                        json.put("keyword3", m.getName());
@ -709,7 +717,7 @@ public class FamilyMemberService extends BaseService {
                //发送添加成功消息模板
                //发送添加成功消息模板
                JSONObject json = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("first", p.getName() + ",您好!您的家人"+m.getName()+"拒绝了您的家人申请。");
                json.put("first", p.getName() + ",您好!"+m.getName()+"拒绝了您的家人申请。");
                json.put("keyword1", "添加家人申请失败");
                json.put("keyword1", "添加家人申请失败");
                json.put("keyword2", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("keyword2", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("remark"," ");
                json.put("remark"," ");

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -1277,7 +1277,7 @@ public class SignPatientLabelInfoService extends BaseService {
                " AND ( sf.doctor_health is null or sf.doctor_health ='' ) " +
                " AND ( sf.doctor_health is null or sf.doctor_health ='' ) " +
                "  AND (p.name like ? or p.address like ? or p.idcard like ? ) " +
                "  AND (p.name like ? or p.address like ? or p.idcard like ? ) " +
                " ORDER BY  p.name DESC,p.address DESC, p.idcard DESC " +
                " ORDER BY  p.name DESC,p.address DESC, p.idcard DESC " +
                " limit "+(page-1)+","+pagesize;
                " limit "+(page-1)*pagesize+","+pagesize;
        List<Map<String, Object>> datas = jdbcTemplate.queryForList(sql, teamCode, "%" + filter + "%", "%" + filter + "%", "%" + filter + "%");
        List<Map<String, Object>> datas = jdbcTemplate.queryForList(sql, teamCode, "%" + filter + "%", "%" + filter + "%", "%" + filter + "%");
        if (datas != null && datas.size() > 0) {
        if (datas != null && datas.size() > 0) {

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -2658,7 +2658,7 @@ public class FamilyContractService extends BaseService {
                    " and sf.admin_team_code = ? " +
                    " and sf.admin_team_code = ? " +
                    " AND (p.name like ? or p.address like ? or p.idcard like ? ) " +
                    " AND (p.name like ? or p.address like ? or p.idcard like ? ) " +
                    " ORDER BY  p.name DESC,p.address DESC, p.idcard DESC " +
                    " ORDER BY  p.name DESC,p.address DESC, p.idcard DESC " +
                    " limit "+(page-1)+","+pagesize;
                    " limit "+(page-1)*pagesize+","+pagesize;
            //查找居民
            //查找居民
            datas = jdbcTemplate.queryForList(sql, doctorCode, team,"%"+filter+"%","%"+filter+"%","%"+filter+"%");
            datas = jdbcTemplate.queryForList(sql, doctorCode, team,"%"+filter+"%","%"+filter+"%","%"+filter+"%");
@ -2682,7 +2682,7 @@ public class FamilyContractService extends BaseService {
                    " and sf.admin_team_code = ? " +
                    " and sf.admin_team_code = ? " +
                    " AND (p.name like ? or p.address like ? or p.idcard like ? ) " +
                    " AND (p.name like ? or p.address like ? or p.idcard like ? ) " +
                    " ORDER BY  p.name DESC,p.address DESC, p.idcard DESC " +
                    " ORDER BY  p.name DESC,p.address DESC, p.idcard DESC " +
                    " limit "+(page-1)+","+pagesize;
                    " limit "+(page-1)*pagesize+","+pagesize;
            //查找居民
            //查找居民
            datas = jdbcTemplate.queryForList(sql, doctorCode, team,"%"+filter+"%","%"+filter+"%","%"+filter+"%");
            datas = jdbcTemplate.queryForList(sql, doctorCode, team,"%"+filter+"%","%"+filter+"%","%"+filter+"%");

+ 2 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -338,21 +338,18 @@ public class AdminTeamService extends BaseService {
        JSONArray result = new JSONArray();
        JSONArray result = new JSONArray();
        SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
        SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
        SignFamily jtSign = signFamilyDao.findSignByPatient(patient, 2);
        SignFamily jtSign = signFamilyDao.findSignByPatient(patient, 2);
        if (ssSign != null&&ssSign.getAdminTeamId()!=null && (doctor.equals(ssSign.getDoctor())
        if (ssSign != null&&ssSign.getAdminTeamId()!=null && (doctor.equals(ssSign.getDoctor())
                || doctor.equals(ssSign.getDoctorHealth()))) {
                || doctor.equals(ssSign.getDoctorHealth()))) {
            AdminTeam team = getTeam(ssSign.getAdminTeamId());
            AdminTeam team = getTeam(ssSign.getAdminTeamId());
            result.put(new JSONObject(team));
            result.put(new JSONObject(team));
        }
        }
        if (jtSign != null && (doctor.equals(jtSign.getDoctor())
        if (jtSign.getAdminTeamId()!=null&&jtSign != null && (doctor.equals(jtSign.getDoctor())
                || doctor.equals(jtSign.getDoctorHealth()))) {
                || doctor.equals(jtSign.getDoctorHealth()))) {
            AdminTeam team = getTeam(jtSign.getAdminTeamId());
            AdminTeam team = getTeam(jtSign.getAdminTeamId());
            if(ssSign == null || (long)ssSign.getAdminTeamId() != jtSign.getAdminTeamId()) {
            if(ssSign == null || ssSign.getAdminTeamId() != jtSign.getAdminTeamId()) {
                result.put(new JSONObject(team));
                result.put(new JSONObject(team));
            }
            }
        }
        }
        return result;
        return result;
    }
    }

+ 38 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java

@ -94,7 +94,6 @@ public class ManagerQuestionnaireService extends BaseService {
    public String createSurvey(String doctor, JSONObject jsonStr, String accessToken) throws Exception {
    public String createSurvey(String doctor, JSONObject jsonStr, String accessToken) throws Exception {
        System.out.println("createSurvey ======》" + jsonStr);
//        问卷信息
//        问卷信息
        String surveyCode = getCode();
        String surveyCode = getCode();
        String surveyName = jsonStr.getString("surveyName");
        String surveyName = jsonStr.getString("surveyName");
@ -345,8 +344,9 @@ public class ManagerQuestionnaireService extends BaseService {
                    //                选择题
                    //                选择题
                    JSONArray options = new JSONArray(tempQestion.get("options").toString());
                    JSONArray options = new JSONArray(tempQestion.get("options").toString());
                    for (Object option : options) {
                    for (Object option : options) {
                        String optionCode = getCode();
//                        String optionCode = getCode();
                        JSONObject tempOption = new JSONObject(option.toString());
                        JSONObject tempOption = new JSONObject(option.toString());
                        String optionCode = tempOption.get("optCode").toString();
                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                        String optionComment = tempOption.get("content").toString();
                        String optionComment = tempOption.get("content").toString();
                        int required = Integer.parseInt(tempOption.get("isRequired").toString());
                        int required = Integer.parseInt(tempOption.get("isRequired").toString());
@ -411,8 +411,9 @@ public class ManagerQuestionnaireService extends BaseService {
                    //                选择题
                    //                选择题
                    JSONArray options1 = new JSONArray(tempQestion.get("options").toString());
                    JSONArray options1 = new JSONArray(tempQestion.get("options").toString());
                    for (Object option : options1) {
                    for (Object option : options1) {
                        String optionCode = getCode();
//                        String optionCode = getCode();
                        JSONObject tempOption = new JSONObject(option.toString());
                        JSONObject tempOption = new JSONObject(option.toString());
                        String optionCode = tempOption.get("optCode").toString();
                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                        String optionComment = tempOption.get("content").toString();
                        String optionComment = tempOption.get("content").toString();
                        int required = Integer.parseInt(tempOption.get("isRequired").toString());
                        int required = Integer.parseInt(tempOption.get("isRequired").toString());
@ -1147,16 +1148,18 @@ public class ManagerQuestionnaireService extends BaseService {
            for (SurveyTemplateOptions option : options) {
            for (SurveyTemplateOptions option : options) {
                Map<String, Object> opt = new HashMap<>();
                Map<String, Object> opt = new HashMap<>();
                String conetent = option.getContent();
                String conetent = option.getContent();
                String optCode = option.getCode();
                int haveComment = option.getHaveComment();
                int haveComment = option.getHaveComment();
                int required = option.getIsRequired();
                int required = option.getIsRequired();
                int optsort = option.getSort();
                int optsort = option.getSort();
                if (!StringUtils.isEmpty(option.getQuestionCodeNext())) {
                if (!StringUtils.isEmpty(option.getQuestionCodeNext())) {
                    String next = option.getQuestionCodeNext();
                    String next = option.getQuestionCodeNext();
                    SurveyTemplateQuestions tempQst = surveyTemplateQuestionsDao.findById(id, next);
                    SurveyTemplateQuestions tempQst = surveyTemplateQuestionsDao.findById(id, next);
//                    跳题结束怎么办?
//                    跳题结束
                    opt.put("nextQuestion", tempQst == null ? 0 : tempQst.getSort());
                    opt.put("nextQuestion", tempQst == null ? 0 : tempQst.getSort());
                }
                }
                opt.put("optCode", optCode);
                opt.put("isRequired", required);
                opt.put("isRequired", required);
                opt.put("content", conetent);
                opt.put("content", conetent);
                opt.put("sort", optsort);
                opt.put("sort", optsort);
@ -1297,6 +1300,11 @@ public class ManagerQuestionnaireService extends BaseService {
//        更改模板标签信息
//        更改模板标签信息
            surveyLabelInfoDao.modifyLabel(templateCode, surveyLabelInfo.getLabel());
            surveyLabelInfoDao.modifyLabel(templateCode, surveyLabelInfo.getLabel());
        }
        }
        List<SurveyTemplateQuestions> ques = surveyTemplateQuestionsDao.findById(templateCode);
        List questions = new ArrayList();
        for (SurveyTemplateQuestions que : ques) {
            questions.add(que.getCode());
        }
        List<SurveyQuestionnaire> surveyQuestionnaires = surveyQuestionnaireDao.findById(code);
        List<SurveyQuestionnaire> surveyQuestionnaires = surveyQuestionnaireDao.findById(code);
        for (SurveyQuestionnaire question : surveyQuestionnaires) {
        for (SurveyQuestionnaire question : surveyQuestionnaires) {
            String qstCode = question.getCode();
            String qstCode = question.getCode();
@ -1308,8 +1316,13 @@ public class ManagerQuestionnaireService extends BaseService {
            Integer maxNum = question.getMaxNum();
            Integer maxNum = question.getMaxNum();
            Integer sort = question.getSort();
            Integer sort = question.getSort();
            String next = question.getQuestionCodeNext();
            String next = question.getQuestionCodeNext();
            //            更改问题到模板问题表(修改模板新增的问题怎么办?)
            System.out.println(templateCode + "," + qstCode + qstTitle + "," + qstComment + "," + qstType + "," + isRequired + "," + minNum + "," + maxNum + "," + sort + "," + next);
            //            删除问题
            Boolean exist = questions.contains(qstCode);
            if (exist) {
//                除掉重复问题
                questions.remove(qstCode);
            }
            //            更改问题到模板问题表(修改模板新增的问题)
            int rows = surveyTemplateQuestionsDao.modifyQuestion(templateCode, qstCode, qstTitle, qstComment, qstType, isRequired, minNum, maxNum, sort, next);
            int rows = surveyTemplateQuestionsDao.modifyQuestion(templateCode, qstCode, qstTitle, qstComment, qstType, isRequired, minNum, maxNum, sort, next);
//            新增问题直接保存
//            新增问题直接保存
            if (rows == 0) {
            if (rows == 0) {
@ -1321,7 +1334,11 @@ public class ManagerQuestionnaireService extends BaseService {
            }
            }
            if (qstType != 2) {
            if (qstType != 2) {
                List<SurveyQuestionnaireOptions> surveyQuestionnaireOptions = surveyQuestionnaireOptionsDao.findByIdAndQstCode(code, question.getCode());
                List<SurveyQuestionnaireOptions> surveyQuestionnaireOptions = surveyQuestionnaireOptionsDao.findByIdAndQstCode(code, question.getCode());
//                问卷的选项编码都是新增的,不是从模板里复用的
                List<SurveyTemplateOptions> templateOption = surveyTemplateOptionsDao.findById(qstCode,templateCode);
                List options = new ArrayList();
                for (SurveyTemplateOptions opt : templateOption) {
                    options.add(opt.getCode());
                }
                for (SurveyQuestionnaireOptions option : surveyQuestionnaireOptions) {
                for (SurveyQuestionnaireOptions option : surveyQuestionnaireOptions) {
                    //         更改到模板选项表   survey_template_options
                    //         更改到模板选项表   survey_template_options
                    String optCode = option.getCode();
                    String optCode = option.getCode();
@ -1330,6 +1347,12 @@ public class ManagerQuestionnaireService extends BaseService {
                    String nextCode = option.getQuestionCodeNext();
                    String nextCode = option.getQuestionCodeNext();
                    Integer required = option.getIsRequired();
                    Integer required = option.getIsRequired();
                    Integer optsort = option.getSort();
                    Integer optsort = option.getSort();
                    //                    删除选项
                    Boolean exists = options.contains(optCode);
                    if (exists) {
//                除掉重复问题
                        options.remove(optCode);
                    }
                    int row = surveyTemplateOptionsDao.modifyOption(templateCode, qstCode, optCode, have, content, nextCode, required, optsort);
                    int row = surveyTemplateOptionsDao.modifyOption(templateCode, qstCode, optCode, have, content, nextCode, required, optsort);
//            新增问题的选项直接保存
//            新增问题的选项直接保存
                    if (row == 0) {
                    if (row == 0) {
@ -1339,8 +1362,16 @@ public class ManagerQuestionnaireService extends BaseService {
                        surveyTemplateOptionsDao.save(surveyTemplateOptions);
                        surveyTemplateOptionsDao.save(surveyTemplateOptions);
                    }
                    }
                }
                }
//               删除选项更改选项状态
                for (Object opt:options) {
                    surveyTemplateOptionsDao.modifyOption(templateCode, qstCode, opt.toString());
                }
            }
            }
        }
        }
//            删除问题更改问题状态
        for (Object qst:questions) {
            surveyTemplateQuestionsDao.modifyQuestion(templateCode,qst.toString());
        }
        return 0;
        return 0;
    }
    }

+ 38 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/im/imController.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.web.common.im;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.util.ImUtill;
@ -31,6 +32,8 @@ public class imController extends BaseController {
    private SignFamilyDao signFamilyDao;
    private SignFamilyDao signFamilyDao;
    @Autowired
    @Autowired
    private DoctorDao doctorDao;
    private DoctorDao doctorDao;
    @Autowired
    private ConsultDao consultDao;
    /**
    /**
     * 获取单个咨询
     * 获取单个咨询
@ -84,6 +87,7 @@ public class imController extends BaseController {
                String sex = ob.get("sex").toString();
                String sex = ob.get("sex").toString();
                String startId = ob.get("start_message_id").toString();
                String startId = ob.get("start_message_id").toString();
                String endId = ob.get("end_message_id").toString();
                String endId = ob.get("end_message_id").toString();
                int type = consultDao.findTypeByCode(id);
                if (StringUtils.isNotEmpty(createTime)){
                if (StringUtils.isNotEmpty(createTime)){
                    Date date = sdf.parse(createTime);
                    Date date = sdf.parse(createTime);
                    map.put("create_time",sdf.format(date));
                    map.put("create_time",sdf.format(date));
@ -97,6 +101,8 @@ public class imController extends BaseController {
                map.put("description", description);
                map.put("description", description);
                map.put("start_message_id", startId);
                map.put("start_message_id", startId);
                map.put("end_message_id", endId);
                map.put("end_message_id", endId);
//                咨询类型:1三师咨询,2家庭医生咨询,3图文咨询,4公共咨询,5病友圈
                map.put("type", type);
                list.add(map);
                list.add(map);
            }
            }
@ -182,6 +188,38 @@ public class imController extends BaseController {
        }
        }
    }
    }
    /**
     * 提醒医生相关信息
     *
     * @param doctor 提醒的医生
     * @param content 提醒的内容
     * @return
     */
    @RequestMapping(value = "/message/remain", method = RequestMethod.POST)
    @ResponseBody
    public String reaminDoctor(String doctor,String content) {
        try {
            JSONObject participants = new JSONObject();
            participants.put(doctor, 0);
            participants.put(getUID(),0);
            Doctor d = doctorDao.findByCode(getUID());
            //创建医生会话讨论组
            JSONObject sessionObj = ImUtill.createSession(participants, ImUtill.SESSION_TYPE_P2P,  d.getName()+"发来消息提醒", "");
            if(sessionObj.getInt("status")==-1){
                throw  new RuntimeException(sessionObj.getString("message"));
            }
            JSONObject session = sessionObj.getJSONObject("data");
            ImUtill.sendImMsg(getUID(),d.getName(),session.getString("id"),"1", content,"REMAIN");
            return success("提醒成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");
        }
    }
    public List getMemberByDoctor(String doctor) {
    public List getMemberByDoctor(String doctor) {
        String sql = "SELECT d.photo,d.`name`,d.sex,d.`code`,d.level " +
        String sql = "SELECT d.photo,d.`name`,d.sex,d.`code`,d.level " +
                " from wlyy_admin_team t,wlyy_admin_team_member m,wlyy_doctor d " +
                " from wlyy_admin_team t,wlyy_admin_team_member m,wlyy_doctor d " +

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -680,7 +680,7 @@ public class DoctorConsultController extends WeixinBaseController {
            consult.setVoice(voice);
            consult.setVoice(voice);
            consult.setDoctor(doctorCode);//设置专科医生
            consult.setDoctor(doctorCode);//设置专科医生
            // 保存到数据库
            // 保存到数据库
            consultTeamService.famousConsult(consult, getUID(), "2");
            JSONObject result = consultTeamService.famousConsult(consult, getUID(), "2");
            // 推送消息给医生
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.D_CT_04.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.您有新的名医咨询.name(), consult.getConsult());
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.D_CT_04.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.您有新的名医咨询.name(), consult.getConsult());
            if (StringUtils.isNotEmpty(images)) {
            if (StringUtils.isNotEmpty(images)) {
@ -689,7 +689,7 @@ public class DoctorConsultController extends WeixinBaseController {
                    PushMsgTask.getInstance().put(consult.getDoctor(), "2", MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.您有新的名医咨询.name(), img);
                    PushMsgTask.getInstance().put(consult.getDoctor(), "2", MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.您有新的名医咨询.name(), img);
                }
                }
            }
            }
            return success("提交成功");
            return write(200,"创建成功!","data",result);
        } catch (Exception ex) {
        } catch (Exception ex) {
            error(ex);
            error(ex);
            return invalidUserException(ex, -1, "提交失败!");
            return invalidUserException(ex, -1, "提交失败!");

+ 17 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -967,19 +967,35 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            @RequestParam(required = false) String patientName,
            @RequestParam(required = false) String patientName,
            Long teamCode) {
            Long teamCode) {
        try {
        try {
            labelType = "4";
            teamCode = (long)646;
            List listNum = new ArrayList();
            List listNum = new ArrayList();
            Map patients = new HashMap();
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(), labelType, patientName, teamCode);
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(), labelType, patientName, teamCode);
            JSONArray jsonAr = new JSONArray(list);
            String str = "jj";
            List<SignFamily> signFamily = familyContractService.findNoHealthSignFamilyNum(teamCode);
            List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatusAndTeamCode(labelType, 1, teamCode);
            List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatusAndTeamCode(labelType, 1, teamCode);
            for (SignPatientLabel label : s) {
            for (SignPatientLabel label : s) {
                Map map = new HashMap();
                Map map = new HashMap();
                String labelName = label.getLabelName();
                String labelName = label.getLabelName();
                JSONArray jsonArray = list.getJSONArray(label.getLabelName());
                JSONArray jsonArray = list.getJSONArray(label.getLabelName());
               /* List codes = new ArrayList();
                for (Object patient:jsonArray) {
                    JSONObject jsonObject = new JSONObject(patient.toString());
                    String code = jsonObject.get("code").toString();
                    codes.add(code);
                }*/
                int length = jsonArray.length();
                int length = jsonArray.length();
                map.put("label", labelName);
                map.put("label", labelName);
                map.put("number", length);
                map.put("number", length);
//                map.put("codes", codes);
                listNum.add(map);
                listNum.add(map);
            }
            }
            return write(200, "查询成功!", "data", listNum);
            patients.put("count",list.length());
            patients.put("count",signFamily.size());
            patients.put("patients",listNum);
            return write(200, "查询成功!", "data", patients);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            error(e);
            return invalidUserException(e, -1, "查询失败");
            return invalidUserException(e, -1, "查询失败");

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -400,13 +400,15 @@ public class ConsultController extends WeixinBaseController {
            consult.setVoice(voice);
            consult.setVoice(voice);
            consult.setDoctor(doctorCode);//设置专科医生
            consult.setDoctor(doctorCode);//设置专科医生
            // 保存到数据库
            // 保存到数据库
            consultTeamService.famousConsult(consult, getUID(), "1");
            JSONObject object  = consultTeamService.famousConsult(consult, getUID(), "1");
            JSONObject resultConsult =  new JSONObject(consult);
            resultConsult.put("session_id",object.getString("session_id"));
            //名医咨询次数减一
            //名医咨询次数减一
            doctorWorkTimeService.setDoctorCurrentConsultTimesRemain(doctorCode);
            doctorWorkTimeService.setDoctorCurrentConsultTimesRemain(doctorCode);
            // 推送消息给医生
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.D_CT_03.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.您有新的名医咨询.name(), consult.getConsult());
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.D_CT_03.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.您有新的名医咨询.name(), consult.getConsult());
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), getUID(), new JSONObject(consult));
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), getUID(), new JSONObject(consult));
            return write(200, "提交成功", "data", consult);
            return write(200, "提交成功", "data", resultConsult);
        } catch (Exception ex) {
        } catch (Exception ex) {
            error(ex);
            error(ex);
            return invalidUserException(ex, -1, "提交失败!");
            return invalidUserException(ex, -1, "提交失败!");