瀏覽代碼

Merge branch 'dev' of wujunjie/patient-co-management into dev

yeshijie 7 年之前
父節點
當前提交
ba1d559bcc

+ 42 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/DoctorDao.java

@ -7,12 +7,14 @@ package com.yihu.wlyy.repository;
import java.util.List;
import java.util.List;
import com.yihu.wlyy.entity.Doctor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.Doctor;
import org.springframework.web.bind.annotation.RequestParam;
public interface DoctorDao extends PagingAndSortingRepository<Doctor, Long>, JpaSpecificationExecutor<Doctor> {
public interface DoctorDao extends PagingAndSortingRepository<Doctor, Long>, JpaSpecificationExecutor<Doctor> {
@ -60,4 +62,42 @@ public interface DoctorDao extends PagingAndSortingRepository<Doctor, Long>, Jpa
    // 身份证查询医生信息
    // 身份证查询医生信息
    @Query("select p from Doctor p where p.idCard = ?1 and p.status = 1")
    @Query("select p from Doctor p where p.idCard = ?1 and p.status = 1")
    Doctor findByIdCard(String idcard);
    Doctor findByIdCard(String idcard);
    //搜索及列表查询
    @Query("SELECT p  FROM Doctor p, WlyyUserRole r, WlyyRole ro " +
            " WHERE r.user = p.code AND p.hospital = ro.code AND p.status = 1 AND p.name = ?1 AND p.idCard = ?2")
    Page<Doctor> findByFilter(String name, String  idcard, Pageable pageable);
    //搜索及列表查询
    @Query("SELECT p  FROM Doctor p, WlyyUserRole r, WlyyRole ro " +
            " WHERE r.user = p.code AND p.hospital = ro.code AND p.status = 1 AND p.name = ?1 ")
    Page<Doctor> findByName(String name, Pageable pageable);
    //搜索及列表查询
    @Query("SELECT p  FROM Doctor p, WlyyUserRole r, WlyyRole ro " +
            " WHERE r.user = p.code AND p.hospital = ro.code AND p.status = 1 AND p.idCard = ?1 ")
    Page<Doctor> findByIdcard(String  idcard, Pageable pageable);
    //搜索及列表查询
    @Query("SELECT p  FROM Doctor p, WlyyUserRole r, WlyyRole ro " +
            " WHERE r.user = p.code AND p.hospital = ro.code AND p.status = 1 ")
    Page<Doctor> findByFilterAll(Pageable pageable);
    //搜索及列表查询不在wlyy_user_role表的医生
    @Query(value = "SELECT p FROM Doctor p where p.status= 1 AND p.name = ?1 AND p.idCard = ?2 ")
    List<Doctor> findDoctorByFilter(String name, String  idcard);
    //搜索及列表查询不在wlyy_user_role表的医生
    @Query(value = "SELECT p FROM Doctor p where p.status= 1 AND p.name = ?1 ")
    List<Doctor> findDoctorByName(String name);
    //搜索及列表查询不在wlyy_user_role表的医生
    @Query(value = "SELECT p FROM Doctor p where p.status= 1 AND p.idCard = ?1 ")
    List<Doctor> findDoctorByIdcard(String  idcard);
    //搜索及列表查询
    @Query("SELECT p  FROM Doctor p, WlyyUserRole r, WlyyRole ro " +
            " WHERE r.user = p.code AND p.hospital = ro.code AND p.status = 1 AND p.code = ?1 ")
    Doctor findListByCode(String code);
}
}

+ 3 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/WlyyRoleDao.java

@ -18,4 +18,7 @@ public interface WlyyRoleDao extends JpaRepository<WlyyRole,Integer> {
    @Query(value = "select b.* from  wlyy_role b where b.name = ?1", nativeQuery = true)
    @Query(value = "select b.* from  wlyy_role b where b.name = ?1", nativeQuery = true)
    WlyyRole findByName(String name);
    WlyyRole findByName(String name);
    @Query(value = "select b.* from  wlyy_role b where b.code = ?1", nativeQuery = true)
    WlyyRole findByCode(String code);
}
}

