瀏覽代碼

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

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

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

@ -30,4 +30,12 @@ public interface DoctorGuidanceTempDao extends PagingAndSortingRepository<Doctor
    //验证医生健康指导模板标题是否重复
    @Query("select t from DoctorGuidanceTemp t where t.owner = ?1 and t.modelName = ?2 ")
    List<DoctorGuidanceTemp> findByTitle(String owner,String title);
    //根据模板文章标题模糊搜索系统指导模板
    @Query(value = "select t from DoctorGuidanceTemp t where t.owner = 'system' and t.modelName like ?1 order by t.sendTimes desc ")
    Page<DoctorGuidanceTemp> listByTileSystem(String filter, Pageable pageRequest);
    //根据模板文章标题模糊搜索个人指导模板
    @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);
}

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

@ -1,6 +1,7 @@
package com.yihu.wlyy.repository.template;
import com.yihu.wlyy.entity.template.DoctorTeamGuidanceTemplate;
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.Modifying;
@ -46,4 +47,9 @@ public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepositor
    @Query("update DoctorTeamGuidanceTemplate t set t.useTimes =  0 ,t.del = 0 where t.teamId = ?1 and t.teamTemplateCode =?2 ")
    int deleteByTeam(int teamId, String guidanceCode);
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceDetail a, DoctorTeamGuidanceTemplate b WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1 AND b.teamId = ?1 AND b.title LIKE ?2 order by b.useTimes desc  ")
    Page<DoctorTeamGuidanceTemplate> listByTile(int teamId, String owner, Pageable pageRequest);
}

+ 65 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java

@ -1,7 +1,9 @@
package com.yihu.wlyy.service.template;
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.repository.template.DoctorTeamGuidanceTemplateDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.CodeFomat;
import com.yihu.wlyy.util.CommonUtil;
@ -29,6 +31,8 @@ public class DoctorGuidanceTempService extends BaseService {
    DoctorGuidanceTempDao guidanceTempDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private DoctorTeamGuidanceTemplateDao doctorTeamGuidanceTemplateDao;
    @Autowired
    private CommonUtil CommonUtil;
@ -247,4 +251,65 @@ public class DoctorGuidanceTempService extends BaseService {
        return listMap;
    }
    /**
     * 根据模板类型、文章标题模糊搜索指导模板
     *
     * @param filter 搜索关键字
     * @param type 1:系统 2:个人 3:团队摸版
     * @param pageSize
     * @param pageNo
     * @return
     * @throws Exception
     */
    public List<Map<String, Object>> listByTitle(String filter,String type, Integer teamId, int pageSize, int pageNo) throws Exception {
        PageRequest pageRequest = new PageRequest(pageNo, pageSize);
        List<Map<String, Object>> listMap = new ArrayList<>();
        if ("1".equals(type)) {
            Page<DoctorGuidanceTemp> temps = guidanceTempDao.listByTileSystem("%"+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);
            }
        } else if ("2".equals(type)) {
            Page<DoctorGuidanceTemp> temps = guidanceTempDao.listByTile("%"+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);
            }
        } else if("3".equals(type) && teamId!=null){
            Page<DoctorTeamGuidanceTemplate> temps = doctorTeamGuidanceTemplateDao.listByTile(teamId,"%"+filter+"%", pageRequest);
            List<DoctorTeamGuidanceTemplate> list = temps.getContent();
            for (int i = 0; i < list.size(); i++) {
                DoctorTeamGuidanceTemplate dgt = list.get(i);
                Map<String, Object> tem = new HashMap<>();
                tem.put("code", dgt.getTeamTemplateCode());
                tem.put("owner", dgt.getCreater());
                tem.put("sendTimes", dgt.getUseTimes());
                tem.put("lastTime", dgt.getCzrq());
                tem.put("modelName", dgt.getTitle());
                listMap.add(tem);
            }
        }
        return listMap;
    }
}

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

@ -53,33 +53,6 @@ public class DoctorGuidanceTempController extends BaseController {
        return write(200, "查询成功!", "data", temp);
    }
    /**
     * 添加指导模板
     *
     * @param content
     * @return
     */
    /*@RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation(value = "添加指导模板")
    public String add(@RequestParam @ApiParam(value = "指导内容") String content) {
        try {
            if (StringUtils.isEmpty(content)) {
                return error(-1, "内容不能为空");
            }
            DoctorGuidanceTemp temp = guidanceTempService.add(getUID(), content);
            if (temp != null) {
                return write(200, "添加成功");
            } else {
                return write(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }*/
//  =====================
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation(value = "添加指导模板")
    @ObserverRequired
@ -111,7 +84,6 @@ public class DoctorGuidanceTempController extends BaseController {
            return error(-1, "添加失败");
        }
    }
//  =====================
    /**
     * 修改指导模板
@ -217,4 +189,46 @@ public class DoctorGuidanceTempController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 根据模板类型、文章标题模糊搜索指导模板
     * (自定义即个人模板)
     * @param filter  搜索关键字
     * @param type  模板类型
     * @param type  teamId
     * @param pageSize 页展示数量
     * @param pageNo  当前页码
     * @return
     */
    @RequestMapping(value = "/search", method = RequestMethod.GET)
    @ApiOperation(value = "模糊搜索指导模板")
    public String searchByTitle(
                        @RequestParam(required = true, defaultValue = "")
                        @ApiParam(value = "搜索关键字") String filter,
                        @RequestParam(required = true, defaultValue = "")
                        @ApiParam(value = "模板类型 1:系统 2:个人 3:团队摸版") String type,
                        @RequestParam(required = false)
                        @ApiParam(value = "3:团队摸版时 团队ID") Integer teamId,
                        @RequestParam(defaultValue = "10")
                        @ApiParam(value = "页展示数量") 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 = null;
            if (StringUtils.isNotEmpty(type) && StringUtils.isNotEmpty(filter)){
                temps = guidanceTempService.listByTitle(filter,type,teamId,pagesize, pageno);
            }else {
                return error(-1, "模板类型不能为空!");
            }
            if (temps == null || temps.size() < 1) {
                return write(200, "查询成功!", "data", new JSONArray());
            } else {
                return write(200, "查询成功!", "data", new JSONArray(temps));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
}