Ver código fonte

指导模板搜索

wujunjie 7 anos atrás
pai
commit
3d0bf441b0

+ 7 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/template/DoctorGuidanceTempDao.java

@ -38,4 +38,11 @@ public interface DoctorGuidanceTempDao extends PagingAndSortingRepository<Doctor
    //根据模板文章标题模糊搜索个人指导模板
    @Query(value = "select t from DoctorGuidanceTemp t where t.owner != 'system' and t.modelName like ?1 order by t.sendTimes desc ")
    Page<DoctorGuidanceTemp> listByTile(String filter, Pageable pageRequest);
    //根据模板文章标题模糊搜索个人指导模板
    @Query(value = "select t from DoctorGuidanceTemp t where t.owner = ?1 and t.modelName like ?2 order by t.sendTimes desc ")
    Page<DoctorGuidanceTemp> listOwnerByTile(String owner, String filter, Pageable pageRequest);
    @Query("select t from DoctorGuidanceTemp t where (t.owner = 'system' or t.owner = ?1) and t.modelName like ?2 order by t.sendTimes desc ")
    Page<DoctorGuidanceTemp> listByTileAll(String owner,String filter, Pageable pageRequest);
}

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

@ -23,6 +23,10 @@ public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepositor
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamId = ?1 ")
    List<DoctorTeamGuidanceTemplate> findGuidanceByTeamId(int teamId, Pageable request);
    //    根据团队ID获取团队内的模板列表(带分页和创建时间倒序)
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamId = ?1 ")
    List<DoctorTeamGuidanceTemplate> countGuidanceByTeamId(int teamId);
    //    由模板编码获取拥有该模板的团队信息
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamTemplateCode = ?1 ")
    List<DoctorTeamGuidanceTemplate> getTeamsByGuidance(String guidanceCode);
@ -52,4 +56,19 @@ public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepositor
            " AND b.del = 1 AND b.title LIKE ?1 order by b.useTimes desc  ")
    Page<DoctorTeamGuidanceTemplate> listByTile(String title, Pageable pageRequest);
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceDetail a, DoctorTeamGuidanceTemplate b WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1 AND b.creater = ?1  AND b.teamId = ?2 AND b.title LIKE ?3 order by b.useTimes desc  ")
    List<DoctorTeamGuidanceTemplate> countTeamListByTile(String doctor, int teamId, String title);
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceDetail a, DoctorTeamGuidanceTemplate b WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1  AND b.creater = ?1  AND b.title LIKE ?2 GROUP BY b.teamId order by b.useTimes desc  ")
    List<DoctorTeamGuidanceTemplate> countTeamListByTile(String doctor, String title);
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceDetail a, DoctorTeamGuidanceTemplate b WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1 AND b.creater = ?1 AND b.title LIKE ?2 order by b.useTimes desc  ")
    List<DoctorTeamGuidanceTemplate> getListByTile(String doctor, String title, Pageable pageRequest);
}

+ 27 - 39
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java

