using Learun.Util;
using System.Data;
using Learun.Application.TwoDevelopment.LogisticsManagement;
using System.Web.Mvc;
using System.Collections.Generic;
using Learun.Application.TwoDevelopment.LR_Desktop;
using Learun.Application.Organization;
using Learun.Application.Base.AuthorizeModule;
using System;
using Learun.Application.Base.SystemModule;
using System.Linq;
namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers
{
///
/// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
/// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
/// 创 建:超级管理员
/// 日 期:2023-06-29 15:27
/// 描 述:教师报修
///
public class RepairReportTeacherController : MvcControllerBase
{
private RepairReportTeacherIBLL repairReportTeacherIBLL = new RepairReportTeacherBLL();
private UserRelationIBLL userRelationIBLL = new UserRelationBLL();
private MessageRindIBLL messageRindIBLL = new MessageRindBLL();
private DataItemIBLL dataItemIBLL = new DataItemBLL();
private UserIBLL userIbll = new UserBLL();
private RoleIBLL roleIBLL = new RoleBLL();
#region 视图功能
///
/// 主页面
///
///
[HttpGet]
public ActionResult Index()
{
return View();
}
///
/// 表单页
///
///
[HttpGet]
public ActionResult Form()
{
return View();
}
///
/// 表单页
///
///
[HttpGet]
public ActionResult FormView()
{
return View();
}
///
/// 表单页
///
///
[HttpGet]
public ActionResult EvaluateFormView()
{
return View();
}
///
/// 统计界面
///
///
[HttpGet]
public ActionResult statisticIndex()
{
return View();
}
///
/// 处理界面
///
///
[HttpGet]
public ActionResult dealIndex()
{
return View();
}
///
/// 表单页处理
///
///
[HttpGet]
public ActionResult dealFormView()
{
return View();
}
#endregion
#region 获取数据
///
/// 获取页面显示列表数据
///
/// 分页参数
/// 查询参数
///
[HttpGet]
[AjaxOnly]
public ActionResult GetPageList(string pagination, string queryJson)
{
Pagination paginationobj = pagination.ToObject();
var data = repairReportTeacherIBLL.GetPageList(paginationobj, queryJson);
var jsonData = new
{
rows = data,
total = paginationobj.total,
page = paginationobj.page,
records = paginationobj.records
};
return Success(jsonData);
}
///
/// 获取表单数据
///
/// 主键
///
[HttpGet]
[AjaxOnly]
public ActionResult GetFormData(string keyValue)
{
var RepairReport_TeacherData = repairReportTeacherIBLL.GetRepairReport_TeacherEntity(keyValue);
var jsonData = new {
RepairReport_Teacher = RepairReport_TeacherData,
};
return Success(jsonData);
}
#endregion
#region 提交数据
///
/// 删除实体数据
///
/// 主键
///
[HttpPost]
[AjaxOnly]
public ActionResult DeleteForm(string keyValue)
{
repairReportTeacherIBLL.DeleteEntity(keyValue);
return Success("删除成功!");
}
///
/// 保存实体数据(新增、修改)
///
/// 主键
/// 实体
///
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
public ActionResult SaveForm(string keyValue, string strEntity)
{
RepairReport_TeacherEntity entity = strEntity.ToObject();
repairReportTeacherIBLL.SaveEntity(keyValue, entity);
//entity.Status = 2;
if (entity.Status == 2)
{
var model = repairReportTeacherIBLL.GetRepairReport_TeacherEntity(keyValue);
//获取所有的维修员账号并添加
var userList = userIbll.GetListByUserIds(model.Creator);
List datalist = dataItemIBLL.GetDetailList("repairtype", "");
string servicevalue = datalist.Where(c => c.F_ItemValue == model.ServiceType).FirstOrDefault().F_ItemName;
string content = "您发起" + model.Address + "-" + servicevalue + "维修请求已处理,请评价。";
addmessagerind(userList, model, content, "评价通知");
}
if (string.IsNullOrEmpty(keyValue))
{
}
return Success("保存成功!");
}
#endregion
#region 扩展数据
///
/// 提交课程异动记录
///
/// 课程异动主键
/// 审核状态
/// 流程Id
///
public ActionResult ModifyStatus(string keyValue, int status, string processId)
{
//修改状态
repairReportTeacherIBLL.ModifyStatus(keyValue, status, processId);
var model = repairReportTeacherIBLL.GetRepairReport_TeacherEntity(keyValue);
//向所有维修员发消息
string roleid = roleIBLL.GetIdByRoleName("维修角色");
var data = userRelationIBLL.GetUserIdList(roleid);
string userIds = "";
foreach (var item in data)
{
if (userIds != "")
{
userIds += ",";
}
userIds += item.F_UserId;
}
//获取所有的维修员账号并添加
var userList = userIbll.GetListByUserIds(userIds);
List datalist = dataItemIBLL.GetDetailList("repairtype", "");
string servicevalue = datalist.Where(c => c.F_ItemValue == model.ServiceType).FirstOrDefault().F_ItemName;
string content = model.DeptName + model.CreatorName + "发起" + model.Address + "-" + servicevalue + "维修请求。";
addmessagerind(userList, model, content);
return Success("提交成功!");
}
private void addmessagerind(List userList,RepairReport_TeacherEntity model,string content,string title= "维修通知")
{
foreach (var userinfo in userList)
{
//站内通知逻辑
MessageRemindEntity entity = new MessageRemindEntity();
entity.ReceiptId = userinfo.F_UserId;
entity.ReceiptName = userinfo.F_RealName;
entity.SenderId = model.Creator;
entity.SenderName = model.CreatorName;
entity.TheTitle = title;
entity.TheContent = content;
entity.InstanceId = model.ID;
entity.ConnectionUrl = "/LogisticsManagement/RepairReportTeacher/FormView?keyValue=";
entity.SendTime = DateTime.Now;
entity.ReadSigns = false;
messageRindIBLL.SaveEntity("", entity);
}
}
#endregion
}
}