Pārlūkot izejas kodu

修改增加积分参数

zd_123 7 gadi atpakaļ
vecāks
revīzija
6abb16b240

+ 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 - 1
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");

+ 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());