Jelajahi Sumber

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

huangwenjie 7 tahun lalu
induk
melakukan
b3f7da318b

+ 26 - 9
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/common/account/CustomerController.java

@ -1,15 +1,14 @@
package com.yihu.wlyy.controller.common.account;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.Doctor;
import com.yihu.wlyy.entity.Patient;
import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.WlyyCustomerLog;
import com.yihu.wlyy.repository.ManageDictDao;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.service.manager.account.CustomerService;
import com.yihu.wlyy.service.manager.family.FamilyMemberService;
import com.yihu.wlyy.service.manager.hos.HosDoctorService;
import com.yihu.wlyy.service.manager.patient.AdminPatientService;
import com.yihu.wlyy.service.manager.sign.SignFamilyService;
import com.yihu.wlyy.service.manager.user.UserService;
import com.yihu.wlyy.service.manager.user.WlyyCustomerLogService;
import io.swagger.annotations.ApiParam;
@ -37,15 +36,9 @@ public class CustomerController extends BaseController {
    @Autowired
    private UserService userService;
    @Autowired
    private ManageDictDao manageDictDao;
    @Autowired
    private AdminPatientService patientService;
    @Autowired
    private CustomerService customerService;
    @Autowired
    private FamilyMemberService familyMemberService;
    @Autowired
    private SignFamilyService signFamilyService;
    @Autowired
    private WlyyCustomerLogService wlyyCustomerLogService;
@ -53,6 +46,8 @@ public class CustomerController extends BaseController {
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private HosDoctorService doctorService;
    @RequestMapping(value = "/login",method = RequestMethod.POST,produces="application/json;charset=UTF-8")
    @ResponseBody
@ -174,4 +169,26 @@ public class CustomerController extends BaseController {
        return write(200,"查询成功","data",respon);
    }
    /**
     * 客服给医生发送短信,微信提醒
     * (医生助手功能)
     * @param msg
     * @param doctorCode
     * @return
     */
    @RequestMapping(value = "/sendMsg",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String sendMsg(@ApiParam(name="msg",value="消息内容")@RequestParam(name="msg")String msg,
                          @ApiParam(name="doctorCode",value="发送给某个医生code")@RequestParam(name="doctorCode")String doctorCode,
                          @ApiParam(name="type",value="发送类型  1发送短信   2发送微信   3短信微信都发送")@RequestParam(name="doctorCode",required = false)String type) throws Exception {
        //用于返回的resp
        Doctor doctor = doctorService.getDoctorByCode(doctorCode);
        if(StringUtils.isBlank(type)){
            type="3";
        }
        Map<String, Object> resp = customerService.sendMsg(doctor,msg,type);
        return write(200,"","data",resp);
    }
}

+ 11 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Doctor.java

@ -99,6 +99,8 @@ public class Doctor extends IdEntity {
    private String adminTeamId;
    private String adminTeamName;
	private String openid; //医生微信openID
    @Column(name = "idcard")
    public String getIdCard() {
        return idCard;
@ -417,4 +419,13 @@ public class Doctor extends IdEntity {
    public void setAdminTeamName(String adminTeamName) {
        this.adminTeamName = adminTeamName;
    }
	@Column(name="openid")
	public String getOpenid() {
		return openid;
	}
	public void setOpenid(String openid) {
		this.openid = openid;
	}
}

+ 51 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java

@ -6,8 +6,13 @@ import com.yihu.wlyy.entity.SignFamily;
import com.yihu.wlyy.service.manager.family.FamilyMemberService;
import com.yihu.wlyy.service.manager.hos.HosDoctorService;
import com.yihu.wlyy.service.manager.sign.FamilyContractService;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@ -25,6 +30,10 @@ public class CustomerService{
	@Autowired
	private HosDoctorService hosDoctorService;
	@Value(("${doctorAssistant.api}")+"/wlyygc/doctor/message")
	private String messageApi;
	public Map<String,Object> findServerInfo(Patient patient) throws Exception {
		Map<String, Object> resp = new HashMap<>();
@ -93,4 +102,46 @@ public class CustomerService{
		return resp;
	}
	/**
	 *
	 * @param doctor
	 * @param msg
	 * @param type  1发送短信   2发送微信   3短信微信都发送
	 * @return
	 */
	public Map<String, Object> sendMsg(Doctor doctor,String msg,String type) {
		Map<String, Object> resp = new HashMap<String, Object>();
		//发送短信消息啦
		String mobile = doctor.getMobile();
		//
		if(!StringUtils.isBlank(mobile)&&!"2".equals(type)){
			List<NameValuePair> par = new ArrayList<NameValuePair>();
			par.add(new BasicNameValuePair("mobiles", mobile));
			par.add(new BasicNameValuePair("content", msg));
			String result = HttpClientUtil.post(messageApi+"/sendMobileMessage",par,"UTF-8");
			JSONObject resultJson = new JSONObject(result);
			if(1!=resultJson.getInt("successNum")){
				resp.put("mobile","-1");//-1代表发送失败
			}
		}
		//发送微信消息啦
		String openId = doctor.getOpenid();
		if(!StringUtils.isBlank(openId)&&!"1".equals(type)){
			List<NameValuePair> par = new ArrayList<NameValuePair>();
			par.add(new BasicNameValuePair("openIds", openId));
			par.add(new BasicNameValuePair("content", msg));
			JSONObject params = new JSONObject();
			String result = HttpClientUtil.post(messageApi+"/sendWechatMessage", par,"UTF-8");
			JSONObject resultJson = new JSONObject(result);
			if(1!=resultJson.getInt("successNum")){
				resp.put("wechat","-1");//-1代表发送失败
			}
		}
		return resp;
	}
}

+ 2 - 0
patient-co-manage/wlyy-manage/src/main/resources/application.yml

@ -73,6 +73,8 @@ im-service:
  im_service_url: http://172.19.103.88:3000/api/v2
yueren:
  api: http://120.77.209.211:8080
doctorAssistant:
  api: http://127.0.0.1:8080
---
spring:

+ 3 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionExpressageDao.java

@ -11,4 +11,7 @@ public interface PrescriptionExpressageDao extends PagingAndSortingRepository<Pr
    @Query("from PrescriptionExpressage p where p.mailno=?1")
    PrescriptionExpressage findByPrescriptionExpressMailno(String mailno);
    @Query(" from PrescriptionExpressage p where p.prescriptionCode=?1 and p.del=1")
    PrescriptionExpressage findByPrescriptionCode(String prescriptionCode);
}

+ 31 - 8
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java

@ -356,18 +356,41 @@ public class PrescriptionService extends ZysoftBaseService{
                    log.setUserCode(prescription.getDoctor());
                    log.setStatus(PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
                    prescriptionLogDao.save(log);
                }
                //判断健管师配送要添加续方消息,提示健管师有续方代配送
                JSONObject message = new JSONObject();
                message.put("title","dispensingComplete");
                message.put("state",1);
                message.put("prescription",prescription.getCode());
                message.put("mes","success");
                    //健管师配送
                    PrescriptionExpressage expressage = prescriptionExpressageDao.findByPrescriptionCode(prescription.getCode());
                    if(StringUtils.isNotBlank(expressage.getExpressageCode())){
                        Message message = new Message();
                        message.setCzrq(new Date());
                        message.setCreateTime(new Date());
                        message.setRead(1);//设置未读
                        message.setOver("1");
                        message.setReceiver(expressage.getExpressageCode());
                        message.setSender("system");
                        message.setCode(getCode());
                        message.setSenderName("系统");
                        message.setTitle("居民"+prescription.getPatientName()+"的续方订单待取药");
                        message.setContent("您有一条新的续方订单待取药!");
                        message.setType(7);//续方订单待取药
                        message.setReadonly(1);//是否只读消息
                        message.setDel("1");
                        message.setRelationCode(prescription.getCode());
                        message.setPrescriptionStatus("0");//待取药
                        message.setData(prescription.getAdminTeamId()+"");
                        messageDao.save(message);
                    }
                    //判断提示健管师有续方代配送,居民待取药
                    JSONObject message = new JSONObject();
                    message.put("title","dispensingComplete");
                    message.put("state",1);
                    message.put("prescription",prescription.getCode());
                    message.put("mes","success");
//                redisTemplate.convertAndSend(channelTopic,message.toString());
//                redisTemplate.watch(channelTopic);
                redisTemplate.opsForList().leftPush(channelTopic,message.toString());
                    redisTemplate.opsForList().leftPush(channelTopic,message.toString());
//                redisTemplate.unwatch();
                }
            }
        }catch (JSONException ex){

+ 1 - 1
patient-co-service/wlyy_service/src/main/resources/application.yml

@ -53,7 +53,7 @@ zysoftApi:
  base: base/CallEhrInterface
redisChannel:
    prescription: redisPrescription
    prescription: redisMessage
---
spring:

+ 26 - 52
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcMessageController.java

@ -1,8 +1,6 @@
package com.yihu.wlyy.web.third.gateway.controller.doctor;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatTemplateData;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.PatientService;
@ -13,18 +11,22 @@ import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/8/17.
@ -108,67 +110,39 @@ public class GcMessageController {
    }
    /**
     * 客服系统发送消息接口 居民没有有openID只发手机短信 有openID发微信模板消息、手机短信
     * 客服系统发送消息接口
     *
     * @param doctorCodes 医生code
     * @param openIds      微信openid
     * @param content     消息内容限制字数70
     * @return
     */
    @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
    @ApiOperation("客服系统发送消息接口")
    @RequestMapping(value = "/sendWechatMessage", method = RequestMethod.POST)
    @ApiOperation("客服系统发送微信模板消息接口")
    public ResultBatchModel sendMessage(
            @ApiParam(name = "doctorCodes", value = "医生code(批量逗号分割)", required = true) @RequestParam(value = "doctorCodes", required = true) String doctorCodes,
            @ApiParam(name = "openIds", value = "微信openid", required = true) @RequestParam(value = "openIds", required = true) String openIds,
            @ApiParam(name = "content", value = "消息内容", required = true) @RequestParam(value = "content", required = true) String content) {
        Integer success = 0;
        Integer error = 0;
        List<String> errorLiust = new ArrayList<>();
        try {
            String templateId = "OqQXrb-e43_TJpq_70_K_y6vYJgY5mpjFYY4c5RWFP4";
        String templateId = "OqQXrb-e43_TJpq_70_K_y6vYJgY5mpjFYY4c5RWFP4";
//            String templateId = "";
            String url = "www.baidu.com";//要带基本地址
            String[] codeArr = doctorCodes.split(",");
            for (String code : codeArr) {
                Doctor doctor = doctorDao.findByCode(code);
                String openId = doctor.getOpenid();
                String name = doctor.getName();
                String mobile = doctor.getMobile();
        String url = "www.baidu.com";//要带基本地址
        String[] codeArr = openIds.split(",");
        for (String openId : codeArr) {
//                String openId = "o7NFZw1QM4YR1O19mLjwfX1Hh11A";
//                String name = "吴家莲";
//                String mobile = "13611153674";
                if (StringUtils.isEmpty(openId) && StringUtils.isNotEmpty(mobile)) {
                    try {
                        smsService.sendMsg(mobile, content);
                        success++;
                    } catch (Exception e) {
                        logger.error("mobile " + mobile + " send message error:" + e.getMessage());
                        error++;
                        errorLiust.add(mobile);
                    }
                } else if (StringUtils.isNotEmpty(openId) && StringUtils.isNotEmpty(mobile)) {
                    try {
                        smsService.sendMsg(mobile, content);
                        success++;
                    } catch (Exception e) {
                        logger.error("mobile " + mobile + " send message error:" + e.getMessage());
                        error++;
                        errorLiust.add(mobile);
                    }
                    try {
                        JSONObject sendJson = packageTemplate("消息头","备注","续方提醒","2017年9月16日 18:00");
                        weiXinTempMsgSendUtils.sendTemplateMessage(templateId, openId, url, sendJson);
                        success++;
                    } catch (Exception e) {
                        logger.error("code " + code + " send Template error:" + e.getMessage());
                        error++;
                        errorLiust.add(code);
                    }
                }
            try {
                JSONObject sendJson = packageTemplate("消息头", "备注", "续方提醒", "2017年9月16日 18:00");
                weiXinTempMsgSendUtils.sendTemplateMessage(templateId, openId, url, sendJson);
                success++;
            } catch (Exception e) {
                logger.error("openids " + openIds + " send Template error:" + e.getMessage());
                error++;
                errorLiust.add(openIds);
            }
            return new ResultBatchModel(success, error, errorLiust);
        } catch (Exception e) {
            return new ResultBatchModel(-1, "找不到该医生!", success, error, errorLiust);
        }
        return new ResultBatchModel(success, error, errorLiust);
    }
    /**

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/redis/RedisThread.java

@ -39,7 +39,7 @@ public class RedisThread implements Runnable {
    @Override
    public void run() {
        String key = SystemConf.getInstance().getSystemProperties().getProperty("redis_prescription_title");
        String key = SystemConf.getInstance().getSystemProperties().getProperty("redisMessage");
        //初始化链接池
        initPool();

+ 0 - 19
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -125,25 +125,6 @@ public class PrescriptionService extends BaseService {
                PrescriptionExpressage expressage = prescriptionExpressageDao.findByPrescriptionCode(code);
                if(StringUtils.isNotBlank(expressage.getExpressageCode())){
                    String content = "您有一条新的续方订单待取药!";
                    Message message = new Message();
                    message.setCzrq(new Date());
                    message.setCreateTime(new Date());
                    message.setRead(1);//设置未读
                    message.setOver("1");
                    message.setReceiver(expressage.getExpressageCode());
                    message.setSender("system");
                    message.setCode(getCode());
                    message.setSenderName("系统");
                    message.setTitle("居民"+prescription.getPatientName()+"的续方订单待取药");
                    message.setContent("您有一条新的续方订单待取药!");
                    message.setType(7);//续方订单待取药
                    message.setReadonly(1);//是否只读消息
                    message.setDel("1");
                    message.setRelationCode(prescription.getCode());
                    message.setPrescriptionStatus("0");//待取药
                    message.setData(prescription.getAdminTeamId()+"");
                    messageDao.save(message);
                    pushMsgTask.put(expressage.getExpressageCode(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.D_P_WRD.name(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.续方消息.name(), content, prescription.getCode());
                }
            }

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/resources/system.properties

@ -112,6 +112,6 @@ returnUrl=wlyy.onepay.returnUrl
#长处方
#redist订阅消息主题
#开方成功/开方失败消息主题
redis_prescription_title=redisPrescription
redisMessage=redisMessage
#是否需要药师审方
pharmacistExaminationType=false

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/redis/RedisThread.java

@ -25,7 +25,7 @@
//
//    @Override
//    public void run() {
//        String key = SystemConf.getInstance().getSystemProperties().getProperty("redis_prescription_title");
//        String key = SystemConf.getInstance().getSystemProperties().getProperty("redisMessage");
//        while (true){
//            redisTemplate.watch(key);
//            String message = redisTemplate.opsForList().rightPop(key);

+ 18 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -49,6 +49,24 @@ public class PrescriptionInfoController extends BaseController {
    @Autowired
    private AdminTeamService adminTeamService;
    @RequestMapping(value = "getRecipeMasterList" , method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取智业长处方信息列表")
    public String getRecipeMasterList(@RequestParam(required = true)@ApiParam(name="patient",value="居民code",defaultValue = "ec7572875d27446cb4f067b13a85d72a")String patient,
                                      @RequestParam(required = false)@ApiParam(name="isRenewal",value="处方是否可续方:1.是;2.无过滤")String isRenewal,
                                      @RequestParam(required = false)@ApiParam(name="startDate",value="开始时间")String startDate,
                                      @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate,
                                      @RequestParam(required = false,defaultValue = "0")@ApiParam(name="diagnosisCode",value="所有诊断(0 全部 1高血压 2糖尿病)")String diagnosisCode,
                                      @RequestParam(required = false)@ApiParam(name="page",value="起始页")Integer page,
                                      @RequestParam(required = false)@ApiParam(name="size",value="每页记录数")Integer size){
        try {
            com.alibaba.fastjson.JSONObject json = prescriptionInfoService.getRecipeMasterList(patient,startDate,endDate,isRenewal,diagnosisCode,page,size);
            return write(200, "查询成功!", "data",json);
        }catch (Exception e){
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getPrescriptionFilter", method = RequestMethod.GET)
    @ApiOperation(value = "获取过滤规则信息列表")

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/system.properties

@ -99,6 +99,6 @@ returnUrl=wlyy.onepay.returnUrl
#长处方
#redist订阅消息主题
redis_prescription_title=redisPrescription
redisMessage=redisMessage
#是否需要药师审方
pharmacistExaminationType=false