451 lines
17 KiB
C#
451 lines
17 KiB
C#
using Core.Web.App_Start;
|
||
using Core.Web.WebHelper;
|
||
using CRM.Core.BLL.Util;
|
||
using CRM.Core.Common.Layui;
|
||
using CRM.Core.DTO;
|
||
using CRM.Core.Model.Enum;
|
||
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Web;
|
||
using System.Web.Mvc;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.Common.StockHelper;
|
||
|
||
namespace Core.Web.Controllers
|
||
{
|
||
public class LiveAuditController : BaseController
|
||
{
|
||
private CACHE_BL _cache = new CACHE_BL();
|
||
|
||
public readonly string webapi = "";
|
||
|
||
public LiveAuditController()
|
||
{
|
||
webapi = _cache.GetValue_Parameter(Parameter.HgActionUrl);
|
||
//webapi = "https://localhost:7263/";
|
||
}
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public ActionResult Index()
|
||
{
|
||
ViewBag.Eid = Eid;
|
||
ViewBag.rightCode = RightsConfig.CONST_直播审核;
|
||
var deptments = GetDeptments();
|
||
ViewBag.companyList = deptments;
|
||
|
||
//获取审核状态及驳回理由的下拉框选项
|
||
var select = GetLiveAuditSelect();
|
||
|
||
ViewBag.Status = select.Status;
|
||
ViewBag.Platforms = select.Platforms;
|
||
|
||
return View();
|
||
}
|
||
|
||
private List<NewsController.DeptmentDto> GetDeptments()
|
||
{
|
||
var data = new List<NewsController.DeptmentDto>();
|
||
var cacheKey = "cache_deptment_list";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
{
|
||
data = CacheHelper.Get<List<NewsController.DeptmentDto>>(cacheKey);
|
||
}
|
||
else
|
||
{
|
||
var webapi = _cache.GetValue_Parameter(Parameter.Hg_Core_WebApi);
|
||
var url = $"{webapi}/api/Department/List";
|
||
var result = Utility.GetData(url, "", Encoding.UTF8);
|
||
var response = JsonConvert.DeserializeObject<ApiResult<List<NewsController.DeptmentDto>>>(result);
|
||
if (response.Code == 0)
|
||
{
|
||
data = response.Data;
|
||
CacheHelper.Set(cacheKey, data);
|
||
}
|
||
}
|
||
return data;
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public JsonResult GetListHtml(Laypage pager, LiveAuditRequestDto dto)
|
||
{
|
||
var url = $"{webapi}api/LiveAudit/Live/Page";
|
||
dto.PageIndex = pager.page;
|
||
dto.PageSize = pager.limit;
|
||
|
||
if (dto.TimeTo.HasValue)
|
||
dto.TimeTo = dto.TimeTo.Value.AddDays(1).AddSeconds(-1);
|
||
|
||
var para = Utility.GetParamToString(dto);
|
||
var result = Utility.GetData(url, para, Encoding.UTF8);
|
||
var page = JsonConvert.DeserializeObject<ApiResult<PageResult<LiveAuditResponseDto>>>(result);
|
||
var list = new List<LiveAuditResponseDto>();
|
||
if (page.Code == 0)
|
||
{
|
||
list = page.Data.Data.ToList();
|
||
}
|
||
var data = new LayuiData<LiveAuditResponseDto>()
|
||
{
|
||
msg = "数据加载成功!",
|
||
count = page.Data.Total,
|
||
code = 0,
|
||
data = list
|
||
};
|
||
return Json(data, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public ActionResult Detail()
|
||
{
|
||
ViewBag.LiveId = Request["LiveId"];
|
||
ViewBag.AuditStatus = Request["AuditStatus"];
|
||
ViewBag.Eid = Eid;
|
||
ViewBag.rightCode = RightsConfig.CONST_直播审核;
|
||
var deptments = GetDeptments();
|
||
ViewBag.companyList = deptments;
|
||
|
||
//获取审核状态及驳回理由的下拉框选项
|
||
var select = GetLiveAuditSelect();
|
||
|
||
ViewBag.Status = select.Status;
|
||
ViewBag.Platforms = select.Platforms;
|
||
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public JsonResult GetDetailListHtml(Laypage pager, LiveAuditRequestDto dto)
|
||
{
|
||
var url = $"{webapi}api/LiveAudit/Page";
|
||
dto.PageIndex = pager.page;
|
||
dto.PageSize = pager.limit;
|
||
|
||
if (dto.TimeTo.HasValue)
|
||
dto.TimeTo = dto.TimeTo.Value.AddDays(1).AddSeconds(-1);
|
||
|
||
if (dto.AuditTimeTo.HasValue)
|
||
dto.AuditTimeTo = dto.AuditTimeTo.Value.AddDays(1).AddSeconds(-1);
|
||
|
||
var para = Utility.GetParamToString(dto);
|
||
var result = Utility.GetData(url, para, Encoding.UTF8);
|
||
var page = JsonConvert.DeserializeObject<ApiResult<PageResult<LiveAuditResponseDto>>>(result);
|
||
var list = new List<LiveAuditResponseDto>();
|
||
if (page.Code == 0)
|
||
{
|
||
list = page.Data.Data.ToList();
|
||
}
|
||
var data = new LayuiData<LiveAuditResponseDto>()
|
||
{
|
||
msg = "数据加载成功!",
|
||
count = page.Data.Total,
|
||
code = 0,
|
||
data = list
|
||
};
|
||
return Json(data, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public ActionResult Log(int Id, string LiveDate)
|
||
{
|
||
ViewBag.Id = Id;
|
||
ViewBag.LiveDate = LiveDate;
|
||
|
||
//获取审核状态及驳回理由的下拉框选项
|
||
var select = GetLiveAuditSelect();
|
||
ViewBag.Reasons = select.Reasons;
|
||
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public JsonResult GetLog(int Id, string LiveDate)
|
||
{
|
||
var url = $"{webapi}api/LiveAudit/Logs";
|
||
var para = $"auditId={Id}&date={LiveDate}";
|
||
var result = Utility.GetData(url, para, Encoding.UTF8);
|
||
var data = JsonConvert.DeserializeObject<ApiResult<List<LiveAuditLogsDto>>>(result);
|
||
|
||
var logs = new List<LiveAuditLogsDto>();
|
||
if (data.Code == 0)
|
||
logs = data.Data.OrderByDescending(x => x.Ctime).ToList();
|
||
|
||
var list = new LayuiData<LiveAuditLogsDto>()
|
||
{
|
||
msg = "数据加载成功!",
|
||
count = data.Data.Count,
|
||
code = 0,
|
||
data = logs
|
||
};
|
||
|
||
return Json(list, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public ActionResult Audit(int Id)
|
||
{
|
||
var url = $"{webapi}api/LiveAudit/Detail";
|
||
var para = $"auditId={Id}";
|
||
var result = Utility.GetData(url, para, Encoding.UTF8);
|
||
var data = JsonConvert.DeserializeObject<ApiResult<LiveAuditDetailDto>>(result);
|
||
var model = new LiveAuditDetailDto();
|
||
if (data.Code == 0)
|
||
{
|
||
model = data.Data;
|
||
}
|
||
|
||
//获取审核状态及驳回理由的下拉框选项
|
||
var select = GetLiveAuditSelect();
|
||
|
||
ViewBag.Status = select.Status;
|
||
ViewBag.Reasons = select.Reasons;
|
||
ViewBag.Model = model.ToJson();
|
||
ViewBag.Id = Id;
|
||
ViewBag.File_Server = _cache.GetValue_Parameter("File_Server");
|
||
ViewBag.UserName = UserName;
|
||
return View();
|
||
}
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
[HttpPost]
|
||
public ActionResult AuditSet(LiveAuditSetDto dto)
|
||
{
|
||
retMsg ret = new retMsg();
|
||
var url = $"{webapi}api/LiveAudit/Audit";
|
||
dto.Operator = UserName;
|
||
var result = Utility.PostAjaxData(url, dto.ToJson(), Encoding.UTF8);
|
||
var data = JsonConvert.DeserializeObject<ApiResult<bool>>(result);
|
||
if (data.Code == 0)
|
||
{
|
||
ret = new retMsg() { result = true, retcode = 200, retmsg = "提交成功!" };
|
||
}
|
||
else
|
||
{
|
||
ret = new retMsg() { result = false, retcode = 200, retmsg = "提交失败!Error:" + data.Message };
|
||
}
|
||
return Json(ret);
|
||
}
|
||
|
||
private LiveAuditSelectDto GetLiveAuditSelect()
|
||
{
|
||
var data = new LiveAuditSelectDto();
|
||
var cacheKey = "Cache_LiveAudit_Select";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
{
|
||
data = CacheHelper.Get<LiveAuditSelectDto>(cacheKey);
|
||
}
|
||
else
|
||
{
|
||
var statusUrl = $"{webapi}api/LiveAudit/select/status";
|
||
var status = Utility.GetData(statusUrl, "", Encoding.UTF8);
|
||
var statusResponse = JsonConvert.DeserializeObject<ApiResult<List<LiveAuditKeyValue>>>(status);
|
||
|
||
var reasonUrl = $"{webapi}api/LiveAudit/select/reason";
|
||
var reason = Utility.GetData(reasonUrl, "", Encoding.UTF8);
|
||
var reasonResponse = JsonConvert.DeserializeObject<ApiResult<List<LiveAuditKeyValue>>>(reason);
|
||
|
||
var platformUrl = $"{webapi}api/LiveAudit/select/platform";
|
||
var platform = Utility.GetData(platformUrl, "", Encoding.UTF8);
|
||
var platformResponse = JsonConvert.DeserializeObject<ApiResult<List<LiveAuditKeyValue>>>(platform);
|
||
|
||
if (statusResponse.Code == 0 && reasonResponse.Code == 0 && platformResponse.Code == 0)
|
||
{
|
||
data.Status = statusResponse.Data;
|
||
data.Reasons = reasonResponse.Data;
|
||
data.Platforms = platformResponse.Data;
|
||
CacheHelper.Set(cacheKey, data);
|
||
}
|
||
}
|
||
return data;
|
||
}
|
||
|
||
#region 新版直播审核
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public ActionResult Index2()
|
||
{
|
||
ViewBag.Eid = Eid;
|
||
ViewBag.rightCode = RightsConfig.CONST_直播审核;
|
||
var deptments = GetDeptments();
|
||
var set = _cache.GetValue_Parameter("LiveAudtiDeptIgnoreSetting");
|
||
if (!string.IsNullOrWhiteSpace(set))
|
||
{
|
||
var containIds = set.Split(',').Select(n => Convert.ToInt32(n)).ToList();
|
||
deptments = deptments.Where(n => !containIds.Contains(n.Id)).ToList();
|
||
}
|
||
|
||
ViewBag.companyList = deptments;
|
||
|
||
//获取审核状态及驳回理由的下拉框选项
|
||
var select = GetLiveAuditSelect();
|
||
|
||
ViewBag.Status = select.Status;
|
||
ViewBag.Platforms = select.Platforms;
|
||
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public JsonResult GetListHtml2(Laypage pager, LiveScheduleRequestDto dto)
|
||
{
|
||
var url = $"{webapi}api/LiveAudit/live/schedulePage";
|
||
dto.PageIndex = pager.page;
|
||
dto.PageSize = pager.limit;
|
||
|
||
if (dto.TimeTo.HasValue)
|
||
dto.TimeTo = dto.TimeTo.Value.AddDays(1).AddSeconds(-1);
|
||
|
||
var para = Utility.GetParamToString(dto);
|
||
var result = Utility.GetData(url, para, Encoding.UTF8);
|
||
var page = JsonConvert.DeserializeObject<ApiResult<PageResult<LiveScheduleResponseDto>>>(result);
|
||
var list = new List<LiveScheduleResponseDto>();
|
||
var count = 0;
|
||
if (page.Code == 0)
|
||
{
|
||
list = page.Data.Data.ToList();
|
||
count = page.Data.Total;
|
||
}
|
||
var data = new LayuiData<LiveScheduleResponseDto>()
|
||
{
|
||
msg = "数据加载成功!",
|
||
count = count,
|
||
code = 0,
|
||
data = list
|
||
};
|
||
return Json(data, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public ActionResult PlayBack(int Id)
|
||
{
|
||
ViewBag.Id = Id;
|
||
|
||
//获取审核状态及驳回理由的下拉框选项
|
||
var select = GetLiveAuditSelect();
|
||
ViewBag.Reasons = select.Reasons;
|
||
ViewBag.Status = select.Status;
|
||
|
||
ViewBag.rightCode = RightsConfig.CONST_直播审核;
|
||
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public JsonResult GetPlayBack(Laypage pager, LivePlayBlackRequestDto dto)
|
||
{
|
||
var url = $"{webapi}api/LiveAudit/Live/PlayBackPage";
|
||
|
||
dto.PageIndex = pager.page;
|
||
dto.PageSize = pager.limit;
|
||
|
||
//if (dto.ETime.HasValue)
|
||
// dto.ETime = dto.ETime.Value.AddDays(1).AddSeconds(-1);
|
||
|
||
var para = Utility.GetParamToString(dto);
|
||
var result = Utility.GetData(url, para, Encoding.UTF8);
|
||
var data = JsonConvert.DeserializeObject<ApiResult<PageResult<LivePlayBlackResponseDto>>>(result);
|
||
|
||
var playBacks = new List<LivePlayBlackResponseDto>();
|
||
var count = 0;
|
||
if (data.Code == 0)
|
||
{
|
||
playBacks = data.Data.Data.OrderByDescending(x => x.ZbDate).ToList();
|
||
count = data.Data.Total;
|
||
}
|
||
|
||
var list = new LayuiData<LivePlayBlackResponseDto>()
|
||
{
|
||
msg = "数据加载成功!",
|
||
count = count,
|
||
code = 0,
|
||
data = playBacks
|
||
};
|
||
|
||
return Json(list, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public ActionResult PlayBackAudit(string Ids, int SchedulesId)
|
||
{
|
||
//获取审核状态及驳回理由的下拉框选项
|
||
var select = GetLiveAuditSelect();
|
||
|
||
ViewBag.Status = select.Status.Where(x => x.Key == 1 || x.Key == 3).ToList();//下拉框只有1:违规,3:审核通过两种选项
|
||
ViewBag.Reasons = select.Reasons;
|
||
ViewBag.Ids = Ids;
|
||
ViewBag.SchedulesId = SchedulesId;
|
||
ViewBag.File_Server = _cache.GetValue_Parameter("File_Server");
|
||
ViewBag.UserName = UserName;
|
||
return View();
|
||
}
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
[HttpPost]
|
||
public ActionResult PlayBackAuditSet(LivePlayBackSetDto dto)
|
||
{
|
||
retMsg ret = new retMsg();
|
||
var url = $"{webapi}api/LiveAudit/AddAudit";
|
||
dto.Operator = UserName;
|
||
var result = Utility.PostAjaxData(url, dto.ToJson(), Encoding.UTF8);
|
||
var data = JsonConvert.DeserializeObject<ApiResult<bool>>(result);
|
||
if (data.Code == 0)
|
||
{
|
||
ret = new retMsg() { result = true, retcode = 200, retmsg = "提交成功!" };
|
||
}
|
||
else
|
||
{
|
||
ret = new retMsg() { result = false, retcode = 200, retmsg = "提交失败!Error:" + data.Message };
|
||
}
|
||
return Json(ret);
|
||
}
|
||
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public ActionResult PlayBackLog(int Id)
|
||
{
|
||
ViewBag.Id = Id;
|
||
|
||
//获取审核状态及驳回理由的下拉框选项
|
||
var select = GetLiveAuditSelect();
|
||
ViewBag.Reasons = select.Reasons;
|
||
ViewBag.Status = select.Status;
|
||
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(RightsConfig.CONST_直播审核, ToolBarConfig.CONST_NotButton, false)]
|
||
public JsonResult GetPlayBackLog(int Id)
|
||
{
|
||
var url = $"{webapi}api/LiveAudit/Live/PlayBackLogPage";
|
||
var para = $"playBackId={Id}&&PageIndex=1&PageSize=999";
|
||
var result = Utility.GetData(url, para, Encoding.UTF8);
|
||
var data = JsonConvert.DeserializeObject<ApiResult<PageResult<LivePlayBackLogsDto>>>(result);
|
||
|
||
var logs = new List<LivePlayBackLogsDto>();
|
||
var count = 0;
|
||
if (data.Code == 0)
|
||
{
|
||
logs = data.Data.Data.OrderByDescending(x => x.Ctime).ToList();
|
||
count = data.Data.Total;
|
||
}
|
||
|
||
var list = new LayuiData<LivePlayBackLogsDto>()
|
||
{
|
||
msg = "数据加载成功!",
|
||
count = count,
|
||
code = 0,
|
||
data = logs
|
||
};
|
||
|
||
return Json(list, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
#endregion 新版直播审核
|
||
}
|
||
} |