ComplianceServer/oldcode/Core.Web/Controllers/LivePlanController.cs

165 lines
6.2 KiB
C#

using Core.Web.App_Start;
using Core.Web.WebHelper;
using CRM.Core.BLL.Util;
using CRM.Core.Common.Layui;
using CRM.Core.Common.WebHelper;
using CRM.Core.DTO;
using CRM.Core.DTO.LivePlan;
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 LivePlanController : BaseController
{
private CACHE_BL _cache = new CACHE_BL();
public readonly string webapi = "";
public LivePlanController()
{
webapi = _cache.GetValue_Parameter(Parameter.Hg_Core_WebApi);
//webapi = "https://localhost:7090";
}
#region
[AuthorizeRedirect(RightsConfig.CONST_直播报备, ToolBarConfig.CONST_NotButton, false)]
public ActionResult Index()
{
ViewBag.Eid = Eid;
ViewBag.rightCode = RightsConfig.CONST_直播报备;
var operatorModel = _cache.GetReportOperator();
var allOperator = new List<Dictionary<string, string>>();
foreach (var company in operatorModel)
{
var channel = new Dictionary<string, string>
{
{ "name", company.Ename },
{ "value", company.Eid.ToString()}
};
allOperator.Add(channel);
}
ViewBag.allOperator = JsonHelper.ToJson(allOperator);
var deptments = _cache.GetReportDeptments();
var allCompany = new List<Dictionary<string, string>>();
foreach (var company in deptments)
{
var channel = new Dictionary<string, string>
{
{ "name", company.Title },
{ "value", company.DepartmentId.ToString()}
};
allCompany.Add(channel);
}
ViewBag.companyList = JsonHelper.ToJson(allCompany);
var setting = _cache.GetValue_Parameter("RejectSetting");
var setList = JsonConvert.DeserializeObject<List<string>>(setting);
var allChannel = new List<Dictionary<string, string>>();
foreach (var company in setList)
{
var channel = new Dictionary<string, string>
{
{ "name", company },
{ "value", company}
};
allChannel.Add(channel);
}
ViewBag.AllChannel = allChannel.ToJson();
return View();
}
[HttpPost]
[AuthorizeRedirect(RightsConfig.CONST_直播报备, ToolBarConfig.CONST_NotButton, false)]
public JsonResult GetListHtml(Laypage pager, LivePlanRequestDto dto)
{
var url = $"{webapi}/api/Live/Plan/Page";
dto.PageIndex = pager.page;
dto.PageSize = pager.limit;
var para = Utility.GetParamToString(dto);
var result = Utility.GetData(url, para, Encoding.UTF8);
var page = JsonConvert.DeserializeObject<ApiResult<PageResult<LivePlanResponseDto>>>(result);
var list = new List<LivePlanResponseDto>();
if (page.Code == 0)
{
list = page.Data.Data.ToList();
}
var data = new LayuiData<LivePlanResponseDto>()
{
msg = "数据加载成功!",
count = page.Data.Total,
code = 0,
data = list
};
return Json(data, JsonRequestBehavior.AllowGet);
}
[AuthorizeRedirect(RightsConfig.CONST_直播报备, ToolBarConfig.CONST_Other1, false)]
public ActionResult ComplianceStatus(int id, int type)
{
ViewBag.rightCode = RightsConfig.CONST_直播报备;
var url = $"{webapi}/api/Live/Plan/Detail";
var para = $"id={id}&type={type}";
var result = Utility.GetData(url, para, Encoding.UTF8);
var data = JsonConvert.DeserializeObject<ApiResult<LivePlanInfoDto>>(result);
if (data.Code == 0)
{
ViewBag.LogList = data.Data.LiveLogs;
}
ViewBag.checktype = type;
var setting = _cache.GetValue_Parameter("RejectSetting");
var setList = JsonConvert.DeserializeObject<List<string>>(setting);
var allChannel = new List<Dictionary<string, string>>();
foreach (var company in setList)
{
var channel = new Dictionary<string, string>
{
{ "name", company },
{ "value", company}
};
allChannel.Add(channel);
}
ViewBag.AllChannel = allChannel.ToJson();
return View(data.Data);
}
[AuthorizeRedirect(RightsConfig.CONST_直播报备, ToolBarConfig.CONST_Other1, false)]
[ValidateInput(false)]
public JsonResult ComplianceStatusSubmit(int checktype, int id, int status, int tostatus)
{
var memo = CRM.Core.Common.TextHelper.Encode(Request["memo"] ?? string.Empty);
var url = $"{webapi}/api/Live/Plan/audit";
LivePlanAuditDto postModel = new LivePlanAuditDto
{
PlanId = id,
CheckType = checktype,
Status = tostatus,
sourcetype = (int)ComplianceCheckSourceType.,
Memo = memo,
OperatorId = Eid,
OperatorName = UserName
};
var result = Utility.PostAjaxData(url, postModel.ToJson(), Encoding.UTF8);
var data = JsonConvert.DeserializeObject<ApiResult<object>>(result);
if (data.Code == 0)
{
return Json(new { result = true, code = 0, msg = "保存成功!" }, JsonRequestBehavior.AllowGet);
}
else
{
return Json(new { result = false, code = 0, msg = $"{data.Message}" }, JsonRequestBehavior.AllowGet);
}
}
#endregion
}
}