118 lines
4.4 KiB
C#
118 lines
4.4 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.BLL;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Wx;
|
|
using WX.CRM.Model.Entity;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.WeiXin
|
|
{
|
|
public class ComplaintAttendanceController : BaseController
|
|
{
|
|
private readonly IWX_COMPLAINTATTENDANCE _complaintattendance;
|
|
|
|
public ComplaintAttendanceController(IWX_COMPLAINTATTENDANCE complaintattendance)
|
|
{
|
|
_complaintattendance = complaintattendance;
|
|
}
|
|
|
|
[HttpGet]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_投诉考勤录入)]
|
|
public ActionResult Index()
|
|
{
|
|
string tableId = "tablist";
|
|
Table tab = new Table(tableId);
|
|
tab.AddHiddenHeadCol("pkid", "ID");
|
|
tab.AddHeadCol("month", "", "年月");
|
|
tab.AddHeadCol("eid", "", "工号");
|
|
tab.AddHeadCol("uname", "", "姓名");
|
|
tab.AddHeadCol("tousu", "", "投诉");
|
|
tab.AddHeadCol("chufa", "", "处罚");
|
|
tab.AddHeadCol("chuqin", "", "出勤率");
|
|
tab.AddHeadRow();
|
|
ViewBag.RptList = tab.GetTable();
|
|
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_投诉考勤录入)]
|
|
public JsonResult Index(int year, int month, int? eid, string columns)
|
|
{
|
|
if (month <= 0 || year <= 0)
|
|
{
|
|
return JsonHandler.ManageMessage("参数错误,请确认!", false);
|
|
}
|
|
DateTime m = new DateTime(year, month, 01);
|
|
var table = new Table(columns, true);
|
|
var where = PredicateExtensionses.True<WX_COMPLAINTATTENDANCE>();
|
|
if (eid.HasValue)
|
|
{
|
|
where = where.And(p => p.EID == eid.Value);
|
|
}
|
|
where = where.And(p => p.MONTH == m);
|
|
var list = _complaintattendance.GetList(where);
|
|
var eids = list.GroupBy(p => p.EID).Select(p => p.Key);
|
|
foreach (var e in eids)
|
|
{
|
|
var str = string.Empty;
|
|
var arr = list.Where(p => p.EID == e);
|
|
foreach (var item in arr)
|
|
{
|
|
str += item.PKID + "|" + item.TYPE + ",";
|
|
}
|
|
str = str.Trim(',');
|
|
table.AddHiddenCol(str);
|
|
table.AddCol(year.ToString() + "-" + month.ToString());
|
|
table.AddCol(e);
|
|
table.AddCol(InnerUserHelper.Instance.GetUsername(InnerUserHelper.Instance.GetUserIdByEidOrName(e.ToString())));
|
|
var wxComplaintattendance1 = list.FirstOrDefault(p => p.EID == e && p.TYPE == 1);
|
|
if (wxComplaintattendance1 != null)
|
|
table.AddCol(wxComplaintattendance1.VAL);
|
|
else
|
|
table.AddCol("");
|
|
var wxComplaintattendance2 = list.FirstOrDefault(p => p.EID == e && p.TYPE == 2);
|
|
if (wxComplaintattendance2 != null)
|
|
table.AddCol(wxComplaintattendance2.VAL);
|
|
else
|
|
table.AddCol("");
|
|
var wxComplaintattendance3 = list.FirstOrDefault(p => p.EID == e && p.TYPE == 3);
|
|
if (wxComplaintattendance3 != null)
|
|
table.AddCol(wxComplaintattendance3.VAL);
|
|
else
|
|
table.AddCol("");
|
|
table.AddRow();
|
|
}
|
|
var json = new
|
|
{
|
|
rowsList = table.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_投诉考勤录入)]
|
|
public JsonResult AddOrUpdate(string pkid, decimal eid, int year, int month, decimal? tousu, decimal? chufa, decimal? chuqin)
|
|
{
|
|
try
|
|
{
|
|
if (eid <= 0 || month <= 0 || year <= 0)
|
|
{
|
|
return JsonHandler.ManageMessage("参数错误,请确认!", false);
|
|
}
|
|
|
|
_complaintattendance.AddOrUpdate(pkid, eid, year, month, tousu, chufa, chuqin);
|
|
|
|
return Json(new { result = "ok", message = "操作成功!" }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error("ComplaintAttendanceController/Put:" + ex.Message);
|
|
return JsonHandler.ManageMessage(ex.Message, false);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|