422 lines
19 KiB
C#
422 lines
19 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 质量会议
|
|
/// </summary>
|
|
public static class CQMS_MeetingService
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
/// 根据主键获取质量会议
|
|
/// </summary>
|
|
/// <param name="MeetingId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Meeting_CQMSMeeting GetCQMSMeetingById(string MeetingId)
|
|
{
|
|
return Funs.DB.Meeting_CQMSMeeting.FirstOrDefault(e => e.MeetingId == MeetingId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据时间段获取月例会集合
|
|
/// </summary>
|
|
/// <param name="startTime"></param>
|
|
/// <param name="endTime"></param>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public static int GetCountByTime(DateTime startTime, DateTime endTime, string projectId)
|
|
{
|
|
return (from x in Funs.DB.Meeting_CQMSMeeting where x.MeetingDate >= startTime && x.MeetingDate < endTime && x.ProjectId == projectId && x.State == BLL.Const.CQMSMeeting_Complete select x).Count();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据时间段获取月例会参会人数
|
|
/// </summary>
|
|
/// <param name="startTime"></param>
|
|
/// <param name="endTime"></param>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public static int? GetSumAttentPersonNumByMeetingDate(DateTime startTime, DateTime endTime, string projectId)
|
|
{
|
|
int? sumAttentPersonNum = (from x in Funs.DB.Meeting_CQMSMeeting where x.MeetingDate >= startTime && x.MeetingDate < endTime && x.ProjectId == projectId && x.State == BLL.Const.CQMSMeeting_Complete select x.AttentPersonNum).Sum();
|
|
if (sumAttentPersonNum == null)
|
|
{
|
|
return 0;
|
|
}
|
|
return sumAttentPersonNum;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据日期和类型获取会议记录集合
|
|
/// </summary>
|
|
/// <param name="startTime">开始时间</param>
|
|
/// <param name="endTime">结束时间</param>
|
|
/// <param name="projectId">项目号</param>
|
|
/// <returns>会议记录集合</returns>
|
|
public static List<Model.Meeting_CQMSMeeting> GetMeetingListsByDate(DateTime startTime, DateTime endTime, string projectId)
|
|
{
|
|
return (from x in Funs.DB.Meeting_CQMSMeeting where x.MeetingDate >= startTime && x.MeetingDate <= endTime && x.ProjectId == projectId orderby x.MeetingDate select x).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加质量会议
|
|
/// </summary>
|
|
/// <param name="CQMSMeeting"></param>
|
|
public static void AddCQMSMeeting(Model.Meeting_CQMSMeeting CQMSMeeting)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Meeting_CQMSMeeting newCQMSMeeting = new Model.Meeting_CQMSMeeting
|
|
{
|
|
MeetingId = CQMSMeeting.MeetingId,
|
|
ProjectId = CQMSMeeting.ProjectId,
|
|
UnitId = CQMSMeeting.UnitId,
|
|
MeetingType = CQMSMeeting.MeetingType,
|
|
MeetingCode = CQMSMeeting.MeetingCode,
|
|
MeetingDate = CQMSMeeting.MeetingDate,
|
|
Place = CQMSMeeting.Place,
|
|
HostMan = CQMSMeeting.HostMan,
|
|
AttentPerson = CQMSMeeting.AttentPerson,
|
|
AttentPersonNum = CQMSMeeting.AttentPersonNum,
|
|
MeetingTheme = CQMSMeeting.MeetingTheme,
|
|
MeetingContents = CQMSMeeting.MeetingContents,
|
|
State = CQMSMeeting.State,
|
|
CompileMan = CQMSMeeting.CompileMan,
|
|
CompileDate = CQMSMeeting.CompileDate,
|
|
};
|
|
db.Meeting_CQMSMeeting.InsertOnSubmit(newCQMSMeeting);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改质量会议
|
|
/// </summary>
|
|
/// <param name="CQMSMeeting"></param>
|
|
public static void UpdateCQMSMeeting(Model.Meeting_CQMSMeeting CQMSMeeting)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Meeting_CQMSMeeting newCQMSMeeting = db.Meeting_CQMSMeeting.FirstOrDefault(e => e.MeetingId == CQMSMeeting.MeetingId);
|
|
if (newCQMSMeeting != null)
|
|
{
|
|
newCQMSMeeting.UnitId = CQMSMeeting.UnitId;
|
|
newCQMSMeeting.MeetingCode = CQMSMeeting.MeetingCode;
|
|
newCQMSMeeting.MeetingDate = CQMSMeeting.MeetingDate;
|
|
newCQMSMeeting.Place = CQMSMeeting.Place;
|
|
newCQMSMeeting.HostMan = CQMSMeeting.HostMan;
|
|
newCQMSMeeting.AttentPerson = CQMSMeeting.AttentPerson;
|
|
newCQMSMeeting.AttentPersonNum = CQMSMeeting.AttentPersonNum;
|
|
newCQMSMeeting.MeetingTheme = CQMSMeeting.MeetingTheme;
|
|
newCQMSMeeting.MeetingContents = CQMSMeeting.MeetingContents;
|
|
newCQMSMeeting.State = CQMSMeeting.State;
|
|
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除质量会议
|
|
/// </summary>
|
|
/// <param name="MeetingId"></param>
|
|
public static void DeleteCQMSMeetingById(string MeetingId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Meeting_CQMSMeeting CQMSMeeting = db.Meeting_CQMSMeeting.FirstOrDefault(e => e.MeetingId == MeetingId);
|
|
if (CQMSMeeting != null)
|
|
{
|
|
BLL.CommonService.DeleteAttachFileById(MeetingId);
|
|
db.Meeting_CQMSMeeting.DeleteOnSubmit(CQMSMeeting);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据状态选择下一步办理类型
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
public static ListItem[] GetDHandleTypeByState(string state)
|
|
{
|
|
if (state == Const.CQMSMeeting_Compile || state == Const.CQMSMeeting_ReCompile)
|
|
{
|
|
ListItem[] lis = new ListItem[1];
|
|
lis[0] = new ListItem("总包质量经理审批", Const.CQMSMeeting_Audit);
|
|
return lis;
|
|
}
|
|
else if (state == Const.CQMSMeeting_Audit)
|
|
{
|
|
ListItem[] lis = new ListItem[2];
|
|
lis[0] = new ListItem("审批完成", Const.CQMSMeeting_Complete);
|
|
lis[1] = new ListItem("重新编制", Const.CQMSMeeting_ReCompile);
|
|
return lis;
|
|
}
|
|
else
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据状态选择下一步办理类型
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.BaseInfoItem> GetDHandleTypeByStateForApi(string state)
|
|
{
|
|
List<Model.BaseInfoItem> list = new List<Model.BaseInfoItem>();
|
|
if (state == Const.CQMSMeeting_Compile || state == Const.CQMSMeeting_ReCompile)
|
|
{
|
|
Model.BaseInfoItem item = new Model.BaseInfoItem();
|
|
item.BaseInfoId = Const.CQMSMeeting_Audit;
|
|
item.BaseInfoName = "总包质量经理审批";
|
|
list.Add(item);
|
|
return list;
|
|
}
|
|
else if (state == Const.CQMSMeeting_Audit)
|
|
{
|
|
Model.BaseInfoItem item = new Model.BaseInfoItem();
|
|
item.BaseInfoId = Const.CQMSMeeting_Complete;
|
|
item.BaseInfoName = "审批完成";
|
|
list.Add(item);
|
|
Model.BaseInfoItem item2 = new Model.BaseInfoItem();
|
|
item2.BaseInfoId = Const.CQMSMeeting_ReCompile;
|
|
item2.BaseInfoName = "重新编制";
|
|
list.Add(item2);
|
|
return list;
|
|
}
|
|
else
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据状态获取办理人
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.BaseInfoItem> GetHandleManListForApi(string state, string id, string projectId)
|
|
{
|
|
List<Model.BaseInfoItem> list = new List<Model.BaseInfoItem>();
|
|
if (state == Const.CQMSMeeting_Compile)
|
|
{
|
|
return null;
|
|
}
|
|
else if (state == Const.CQMSMeeting_ReCompile)
|
|
{
|
|
var user = BLL.Person_PersonsService.GetPerson_PersonsById(BLL.CQMS_MeetingApproveService.GetAuditMan(id, BLL.Const.CQMSMeeting_Compile).ApproveMan);
|
|
Model.BaseInfoItem item = new Model.BaseInfoItem();
|
|
item.BaseInfoId = user.PersonId;
|
|
item.BaseInfoName = user.PersonName;
|
|
list.Add(item);
|
|
return list;
|
|
}
|
|
else if (state == Const.CQMSMeeting_Audit)
|
|
{
|
|
var users = BLL.SitePerson_PersonService.GetSitePerson_PersonListByProjectIdUnitTypeRoleIds(projectId, Const.ProjectUnitType_1, null);
|
|
foreach (var user in users)
|
|
{
|
|
Model.BaseInfoItem item = new Model.BaseInfoItem();
|
|
item.BaseInfoId = user.PersonId;
|
|
item.BaseInfoName = user.PersonName;
|
|
list.Add(item);
|
|
}
|
|
return list;
|
|
}
|
|
else
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 把状态转换代号为文字形式
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
public static string ConvertState(object state)
|
|
{
|
|
if (state != null)
|
|
{
|
|
if (state.ToString() == BLL.Const.CQMSMeeting_ReCompile)
|
|
{
|
|
return "重新编制";
|
|
}
|
|
else if (state.ToString() == BLL.Const.CQMSMeeting_Compile)
|
|
{
|
|
return "编制";
|
|
}
|
|
else if (state.ToString() == BLL.Const.CQMSMeeting_Audit)
|
|
{
|
|
return "总包质量经理审批";
|
|
}
|
|
else if (state.ToString() == BLL.Const.CQMSMeeting_Complete)
|
|
{
|
|
return "审批完成";
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
public static List<Model.Meeting_CQMSMeeting> getListDataForApi(string projectId, int startRowIndex, int maximumRows, string meetingType)
|
|
{
|
|
using (var db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
IQueryable<Model.Meeting_CQMSMeeting> q = db.Meeting_CQMSMeeting;
|
|
if (!string.IsNullOrEmpty(projectId))
|
|
{
|
|
q = q.Where(e => e.ProjectId == projectId);
|
|
}
|
|
if (!string.IsNullOrEmpty(meetingType))
|
|
{
|
|
q = q.Where(e => e.MeetingType == meetingType);
|
|
}
|
|
var qres = from x in q
|
|
orderby x.CompileDate descending
|
|
select new
|
|
{
|
|
x.MeetingId,
|
|
x.ProjectId,
|
|
x.UnitId,
|
|
UnitName = (from y in db.Base_Unit where y.UnitId == x.UnitId select y.UnitName).First(),
|
|
x.MeetingType,
|
|
MeetingTypeStr = x.MeetingType == "M" ? "质量月例会" : "质量专题会",
|
|
x.MeetingCode,
|
|
x.MeetingDate,
|
|
x.Place,
|
|
x.HostMan,
|
|
HostManName = BLL.Person_PersonsService.getPersonsNamesPersonIds(x.HostMan),
|
|
x.AttentPerson,
|
|
AttentPersonName = BLL.Person_PersonsService.getPersonsNamesPersonIds(x.AttentPerson),
|
|
x.AttentPersonNum,
|
|
x.MeetingTheme,
|
|
x.MeetingContents,
|
|
x.CompileDate,
|
|
x.CompileMan,
|
|
x.State,
|
|
StateStr = ConvertState(x.State),
|
|
CompileManName = (from y in db.Person_Persons where y.PersonId == x.CompileMan select y.PersonName).First(),
|
|
HandleManName = BLL.CQMS_MeetingApproveService.GetHandleManName(x.MeetingId),
|
|
x.AttachUrl,
|
|
};
|
|
List<Model.Meeting_CQMSMeeting> res = new List<Model.Meeting_CQMSMeeting>();
|
|
var list = qres.Skip(startRowIndex).Take(maximumRows).ToList();
|
|
foreach (var item in list)
|
|
{
|
|
Model.Meeting_CQMSMeeting cd = new Model.Meeting_CQMSMeeting();
|
|
cd.MeetingId = item.MeetingId;
|
|
cd.ProjectId = item.ProjectId;
|
|
cd.UnitId = item.UnitId + "$" + item.UnitName;
|
|
cd.MeetingType = item.MeetingType + "$" + item.MeetingTypeStr;
|
|
cd.MeetingCode = item.MeetingCode;
|
|
cd.MeetingDate = item.MeetingDate;
|
|
cd.Place = item.Place;
|
|
cd.HostMan = item.HostMan + "$" + item.HostManName;
|
|
cd.AttentPerson = item.AttentPerson + "$" + item.AttentPersonName;
|
|
cd.AttentPersonNum = item.AttentPersonNum;
|
|
cd.MeetingTheme = item.MeetingTheme;
|
|
cd.MeetingContents = item.MeetingContents;
|
|
cd.CompileDate = item.CompileDate;
|
|
cd.CompileMan = item.CompileMan + "$" + item.CompileManName;
|
|
cd.State = item.State + "$" + item.StateStr + "$" + item.HandleManName;
|
|
cd.AttachUrl = AttachFileService.getFileUrl(item.MeetingId);
|
|
res.Add(cd);
|
|
}
|
|
return res;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取质量会议信息
|
|
/// </summary>
|
|
/// <param name="UnitWorkId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Meeting_CQMSMeeting GetMeetingByMeetingIdForApi(string MeetingId)
|
|
{
|
|
using (var db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var q = db.Meeting_CQMSMeeting.FirstOrDefault(e => e.MeetingId == MeetingId);
|
|
if (q != null)
|
|
{
|
|
q.UnitId = q.UnitId + "$" + BLL.UnitService.GetUnitNameByUnitId(q.UnitId);
|
|
q.MeetingType = q.MeetingType + "$" + (q.MeetingType == "M" ? "质量月例会" : "质量专题会");
|
|
q.HostMan = q.HostMan + "$" + BLL.Person_PersonsService.getPersonsNamesPersonIds(q.HostMan);
|
|
q.AttentPerson = q.AttentPerson + "$" + BLL.Person_PersonsService.getPersonsNamesPersonIds(q.AttentPerson);
|
|
q.CompileMan = q.CompileMan + "$" + BLL.Person_PersonsService.GetPersonsNameById(q.CompileMan);
|
|
q.State = q.State + "$" + ConvertState(q.State) + "$" + BLL.CQMS_MeetingApproveService.GetHandleManName(q.MeetingId);
|
|
q.AttachUrl = AttachFileService.getFileUrl(q.MeetingId);
|
|
}
|
|
return q;
|
|
}
|
|
}
|
|
|
|
public static void AddMeetingForApi(Model.Meeting_CQMSMeeting Meeting)
|
|
{
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
Model.Meeting_CQMSMeeting newCQMSMeeting = new Model.Meeting_CQMSMeeting
|
|
{
|
|
MeetingId = Meeting.MeetingId,
|
|
ProjectId = Meeting.ProjectId,
|
|
UnitId = Meeting.UnitId,
|
|
MeetingType = Meeting.MeetingType,
|
|
MeetingCode = Meeting.MeetingCode,
|
|
MeetingDate = Meeting.MeetingDate,
|
|
Place = Meeting.Place,
|
|
HostMan = Meeting.HostMan,
|
|
AttentPerson = Meeting.AttentPerson,
|
|
AttentPersonNum = Meeting.AttentPersonNum,
|
|
MeetingTheme = Meeting.MeetingTheme,
|
|
MeetingContents = Meeting.MeetingContents,
|
|
State = Meeting.State,
|
|
CompileMan = Meeting.CompileMan,
|
|
CompileDate = Meeting.CompileDate,
|
|
};
|
|
|
|
db.Meeting_CQMSMeeting.InsertOnSubmit(newCQMSMeeting);
|
|
db.SubmitChanges();
|
|
|
|
Model.Meeting_CQMSMeetingApprove approve = new Model.Meeting_CQMSMeetingApprove();
|
|
approve.MeetingApproveId = BLL.SQLHelper.GetNewID();
|
|
approve.MeetingId = Meeting.MeetingId;
|
|
approve.ApproveType = BLL.Const.CQMSMeeting_Compile;
|
|
approve.ApproveMan = Meeting.CompileMan;
|
|
approve.ApproveDate = Meeting.CompileDate;
|
|
db.Meeting_CQMSMeetingApprove.InsertOnSubmit(approve);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
public static void UpdateMeetingForApi(Model.Meeting_CQMSMeeting Meeting)
|
|
{
|
|
|
|
using (var db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
Model.Meeting_CQMSMeeting newMeeting = db.Meeting_CQMSMeeting.First(e => e.MeetingId == Meeting.MeetingId);
|
|
if (!string.IsNullOrEmpty(Meeting.UnitId))
|
|
newMeeting.UnitId = Meeting.UnitId;
|
|
if (!string.IsNullOrEmpty(Meeting.MeetingCode))
|
|
newMeeting.MeetingCode = Meeting.MeetingCode;
|
|
if (Meeting.MeetingDate.HasValue)
|
|
newMeeting.MeetingDate = Meeting.MeetingDate;
|
|
if (!string.IsNullOrEmpty(Meeting.Place))
|
|
newMeeting.Place = Meeting.Place;
|
|
if (!string.IsNullOrEmpty(Meeting.HostMan))
|
|
newMeeting.HostMan = Meeting.HostMan;
|
|
if (!string.IsNullOrEmpty(Meeting.AttentPerson))
|
|
newMeeting.AttentPerson = Meeting.AttentPerson;
|
|
if (Meeting.AttentPersonNum.HasValue)
|
|
newMeeting.AttentPersonNum = Meeting.AttentPersonNum;
|
|
if (!string.IsNullOrEmpty(Meeting.MeetingTheme))
|
|
newMeeting.MeetingTheme = Meeting.MeetingTheme;
|
|
if (!string.IsNullOrEmpty(Meeting.MeetingContents))
|
|
newMeeting.MeetingContents = Meeting.MeetingContents;
|
|
if (!string.IsNullOrEmpty(Meeting.State))
|
|
newMeeting.State = Meeting.State;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|