+ 228 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/user/ManageRangeService.java

@ -0,0 +1,228 @@
package com.yihu.wlyy.service.manager.user;
import com.yihu.wlyy.entity.*;
import com.yihu.wlyy.repository.*;
import com.yihu.wlyy.util.Envelop;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.*;
/**
 * Created by Reece on 2018/1/16.
 */
@Service
public class ManageRangeService extends BaseJpaService<Doctor, DoctorDao> {
    @Autowired
    private WlyyUserRoleDao userRoleDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private WlyyRoleDao roleDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * wlyy_user_role 列表展示及页面搜索医生信息
     *
     * @param name
     * @param idcard
     * @param page
     * @param pageSize
     * @return
     * @throws Exception
     */
    public List<Doctor> searchList(String name, String idcard, Integer page, Integer pageSize) throws Exception {
        if (page == null) {
            page = 1;
        }
        if (page == null) {
            pageSize = 15;
        }
        // 展示状态排序
        Sort sort = new Sort(Sort.Direction.ASC, "id");
        PageRequest pageRequest = new PageRequest(page - 1, pageSize, sort);
        List<Doctor> userList = null;
        /*if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(idcard)) {
            userList = doctorDao.findByFilter(name, idcard, pageRequest);
        } else if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(idcard)) {
            userList = doctorDao.findByIdcard(idcard, pageRequest);
        } else if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(idcard)) {
            userList = doctorDao.findByName(name, pageRequest);
        } else {
            userList = doctorDao.findByFilterAll(pageRequest);
        }*/
        String sql = "SELECT p.code,p.name,p.sex,p.idCard,p.mobile,ro.code hospital,ro.name hospitalName " +
                " FROM wlyy_doctor p, wlyy_user_role r, wlyy_role ro  " +
                " WHERE r.user = p.code AND r.role = ro.code AND p.status = 1 ";
        if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(idcard)) {
            sql += " AND p.name = " + name + " AND p.idcard = " + idcard;
        } else if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(idcard)) {
            sql += " AND p.idcard = " + idcard;;
        } else if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(idcard)) {
            sql += " AND p.name = " + name;
        }
        sql += " ORDER BY p.id ASC  limit "+ (page-1) +"," +pageSize;
        userList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Doctor.class));
        return userList;
    }
    /**
     * wlyy_user_role 列表展示及页面搜索医生信息
     *
     * @return
     * @throws Exception
     */
    public List<Doctor> searchList(String name, String idcard) throws Exception {
        List<Doctor> userList = null;
        String sql = "SELECT p.code,p.name,p.sex,p.idcard,p.mobile,ro.code hospital,ro.name hospitalName " +
                " FROM wlyy_doctor p, wlyy_user_role r, wlyy_role ro  " +
                " WHERE r.user = p.code AND r.role = ro.code AND p.status = 1  ";
        if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(idcard)) {
            sql += " AND p.name = " + name + " AND p.idcard = " + idcard;
        } else if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(idcard)) {
            sql += " AND p.idcard = " + idcard;;
        } else if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(idcard)) {
            sql += " AND p.name = " + name;
        }
        sql += " ORDER BY p.id ASC  ";
        userList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Doctor.class));
        return userList;
    }
    /**
     * 查询所有的医院信息
     *
     * @return
     * @throws Exception
     */
    public List<WlyyRole> getHostpitalList() throws Exception {
        // 展示状态排序
        List<WlyyRole> roleList = roleDao.findAll();
        return roleList;
    }
    /**
     * wlyy_user_role 列表展示及页面搜索医生信息
     * @return
     * @throws Exception
     */
    public List<Doctor> getDoctorList(String name, String idcard) throws Exception {
        // 展示状态排序
        List<Doctor> userList = null;
        if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(idcard)) {
            userList = doctorDao.findDoctorByFilter(name, idcard);
        } else if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(idcard)) {
            userList = doctorDao.findDoctorByIdcard(idcard);
        } else if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(idcard)) {
            userList = doctorDao.findDoctorByName(name);
        }
        return userList;
    }
    /**
     * 用户删除
     * @param doc
     * @param hospital
     * @return
     * @throws Exception
     */
    public boolean deleteUserRole(String doc,String hospital) throws Exception {
        Boolean flag = false;
        try {
            WlyyUserRole role = userRoleDao.findByUserAndRole(doc,hospital);
            userRoleDao.delete(role);
            flag = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
    //保存先判断wlyy_role是否存在在新增
    public int saveUserRole(String doc, String hospital) throws Exception {
        int flag = 200;
        try {
            Doctor doctor = doctorDao.findByCode(doc);
            if (doctor != null) {
                WlyyUserRole wlyyUserRole = userRoleDao.findByUserAndRole(doc, hospital);
                if (wlyyUserRole == null) {
                    WlyyUserRole userRole = new WlyyUserRole();
                    userRole.setUser(doc);
                    userRole.setRole(hospital);
                    userRole.setCzrq(new Date());
                    userRole.setCzy("1");
                    userRoleDao.save(userRole);
                } else {
                    flag = -1;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            flag = -2;
        }
        return flag;
    }
    /**
     * 列表页查询医生详情
     *
     * @param doc
     * @return
     */
    public List<Doctor> getUser(String doc,String hospital) throws Exception{
        List<Doctor> doctor = null;
        try {
            String sql = "SELECT p.code,p.name,p.sex,p.idcard,p.mobile,ro.code hospital,ro.name hospitalName " +
                    " FROM wlyy_doctor p, wlyy_user_role r, wlyy_role ro  " +
                    " WHERE r.user = p.code AND r.role = ro.code AND p.status = 1  " +
                    " and r.user = "+ doc +" and ro.code = "+ hospital;
            doctor =  jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(Doctor.class));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return doctor;
    }
    /**
     * 编辑医生相关信息
     *
     * @param doc         编辑医生code(批量添加逗号分隔)
     * @param oldHospital 修改前的医生权限code
     * @param hospital    修改后的医生权限code
     * @return
     */
    public void updateUserRole(String doc, String oldHospital, String hospital) throws Exception {
        try {
            WlyyUserRole userRole = userRoleDao.findByUserAndRole(doc,oldHospital);
            userRole.setRole(hospital);
            userRoleDao.save(userRole);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/template/DoctorTeamGuidanceTemplateDao.java

@ -68,7 +68,7 @@ public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepositor
    // 根据模板文章标题模糊搜索团队指导模板
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceTemplate b ,DoctorTeamGuidanceDetail a WHERE a.code = b.teamTemplateCode  " +
    @Query("SELECT b FROM DoctorTeamGuidanceTemplate b ,DoctorTeamGuidanceDetail a WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1 AND b.creater = ?1 AND b.title LIKE ?2 ")
    List<DoctorTeamGuidanceTemplate> getListByTile(String doctor, String title, Pageable pageRequest);
            " AND b.del = 1 AND b.teamId = ?1 AND b.title LIKE ?2 ")
    List<DoctorTeamGuidanceTemplate> getListByTile(int teamId, String title, Pageable pageRequest);
}
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorTeamGuidanceService.java

@ -277,7 +277,7 @@ public class DoctorTeamGuidanceService extends BaseService {
        if (StringUtils.isEmpty(filter)){
        if (StringUtils.isEmpty(filter)){
            listGuidances = doctorTeamGuidanceTemplateDao.findGuidanceByTeamId(teamId, request);
            listGuidances = doctorTeamGuidanceTemplateDao.findGuidanceByTeamId(teamId, request);
        }else {
        }else {
            listGuidances = doctorTeamGuidanceTemplateDao.getListByTile(doctor,"%"+filter+"%", request);
            listGuidances = doctorTeamGuidanceTemplateDao.getListByTile(teamId,"%"+filter+"%", request);
        }
        }
        for (DoctorTeamGuidanceTemplate guidance : listGuidances) {
        for (DoctorTeamGuidanceTemplate guidance : listGuidances) {