wujunjie пре 8 година
родитељ
комит
47f0a9789a

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

@ -1,6 +1,9 @@
package com.yihu.wlyy.repository.template;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -17,8 +20,8 @@ public interface DoctorGuidanceTempDao extends PagingAndSortingRepository<Doctor
    int deleteByCode(String code);
    @Query("select t from DoctorGuidanceTemp t where t.owner = ?1 order by t.sendTimes desc")
    List<DoctorGuidanceTemp> findByOwner(String owner);
    Page<List<DoctorGuidanceTemp>> findByOwner(String owner, Pageable pageRequest);
    @Query("select t from DoctorGuidanceTemp t where t.owner = ?1 or t.owner = 'system' order by t.sendTimes desc")
    List<DoctorGuidanceTemp> findByOwnerAndSystem(String owner);
    Page<List<DoctorGuidanceTemp>> findByOwnerAndSystem(String owner, Pageable pageRequest);
}

+ 46 - 25
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java

@ -6,6 +6,8 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.CommonUtil;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -150,42 +152,61 @@ public class DoctorGuidanceTempService extends BaseService {
     * @param type   模板类型
     * @return
     */
    public List<Map<String,Object>> list(String doctor, String type) throws Exception {
        List<DoctorGuidanceTemp> temps = null;
    public List<Map<String,Object>> list(String doctor, String type,int pageSize) throws Exception {
//        List<DoctorGuidanceTemp> temps = null;
        Page<List<DoctorGuidanceTemp>> temps = null;
        PageRequest pageRequest = new PageRequest(0, pageSize);
        List<Map<String,Object>> listMap = new ArrayList<>();
        if (type.equals("1")) {
            temps = guidanceTempDao.findByOwner("system");
            for(DoctorGuidanceTemp temp : temps){
            temps = guidanceTempDao.findByOwner("system",pageRequest);
            /*for(List<DoctorGuidanceTemp> te : temps){
                for (DoctorGuidanceTemp temp : te){
                    Map<String,Object> tem = new HashMap<>();
                    tem.put("code",temp.getCode());
                    tem.put("owner",temp.getOwner());
                    tem.put("sendTimes",temp.getSendTimes());
                    tem.put("lastTime",temp.getLastTime());
                    tem.put("modelName",temp.getModelName());
                    listMap.add(tem);
                }
            }*/
            List<List<DoctorGuidanceTemp>> temd = temps.getContent();
            for (int i=0;i<temd.size();i++){
                DoctorGuidanceTemp doctorGuidanceTemp = (DoctorGuidanceTemp)temd.get(i);
                Map<String,Object> tem = new HashMap<>();
                tem.put("code",temp.getCode());
                tem.put("owner",temp.getOwner());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("lastTime",temp.getLastTime());
                tem.put("modelName",temp.getModelName());
                tem.put("code",doctorGuidanceTemp.getCode());
                tem.put("owner",doctorGuidanceTemp.getOwner());
                tem.put("sendTimes",doctorGuidanceTemp.getSendTimes());
                tem.put("lastTime",doctorGuidanceTemp.getLastTime());
                tem.put("modelName",doctorGuidanceTemp.getModelName());
                listMap.add(tem);
            }
        } else if (type.equals("2")) {
            temps = guidanceTempDao.findByOwner(doctor);
            for(DoctorGuidanceTemp temp : temps){
                Map<String,Object> tem = new HashMap<>();
                tem.put("code",temp.getCode());
                tem.put("owner",temp.getOwner());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("lastTime",temp.getLastTime());
                tem.put("modelName",temp.getModelName());
                listMap.add(tem);
            temps = guidanceTempDao.findByOwner(doctor,pageRequest);
            List<List<DoctorGuidanceTemp>> temd = temps.getContent();
            for (int i=0;i<temd.size();i++){
                DoctorGuidanceTemp doctorGuidanceTemp = (DoctorGuidanceTemp)temd.get(i);
                    Map<String,Object> tem = new HashMap<>();
                    tem.put("code",doctorGuidanceTemp.getCode());
                    tem.put("owner",doctorGuidanceTemp.getOwner());
                    tem.put("sendTimes",doctorGuidanceTemp.getSendTimes());
                    tem.put("lastTime",doctorGuidanceTemp.getLastTime());
                    tem.put("modelName",doctorGuidanceTemp.getModelName());
                    listMap.add(tem);
            }
        } else {
            temps = guidanceTempDao.findByOwnerAndSystem(doctor);
            for(DoctorGuidanceTemp temp : temps){
            temps = guidanceTempDao.findByOwnerAndSystem(doctor,pageRequest);
            List<List<DoctorGuidanceTemp>> temd = temps.getContent();
            for (int i=0;i<temd.size();i++){
                DoctorGuidanceTemp doctorGuidanceTemp = (DoctorGuidanceTemp)temd.get(i);
                Map<String,Object> tem = new HashMap<>();
                tem.put("code",temp.getCode());
                tem.put("owner",temp.getOwner());
                tem.put("sendTimes",temp.getSendTimes());
                tem.put("lastTime",temp.getLastTime());
                tem.put("modelName",temp.getModelName());
                tem.put("code",doctorGuidanceTemp.getCode());
                tem.put("owner",doctorGuidanceTemp.getOwner());
                tem.put("sendTimes",doctorGuidanceTemp.getSendTimes());
                tem.put("lastTime",doctorGuidanceTemp.getLastTime());
                tem.put("modelName",doctorGuidanceTemp.getModelName());
                listMap.add(tem);
            }
        }

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

@ -2,7 +2,6 @@ package com.yihu.wlyy.web.doctor.template;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import com.yihu.wlyy.service.template.DoctorGuidanceTempService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -178,9 +177,11 @@ public class DoctorGuidanceTempController extends BaseController {
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "查询指导模板")
    public String list(@RequestParam(required = false, defaultValue = "")
                       @ApiParam(value = "模板类型 1:系统 2:自定义 为空:所有") String type) {
                       @ApiParam(value = "模板类型 1:系统 2:自定义 为空:所有") String type,
                       @RequestParam(defaultValue = "10") String pageSize) {
        try {
            List<Map<String,Object>> temps = guidanceTempService.list(getUID(), type);
            int pagesize = Integer.parseInt(pageSize);
            List<Map<String,Object>> temps = guidanceTempService.list(getUID(), type,pagesize);
            if (temps == null || temps.size() < 1) {
                return write(200, "查询成功", "data", new JSONArray());