Browse Source

药盒的代码提交

liuwenbin 7 years ago
parent
commit
0f4f19aed3

+ 5 - 5
common/common-entity/src/main/java/com/yihu/wlyy/entity/kit/KitUseRemindRecord.java

@ -20,7 +20,7 @@ public class KitUseRemindRecord extends IdEntity {
    private Date insertTime;//记录添加时间
    private Integer remindType;//提醒类型(1、到点,2、超时,3、漏用)
    private String kitAccountId;//药盒账号id
    private String deviveModel;//药盒型号
    private String deviceModel;//药盒型号
    private String patientCode;//居民code
    private String patientName;//居民姓名
    private String drugDetail;//药品清单json串
@ -68,12 +68,12 @@ public class KitUseRemindRecord extends IdEntity {
        this.kitAccountId = kitAccountId;
    }
    public String getDeviveModel() {
        return deviveModel;
    public String getDeviceModel() {
        return deviceModel;
    }
    public void setDeviveModel(String deviveModel) {
        this.deviveModel = deviveModel;
    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }
    public String getPatientCode() {

+ 52 - 31
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/kit/KitService.java

@ -60,40 +60,60 @@ public class KitService extends BaseService {
    public void kitBinding(String deviceSn,String type,String patientCode) throws Exception{
        Patient patient = patientService.findByCode(patientCode);
        JSONObject dataJSONStr = jyKitService.kitBinding(deviceSn,patient.getMobile(),type);
        //绑定成功,设备添加到device库
        String sn = dataJSONStr.getString("device_sn");//设备编码
        String deviceType = dataJSONStr.getString("device_type");//设备型号
        String maxAlarm = dataJSONStr.getString("max_alarm");//设备闹钟数
        String maxDrugs = dataJSONStr.getString("max_drugs");//设备药格数
        PatientDevice patientDevice = null;
        if("1".equals(type)){
        System.out.println("sn:"+sn+",deviceType:"+deviceType+",maxAlarm:"+maxAlarm+",maxDrugs:"+maxDrugs);
            //绑定成功,设备添加到device库
            String sn = dataJSONStr.getString("device_sn");//设备编码
            String deviceType = dataJSONStr.getString("device_type");//设备型号
            String maxAlarm = dataJSONStr.getString("max_alarm");//设备闹钟数
            String maxDrugs = dataJSONStr.getString("max_drugs");//设备药格数
            System.out.println("sn:"+sn+",deviceType:"+deviceType+",maxAlarm:"+maxAlarm+",maxDrugs:"+maxDrugs);
        //添加设备
        DeviceDetail deviceDetail = new DeviceDetail();
        deviceDetail.setDeviceModel(deviceType);//设备型号
        deviceDetail.setDeviceName("");
        deviceDetail.setDeviceCode(sn);
        deviceDetail.setLinkman(patient.getName());
        String sql = " select f.* from wlyy_sign_family f where f.patient='' and p.status=1 ";
        List<Map<String, Object>> signFamilys1 = jdbcTemplate.queryForList(sql);
        if(signFamilys1.size()>0){
            deviceDetail.setOrgName(signFamilys1.get(0).get("hospital_name")+"");
            deviceDetail.setTel(patient.getMobile());
            deviceDetail.setGrantAdminTeam(signFamilys1.get(0).get("admin_team_code")+"");
            deviceDetail.setGrantOrgCode(signFamilys1.get(0).get("hospital")+"");
            deviceDetail.setGrantTime(new Date());
            //添加设备
            DeviceDetail deviceDetail = new DeviceDetail();
            deviceDetail.setDeviceModel(deviceType);//设备型号
            deviceDetail.setDeviceName("巨烨科技智能药盒");
            deviceDetail.setDeviceCode(sn);
            deviceDetail.setLinkman(patient.getName());
            String sql = " select f.* from wlyy_sign_family f where f.patient='"+patientCode+"' and f.status=1 ";
            List<Map<String, Object>> signFamilys1 = jdbcTemplate.queryForList(sql);
            if(signFamilys1.size()>0){
                deviceDetail.setOrgName(signFamilys1.get(0).get("hospital_name")+"");
                deviceDetail.setTel(patient.getMobile());
                deviceDetail.setGrantAdminTeam(signFamilys1.get(0).get("admin_team_code")+"");
                deviceDetail.setGrantOrgCode(signFamilys1.get(0).get("hospital")+"");
                deviceDetail.setGrantTime(new Date());
            }
            deviceDetail = deviceDetailDao.save(deviceDetail);
            patientDevice = new PatientDevice();
            patientDevice.setDeviceId(deviceDetail.getId());
            patientDevice.setDeviceSn(deviceDetail.getDeviceCode());
            patientDevice.setDeviceName(deviceDetail.getDeviceName());
            patientDevice.setUser(patientCode);
            patientDevice.setCategoryCode("3");
            patientDevice.setUserType("-1");
            patientDevice.setUserIdcard(patient.getIdcard());
            patientDevice.setCzrq(new Date());
        }else {
            List<PatientDevice> list = patientDeviceDao.findByDeviceSn(deviceSn);
            if(list.size()>0){
                patientDevice = list.get(0);
            }else{
                throw new Exception(" 数据库中没有该设备!");
            }
        }
        deviceDetail = deviceDetailDao.save(deviceDetail);
        //添加绑定关系
        PatientDevice patientDevice = new PatientDevice();
        patientDevice.setDeviceId(deviceDetail.getId());
        patientDevice.setDeviceSn(deviceDetail.getDeviceCode());
        patientDevice.setDeviceName(deviceDetail.getDeviceName());
        patientDevice.setUser(patientCode);
        patientDevice.setCategoryCode("3");
        patientDevice.setUserType("-1");
        patientDevice.setUserIdcard(patient.getIdcard());
        patientDevice.setCzrq(new Date());
//        PatientDevice patientDevice = new PatientDevice();
//        patientDevice.setDeviceId(deviceDetail.getId());
//        patientDevice.setDeviceSn(deviceDetail.getDeviceCode());
//        patientDevice.setDeviceName(deviceDetail.getDeviceName());
//        patientDevice.setUser(patientCode);
//        patientDevice.setCategoryCode("3");
//        patientDevice.setUserType("-1");
//        patientDevice.setUserIdcard(patient.getIdcard());
//        patientDevice.setCzrq(new Date());
        if("1".equals(type)){
            type="0";
        }else if("2".equals(type)){
@ -122,7 +142,8 @@ public class KitService extends BaseService {
        kitUseRemindRecord.setRemindType(Integer.valueOf(remindType));
        kitUseRemindRecord.setInsertTime(currentTime);
        kitUseRemindRecord.setKitAccountId(kitAccountId);
//        kitUseRemindRecord.setDeviveModel();//药盒型号
        DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviveSn);
        kitUseRemindRecord.setDeviceModel(deviceDetail!=null?deviceDetail.getDeviceModel():null);//药盒型号
        kitUseRemindRecord.setDeviceSn(deviveSn);
        //根据药盒sn码和居民的绑定关系表,获取居民信息
        List<PatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(deviveSn);

+ 16 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/kit/JyKitService.java

@ -32,7 +32,7 @@ public class JyKitService {
    @Value("${juye.companyCode}")
    private String companyCode;
//    @Value("${juye.url}")
    private String jyUrl="http://zayata.ocip.net:30080/index.php?s=/Company/Device/";
    private String jyUrl="http://zayata.oicp.net:30080/index.php?s=/Company/Device/";
//    @Value("${juye.token}")
//    private String token;
    @Autowired
@ -66,9 +66,15 @@ public class JyKitService {
        params.add(new BasicNameValuePair("type", type));
        String response = getRequestPost(params,kitBinding);
        JSONObject returnJson = JSONObject.fromObject(response);
        if (returnJson.getInt("status") != 200) {
        if (!"200".equals(returnJson.getString("code"))) {
//            if(){
//
//            }
            throw new Exception("jy kitBinding error status not 200");
        }
        if("2".equals(type)){//解绑就不解析data数据
            return new JSONObject();
        }
        JSONObject dataJSONStr = null ;
        if (returnJson.containsKey("data")) {
            dataJSONStr = returnJson.getJSONObject("data");//返回设备信息
@ -113,7 +119,7 @@ public class JyKitService {
        params.add(new BasicNameValuePair("device_sn", deviceSn));
        String response = getRequestPost(params,getKitSetInfo);
        JSONObject returnJson = JSONObject.fromObject(response);
        if (returnJson.getInt("status") != 200) {
        if (!"200".equals(returnJson.getString("code"))) {
            throw new Exception("jy kitInfo error status not 200");
        }
        JSONArray dataJSONStr = null ;
@ -144,7 +150,7 @@ public class JyKitService {
        List<NameValuePair> params = new ArrayList<>();
        String response = getRequestPost(params,getKitToken);
        JSONObject returnJson = JSONObject.fromObject(response);
        if (returnJson.getInt("status") != 200) {
        if (!"200".equals(returnJson.getString("code"))) {
            throw new Exception("jy kitInfo error status not 200");
        }
        String token = null;
@ -153,7 +159,8 @@ public class JyKitService {
            dataJSONStr = returnJson.getJSONObject("data");
            token = dataJSONStr.getString("token");//token
            String timeTerm = dataJSONStr.getString("time_term");//token过期时间戳
            Long overTime = Long.valueOf(timeTerm) - new Date().getTime();
            Long temp = new Date().getTime()/1000;
            Long overTime = Long.valueOf(timeTerm) - temp;
            //存储在redis中
            redisTemplate.opsForValue().set(timeTermRedisKey,timeTerm,overTime,TimeUnit.SECONDS);
@ -217,4 +224,8 @@ public class JyKitService {
        String response = httpClientUtil.get(url+paramStr,  "UTF-8");
        return response;
    }
//    public String returnStatus(){
//
//    }
}

+ 5 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/kit/JyKitController.java

@ -42,6 +42,7 @@ public class JyKitController extends BaseController {
            @ApiParam(name = "kitAccountId", value = "药盒账号id")@RequestParam(value = "kitAccountId", required = true) String kitAccountId,
            @ApiParam(name = "drugDetail", value = "药品清单json串")@RequestParam(value = "drugDetail", required = true) String drugDetail) {
        try {
            System.out.println("useDrugRecord-->useTime:"+useTime+"normalTime:"+normalTime+"recordType:"+recordType+"useDrugStatus:"+useDrugStatus+"kitSn:"+kitSn+"kitAccountId:"+kitAccountId+"drugDetail:"+drugDetail);
            kitService.useDrugRecord(useTime,normalTime,recordType,useDrugStatus,kitSn,kitAccountId,drugDetail);
            return write(200, "请求成功!");
        } catch (Exception e) {
@ -56,17 +57,19 @@ public class JyKitController extends BaseController {
            @ApiParam(name = "normalTime", value = "计划用药时间 yyyy-MM-dd HH:mm")
            @RequestParam(value = "normalTime", required = true) String normalTime,
            @ApiParam(name = "kitSn", value = "药盒sn码")
            @RequestParam(value = "normalTime", required = true) String kitSn,
            @RequestParam(value = "kitSn", required = true) String kitSn,
            @ApiParam(name = "kitAccountId", value = "药盒账号id")
            @RequestParam(value = "kitAccountId", required = true) String kitAccountId,
            @ApiParam(name = "remindType", value = "提醒类型(1、到点,2、超时,3、漏用)")
            @RequestParam(value = "remindType", required = true) String remindType,
            @ApiParam(name = "drugDetail", value = "药品清单json串")
            @RequestParam(value = "kitAccountId", required = true) String drugDetail) {
            @RequestParam(value = "drugDetail", required = true) String drugDetail) {
        try {
            System.out.println("useRemindRecord-->normalTime:"+normalTime+"kitSn:"+kitSn+"kitAccountId:"+kitAccountId+"remindType:"+remindType+"drugDetail:"+drugDetail);
            kitService.drugUseRemind(normalTime,remindType,kitSn,kitAccountId,drugDetail);
            return write(200, "请求成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"请求失败!");
        }
    }