231 lines
9.5 KiB
C#
231 lines
9.5 KiB
C#
using Core.Web.App_Start;
|
|
using Core.Web.WebHelper;
|
|
using CRM.Core.BLL;
|
|
using CRM.Core.BLL.Application.B;
|
|
using CRM.Core.BLL.Application.Bill;
|
|
using CRM.Core.BLL.Util;
|
|
using CRM.Core.Common.Layui;
|
|
using CRM.Core.Common.WebHelper;
|
|
using CRM.Core.DTO;
|
|
using CRM.Core.DTO.Bill;
|
|
using CRM.Core.Model.Entity;
|
|
using CRM.Core.Model.Enum;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace Core.Web.Controllers
|
|
{
|
|
public class MeetingController : BaseController
|
|
{
|
|
private CACHE_BL cache_BL = new CACHE_BL();
|
|
|
|
[HttpGet]
|
|
[AuthorizeRedirect(RightsConfig.CONST_培训档案管理, ToolBarConfig.CONST_NotButton, true)]
|
|
public ActionResult Index()
|
|
{
|
|
ViewBag.rightCode = RightsConfig.CONST_培训档案管理;
|
|
ViewBag.eid = Eid;
|
|
ViewBag.userName = UserName;
|
|
ViewBag.File_Server = cache_BL.GetValue_Parameter("File_Server");
|
|
var webapi = cache_BL.GetValue_Parameter(Parameter.Hg_Core_WebApi);
|
|
var companyList = cache_BL.GetCompanyVirtual();
|
|
ViewBag.companyList = cache_BL.GetCompanyVirtual();
|
|
var allChannel = new List<Dictionary<string, string>>();
|
|
foreach (var company in companyList)
|
|
{
|
|
var channel = new Dictionary<string, string>
|
|
{
|
|
{ "name", company.CompanyName },
|
|
{ "value", company.Channel.Replace(",", ";") }
|
|
};
|
|
allChannel.Add(channel);
|
|
}
|
|
allChannel.Add(new Dictionary<string, string>
|
|
{
|
|
{ "name", "合规风控中心" },
|
|
{ "value", "-1" }
|
|
});
|
|
allChannel.Add(new Dictionary<string, string>
|
|
{
|
|
{ "name", "其他部门" },
|
|
{ "value", "-2" }
|
|
});
|
|
ViewBag.AllChannel = JsonHelper.ToJson(allChannel);
|
|
ViewBag.webapi = webapi;
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
[AuthorizeRedirect(RightsConfig.CONST_培训档案管理, ToolBarConfig.CONST_Export, false)]
|
|
public FileResult Export()
|
|
{
|
|
var webapi = cache_BL.GetValue_Parameter(Parameter.Hg_Core_WebApi);
|
|
var url = webapi + "/api/meeting/page";
|
|
var queryString = Request.QueryString.ToString();
|
|
var json = Utility.GetData(url, queryString, Encoding.Default);
|
|
Dictionary<string, object> res = JsonHelper.JsonDivertToObj<Dictionary<string, object>>(json);
|
|
var dataList = (res["data"] as IDictionary<string, object>)["data"];
|
|
var dataListJson = JsonHelper.ObjDivertToJson(dataList);
|
|
IList<IDictionary<string, object>> dicList = JsonHelper.JsonDivertToObj<IList<IDictionary<string, object>>>(dataListJson); //提取数据
|
|
List<MeetingItem> modelList = new List<MeetingItem>();
|
|
|
|
foreach (var item in dicList)
|
|
{
|
|
MeetingItem r = new MeetingItem();
|
|
r.id = item["id"]?.ToString();
|
|
r.meetingName = item["meetingName"]?.ToString();
|
|
r.meetingType = item["meetingType"]?.ToString();
|
|
var channelJson = JsonHelper.ObjDivertToJson(item["channelList"] ?? "");
|
|
r.channelList = string.Join(",", JsonHelper.JsonDivertToObj<IList<string>>(channelJson));
|
|
r.meetingTime = item["meetingTime"]?.ToString();
|
|
r.meetingSite = item["meetingSite"]?.ToString();
|
|
r.comperes = item["comperes"]?.ToString();
|
|
r.createUser = item["createUser"]?.ToString();
|
|
r.createTime = item["createTime"]?.ToString();
|
|
r.updateUser = item["updateUser"]?.ToString();
|
|
r.updateTime = item["updateTime"]?.ToString();
|
|
|
|
modelList.Add(r);
|
|
}
|
|
//提取数据
|
|
|
|
String file = string.Format("培训档案管理 {0}.xls", DateTime.Now.ToLocalTime().ToString("yyyyMMddHHmmssfffff"));
|
|
return File(ExcelHelper.ExportListModelToExcel<MeetingItem>(modelList, "培训档案管理", 30000, null), "application/ms-excel", file);
|
|
}
|
|
|
|
[HttpGet]
|
|
[AuthorizeRedirect(RightsConfig.CONST_培训档案管理, ToolBarConfig.CONST_Edit, true)]
|
|
public ActionResult Edit(int? id = null)
|
|
{
|
|
ViewBag.id = id;
|
|
ViewBag.rightCode = RightsConfig.CONST_培训档案管理;
|
|
ViewBag.eid = Eid;
|
|
ViewBag.userName = UserName;
|
|
ViewBag.File_Server = cache_BL.GetValue_Parameter("File_Server");
|
|
|
|
//ViewBag.File_Server = "https://localhost:5300";
|
|
var webapi = cache_BL.GetValue_Parameter(Parameter.Hg_Core_WebApi);
|
|
var companyList = cache_BL.GetCompanyVirtual();
|
|
ViewBag.companyList = cache_BL.GetCompanyVirtual();
|
|
var allChannel = new List<Dictionary<string, string>>();
|
|
foreach (var company in companyList)
|
|
{
|
|
var channel = new Dictionary<string, string>
|
|
{
|
|
{ "name", company.CompanyName },
|
|
{ "value", company.Channel.Replace(",", ";") }
|
|
};
|
|
allChannel.Add(channel);
|
|
}
|
|
allChannel.Add(new Dictionary<string, string>
|
|
{
|
|
{ "name", "合规风控中心" },
|
|
{ "value", "-1" }
|
|
});
|
|
allChannel.Add(new Dictionary<string, string>
|
|
{
|
|
{ "name", "其他部门" },
|
|
{ "value", "-2" }
|
|
});
|
|
ViewBag.AllChannel = JsonHelper.ToJson(allChannel);
|
|
|
|
ViewBag.webapi = webapi;
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
[AuthorizeRedirect(RightsConfig.CONST_培训档案管理, ToolBarConfig.CONST_Other1, true)]
|
|
public ActionResult Upload(int? id = null)
|
|
{
|
|
ViewBag.id = id;
|
|
ViewBag.rightCode = RightsConfig.CONST_培训档案管理;
|
|
ViewBag.eid = Eid;
|
|
ViewBag.userName = UserName;
|
|
ViewBag.File_Server = cache_BL.GetValue_Parameter("File_Server");
|
|
var webapi = cache_BL.GetValue_Parameter(Parameter.Hg_Core_WebApi);
|
|
ViewBag.webapi = webapi;
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
[AuthorizeRedirect(RightsConfig.CONST_培训档案管理, ToolBarConfig.CONST_Export, false)]
|
|
public FileResult ExportData(string param)
|
|
{
|
|
var webapi = cache_BL.GetValue_Parameter(Parameter.Hg_Core_WebApi);
|
|
var url = $"{webapi}/api/meeting/page";
|
|
|
|
var meetingDto = Utility.ToObject<MeetingRequestDto>(param);
|
|
var para = $"MeetingName={meetingDto.MeetingName}&MeetingType={meetingDto.MeetingType}&Compere={meetingDto.Compere}&Paricipant={meetingDto.Paricipant}&CreateUser={meetingDto.CreateUser}&Channels={meetingDto.Channels}&MeetingDateForm={meetingDto.MeetingDateForm}&MeetingDateTo={meetingDto.MeetingDateTo}&CreateTimeForm={meetingDto.CreateTimeForm}&CreateTimeTo={meetingDto.CreateTimeTo}&PageIndex=1&PageSize=100000";
|
|
|
|
var data = Utility.GetData(url, para, Encoding.Default);
|
|
var apiData = Utility.ToObject<MeetingResponseDto>(data);
|
|
|
|
string checkedFilds = Server.UrlDecode(Request.Cookies["checkedFilds"].Value);
|
|
string checkedTitle = Server.UrlDecode(Request.Cookies["checkedTitles"].Value);
|
|
Request.Cookies.Remove("checkedFilds");//用完后删除cookies
|
|
Request.Cookies.Remove("checkedTitles");//用完后删除cookies
|
|
|
|
String file = string.Format("培训档案{0}.xls", DateTime.Now.ToLocalTime().ToString("yyyyMMddHHmmssfffff"));
|
|
return File(ExcelHelper.ExportListModelToExcel<MeetingDataDto>(apiData.Data.Data, "sheet", 30000, checkedFilds, checkedTitle, DataFormart), "application/ms-excel", file);
|
|
}
|
|
|
|
public string DataFormart(string key, object value)
|
|
{
|
|
string formartValue = string.Empty;
|
|
switch (key)
|
|
{
|
|
case "ChannelList":
|
|
formartValue = string.Join("\n", Utility.ToObject<List<string>>(Utility.ToJson(value)));
|
|
break;
|
|
|
|
default: formartValue = string.Format("{0}", value); break;
|
|
}
|
|
return formartValue;
|
|
}
|
|
}
|
|
|
|
public class MeetingItem
|
|
{
|
|
[DisplayName("序号")]
|
|
public string id { get; set; }
|
|
|
|
[DisplayName("会议名称")]
|
|
public string meetingName { get; set; }
|
|
|
|
[DisplayName("会议类型")]
|
|
public string meetingType { get; set; }
|
|
|
|
[DisplayName("参训事业部")]
|
|
public string channelList { get; set; }
|
|
|
|
[DisplayName("会议时间")]
|
|
public string meetingTime { get; set; }
|
|
|
|
[DisplayName("会议地点")]
|
|
public string meetingSite { get; set; }
|
|
|
|
[DisplayName("主讲人")]
|
|
public string comperes { get; set; }
|
|
|
|
[DisplayName("备注")]
|
|
public string remark { get; set; }
|
|
|
|
[DisplayName("创建人")]
|
|
public string createUser { get; set; }
|
|
|
|
[DisplayName("创建时间")]
|
|
public string createTime { get; set; }
|
|
|
|
[DisplayName("更新人")]
|
|
public string updateUser { get; set; }
|
|
|
|
[DisplayName("更新时间")]
|
|
public string updateTime { get; set; }
|
|
}
|
|
} |