Browse Source

物联网增加接口:根据疾病类型,分页参数查询数量总数和设备码

huangwenjie 7 years ago
parent
commit
52a6e80082

+ 36 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java

@ -42,6 +42,7 @@ import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
@ -1100,4 +1101,39 @@ public class PatientDeviceService extends BaseService {
        }
        return name;
    }
    
    /**
     * 根据病种类型,搜索已绑定设备的居民设备SN码
     * @param type 1高血压 2糖尿病
     */
    public com.alibaba.fastjson.JSONObject iotSearchPatientDeviceSN(String type,Integer page,Integer pageSize){
    
        if(page != 0){
            page = page - 1;
        }
        
        StringBuffer sql = new StringBuffer("select t.device_sn from");
        sql.append("  ( SELECT DISTINCT d.* FROM wlyy_patient_device d, wlyy_sign_family f WHERE f.`status` > 0 AND f.patient = d.`user` ) t, ");
        sql.append("    wlyy_patient p " );
        sql.append("  LEFT JOIN wlyy_sign_patient_label_info l on  p. CODE = l.patient");
        sql.append("   and l.`status`=1 AND l.label_type = 3 and l.label='"+type+"'");
        sql.append(" WHERE t.user = p. CODE limit "+page+","+pageSize);
        List<String> list = jdbcTemplate.queryForList(sql.toString(),String.class);
        
        Integer count = 0;
    
        StringBuffer countsql = new StringBuffer("select count(t.device_sn) total from");
        countsql.append("  ( SELECT DISTINCT d.* FROM wlyy_patient_device d, wlyy_sign_family f WHERE f.`status` > 0 AND f.patient = d.`user` ) t, ");
        countsql.append("    wlyy_patient p " );
        countsql.append("  LEFT JOIN wlyy_sign_patient_label_info l on  p. CODE = l.patient");
        countsql.append("   and l.`status`=1 AND l.label_type = 3 and l.label='"+type+"'");
        countsql.append(" WHERE t.user = p. CODE ");
    
        count = jdbcTemplate.queryForObject(countsql.toString(),Integer.class);
    
        com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject();
        result.put("total",count);
        result.put("list",list);
        return result;
    }
}

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

@ -65,8 +65,6 @@ public class PrescriptionService extends BaseService {
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private PrescriptionNoticesService prescriptionNoticesService;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private JwPrescriptionService jwPrescriptionService;

+ 17 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/iot/IotMonitoringHealthController.java

@ -227,5 +227,22 @@ public class IotMonitoringHealthController extends BaseController {
            return error(-1,e.getMessage());
        }
    }
    
    @RequestMapping(value = "/searchpatientdevicesn",method = RequestMethod.GET)
    @ApiOperation("根据病种类型,搜索已绑定设备的居民设备SN码")
    public String searchpatientdevicesn(
            @ApiParam(name="type",value="1高血压 2糖尿病")
            @RequestParam(value="type",required = true) String type,
            @ApiParam(name="page",value="第几页(默认第一页)",defaultValue = "1")
            @RequestParam(value="page",required = false) Integer page,
            @ApiParam(name="pageSize",value="每页几行(默认10条记录)",defaultValue = "10")
            @RequestParam(value="pageSize",required = false) Integer pageSize){
        try {
            return write(200,"查询成功","data",patientDeviceService.iotSearchPatientDeviceSN(type,page,pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
}