Beispiel #1
0
        public Dictionary <int, List <TrainDTO> > getTrainDTOByUserA(User user)
        {
            TrainInfoDAO          trainInfoDao          = new TrainInfoDAO();
            DevicePrescriptionDAO devicePrescriptionDao = new DevicePrescriptionDAO();
            PrescriptionResultDAO prescriptionResultDao = new PrescriptionResultDAO();
            DeviceSortDAO         deviceSortDao         = new DeviceSortDAO();

            Dictionary <int, List <TrainDTO> > dic = new Dictionary <int, List <TrainDTO> >();

            //找到该用户训练记录(训练记录状态为0或2)
            List <TrainInfo> trainInfos = trainInfoDao.GetFinishOrNormalTrainInfoByUserId(user.Pk_User_Id);

            foreach (TrainInfo trainInfo in trainInfos)
            {
                //根据训练信息id查找处方
                List <DevicePrescription> devicePrescriptions = devicePrescriptionDao.GetByTIId(trainInfo.Pk_TI_Id);
                foreach (DevicePrescription devicePrescription in devicePrescriptions)
                {
                    int devId = devicePrescription.Fk_DS_Id;

                    //根据处方查找训练结果
                    PrescriptionResult prescriptionResult =
                        prescriptionResultDao.GetByDPId(devicePrescription.Pk_DP_Id);
                    if (prescriptionResult == null)
                    {
                        //如果没有训练结果,
                        continue;
                    }

                    //查找字典是否有以此设备名字命名的key,不存在则先创建
                    if (!dic.ContainsKey(devId))
                    {
                        List <TrainDTO> trainDtos = new List <TrainDTO>();
                        dic.Add(devId, trainDtos);
                    }
                    //                    Console.WriteLine(prescriptionResult.PR_Evaluate);
                    //PR_Evaluate 总是1????
                    dic[devId].Add(new TrainDTO(trainInfo, devicePrescription, prescriptionResult));
                }
            }

            return(dic);

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// 添加训练结果,返回主键
        /// </summary>
        public void AddPrescriptionResult(object siId, TrainInfo trainInfo,
                                          Dictionary <DevicePrescription, PrescriptionResult> prescriptionDic)
        {
            UploadManagementDAO   uploadManagementDao   = new UploadManagementDAO();
            DevicePrescriptionDAO devicePrescriptionDao = new DevicePrescriptionDAO();
            PrescriptionResultDAO prescriptionResultDao = new PrescriptionResultDAO();

            using (TransactionScope ts = new TransactionScope()) //使整个代码块成为事务性代码
            {
                //插入训练信息和上传表
                int tiId = (int)new TrainInfoDAO().Insert(trainInfo);
                uploadManagementDao.Insert(new UploadManagement(tiId, "bdl_traininfo", 0));
                if (siId != null)
                {
                    //改变症状表外键关联
                    var symptomInfo = symptomInfoDao.Load((int)siId);
                    symptomInfo.Fk_TI_Id = tiId;
                    symptomInfoDao.UpdateByPrimaryKey(symptomInfo);
                    //将更新信息插入至上传表
                    uploadManagementDao.Insert(new UploadManagement(tiId, "bdl_traininfo", 1));
                }
                if (prescriptionDic != null)
                {
                    int dpId;
                    int prId;
                    foreach (KeyValuePair <DevicePrescription, PrescriptionResult> prescription in prescriptionDic)
                    {
                        DevicePrescription devicePrescription = prescription.Key;
                        PrescriptionResult prescriptionResult = prescription.Value;
                        //插入设备处方、上传表
                        devicePrescription.Fk_TI_Id = tiId;
                        dpId = (int)devicePrescriptionDao.Insert(devicePrescription);
                        uploadManagementDao.Insert(new UploadManagement(dpId, "bdl_deviceprescription", 0));

                        //插入设备处方结果、上传表
                        prescriptionResult.Fk_DP_Id = dpId;
                        prId = (int)prescriptionResultDao.Insert(prescriptionResult);
                        uploadManagementDao.Insert(new UploadManagement(prId, "bdl_prescriptionresult", 0));
                    }
                }

                ts.Complete();
            }
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uploadManagement">传入上传管理者实体</param>
        /// <returns>返回可以用来上传的辅助对象</returns>
        public ServiceResult GetServiceResult(UploadManagement uploadManagement)
        {
            //service返回结果对象
            ServiceResult serviceResult = new ServiceResult();
            //提前载入唯一Setter
            SetterDAO setterDAO = new SetterDAO();
            Setter    setter    = setterDAO.getSetter();
            //需要加入解密逻辑 TODO
            string mac = "";

            //try
            //{
            //    byte[] deBytes = AesUtil.Decrypt(Encoding.GetEncoding("GBK").GetBytes(setter.Set_Unique_Id),
            //        ProtocolConstant.USB_DOG_PASSWORD);
            //    mac = Encoding.GetEncoding("GBK").GetString(deBytes);
            //}
            //catch (Exception ex)
            //{
            //    mac = setter.Set_Unique_Id.Replace(":", "");
            //}
            byte[] a = ProtocolUtil.StringToBcd(setter.Set_Unique_Id);
            byte[] b = AesUtil.Decrypt(a, ProtocolConstant.USB_DOG_PASSWORD);
            mac = Encoding.GetEncoding("GBK").GetString(b).Replace(":", "-");

            ///if识别出表,设置发送路径,select出实体,转化至DTO,json打成string,返回
            //识别是否是权限用户添加
            if (uploadManagement.UM_DataTable == "bdl_auth")
            {
                AuthDAO authDAO = new AuthDAO();
                Auther  auther  = authDAO.Load(uploadManagement.UM_DataId);
                if (auther == null)
                {
                    return(null);
                }
                AutherDTO autherDTO = new AutherDTO(setter, auther, mac);


                //serviceResult.URL = "clientController/addClient.action";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <AutherDTO>(autherDTO);
            }
            //bdl_customdata表
            else if (uploadManagement.UM_DataTable == "bdl_customdata")
            {
                CustomDataDAO customDataDAO = new CustomDataDAO();
                CustomData    customData    = customDataDAO.Load(uploadManagement.UM_DataId);
                if (customData == null)
                {
                    return(null);
                }
                CustomDataDTO customDataDTO = new CustomDataDTO(customData, mac);
                serviceResult.Data = JsonTools.Obj2JSONStrNew <CustomDataDTO>(customDataDTO);
            }
            //bdl_datacode表
            else if (uploadManagement.UM_DataTable == "bdl_datacode")
            {
                DataCodeDAO dataCodedao = new DataCodeDAO();
                DataCode    dataCode    = dataCodedao.Load(uploadManagement.UM_DataId);

                if (dataCode == null)
                {
                    return(null);
                }
                DataCodeDTO dataCodeDTO = new DataCodeDTO(dataCode, mac);
                serviceResult.Data = JsonTools.Obj2JSONStrNew <DataCodeDTO>(dataCodeDTO);
            }
            //bdl_deviceset表
            else if (uploadManagement.UM_DataTable == "bdl_deviceset")
            {
                DeviceSetDAO deviceSetDAO = new DeviceSetDAO();
                DeviceSet    deviceSet    = deviceSetDAO.Load(uploadManagement.UM_DataId);
                if (deviceSet == null)
                {
                    return(null);
                }
                DeviceSetDTO deviceSetDTO = new DeviceSetDTO(deviceSet, mac);

                serviceResult.Data = JsonTools.Obj2JSONStrNew <DeviceSetDTO>(deviceSetDTO);
            }
            //bdl_devicesort表
            else if (uploadManagement.UM_DataTable == "bdl_devicesort")
            {
                DeviceSortDAO deviceSortDAO = new DeviceSortDAO();
                DeviceSort    deviceSort    = deviceSortDAO.Load(uploadManagement.UM_DataId);
                if (deviceSort == null)
                {
                    return(null);
                }
                DeviceSortDTO deviceSortDTO = new DeviceSortDTO(deviceSort, mac);


                serviceResult.Data = JsonTools.Obj2JSONStrNew <DeviceSortDTO>(deviceSortDTO);
            }
            //bdl_onlinedevice表
            else if (uploadManagement.UM_DataTable == "bdl_onlinedevice")
            {
                OnlineDeviceDAO onlineDeviceDAO = new OnlineDeviceDAO();
                OnlineDevice    onlineDevice    = onlineDeviceDAO.Load(uploadManagement.UM_DataId);

                if (onlineDevice == null)
                {
                    return(null);
                }
                OnlineDeviceDTO onlineDeviceDTO = new OnlineDeviceDTO(onlineDevice, mac);

                serviceResult.Data = JsonTools.Obj2JSONStrNew <OnlineDeviceDTO>(onlineDeviceDTO);
            }
            //bdl_set表
            else if (uploadManagement.UM_DataTable == "bdl_set")
            {
                SetterDAO setterDAO1 = new SetterDAO();
                Setter    setter1    = setterDAO1.Load(uploadManagement.UM_DataId);

                if (setter1 == null)
                {
                    return(null);
                }

                SetterDTO setterDTO = new SetterDTO(setter1, mac);

                serviceResult.Data = JsonTools.Obj2JSONStrNew <SetterDTO>(setterDTO);
            }
            //病人表
            else if (uploadManagement.UM_DataTable == "bdl_user")
            {
                UserDAO userDAO = new UserDAO();
                User    user    = userDAO.Load(uploadManagement.UM_DataId);
                if (user == null)
                {
                    return(null);
                }


                UserDTO userDTO = new UserDTO(user, mac);
                //serviceResult.URL = "bigData/bodyStrongUser";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <UserDTO>(userDTO);
            }

            //症状表
            else if (uploadManagement.UM_DataTable == "bdl_symptominfo")
            {
                SymptomInfoDao symptomInfoDao = new SymptomInfoDao();
                var            result         = symptomInfoDao.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }


                SymptomInfoDTO symptomInfoDTO = new SymptomInfoDTO(result, mac);
                //serviceResult.URL = "bigData/symptomInfo";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <SymptomInfoDTO>(symptomInfoDTO);
            }

            //训练处方总表
            else if (uploadManagement.UM_DataTable == "bdl_traininfo")
            {
                TrainInfoDAO trainInfoDAO = new TrainInfoDAO();
                var          result       = trainInfoDAO.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }


                TrainInfoDTO trainInfoDTO = new TrainInfoDTO(result, mac);
                //serviceResult.URL = "bigData/trainInfo";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <TrainInfoDTO>(trainInfoDTO);
            }

            //总表中的一条数据对某台设备的具体处方
            else if (uploadManagement.UM_DataTable == "bdl_deviceprescription")
            {
                DevicePrescriptionDAO devicePrescriptionDAO = new DevicePrescriptionDAO();
                var result = devicePrescriptionDAO.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }


                DevicePrescriptionDTO devicePrescriptionDTO = new DevicePrescriptionDTO(result, mac);
                //serviceResult.URL = "bigData/devicePrescription";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <DevicePrescriptionDTO>(devicePrescriptionDTO);
            }
            //具体处方的具体反馈
            else if (uploadManagement.UM_DataTable == "bdl_prescriptionresult")
            {
                PrescriptionResultDAO prescriptionResultDAO = new PrescriptionResultDAO();
                var result = prescriptionResultDAO.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }


                PrescriptionResultDTO prescriptionResultDTO = new PrescriptionResultDTO(result, mac);
                //serviceResult.URL = "bigData/prescriptionResult";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <PrescriptionResultDTO>(prescriptionResultDTO);
            }
            else if (uploadManagement.UM_DataTable == "bdl_physicalpower")
            {
                PhysicalPowerDAO physicalPowerDAO = new PhysicalPowerDAO();
                var result = physicalPowerDAO.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }

                PhysicalPowerDTO physicalPowerDTO = new PhysicalPowerDTO(result, mac);
                //serviceResult.URL = "bigData/physicalPower";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <PhysicalPowerDTO>(physicalPowerDTO);
            }
            else if (uploadManagement.UM_DataTable == "bdl_error")
            {
                ErrorDao errorDao = new ErrorDao();
                var      result   = errorDao.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }

                ErrorDTO errorDTO = new ErrorDTO(result, mac);
                //serviceResult.URL = "bigData/physicalPower";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <ErrorDTO>(errorDTO);
            }

            return(serviceResult);
        }