소스 검색

智业统计指标接口

huangwenjie 7 년 전
부모
커밋
928977575c

+ 24 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/ZysoftServiceController.java

@ -298,6 +298,30 @@ public class ZysoftServiceController {
		}
	
	}
	@RequestMapping(value = "getstatictagbyidcard",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("根据身份证号查询服务记录指标")
	public Result getStaticTagByIdcard(@ApiParam(name="idcard",value="居民身份证号",defaultValue = "350211195007234014")
	                           @RequestParam(value = "idcard",required = true) String idcard,
	                           @ApiParam(name="start_time",value="开始时间YYYY-MM-DD HH:MM:SS格式",defaultValue = "2017-07-01 00:00:00")
	                           @RequestParam(value = "start_time",required = true) String start_time,
	                           @ApiParam(name="end_time",value="开始时间YYYY-MM-DD HH:MM:SS格式",defaultValue = "2018-07-01 00:00:00")
	                           @RequestParam(value = "end_time",required = true) String end_time){
		try {
			com.alibaba.fastjson.JSONArray result = zysoftService.getstatictagbyidcard(idcard,start_time,end_time);
			return Result.success("请求成功!",result);
		} catch (Exception ex) {
			if(ex instanceof ApiException)
			{
				ApiException apiEx = (ApiException) ex;
				return Result.error(apiEx.errorCode(),ex.getMessage());
			}
			else{
				return Result.error(ex.getMessage());
			}
		}
		
	}
}

+ 179 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftService.java

