Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

# Conflicts:
#	patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java
wangzhinan 7 năm trước cách đây
mục cha
commit
4ff9cebff0

+ 91 - 44
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
import com.yihu.wlyy.entity.specialist.SpecialDisease;
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
@ -20,7 +21,10 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.specialist.PatientDiseaseServerDao;
import com.yihu.wlyy.repository.specialist.SpecialDiseaseDao;
import com.yihu.wlyy.repository.specialist.TeamDiseaseRelationDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
@ -38,6 +42,9 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import static com.yihu.wlyy.service.common.util.ManageUtilService.page;
/**
 * Created by Trick on 2018/5/31.
@ -73,6 +80,10 @@ public class SpecialistService extends BaseService {
    private MessageDao messageDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    public String setPatientLabelInfo(List<SignPatientLabelInfo> list) {
        if (list != null && list.size() > 0) {
@ -525,7 +536,7 @@ public class SpecialistService extends BaseService {
        return mes;
    }
    public String agreeSpecialistTeam(String state, String relationCode, String remark, Long mesId) throws Exception {
    public String agreeSpecialistTeam(String token, String state, String relationCode, String remark, Long mesId) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("state", state);
        param.put("relationCode", relationCode);
@ -542,57 +553,64 @@ public class SpecialistService extends BaseService {
                messageDao.save(m);
            }
            JSONObject josn = rs.getJSONObject("obj");
            Patient p = patientDao.findByCode(josn.getString("patient"));
            Doctor d = doctorDao.findByCode(josn.getString("doctor"));
            //如果医生拒绝,置空疾病服务类型
            if("0".equals(state)){
               List<PatientDiseaseServer> servers =  patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(relationCode,"1");
               for (PatientDiseaseServer server:servers){
                   server.setDel("0");
               }
            if ("0".equals(state)) {
                List<PatientDiseaseServer> servers = patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(relationCode, "1");
                for (PatientDiseaseServer server : servers) {
                    server.setDel("0");
                }
                patientDiseaseServerDao.save(servers);
            }
            JSONObject josn =  rs.getJSONObject("obj");
            SignFamily sign =  signFamilyDao.findByPatient(josn.getString("patient"));
            //判断是否有家庭医生,有家庭医生则通知家庭医生
            if(sign!=null){
                Patient p = patientDao.findByCode(josn.getString("patient"));
                Doctor d = doctorDao.findByCode(josn.getString("doctor"));
                // 添加签约申请消息
                Message message = new Message();
                message.setCzrq(new Date());
                message.setCreateTime(new Date());
                message.setContent("您有一个居民开通共管服务!");
                message.setRead(1);//设置未读
                message.setReceiver(sign.getDoctor());//设置接受医生的code
                message.setSender(p.getCode());//设置发送的用户
                message.setSenderName(p.getName());
                message.setCode(getCode());
                message.setTitle("专科医生共管通知");
                message.setType(18);//家庭签约取消信息
                message.setReadonly(0);//是否只读消息
                message.setSex(p.getSex());
                message.setOver("1");//未处理
                message.setRelationCode(relationCode);
                message.setDel("1");
                message.setState(1);
                JSONObject dataJson = new JSONObject();
                dataJson.put("doctor",d.getCode());
                dataJson.put("doctorName",d.getName());
                dataJson.put("hospital",d.getHospital());
                dataJson.put("hospitalName",d.getHospitalName());
                dataJson.put("dept",d.getDept());
                dataJson.put("deptName",d.getDeptName());
                message.setReason(dataJson.toString());
                messageDao.save(message);
                //推送给居民模板消息
                pushWeiTemp(token, "0", remark, p, d);
            } else {
                //医生同意,推送全科医生消息
                SignFamily sign = signFamilyDao.findByPatient(josn.getString("patient"));
                //判断是否有家庭医生,有家庭医生则通知家庭医生
                if (sign != null) {
                    // 添加签约申请消息
                    Message message = new Message();
                    message.setCzrq(new Date());
                    message.setCreateTime(new Date());
                    message.setContent("您有一个居民开通共管服务!");
                    message.setRead(1);//设置未读
                    message.setReceiver(sign.getDoctor());//设置接受医生的code
                    message.setSender(p.getCode());//设置发送的用户
                    message.setSenderName(p.getName());
                    message.setCode(getCode());
                    message.setTitle("专科医生共管通知");
                    message.setType(18);//家庭签约取消信息
                    message.setReadonly(0);//是否只读消息
                    message.setSex(p.getSex());
                    message.setOver("1");//未处理
                    message.setRelationCode(relationCode);
                    message.setDel("1");
                    message.setState(1);
                    JSONObject dataJson = new JSONObject();
                    dataJson.put("doctor", d.getCode());
                    dataJson.put("doctorName", d.getName());
                    dataJson.put("hospital", d.getHospital());
                    dataJson.put("hospitalName", d.getHospitalName());
                    dataJson.put("dept", d.getDept());
                    dataJson.put("deptName", d.getDeptName());
                    message.setReason(dataJson.toString());
                    messageDao.save(message);
                    //推送给居民模板消息
                    pushWeiTemp(token, "1", "", p, d);
                }
            }
            return "1";
        }
        return "0";
    }
    public JSONObject findPatientSigninfo(String code,String messageCode) throws Exception {
    public JSONObject findPatientSigninfo(String code) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("code", code);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/findPatientSigninfo", param);
@ -634,5 +652,34 @@ public class SpecialistService extends BaseService {
        return null;
    }
    public void pushWeiTemp(String token, String state, String remark, Patient patient, Doctor doctor) {
        logger.info("pushWeiTemp:"+patient.getCode()+"__openid:"+patient.getOpenid());
        if (StringUtils.isNotBlank(patient.getOpenid())) {
            WechatTemplateConfig temp;
            JSONObject json = new JSONObject();
            if ("0".equals(state)) {
                //拒绝
                temp = templateConfigDao.findByScene("template_deal_with", "tdwspref");
                json.put("toUser", patient.getCode());
                json.put("keyword1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("keyword2", temp.getKeyword2().replace("key1", doctor.getName()));
                json.put("remark", temp.getRemark().replace("key1", remark));
                json.put("first", temp.getFirst().replace("key1", patient.getName()));
            } else {
                //同意
                temp = templateConfigDao.findByScene("template_deal_with", "tdwspref");
                json.put("toUser", patient.getCode());
                json.put("keyword1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("keyword2", temp.getKeyword2().replace("key1", doctor.getName()));
                json.put("remark", temp.getRemark());
                json.put("first", temp.getFirst().replace("key1", patient.getName()));
            }
            logger.info("pushWeiTempJOSN:"+json.toString());
            pushMsgTask.putWxMsg(token, 24, patient.getOpenid(), patient.getName(), json);
        }
    }
}

+ 3 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java

@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.service.specialist.SpecialistService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -23,7 +23,7 @@ import java.util.List;
@RestController
@RequestMapping(value = "/doctor/specialist", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-专病管理")
public class SpecialistController extends BaseController {
public class SpecialistController extends WeixinBaseController {
    @Autowired
    private SpecialistService specialistService;
@ -223,7 +223,7 @@ public class SpecialistController extends BaseController {
                                      @ApiParam(name = "remark", value = "审核失败原因") @RequestParam(required = false) String remark,
                                      @ApiParam(name = "mesId", value = "消息Id") @RequestParam(required = false) Long mesId) throws Exception {
        try {
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(state, relationCode, remark, mesId));
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(getAccessToken(),state, relationCode, remark, mesId));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");