瀏覽代碼

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

humingfen 7 年之前
父節點
當前提交
613eac584c

+ 51 - 55
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -475,23 +475,27 @@ public class DeviceService extends BaseService{
                userType = "-1";
            }
            PatientDevice patientDevice = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn,type,userType);
            int dataUoloadCount = 0;
            if (patientDevice!=null){
                String today = DateUtil.getStringDateShort();
                String startTime = today+" 00:00:00";
                String endTime = today+" 23:59:59";
                int dateType =1;
                if (deviceType==1){
                    dateType=2;
                }else if (deviceType==2){
                    dateType=1;
            try {
                PatientDevice patientDevice = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn,type,userType);
                if (patientDevice!=null){
                    String today = DateUtil.getStringDateShort();
                    String startTime = today+" 00:00:00";
                    String endTime = today+" 23:59:59";
                    int dateType =1;
                    if (deviceType==1){
                        dateType=2;
                    }else if (deviceType==2){
                        dateType=1;
                    }
                    String countSql = "SELECT count(*) num FROM device.wlyy_patient_health_index where `user`='"+patientDevice.getUser()+"' and type = "+dateType+" AND record_date >'"+startTime+"' and record_date <= '"+endTime+"'";
                    Map<String,Object> countMap = jdbcTemplate.queryForMap(countSql);
                    dataUoloadCount = Integer.valueOf(String.valueOf(countMap.get("num")));
                }else {
                    throw new Exception("This device is not relate patient!");
                }
                String countSql = "SELECT count(*) num FROM device.wlyy_patient_health_index where `user`='"+patientDevice.getUser()+"' and type = "+dateType+" AND record_date >'"+startTime+"' and record_date <= '"+endTime+"'";
                Map<String,Object> countMap = jdbcTemplate.queryForMap(countSql);
                dataUoloadCount = Integer.valueOf(String.valueOf(countMap.get("num")));
            }else {
                throw new Exception("This device is not relate patient!");
            }catch (Exception e){
                logger.error(e.getMessage());
            }
            PatientHealthIndex result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json);
            if (result == null) {
@ -508,51 +512,43 @@ public class DeviceService extends BaseService{
                    flagStr="GLU_MEASURE";
                }
                //增加积分
                if (dataUoloadCount == 0 && "350205".equals(patient.getTown())){
                    String sql = "select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'";
                    Map<String,Object> deviceCountMap = jdbcTemplate.queryForMap(sql);
                    if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){
                        String url = wlyyService + "healthBank/insertCredits";
                        List<NameValuePair> params = new ArrayList<>();
                        params.add(new BasicNameValuePair("creditsDetail", "{\"tradeType\":\"HEALTH_TASK\",\"flag\":\""+flagStr+"\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+result.getUser()+"\",\"hospital\":\"350205\"}"));
                        String response = HttpClientUtil.post(url, params, "UTF-8");
                        System.out.println(response);
                        com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response);
                        String status = jsonObject.getString("status");
                        if (!"200".equals(status)){
                            logger.error(jsonObject.getString("msg"));
                try {
                    //增加积分
                    if (dataUoloadCount == 0 && "350205".equals(patient.getTown())){
                        String sql = "select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'";
                        Map<String,Object> deviceCountMap = jdbcTemplate.queryForMap(sql);
                        if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){
                            String url = wlyyService + "healthBank/insertCredits";
                            List<NameValuePair> params = new ArrayList<>();
                            params.add(new BasicNameValuePair("creditsDetail", "{\"tradeType\":\"ACTIVITY_TASK\",\"flag\":\""+flagStr+"\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+result.getUser()+"\",\"hospital\":\"350205\"}"));
                            String response = HttpClientUtil.post(url, params, "UTF-8");
                            System.out.println(response);
                            com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response);
                            String status = jsonObject.getString("status");
                            if (!"200".equals(status)){
                                logger.error(jsonObject.getString("msg"));
                            }
                        }
                /*if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){
                    String url = wlyyService + "/healthBank/insertCredits";
                    org.json.JSONObject params = new org.json.JSONObject();
                    String creditDetail = "{\"tradeType\":\"HEALTH_TASK\",\"flag\":\"MEASURE\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+result.getUser()+"\",\"hospital\":\""+patient.getTown()+"\"}";
                    params.put("creditsDetail", creditDetail);
                    String response = HttpClientUtil.postBody(url, params);
                    com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response);
                    String status = jsonObject.getString("status");
                    if (!"200".equals(status)){
                        logger.error(jsonObject.getString("msg"));
                    }
                }*/
                    }
                }
                //增加活跃度
                if (dataUoloadCount == 0){
                    String url = wlyyService + "healthBank/createActiveRecord";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("activeRecord", "{\"taskCode\":\""+flagStr+"\",\"patientId\":\""+result.getUser()+"\"}"));
                    String response = HttpClientUtil.post(url, params, "UTF-8");
                    if (StringUtils.isNotEmpty(response)){
                        com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
                        if (!"200".equals(jsonObject.getString("status"))){
                            logger.info("添加活跃度失败!");
                    //增加活跃度
                    if (dataUoloadCount == 0){
                        String url = wlyyService + "healthBank/createActiveRecord";
                        List<NameValuePair> params = new ArrayList<>();
                        params.add(new BasicNameValuePair("activeRecord", "{\"taskCode\":\""+flagStr+"\",\"patientId\":\""+result.getUser()+"\"}"));
                        String response = HttpClientUtil.post(url, params, "UTF-8");
                        if (StringUtils.isNotEmpty(response)){
                            com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
                            if (!"200".equals(jsonObject.getString("status"))){
                                logger.info("添加活跃度失败!");
                            }
                        }
                    }
                }catch (Exception e){
                    logger.error(e.getMessage());
                }
                //血糖、血压数据需校验,如果超标,需要发送消息给医生

+ 1 - 0
patient-co/patient-co-wlyy-job/src/main/resources/application-dev.yml

@ -115,6 +115,7 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_dev  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_dev #设备测量提醒
  consumers:
    count: 10 #消费者集群数

+ 1 - 0
patient-co/patient-co-wlyy-job/src/main/resources/application-prod.yml

@ -116,6 +116,7 @@ activemq:
  url: tcp://59.61.92.90:9103
  queue:
    healtHarticleQueue: healthArticleChannel  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel #设备测量提醒
  consumers:
    count: 10 #消费者集群数

+ 1 - 0
patient-co/patient-co-wlyy-job/src/main/resources/application-test.yml

@ -113,6 +113,7 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_test  #健康文章推送
    deviceMeasurementRemindingQueue : deviceMeasurementChannel_test #设备测量提醒
  consumers:
    count: 10 #消费者集群数

+ 8 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/TaskService.java

@ -139,12 +139,16 @@ public class TaskService {
        }
        Patient patient = patientDao.findByCode(patientId);
        String unionId = object.getString("unionId");
        Patient patient1 = patientDao.findByUnionid(unionId);
        if (patient1 != null){
        if(patient.getUnionid() != null){
            throw new Exception("该居民已报名!");
        }else {
            Patient patient1 = patientDao.findByUnionid(unionId);
            if (patient1 != null){
                throw new Exception("该居民已报名!");
            }
            patient.setUnionid(unionId);
            patientDao.save(patient);
        }
        patient.setUnionid(unionId);
        patientDao.save(patient);
        object.put("unionId",unionId);
        object.put("patientIdcard",patient.getIdcard());
        object.put("patientOpenid",patient.getOpenid());

+ 16 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java

@ -170,7 +170,7 @@ public class DoctorDeviceController extends BaseController {
				}else if ("2".equals(device.getCategoryCode())){
					flagStr="BP_BIND";
				}
				String creditDetail = "{\"tradeType\":\"HEALTH_TASK\",\"flag\":\""+flagStr+"\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+device.getUser()+"\",\"hospital\":\""+patient.getTown()+"\"}";
				String creditDetail = "{\"tradeType\":\"ACTIVITY_TASK\",\"flag\":\""+flagStr+"\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+device.getUser()+"\",\"hospital\":\""+patient.getTown()+"\"}";
				JSONObject jsonObject = JSONObject.parseObject(creditDetail);
				JSONObject response = creditLogService.insert(jsonObject);
				String status = response.getString("status");
@ -481,23 +481,27 @@ public class DoctorDeviceController extends BaseController {
			return write(200,"提醒成功!");
		}catch (Exception e){
			error(e);
			e.printStackTrace();
			return error( -1, "提醒失败!");
		}
	}
	public void sender(List<DeviceWxMessageDTO> deviceWxMessageList){
		//发送到队列
		deviceWxMessageList.stream().forEach(one->{
			jmsTemplate.send(devcieChannelName, new MessageCreator() {
				@Override
				public Message createMessage(Session session) throws JMSException {
					TextMessage textMessage = session.createTextMessage();
					textMessage.setText(net.sf.json.JSONObject.fromObject(one).toString());
					return textMessage;
				}
			});
		});
        try{
            deviceWxMessageList.stream().forEach(one->{
                jmsTemplate.send(devcieChannelName, new MessageCreator() {
                    @Override
                    public Message createMessage(Session session) throws JMSException {
                        TextMessage textMessage = session.createTextMessage();
                        textMessage.setText(net.sf.json.JSONObject.fromObject(one).toString());
                        return textMessage;
                    }
                });
            });
        }catch (Exception e){
            e.printStackTrace();
        }
	}
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -253,7 +253,7 @@ public class PatientDeviceController extends BaseController {
                }else if ("2".equals(device.getCategoryCode())){
                    flagStr="BP_BIND";
                }
                String creditDetail = "{\"tradeType\":\"HEALTH_TASK\",\"flag\":\""+flagStr+"\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+device.getUser()+"\",\"hospital\":\""+patient.getTown()+"\"}";
                String creditDetail = "{\"tradeType\":\"ACTIVITY_TASK\",\"flag\":\""+flagStr+"\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+device.getUser()+"\",\"hospital\":\""+patient.getTown()+"\"}";
                com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(creditDetail);
                com.alibaba.fastjson.JSONObject response = creditLogService.insert(jsonObject);
                System.out.println("添加积分返回数据======"+response.toJSONString());