/// <summary> /// 获取图片路径 /// </summary> /// <returns></returns> public JsonResult GetMonitorPics(SourceInputDto input) { var endDate = DateTime.Parse(input.BeginDate).AddMinutes(5).ToString("yyyy-MM-dd HH:mm:ss"); string andExpression = " and s.created_date >= '" + input.BeginDate + "' and s.created_date <= '" + endDate + "'"; string joinExpression = ""; joinExpression += " inner join bas_device d on d.device_no = s.device_no"; joinExpression += " inner join bas_loc l on l.loc_no = d.loc_no"; joinExpression += " inner join bas_line ln on ln.line_no = l.line_no"; if (!string.IsNullOrEmpty(input.LocNo)) { andExpression += " and d.loc_no = '" + input.LocNo + "'"; } if (!string.IsNullOrEmpty(input.ProcessNo)) { andExpression += " and l.process_no = '" + input.ProcessNo + "'"; } if (!string.IsNullOrEmpty(input.LineNo)) { andExpression += " and l.line_no = '" + input.LineNo + "'"; } if (!string.IsNullOrEmpty(input.WorkshopNo)) { andExpression += " and ln.workshop_no = '" + input.WorkshopNo + "'"; } string sql = $"select distinct s.* from biz_source s {joinExpression} where 1=1 {andExpression}"; sql += $" order by created_date limit {(input.PageIndex - 1) * 20}, {20}"; string countSql = $"select DISTINCT s.source_id from biz_source s {joinExpression} where 1=1 {andExpression}"; var total = srcOp.GetRowCount(countSql); var imgList = srcOp.GetDataByRawSql <SourceViewEntity>(sql); var list = new List <MonitorFile>(); string isCompressed = ConfigurationManager.AppSettings["IsCompressed"]; var isRealCompressed = true; // 不满足获取压缩图片的条件 if (isCompressed != "Yes" || !input.IsCompressed || imgList.Count(_ => _.CurrentStatus != (int)RowStatusEnum.Ready) > 0) { isRealCompressed = false; } GetImages(imgList, list, isRealCompressed); return(Json(new { Data = list, IsCompressed = isRealCompressed, Total = total % 20 == 0 ? total / 20 : total / 20 + 1 }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 分页获取问题数据 /// </summary> /// <returns></returns> public ActionResult Questions(SurveyInputDto input) { if (input.PageIndex < 1) { input.PageIndex = 1; } string andExpression = ""; if (!string.IsNullOrEmpty(input.SurveyNo)) { andExpression += " and survey_no like '%" + input.SurveyNo + "%'"; } if (!string.IsNullOrEmpty(input.SurveyDate)) { var dates = input.SurveyDate.Split(new string[] { " - " }, StringSplitOptions.RemoveEmptyEntries); var beginDate = dates[0].Trim(); var endDate = dates[1].Trim(); andExpression += " and survey_date>='" + beginDate + "'"; andExpression += " and survey_date<='" + endDate + "'"; } string sql = $"select * from biz_survey where 1=1{andExpression}"; sql += $" order by survey_date desc limit {(input.PageIndex - 1) * 15}, {15}"; string countSql = $"select survey_id from biz_survey where 1=1{andExpression}"; IList <SurveyViewModel> records = qsOp.GetDataByRawSql(sql) .Select(_ => new SurveyViewModel { SurveyId = _.SurveyId, SurveyNo = _.SurveyNo, SurveyDate = _.SurveyDate.ToString("yyyy-MM-dd HH:mm:ss"), SurveyDesc = _.SurveyDesc == null ? "" : _.SurveyDesc }).ToList(); var total = qsOp.GetRowCount(countSql); return(Json(new { data = records, total }, JsonRequestBehavior.AllowGet)); }