@ -1027,6 +1027,185 @@ public class ZysoftService {
                result.put("type",data_type);
            }
        
        }catch (JSONException ex){
            ex.printStackTrace();
            error = ex.getMessage();
            errMsg = ex.getMessage();
            status = "0";
        }catch (Exception e){
            e.printStackTrace();
            error = e.getMessage();
            status = "0";
        }
    
        return result;
    }
    
    /**
     * 根据身份证号查询服务记录指标
     * @param idcard
     * @return
     */
    public com.alibaba.fastjson.JSONArray getstatictagbyidcard(String idcard,String start_time,String end_time) {
        String error = null;
        String status = "1";
        String errMsg = null;
        com.alibaba.fastjson.JSONArray result = new JSONArray();
    
        try{
            String name = "";//居民姓名
            String datatype = "";//1血糖,2血压
            Long total = new Long("0");
            String sql = "";//待执行的SQL语句
            Map<String, Object> totalCountMap = new HashMap<>();
        
        
            if(StringUtils.isBlank(idcard)){
                throw new Exception("身份证号不允许为空");
            }
        
            if(StringUtils.isBlank(start_time) || StringUtils.isBlank(end_time)){
                throw new Exception("开始时间和结束时间不能为空");
            }
        
            Patient patient = patientDao.findByIdcard(idcard);
            System.out.println(patient.getCode());
            if(StringUtils.isNotBlank(patient.getCode())){
                name = patient.getName();
            }else{
                throw new Exception(idcard+"-该身份证号找不到居民");
            }
        
            //1咨询量
            com.alibaba.fastjson.JSONObject obj1 = new com.alibaba.fastjson.JSONObject();
            sql = "select count(1) AS totalCount from wlyy_consult where patient ='"+patient.getCode()+"' and czrq BETWEEN '"+start_time+"' and '"+end_time+"'";
            totalCountMap = jdbcTemplate.queryForMap(sql);
            if (totalCountMap.get("totalCount") == null) {
                totalCountMap.put("totalCount", 0);
            }
            total = (Long)totalCountMap.get("totalCount");
            obj1.put("dataType","1");
            obj1.put("total",String.valueOf(total));
            obj1.put("type","0");
            obj1.put("name",name);
            obj1.put("idcard",patient.getIdcard());
            result.add(obj1);
            
        
            //2健康教育量
            com.alibaba.fastjson.JSONObject obj2 = new com.alibaba.fastjson.JSONObject();
            //查询总数sql
            String countSql = "SELECT COUNT(*) AS count FROM " + esType + "  where patientCode= '" + patient.getCode() + "' and userType = 1";
            Long totalES = elasticsearchUtil.excuteForLong(countSql,esIndex, esType);
            JSONArray re = new JSONArray();
            obj2.put("dataType","2");
            obj2.put("total",totalES);
            obj2.put("type","0");
            obj2.put("name",name);
            obj2.put("idcard",patient.getIdcard());
            result.add(obj2);
        
            //3代预约量
            com.alibaba.fastjson.JSONObject obj3 = new com.alibaba.fastjson.JSONObject();
            sql = "select count(1) AS totalCount from wlyy_patient_reservation where patient='"+patient.getCode()+"' and doctor is not null and czrq BETWEEN '"+start_time+"' and '"+end_time+"'";
        
            totalCountMap = jdbcTemplate.queryForMap(sql);
            if (totalCountMap.get("totalCount") == null) {
                totalCountMap.put("totalCount", 0);
            }
            total = (Long)totalCountMap.get("totalCount");
            obj3.put("dataType","3");
            obj3.put("total",String.valueOf(total));
            obj3.put("type","0");
            obj3.put("name",name);
            obj3.put("idcard",patient.getIdcard());
            result.add(obj3);
        
            //4长处方续方量
            com.alibaba.fastjson.JSONObject obj4 = new com.alibaba.fastjson.JSONObject();
            sql = "select count(1) AS totalCount from wlyy_prescription where patient ='"+patient.getCode()+"' and create_time BETWEEN '"+start_time+"' and '"+end_time+"'";
        
            totalCountMap = jdbcTemplate.queryForMap(sql);
            if (totalCountMap.get("totalCount") == null) {
                totalCountMap.put("totalCount", 0);
            }
            total = (Long)totalCountMap.get("totalCount");
            obj4.put("dataType","4");
            obj4.put("total",String.valueOf(total));
            obj4.put("type","0");
            obj4.put("name",name);
            obj4.put("idcard",patient.getIdcard());
            result.add(obj4);
        
            //5体征测量总数
            //血糖
            com.alibaba.fastjson.JSONObject obj51 = new com.alibaba.fastjson.JSONObject();
            sql = "select count(1) AS totalCount from device.wlyy_patient_health_index where `user` ='"+patient.getCode()+"' and type=1 and record_date BETWEEN '"+start_time+"' and '"+end_time+"'";
        
            totalCountMap = jdbcTemplate.queryForMap(sql);
            if (totalCountMap.get("totalCount") == null) {
                totalCountMap.put("totalCount", 0);
            }
            total = (Long)totalCountMap.get("totalCount");
            obj51.put("dataType","5");
            obj51.put("total",String.valueOf(total));
            obj51.put("type","1");//血糖
            obj51.put("name",name);
            obj51.put("idcard",patient.getIdcard());
            result.add(obj51);
    
            //血压
            com.alibaba.fastjson.JSONObject obj52 = new com.alibaba.fastjson.JSONObject();
            sql = "select count(1) AS totalCount from device.wlyy_patient_health_index where `user` ='"+patient.getCode()+"' and type=2 and record_date BETWEEN '"+start_time+"' and '"+end_time+"'";
    
            totalCountMap = jdbcTemplate.queryForMap(sql);
            if (totalCountMap.get("totalCount") == null) {
                totalCountMap.put("totalCount", 0);
            }
            total = (Long)totalCountMap.get("totalCount");
            obj52.put("dataType","5");
            obj52.put("total",String.valueOf(total));
            obj52.put("type","2");//血压
            obj52.put("name",name);
            obj52.put("idcard",patient.getIdcard());
            result.add(obj52);
        
            //6体征异常量
            //血糖
            com.alibaba.fastjson.JSONObject obj61 = new com.alibaba.fastjson.JSONObject();
            sql = "select count(1) AS totalCount from device.wlyy_patient_health_index where `user` ='"+patient.getCode()+"' and type=1 and status = 1 and record_date BETWEEN '"+start_time+"' and '"+end_time+"'";
        
            totalCountMap = jdbcTemplate.queryForMap(sql);
            if (totalCountMap.get("totalCount") == null) {
                totalCountMap.put("totalCount", 0);
            }
            total = (Long)totalCountMap.get("totalCount");
            obj61.put("dataType","6");
            obj61.put("total",String.valueOf(total));
            obj61.put("type","1");//血糖
            obj61.put("name",name);
            obj61.put("idcard",patient.getIdcard());
            result.add(obj61);
    
            //血压
            com.alibaba.fastjson.JSONObject obj62 = new com.alibaba.fastjson.JSONObject();
            sql = "select count(1) AS totalCount from device.wlyy_patient_health_index where `user` ='"+patient.getCode()+"' and type=2 and status = 1 and record_date BETWEEN '"+start_time+"' and '"+end_time+"'";
    
            totalCountMap = jdbcTemplate.queryForMap(sql);
            if (totalCountMap.get("totalCount") == null) {
                totalCountMap.put("totalCount", 0);
            }
            total = (Long)totalCountMap.get("totalCount");
            obj62.put("dataType","6");
            obj62.put("total",String.valueOf(total));
            obj62.put("type","2");//血压
            obj62.put("name",name);
            obj62.put("idcard",patient.getIdcard());
            result.add(obj62);
            
            
        
        }catch (JSONException ex){
            ex.printStackTrace();
            error = ex.getMessage();

+ 5 - 5
patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu.txt

@ -79,11 +79,11 @@
		   "name":"我的设备",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdsb%2fhtml%2fmy-equipments.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
        {
         	"type":"click",
         	"name":"操作说明",
         	"key":"caozuoshuoming"
        }
		{
		   "type":"view",
		   "name":"健康银行",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjf%2fhtml%2funopened.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		}
	 ]
  }
]