340 lines
12 KiB
C#
340 lines
12 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using model;
|
|
using model.crmodel;
|
|
using model.viewmodel;
|
|
using services;
|
|
using System.Diagnostics;
|
|
using web.Models;
|
|
using Newtonsoft.Json;
|
|
using common;
|
|
|
|
namespace web.Controllers
|
|
{
|
|
public class HomeController : Controller
|
|
{
|
|
private readonly ILogger<HomeController> _logger;
|
|
private readonly IwwUserinfoService _iwwUserinfoService;
|
|
|
|
public HomeController(IwwUserinfoService iwwUserinfoService, ILogger<HomeController> logger)
|
|
{
|
|
_logger = logger;
|
|
_iwwUserinfoService = iwwUserinfoService;
|
|
}
|
|
|
|
public IActionResult Default(string machineid)
|
|
{
|
|
List<wwUserinfoView> accountList = _iwwUserinfoService.GetMyDefault(machineid);
|
|
if (accountList.Count() == 0)
|
|
{
|
|
return Redirect("Index?needBind=1&machineid=" + machineid);
|
|
}
|
|
else
|
|
{
|
|
var defaultAcount = accountList.FirstOrDefault(m => m.isdefault == 1);
|
|
if (defaultAcount != null)
|
|
{
|
|
return Redirect("CSelectionTag?machineid=" + machineid + "&userid=" + defaultAcount.userid + "&corpid=" + defaultAcount.corpid);//直接进入默认
|
|
}
|
|
else
|
|
{
|
|
return Redirect("Index?machineid=" + machineid);//如果没有默认,就进入进行自己选择
|
|
}
|
|
}
|
|
}
|
|
|
|
public IActionResult Index(string machineid, int? needBind)
|
|
{
|
|
if (string.IsNullOrEmpty(machineid))
|
|
{
|
|
return Redirect("Error");//跳转
|
|
}
|
|
ViewBag.Machineid = machineid;
|
|
if (needBind.HasValue)
|
|
{
|
|
ViewBag.needBind = 1;
|
|
}
|
|
else
|
|
{
|
|
ViewBag.needBind = 0;
|
|
}
|
|
return View();
|
|
}
|
|
|
|
public JsonResult GetWeWorktHtmlList(string machineid, string name)
|
|
{
|
|
var layUidata = new LayuiData<wwUserinfoView>();
|
|
try
|
|
{
|
|
List<wwUserinfoView> list = _iwwUserinfoService.GetMyUserList(machineid, name);
|
|
foreach (var item in list)
|
|
{
|
|
try
|
|
{
|
|
var json = JsonConvert.DeserializeObject<wwUserinfoExinfo>(item.exinfo);
|
|
item.thumb_avatar = json.thumb_avatar ?? json.avatar;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_logger.LogError(e.ToString());
|
|
}
|
|
}
|
|
layUidata.msg = "数据加载成功";
|
|
layUidata.code = 0;
|
|
layUidata.data = list;
|
|
layUidata.count = 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex.ToString());
|
|
LogHelper.Error(ex.ToString());
|
|
|
|
layUidata.SetFail(1, "出现错误!" + ex.Message);
|
|
}
|
|
return Json(layUidata);
|
|
}
|
|
|
|
public IActionResult Bind(string machineid)
|
|
{
|
|
ViewBag.machineid = machineid;
|
|
return View();
|
|
}
|
|
|
|
public JsonResult BindSave(string machineid, string mobile, string remark)
|
|
{
|
|
ValidationErrors erro = new ValidationErrors();
|
|
bool result = _iwwUserinfoService.BindUser(machineid, mobile, remark, ref erro);
|
|
retMsg ret = new retMsg() { result = result, retcode = 200, retmsg = "设置成功!" };
|
|
if (!result)
|
|
{
|
|
ret.retmsg = erro.Error;
|
|
}
|
|
return Json(ret);
|
|
}
|
|
|
|
public JsonResult DisBind(string machineid, string userid, string corpid)
|
|
{
|
|
ValidationErrors erro = new ValidationErrors();
|
|
bool result = _iwwUserinfoService.DisBindUser(machineid, userid, corpid, ref erro);
|
|
retMsg ret = new retMsg() { result = result, retcode = 200, retmsg = "操作成功!" };
|
|
if (!result)
|
|
{
|
|
ret.retmsg = erro.Error;
|
|
}
|
|
return Json(ret);
|
|
}
|
|
|
|
public IActionResult AllTab(string machineid, string userid, string corpid)
|
|
{
|
|
ViewBag.machineid = machineid;
|
|
ViewBag.userid = userid;
|
|
ViewBag.corpid = corpid;
|
|
return View();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 时间格式
|
|
/// </summary>
|
|
/// <param name="machineid"></param>
|
|
/// <param name="userid"></param>
|
|
/// <param name="corpid"></param>
|
|
/// <returns></returns>
|
|
public IActionResult CSelection(string machineid, string userid, string corpid)
|
|
{
|
|
ViewBag.machineid = machineid;
|
|
ViewBag.userid = userid;
|
|
ViewBag.corpid = corpid;
|
|
ViewBag.MyUser = _iwwUserinfoService.GetMyUserOne(machineid, corpid, userid);
|
|
Dictionary<string, string> customTags = new Dictionary<string, string>();
|
|
var list = _iwwUserinfoService.GetExtUserList(machineid, corpid, userid, ref customTags);//List<wwExtuserView> list =
|
|
|
|
//ViewBag.customTags = customTags;//自定义标签
|
|
ViewBag.Data = Newtonsoft.Json.JsonConvert.SerializeObject(list);
|
|
ViewBag.DataList = list;
|
|
Dictionary<string, List<string>> diclist = new Dictionary<string, List<string>>();
|
|
//var tagList = _iwwUserinfoService.GetGroupTagList(corpid);//获取所有标签
|
|
//ViewBag.TagList = tagList;//所有标签
|
|
foreach (var item in list)
|
|
{
|
|
if (item.type != 2)
|
|
{
|
|
string yearStr = item.createtime2.Year.ToString();
|
|
if (diclist.ContainsKey(yearStr))
|
|
{
|
|
if (diclist[yearStr].Where(m => m == item.cmonth).Count() > 0)
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
diclist[yearStr].Add(item.cmonth);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
diclist.Add(yearStr, new List<string>() { item.cmonth });
|
|
}
|
|
}
|
|
}
|
|
ViewBag.YearMonthList = diclist;
|
|
|
|
return View();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 标签方式查看数据
|
|
/// </summary>
|
|
/// <param name="machineid"></param>
|
|
/// <param name="userid"></param>
|
|
/// <param name="corpid"></param>
|
|
/// <returns></returns>
|
|
public IActionResult CSelectionTag(string machineid, string userid, string corpid)
|
|
{
|
|
ViewBag.machineid = machineid;
|
|
ViewBag.userid = userid;
|
|
ViewBag.corpid = corpid;
|
|
ViewBag.MyUser = _iwwUserinfoService.GetMyUserOne(machineid, corpid, userid);
|
|
Dictionary<string, string> customTags = new Dictionary<string, string>();
|
|
var list = _iwwUserinfoService.GetExtUserList(machineid, corpid, userid, ref customTags);//List<wwExtuserView> list =
|
|
|
|
ViewBag.customTags = customTags;//自定义标签
|
|
ViewBag.Data = Newtonsoft.Json.JsonConvert.SerializeObject(list);
|
|
ViewBag.DataList = list;
|
|
Dictionary<string, List<string>> diclist = new Dictionary<string, List<string>>();
|
|
var tagList = _iwwUserinfoService.GetGroupTagList(corpid);//获取所有标签
|
|
ViewBag.TagList = tagList;//所有标签
|
|
foreach (var item in list)
|
|
{
|
|
if (item.type != 2)
|
|
{
|
|
string yearStr = item.createtime2.Year.ToString();
|
|
if (diclist.ContainsKey(yearStr))
|
|
{
|
|
if (diclist[yearStr].Where(m => m == item.cmonth).Count() > 0)
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
diclist[yearStr].Add(item.cmonth);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
diclist.Add(yearStr, new List<string>() { item.cmonth });
|
|
}
|
|
}
|
|
}
|
|
ViewBag.YearMonthList = diclist;
|
|
|
|
return View();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 企业筛选
|
|
/// </summary>
|
|
/// <param name="machineid"></param>
|
|
/// <param name="userid"></param>
|
|
/// <param name="corpid"></param>
|
|
/// <returns></returns>
|
|
public IActionResult CSelectionQY(string machineid, string userid, string corpid)
|
|
{
|
|
ViewBag.machineid = machineid;
|
|
ViewBag.userid = userid;
|
|
ViewBag.corpid = corpid;
|
|
ViewBag.MyUser = _iwwUserinfoService.GetMyUserOne(machineid, corpid, userid);
|
|
Dictionary<string, string> customTags = new Dictionary<string, string>();
|
|
var list = _iwwUserinfoService.GetExtUserList(machineid, corpid, userid, ref customTags);//List<wwExtuserView> list =
|
|
|
|
ViewBag.customTags = customTags;//自定义标签
|
|
ViewBag.Data = Newtonsoft.Json.JsonConvert.SerializeObject(list);
|
|
ViewBag.DataList = list;
|
|
Dictionary<string, List<string>> diclist = new Dictionary<string, List<string>>();
|
|
var tagList = _iwwUserinfoService.GetGroupTagList(corpid);//获取所有标签
|
|
ViewBag.TagList = tagList;//所有标签
|
|
foreach (var item in list)
|
|
{
|
|
if (item.type != 2)
|
|
{
|
|
string yearStr = item.createtime2.Year.ToString();
|
|
if (diclist.ContainsKey(yearStr))
|
|
{
|
|
if (diclist[yearStr].Where(m => m == item.cmonth).Count() > 0)
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
diclist[yearStr].Add(item.cmonth);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
diclist.Add(yearStr, new List<string>() { item.cmonth });
|
|
}
|
|
}
|
|
}
|
|
ViewBag.YearMonthList = diclist;
|
|
|
|
return View();
|
|
}
|
|
|
|
public JsonResult CSelectionWorkAll(string machineid, string userid, string corpid)
|
|
{
|
|
var layUidata = new LayuiData<wwExtuserView>();
|
|
try
|
|
{
|
|
Dictionary<string, string> customTags = new Dictionary<string, string>();
|
|
List<wwExtuserView> list = _iwwUserinfoService.GetExtUserList(machineid, corpid, userid, ref customTags);
|
|
//Dictionary<string, List<string>> diclist = new Dictionary<string, List<string>>();
|
|
//foreach (var item in list.GroupBy(m=>m.cmonth))
|
|
//{
|
|
//}
|
|
layUidata.msg = "数据加载成功";
|
|
layUidata.code = 0;
|
|
layUidata.data = list;
|
|
layUidata.count = 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex.ToString());
|
|
layUidata.SetFail(1, "出现错误!" + ex.Message);
|
|
|
|
LogHelper.Error(ex.ToString());
|
|
}
|
|
return Json(layUidata);
|
|
}
|
|
|
|
public JsonResult SetDefault(string machineid, string userid, string corpid)
|
|
{
|
|
ValidationErrors erro = new ValidationErrors();
|
|
var result = true;
|
|
retMsg ret = new retMsg() { result = result, retcode = 200, retmsg = "操作成功!" };
|
|
try
|
|
{
|
|
result = _iwwUserinfoService.SetDefault(machineid, corpid, userid);
|
|
|
|
if (!result)
|
|
{
|
|
ret.retmsg = "出现错误!";
|
|
ret.result = result;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.ToString());
|
|
}
|
|
return Json(ret);
|
|
}
|
|
|
|
public IActionResult Privacy()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
public IActionResult Error()
|
|
{
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
}
|
|
}
|
|
} |