浏览代码

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

lyr 8 年之前
父节点
当前提交
04a1563824

+ 23 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/template/DoctorGuidanceTemp.java

@ -26,11 +26,32 @@ public class DoctorGuidanceTemp extends IdEntity{
    // 最后一次发送时间
    private Date lastTime;
//    模板名称
    private String modelName;
//    图片地址
    private String imagesUrl;
    public String getModelName() {
        return modelName;
    }
    public void setModelName(String modelName) {
        this.modelName = modelName;
    }
    public String getImagesUrl() {
        return imagesUrl;
    }
    public void setImagesUrl(String imagesUrl) {
        this.imagesUrl = imagesUrl;
    }
    public String getCode() {
        return code;
    }
//=================
    public void setCode(String code) {
        this.code = code;
    }
@ -76,4 +97,6 @@ public class DoctorGuidanceTemp extends IdEntity{
    public void setLastTime(Date lastTime) {
        this.lastTime = lastTime;
    }
}

+ 2 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -1,9 +1,5 @@
package com.yihu.wlyy.interceptors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.entity.url.CudUrl;
import com.yihu.wlyy.logs.InterfaceCallLogs;
import com.yihu.wlyy.util.DateUtil;
@ -15,13 +11,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import java.lang.annotation.Annotation;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
/**
 * 医生权限校验

+ 47 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java

@ -3,13 +3,14 @@ package com.yihu.wlyy.service.template;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempDao;
import com.yihu.wlyy.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 医生健康指导模板
@ -21,6 +22,46 @@ public class DoctorGuidanceTempService extends BaseService {
    @Autowired
    DoctorGuidanceTempDao guidanceTempDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
    /**
     * 记录医生健康指导模板使用次数
     * @param modelCode 健康指导模板编码
     */
    public void countSend(String modelCode){
        synchronized (this){
            String sql = "UPDATE wlyy_doctor_guidance_temp  " +
                    "SET send_times=send_times+1 " +
                    "WHERE CODE=?";
            jdbcTemplate.update(sql,modelCode);
        }
    }
    /**
     * 查询单个指导模板详情
     * @param modelCode
     * @return
     * @throws Exception
     */
    public JSONObject listDetail(String modelCode) throws Exception {
        String sql = "SELECT wdgt.`model_name`,wdgt.`content`,wdgt.`images_url`,wdgt.`create_time`,wdgt.`send_times` " +
                "FROM wlyy_doctor_guidance_temp wdgt " +
                "WHERE wdgt.`code`=?";
        Map temp=(Map)jdbcTemplate.queryForMap(sql,modelCode);
        String modelName= (String)temp.get("model_name");
        String content= (String)temp.get("content");
        String imagesUrl= (String)temp.get("images_url");
        String createTime = (String)temp.get("create_time").toString();
        String sendTimes = (String)temp.get("send_times").toString();
        JSONObject json = new JSONObject();
        json.put("modelName",modelName);
        json.put("content",content);
        json.put("imagesUrl",imagesUrl);
        json.put("createTime",createTime);
        json.put("sendTimes",sendTimes);
        return json;
    }
    /**
     * 添加指导模板
@ -29,7 +70,7 @@ public class DoctorGuidanceTempService extends BaseService {
     * @param content 指导内容
     * @return
     */
    public DoctorGuidanceTemp add(String doctor, String content) {
    public DoctorGuidanceTemp add(String doctor, String content,String modelName,String imagesUrl) {
        DoctorGuidanceTemp guidanceTemp = new DoctorGuidanceTemp();
        guidanceTemp.setCode(getCode());
@ -38,6 +79,9 @@ public class DoctorGuidanceTempService extends BaseService {
        guidanceTemp.setSendTimes(0);
        guidanceTemp.setCreateTime(new Date());
        guidanceTemp.setModelName(modelName);
        guidanceTemp.setImagesUrl(imagesUrl);
        return guidanceTempDao.save(guidanceTemp);
    }

+ 70 - 16
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java

@ -2,13 +2,15 @@ package com.yihu.wlyy.web.doctor.health;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.PatientHealthGuidance;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.template.DoctorGuidanceTempService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -23,11 +25,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yihu.wlyy.entity.patient.PatientHealthGuidance;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.web.WeixinBaseController;
/**
 * 医生端:健康指导控制类
 * @author George
@ -49,6 +46,10 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
	@Autowired
	private ConsultService consultService;
//======================
	@Autowired
	DoctorGuidanceTempService doctorGuidanceTempService;
//	=======================
	/**
	 * 获取某个健康指导
	 *
@ -57,19 +58,60 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
	 */
	@RequestMapping(value = "/id")
	@ResponseBody
	public String getHealthGuidance(Long id){
	public String getHealthGuidance(@RequestParam String id){
		Long idl = Long.parseLong(id);
		try{
			if(id == null || id < 1){
			if(idl == null || idl < 1){
				return error(-1,"参数错误");
			}
			JSONObject guidance = patientHealthGuidanceService.findById(id);
			JSONObject guidance = patientHealthGuidanceService.findById(idl);
			return write(200,"查询成功","data",guidance);
		}catch (Exception e){
			return error(-1,"查询失败");
		}
	}
	/*/**
	 * 添加患者健康指导
	 * @param patient 患者标识
	 * @param content 指导内容
	 * @return
	 */
	/*@RequestMapping(value = "add")
	@ResponseBody
	public String add(String patient, String content, @RequestParam(required = false) String images, @RequestParam(required = false) String voice) {
		try {
			PatientHealthGuidance guidance = new PatientHealthGuidance();
			guidance.setContent(content);
			guidance.setDoctor(getUID());
			guidance.setPatient(patient);
			Doctor doctor = doctorService.findDoctorByCode(getUID());
			if (StringUtils.isNotEmpty(images)) {
				images = CommonUtil.copyTempImage(images);
			}
			guidance.setImages(images);
			if (StringUtils.isNotEmpty(voice)) {
				images = CommonUtil.copyTempVoice(voice);
			}
			guidance.setVoice(voice);
			// 保存
			if (patientHealthGuidanceService.add(guidance, getAccessToken()) != null) {
				Patient p = patientService.findByCode(patient);
				consultService.sendMucMessageBySingnType(getUID(),doctor.getName(),patient,content,"1",p.getName());
				BusinessLogs.info(BusinessLogs.BusinessType.guidance, patient, new JSONObject(guidance));
				return success("保存成功!");
			} else {
				return error(-1, "保存失败!");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "保存失败!");
		}
	}*/
	//  ====================修改代码========================
	/**
	 * 添加患者健康指导
	 * @param patient 患者标识
@ -78,7 +120,7 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
	 */
	@RequestMapping(value = "add")
	@ResponseBody
	public String add(String patient, String content, @RequestParam(required = false) String images, @RequestParam(required = false) String voice) {
	public String add(@RequestParam String patient,@RequestParam String content, @RequestParam(required = false) String images, @RequestParam(required = false) String voice) {
		try {
			PatientHealthGuidance guidance = new PatientHealthGuidance();
			guidance.setContent(content);
@ -100,6 +142,9 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
				Patient p = patientService.findByCode(patient);
				consultService.sendMucMessageBySingnType(getUID(),doctor.getName(),patient,content,"1",p.getName());
				BusinessLogs.info(BusinessLogs.BusinessType.guidance, patient, new JSONObject(guidance));
//				发送成功记录模板发送次数
				doctorGuidanceTempService.countSend("96961fb9d100424896e18c1d1dfde1eb");
				return success("保存成功!");
			} else {
				return error(-1, "保存失败!");
@ -109,25 +154,34 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
			return error(-1, "保存失败!");
		}
	}
	//  ============================================
	/**
	 * 查询患者的健康指导
	 * @param patient 患者标识
	 * @param begin 开始时间
	 * @param end 结束时间
	 * @param begin   开始时间
	 * @param end     结束时间
	 * @param id	  指导编码
	 * @param pagesize 展示页数
	 * @return
	 */
	@RequestMapping(value = "list")
	@ResponseBody
	public String list(@RequestParam(required = false) String patient, @RequestParam(required = false) String begin, @RequestParam(required = false) String end, long id, int pagesize) {
	public String list(@RequestParam(required = false) String patient,
					   @RequestParam(required = false) String begin,
					   @RequestParam(required = false) String end,
					   @RequestParam String id,
					   @RequestParam String pagesize) {
		try {
			Long idl = Long.parseLong(id);
			int  page = Integer.parseInt(pagesize);
			if (StringUtils.isNotEmpty(begin)) {
				begin = begin + " 00:00:00";
			}
			if (StringUtils.isNotEmpty(end)) {
				end = end + " 23:59:59";
			}
			JSONArray array = patientHealthGuidanceService.findPatientGuidanceByDoctor(getUID(), patient, begin, end, id, pagesize);
			JSONArray array = patientHealthGuidanceService.findPatientGuidanceByDoctor(getUID(), patient, begin, end, idl, page);
			return write(200, "查询成功!", "list", array);
		} catch (Exception e) {
			error(e);

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

@ -8,6 +8,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -29,13 +30,30 @@ public class DoctorGuidanceTempController extends BaseController {
    @Autowired
    DoctorGuidanceTempService guidanceTempService;
    /**
     * 查询单个模板详情
     * @return
     */
    @RequestMapping(value = "/listDetail", method = RequestMethod.GET)
    @ApiOperation(value = "查询单个模板详情")
    public String listDetail(@RequestParam @ApiParam(value = "指导模板编码") String modelCode) {
        JSONObject temp = null;
        try {
            temp = guidanceTempService.listDetail(modelCode);
        } catch (Exception e) {
            e.printStackTrace();
            return invalidUserException(e, -1, "查询失败!");
        }
        return write(200, "查询成功!", "data", temp);
    }
    /**
     * 添加指导模板
     *
     * @param content
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    /*@RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation(value = "添加指导模板")
    public String add(@RequestParam @ApiParam(value = "指导内容") String content) {
        try {
@ -45,6 +63,32 @@ public class DoctorGuidanceTempController extends BaseController {
            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 = "添加指导模板")
    public String add(@RequestParam @ApiParam(value = "指导内容") String content,
                      @RequestParam @ApiParam(value = "模板名称") String modelName,
                      @RequestParam(required = false) @ApiParam(value = "图片内容") String imagesUrl) {
        try {
            if (StringUtils.isEmpty(content)) {
                return error(-1, "内容不能为空");
            }
            if(modelName.length()<1||modelName.length()>10){
                return error(-1,"模板名称不能为空且再10字之内");
            }
            DoctorGuidanceTemp temp = guidanceTempService.add(getUID(), content,modelName,imagesUrl);
            if (temp != null) {
                return write(200, "添加成功");
            } else {
@ -55,6 +99,7 @@ public class DoctorGuidanceTempController extends BaseController {
            return error(-1, "添加失败");
        }
    }
//  =====================
    /**
     * 修改指导模板