@ -7,6 +7,7 @@ import com.yihu.wlyy.repository.template.DoctorTeamGuidanceTemplateDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.CodeFomat;
import com.yihu.wlyy.util.CommonUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -201,53 +202,40 @@ public class DoctorGuidanceTempService extends BaseService {
     * @param type   模板类型
     * @return
     */
    public List<Map<String, Object>> list(String doctor, String type, int pageSize, int pageNo) throws Exception {
    public List<Map<String, Object>> list(String doctor,String filter, String type, int pageSize, int pageNo) throws Exception {
        Page<DoctorGuidanceTemp> temps = null;
        PageRequest pageRequest = new PageRequest(pageNo, pageSize);
        List<Map<String, Object>> listMap = new ArrayList<>();
        if (type.equals("1")) {
            temps = guidanceTempDao.findByOwner("system", pageRequest);
            List<DoctorGuidanceTemp> list = temps.getContent();
            for (int i = 0; i < list.size(); i++) {
                DoctorGuidanceTemp dgt = list.get(i);
                Map<String, Object> tem = new HashMap<>();
                tem.put("code", dgt.getCode());
                tem.put("owner", dgt.getOwner());
                tem.put("sendTimes", dgt.getSendTimes());
                tem.put("lastTime", dgt.getLastTime());
                tem.put("modelName", dgt.getModelName());
                listMap.add(tem);
            }
        } else if (type.equals("2")) {
            temps = guidanceTempDao.findByOwner(doctor, pageRequest);
            List<DoctorGuidanceTemp> list = temps.getContent();
            for (int i = 0; i < list.size(); i++) {
                DoctorGuidanceTemp dgt = list.get(i);
                Map<String, Object> tem = new HashMap<>();
                tem.put("code", dgt.getCode());
                tem.put("owner", dgt.getOwner());
                tem.put("sendTimes", dgt.getSendTimes());
                tem.put("lastTime", dgt.getLastTime());
                tem.put("modelName", dgt.getModelName());
                listMap.add(tem);
        if (StringUtils.isEmpty(filter)){
            if (type.equals("1")) {
                temps = guidanceTempDao.findByOwner("system", pageRequest);
            } else if (type.equals("2")) {
                temps = guidanceTempDao.findByOwner(doctor, pageRequest);
            } else {
                temps = guidanceTempDao.findByOwnerAndSystem(doctor, pageRequest);
            }
        } else {
            temps = guidanceTempDao.findByOwnerAndSystem(doctor, pageRequest);
            List<DoctorGuidanceTemp> list = temps.getContent();
            for (int i = 0; i < list.size(); i++) {
                DoctorGuidanceTemp dgt = list.get(i);
                Map<String, Object> tem = new HashMap<>();
                tem.put("code", dgt.getCode());
                tem.put("owner", dgt.getOwner());
                tem.put("sendTimes", dgt.getSendTimes());
                tem.put("lastTime", dgt.getLastTime());
                tem.put("modelName", dgt.getModelName());
                listMap.add(tem);
        }else {
            if (type.equals("1")) {
                temps = guidanceTempDao.listByTileSystem("%"+filter+"%", pageRequest);
            } else if (type.equals("2")) {
                temps = guidanceTempDao.listOwnerByTile(doctor,"%"+filter+"%", pageRequest);
            } else {
                temps = guidanceTempDao.listByTileAll(doctor,"%"+filter+"%", pageRequest);
            }
        }
        List<DoctorGuidanceTemp> list = temps.getContent();
        for (int i = 0; i < list.size(); i++) {
            DoctorGuidanceTemp dgt = list.get(i);
            Map<String, Object> tem = new HashMap<>();
            tem.put("code", dgt.getCode());
            tem.put("owner", dgt.getOwner());
            tem.put("sendTimes", dgt.getSendTimes());
            tem.put("lastTime", dgt.getLastTime());
            tem.put("modelName", dgt.getModelName());
            listMap.add(tem);
        }
        return listMap;
    }

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

@ -260,18 +260,26 @@ public class DoctorTeamGuidanceService extends BaseService {
    /**
     * 根据医生所属的单个团队获取团队模板列表
     *
     * @param doctor
     * @param filter
     * @param teamId
     * @param pageNo
     * @param pageSize
     * @return
     * @throws Exception
     */
    public List getTeamGuidanceList(int teamId, int pageNo, int pageSize) throws Exception {
    public List getTeamGuidanceList(String doctor, String filter, int teamId, int pageNo, int pageSize) throws Exception {
        Sort sort = new Sort(Sort.Direction.DESC, "createTime");
        PageRequest request = new PageRequest(pageNo, pageSize, sort);
        List<DoctorTeamGuidanceTemplate> listGuidances = doctorTeamGuidanceTemplateDao.findGuidanceByTeamId(teamId, request);
        List list = new ArrayList();
        List<DoctorTeamGuidanceTemplate> listGuidances = null;
        if (StringUtils.isEmpty(filter)){
            listGuidances = doctorTeamGuidanceTemplateDao.findGuidanceByTeamId(teamId, request);
        }else {
            listGuidances = doctorTeamGuidanceTemplateDao.getListByTile(doctor,"%"+filter+"%", request);
        }
        for (DoctorTeamGuidanceTemplate guidance : listGuidances) {
            Map map = new HashMap();
            String title = guidance.getTitle();
@ -282,9 +290,46 @@ public class DoctorTeamGuidanceService extends BaseService {
            map.put("useTimes", useTimes);
            list.add(map);
        }
        return list;
    }
    /**
     * 获取此医生所在的团队列表。
     *
     * @param doctorCode
     * @param filter 搜索关键字
     * @return
     */
    public List getDoctorTeams(String doctorCode,String filter) throws Exception{
        List teamList = null;
        try {
            List<AdminTeam> doctorTeams = memberDao.findDoctorTeams(doctorCode);
            teamList = new ArrayList();
            for (AdminTeam AdminTeam : doctorTeams){
                Map map = new HashMap();
                String teamName = AdminTeam.getName();
                Long teamId = AdminTeam.getId();
                map.put("teamName", teamName);
                map.put("teamId", teamId);
                if (StringUtils.isNotEmpty(filter)){
                    List<DoctorTeamGuidanceTemplate> guidances = doctorTeamGuidanceTemplateDao.countTeamListByTile(doctorCode,Integer.valueOf(teamId.toString()),"%"+filter+"%");
                    map.put("amount", guidances.size());
                }else {
                    List<DoctorTeamGuidanceTemplate> listGuidances = doctorTeamGuidanceTemplateDao.countGuidanceByTeamId(Integer.valueOf(teamId.toString()));
                    map.put("amount", listGuidances.size());
                }
                teamList.add(map);
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return teamList;
    }
    /**
     * 根据团队模板编码获取单个 有效的 模板详情
     *

+ 5 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorGuidanceTempController.java

@ -170,14 +170,17 @@ public class DoctorGuidanceTempController extends BaseController {
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "查询指导模板")
    public String list(@RequestParam(required = false, defaultValue = "")
    public String list(
                       @RequestParam(required = false, defaultValue = "")
                       @ApiParam(value = "搜索关键字") String filter,
                       @RequestParam(required = false, defaultValue = "")
                       @ApiParam(value = "模板类型 1:系统 2:自定义 为空:所有") String type,
                       @RequestParam(defaultValue = "10") String pageSize,
                       @RequestParam(defaultValue = "1") @ApiParam(value = "当前页码") String pageNo) {
        try {
            int pagesize = Integer.parseInt(pageSize);
            int pageno = Integer.parseInt(pageNo) - 1;
            List<Map<String, Object>> temps = guidanceTempService.list(getUID(), type, pagesize, pageno);
            List<Map<String, Object>> temps = guidanceTempService.list(getUID(),filter, type, pagesize, pageno);
            if (temps == null || temps.size() < 1) {
                return write(200, "查询成功", "data", new JSONArray());

+ 9 - 16
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorTeamGuidanceController.java

@ -4,8 +4,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import com.yihu.wlyy.entity.template.DoctorTeamGuidanceTemplate;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempDao;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.template.DoctorTeamGuidanceService;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
@ -31,8 +31,6 @@ import java.util.*;
@Api(description = "医生端&后端团队指导模板")
public class DoctorTeamGuidanceController extends WeixinBaseController {
    @Autowired
    private AdminTeamService adminTeamService;
    @Autowired
    private DoctorTeamGuidanceService doctorTeamGuidanceService;
    @Autowired
@ -48,19 +46,10 @@ public class DoctorTeamGuidanceController extends WeixinBaseController {
    @RequestMapping(value = "/getDoctorTeams", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取医生所属的所有团队")
    public String getHealthIndexHistory() {
    public String getHealthIndexHistory(@RequestParam(required = false, defaultValue = "") @ApiParam(value = "搜索关键字") String filter) {
        try {
            String doctorCode = getUID();
            List<AdminTeam> doctorTeams = adminTeamService.getDoctorTeams(doctorCode);
            List teamList = new ArrayList();
            for (AdminTeam AdminTeam : doctorTeams) {
                Map map = new HashMap();
                String teamName = AdminTeam.getName();
                Long teamId = AdminTeam.getId();
                map.put("teamName", teamName);
                map.put("teamId", teamId);
                teamList.add(map);
            }
            List teamList = doctorTeamGuidanceService.getDoctorTeams(doctorCode,filter);
            return write(200, "获取医生所属团队成功!", "teamList", teamList);
        } catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());
@ -76,11 +65,15 @@ public class DoctorTeamGuidanceController extends WeixinBaseController {
    @RequestMapping(value = "/getTeamGuidanceList", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取单个团队模板列表")
    public String getTeamGuidanceList(@RequestParam int teamId,
    public String getTeamGuidanceList(
                                      @RequestParam(required = false, defaultValue = "")
                                      @ApiParam(value = "搜索关键字") String filter,
                                      @RequestParam(required = false, defaultValue = "")
                                      @ApiParam(value = "团队ID") Integer teamId,
                                      @RequestParam int pageNo,
                                      @RequestParam int pageSize) {
        try {
            List list = doctorTeamGuidanceService.getTeamGuidanceList(teamId, pageNo - 1, pageSize);
            List list = doctorTeamGuidanceService.getTeamGuidanceList(getUID(),filter,teamId, pageNo - 1, pageSize);
            return write(200, "获取团队模板列表成功!", "templateList", list);
        } catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());