public ActionResult ResultDetail(InspenctionResultSearchModel model) { IInspectionTimePlanBLL planTimeBll = BLLFactory <IInspectionTimePlanBLL> .GetBLL("InspectionTimePlanBLL"); var planTime = planTimeBll.GetEntity(p => p.Id == model.PlanTimeId); if (planTime != null) { InspectionResultModel res = new InspectionResultModel() { PlanName = planTime.InspectionPlan.PlanName, PointList = planTime.InspectionPlan.PlanPoints.Select(p => p.InspectionPoint).ToList(), ResultList = planTime.InspectionResults.Where(r => r.PlanDate >= model.StartDate && r.PlanDate < model.EndDate).ToList() }; return(View(res)); } else { return(RedirectToAction("ResultMonitorList")); } }
public ApiResultModel UploadResult(InspectionResultModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前用户 IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); IInspectionTimePlanBLL planTimeBll = BLLFactory <IInspectionTimePlanBLL> .GetBLL("InspectionTimePlanBLL"); if (!planTimeBll.Exist(p => p.Id == model.TimePlanId)) { resultModel.result = "该巡检安排已不存在"; return(resultModel); } IInspectionResultBLL resultBll = BLLFactory <IInspectionResultBLL> .GetBLL("InspectionResultBLL"); //单条巡检结果初始化 T_InspectionResult result = new T_InspectionResult() { TimePlanId = model.TimePlanId, PointId = model.PointId, Status = model.Status, Desc = model.Desc, UploadUserId = model.UserId, DelFlag = ConstantParam.DEL_FLAG_DEFAULT, Longitude = model.Longitude, Latitude = model.Latitude }; //如果状态为异常,则设置处理状态为未处理 if (model.Status == ConstantParam.EXCEPTION) { result.DisposeStatus = ConstantParam.NO_DISPOSE; } //巡检异常文件资源保存目录 string dir = HttpContext.Current.Server.MapPath(ConstantParam.QUESTION_FILE + user.PropertyPlaceId); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } //问题图片上传 if (!string.IsNullOrEmpty(model.ImgFiles)) { var fileName = DateTime.Now.ToFileTime().ToString() + ".zip"; string filepath = Path.Combine(dir, fileName); using (FileStream fs = new FileStream(filepath, FileMode.Create)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] datas = Convert.FromBase64String(model.ImgFiles); bw.Write(datas); bw.Close(); } } //图片集路径保存 result.Imgs = PropertyUtils.UnZip(filepath, dir, ConstantParam.QUESTION_FILE + user.PropertyPlaceId); } //语音文件上传 if (!string.IsNullOrEmpty(model.AudioFile)) { var fileName = DateTime.Now.ToFileTime().ToString() + ".amr"; string filepath = Path.Combine(dir, fileName); using (FileStream fs = new FileStream(filepath, FileMode.Create)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] datas = Convert.FromBase64String(model.AudioFile); bw.Write(datas); bw.Close(); } } //语音路径保存 result.AudioPath = ConstantParam.QUESTION_FILE + user.PropertyPlaceId + "/" + fileName; } result.ClientSaveTime = model.ClientSaveTime; result.PlanDate = model.PlanDate; result.UploadTime = DateTime.Now; //上传巡检结果 resultBll.Save(result); } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }