Browse Source

Merge branch 'dev' of huangzhanpeng/wlyy_management into dev

lyr 8 years ago
parent
commit
29b2a3c6c2

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/SystemDictDao.java

@ -14,4 +14,7 @@ public interface SystemDictDao extends PagingAndSortingRepository<SystemDict, Lo
    @Query("from SystemDict s where s.dictName=?1 order by sort asc ")
    List<SystemDict> findByDictName(String name);
    @Query("select s.value from SystemDict s where s.dictName=?1 and s.code =?2")
    String findByDictNameAndCode(String dictName,String code);
}

+ 120 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -13,6 +13,8 @@ import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.followup.FollowupContentDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.FollowupUploadTask;
import com.yihu.wlyy.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
@ -47,37 +49,115 @@ public class FollowUpService extends BaseService {
	private FollowupContentDao followupContentDao;
	@Autowired
	private SystemDictDao systemDictDao;
	private SystemDictService systemDictService;
	@Autowired
	private ObjectMapper objectMapper;
	/**
	 * 转译随访信息
     */
	private Map<String,String> getFollowupDetail(Followup followup) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		//患者信息
		String patientCode = followup.getPatientCode();
		Patient patient = patientDao.findByCode(patientCode);
		if(patient!=null) {
			re.put("patientCode",patientCode);
			re.put("patientName",patient.getName());
			re.put("idcard",patient.getIdcard());
			re.put("sex",String.valueOf(patient.getSex()));
			re.put("birthday",DateUtil.dateToStrLong(patient.getBirthday()));
		}
		else{
			throw new Exception("not exit patient:"+patientCode);
		}
		re.put("id",String.valueOf(followup.getId()));
		re.put("followupNo",followup.getFollowupNo());
		re.put("followupDate",DateUtil.dateToStrLong(followup.getFollowupDate()));
		re.put("followupNextDate",DateUtil.dateToStrLong(followup.getFollowupNextDate()));
		//随访方式转译
		re.put("followupType",followup.getFollowupType());
		String followupTypeName = systemDictService.getDictValue("FOLLOWUP_WAY_DICT",followup.getFollowupType());
		re.put("followupTypeName",followupTypeName);
		//随访类别转译
		re.put("followupClass",followup.getFollowupClass());
		String followupClassName = systemDictService.getDictValue("FOLLOWUP_CLASS_DICT",followup.getFollowupClass());
		re.put("followupClassName",followupClassName);
		//随访管理状态转译
		re.put("followupManagerStatus",followup.getFollowupManagerStatus());
		String followupManagerStatusName = systemDictService.getDictValue("FOLLOWUP_MANAGER_STATUS",followup.getFollowupManagerStatus());
		re.put("followupManagerStatusName",followupManagerStatusName);
		re.put("doctorCode",followup.getDoctorCode());
		re.put("doctorName",followup.getDoctorName());
		re.put("orgCode",followup.getOrgCode());
		re.put("orgName",followup.getOrgName());
		re.put("dataFrom",followup.getDataFrom());
		re.put("status",followup.getStatus());
		re.put("followupContentPhone",followup.getFollowupContentPhone());
		re.put("createTime",DateUtil.dateToStrLong(followup.getCreateTime()));
		re.put("creater",followup.getCreater());
		return re;
	}
	/**
	 * 获取医生随访列表
     */
	public List<Followup> getListByDoctor(String doctorCode,String startTime,String endTime,String page,String pageSize) throws Exception
	public List<Map<String,String>> getListByDoctor(String doctorCode,String startTime,String endTime,String page,String pageSize) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
		// 分页信息
		int pageInt = Integer.valueOf(page)-1;
		int pageSizeInt =  Integer.valueOf(pageSize);
		Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
		return followupDao.findByDoctor(doctorCode,DateUtil.strToDate(startTime),DateUtil.strToDate(endTime),pageRequest);
		List<Followup> list = followupDao.findByDoctor(doctorCode,DateUtil.strToDate(startTime),DateUtil.strToDate(endTime),pageRequest);
		if(list!=null && list.size()>0)
		{
		    for(Followup followup : list)
			{
				Map<String,String> map = getFollowupDetail(followup);
				re.add(map);
			}
		}
		return re;
	}
	/**
	 * 获取医生随访列表(创建者)
	 */
	public List<Followup> getListByCreater(String doctorCode,String startTime,String endTime,String page,String pageSize) throws Exception
	public List<Map<String,String>> getListByCreater(String doctorCode,String startTime,String endTime,String page,String pageSize) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
		// 分页信息
		int pageInt = Integer.valueOf(page)-1;
		int pageSizeInt =  Integer.valueOf(pageSize);
		Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
		return followupDao.findByCreater(doctorCode,DateUtil.strToDate(startTime),DateUtil.strToDate(endTime),pageRequest);
		List<Followup> list = followupDao.findByCreater(doctorCode,DateUtil.strToDate(startTime),DateUtil.strToDate(endTime),pageRequest);
		if(list!=null && list.size()>0)
		{
			for(Followup followup : list)
			{
				Map<String,String> map = getFollowupDetail(followup);
				re.add(map);
			}
		}
		return re;
	}
	/**
@ -206,8 +286,42 @@ public class FollowUpService extends BaseService {
		}
	}
	/**
	 * 完成随访记录,并上传随访记录
     */
	public void finishFollowup(String id) throws Exception {
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			followup.setStatus("1");  //状态 0取消 1已完成 2未开始 3进行中
			followupDao.save(followup);
			//上传随访计划
			new Thread(new FollowupUploadTask(String.valueOf(followup.getId()))).start();
		}
		else{
			throw new Exception("not exit follow:"+id+".\r\n");
		}
	}
	/*********************************** 随访详情 *******************************************************************/
	/**
	 * 获取面访项目列表
	 */
	public Map<String,String> getFollowup(String id) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			re = getFollowupDetail(followup);
		}
		else{
			throw new Exception("not exit follow:"+id+".\r\n");
		}
		return re;
	}
	/**
	 * 获取面访项目列表
	 */
@ -217,7 +331,7 @@ public class FollowUpService extends BaseService {
		//获取已填写的面访项目
		List<String> project = followupContentDao.findProjectByFollowupId(Long.valueOf(id));
		//获取所有面访项目
		List<SystemDict> dictList = systemDictDao.findByDictName("FOLLOWUP_PROJECT");
		List<SystemDict> dictList = systemDictService.getDictByDictName("FOLLOWUP_PROJECT");
		if (dictList!=null && dictList.size()>0)
		{
			for(SystemDict dict:dictList)

+ 47 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/system/SystemDictService.java

@ -3,7 +3,10 @@ package com.yihu.wlyy.service.system;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.dict.SystemDictListDao;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@ -16,9 +19,52 @@ public class SystemDictService {
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
    private SystemDictListDao systemDictListDao;
    private StringRedisTemplate redisTemplate;
    public List<SystemDict> getDictByDictName(String name) {
        return systemDictDao.findByDictName(name);
    }
    /**
     * 字典转译
     * @param dictName
     * @param code
     * @return
     */
    public String getDictValue(String dictName,String code){
        String re = "";
        try {
            if(!StringUtils.isEmpty(code))
            {
                //判断该字典redis是否存在
                String exit = redisTemplate.opsForValue().get("systemDict:"+dictName);
                if(!StringUtils.isEmpty(exit))
                {
                    re =  redisTemplate.opsForValue().get("systemDict:"+dictName+":"+code);
                }
                else{
                    List<SystemDict> list = systemDictDao.findByDictName(dictName);
                    if(list!=null && list.size()>0)
                    {
                        redisTemplate.opsForValue().set("systemDict:"+dictName,"1");
                        for(SystemDict item:list)
                        {
                            redisTemplate.opsForValue().set("systemDict:"+dictName+":"+item.getCode(),item.getValue());
                            if(code.equals(item.getCode()))
                            {
                                re = item.getValue();
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            re = systemDictDao.findByDictNameAndCode(dictName,code);
        }
        return re;
    }
}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -462,6 +462,9 @@ public class GuahaoXMService implements IGuahaoService {
            } else if (StringUtils.startsWith(xml, "System-Error")) {
                // 调用失败
                throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
            }  else if (StringUtils.startsWith(xml, "Error")) {
                // 调用失败
                throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
            }
            //预约成功

+ 39 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/FollowupUploadTask.java

@ -0,0 +1,39 @@
package com.yihu.wlyy.task;
import com.yihu.wlyy.service.third.jw.JwArchivesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
/**
 * 随访记录上传
 * Created by hzp on 2016/12/13.
 */
public class FollowupUploadTask implements Runnable {
    private static Logger logger = LoggerFactory.getLogger(FollowupUploadTask.class);
    @Autowired
    private JwArchivesService jwArchivesService;
    String id = "";
    public FollowupUploadTask(String id) {
        this.id = id;
    }
    @Override
    public void run() {
        try {
            Thread.sleep(3000);
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            jwArchivesService.uploadFollowup(id);
            logger.info("followup:"+id+" upload success.");
        }
        catch (Exception e) {
            e.printStackTrace();
            logger.info("followup:"+id+" upload fail."+e.getMessage());
        }
    }
}

+ 31 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -51,7 +51,7 @@ public class DoctorFollowUpController extends BaseController {
							  @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
							  @RequestParam(value="pageSize",required = true) String pageSize) {
		try {
			List<Followup> result = followUpService.getListByDoctor(getUID(),startTime,endTime,page,pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
			List<Map<String,String>> result = followUpService.getListByDoctor(getUID(),startTime,endTime,page,pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
			return write(200, "获取随访列表成功!", "data", result);
		} catch (Exception e) {
@ -71,7 +71,7 @@ public class DoctorFollowUpController extends BaseController {
						  @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
						  @RequestParam(value="pageSize",required = true) String pageSize) {
		try {
			List<Followup> result = followUpService.getListByCreater(getUID(),startTime,endTime,page,pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
			List<Map<String,String>> result = followUpService.getListByCreater(getUID(),startTime,endTime,page,pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
			return write(200, "获取随访列表成功!", "data", result);
		} catch (Exception e) {
@ -155,7 +155,36 @@ public class DoctorFollowUpController extends BaseController {
		}
	}
	@ApiOperation("完成随访记录")
	@RequestMapping(value = "/finishFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String finishFollowup(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
									 @RequestParam(value="id",required = true) String id)
	{
		try {
			followUpService.finishFollowup(id);
			return write(200, "完成随访记录成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "完成随访记录失败!"+e.getMessage());
		}
	}
	/*********************************** 随访详情 *******************************************************************/
	@ApiOperation("获取面访信息")
	@RequestMapping(value = "/getFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowup(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
									 @RequestParam(value="id",required = true) String id)
	{
		try {
			Map<String,String> response = followUpService.getFollowup(id);
			return write(200, "获取面访信息成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取面访信息失败!"+e.getMessage());
		}
	}
	@ApiOperation("获取面访项目列表")
	@RequestMapping(value = "/getFollowupProject", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody