using DIXWeb.DAL; using DIXWeb.DataRepository; using DIXWeb.Entity.GlobalM; using DIXWeb.Entity.Workflow; using DIXWeb.Util; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Linq.Dynamic; using System.Text; namespace DIXWeb.Business.GlobalM { public class WorkListBusiness : BaseBusiness { #region Íⲿ½Ó¿Ú /// /// »ñÈ¡Êý¾ÝÁбí /// /// ²éѯÀàÐÍ /// ¹Ø¼ü×Ö /// public List GetDataList(int viewType, string subject, string billno, Pagination pagination) { var plist = new List(); plist.Add(GlobalDataHelper.NewSqlParameter("@Subject", subject)); plist.Add(GlobalDataHelper.NewSqlParameter("@BillNo", billno)); plist.Add(GlobalDataHelper.NewSqlParameter("@viewType", viewType)); plist.Add(GlobalDataHelper.NewSqlParameter("@UserId", GlobalDataHelper.GetLoginUserNo())); List rlist = Service.GetListByProcNew("wp_wf_getMyworklist", plist); return rlist.GetPagination(pagination).ToList(); } /// /// »ñÈ¡Ö¸¶¨µÄµ¥ÌõÊý¾Ý /// /// Ö÷¼ü /// public WorkListModel GetWorkListInst(int btid, string bizdataids) { WorkListModel rm = null; List rlist = Service.GetListByProcNew("wp_wf_getworklist", new List() { new System.Data.SqlClient.SqlParameter("@btid", btid) }); if (rlist != null && rlist.Count > 0) { rm = rlist[0]; string userindex = GlobalDataHelper.GetLoginUser().Id.ToString().PadLeft(3, '0'); userindex = userindex.Substring(0, 3); if (rm.Id == 0) rm.BillNo = rm.BillCode + userindex + System.DateTime.Now.ToString("yyMMddHHmmssfff"); } else rm = new WorkListModel(); rm.BizDataIds = bizdataids; return rm; } /// /// »ñÈ¡Ö¸¶¨µÄµ¥ÌõÊý¾Ý /// /// Ö÷¼ü /// public WorkListModel GetWorkListInstNew(int instid, string billno, int btid) { WorkListModel rm = null; List rlist = Service.GetListByProcNew("wp_workflow_getworklist", new List() { new System.Data.SqlClient.SqlParameter("@id", instid), new System.Data.SqlClient.SqlParameter("@billno", billno) , new System.Data.SqlClient.SqlParameter("@btid", btid) }); if (rlist != null && rlist.Count > 0) { rm = rlist[0]; if (billno == "") { string userindex = GlobalDataHelper.GetLoginUser().Id.ToString().PadLeft(3, '0'); userindex = userindex.Substring(0, 3); if (rm.Id == 0) rm.BillNo = rm.BillCode + userindex + System.DateTime.Now.ToString("yyMMddHHmmssfff"); } } else rm = new WorkListModel(); return rm; } void SetupSysInfo(WorkList data, bool isCreate) { if (isCreate) { data.CreateTime = DateTime.Now; data.CreateUserId = GlobalDataHelper.GetLoginUserNo(); } data.CHtime = DateTime.Now; data.ChUserId = GlobalDataHelper.GetLoginUserNo(); } /// /// Ìí¼ÓÊý¾Ý /// /// Êý¾Ý public ResultMessage SubmitBill(WorkListModel newData) { SetupSysInfo(newData, true); var plist = new List(); plist.Add(GlobalDataHelper.NewSqlParameter("@Subject", newData.Subject)); plist.Add(GlobalDataHelper.NewSqlParameter("@BillNo", newData.BillNo)); plist.Add(GlobalDataHelper.NewSqlParameter("@BillTypeId", newData.BillTypeId)); plist.Add(GlobalDataHelper.NewSqlParameter("@UserId", GlobalDataHelper.GetLoginUserNo())); ResultMessage rm = Service.SubmitDataByProc("wp_worklist_submitbill", plist); return rm; } /// /// Ìí¼ÓÊý¾Ý /// /// Êý¾Ý public ResultMessage AddData(WorkListModel newData) { SetupSysInfo(newData, true); var plist = new List(); plist.Add(GlobalDataHelper.NewSqlParameter("@Subject", newData.Subject)); plist.Add(GlobalDataHelper.NewSqlParameter("@BillNo", newData.BillNo)); plist.Add(GlobalDataHelper.NewSqlParameter("@BillTypeId", newData.BillTypeId)); plist.Add(GlobalDataHelper.NewSqlParameter("@UserId", GlobalDataHelper.GetLoginUserNo())); plist.Add(GlobalDataHelper.NewSqlParameter("@BizDataIds", newData.BizDataIds)); ResultMessage rm = Service.SubmitDataByProc("wp_worklist_newdata", plist); return rm; } /// /// ¸üÐÂÊý¾Ý /// public ResultMessage UpdateData(WorkListModel theData) { SetupSysInfo(theData, false); return null; } /// /// ɾ³ýÊý¾Ý /// /// ɾ³ýµÄÊý¾Ý public void DeleteData(List ids) { Delete(ids); } public ResultMessage HandleBill(string ids, int type) { ids = string.IsNullOrEmpty(ids) ? "" : ids.Trim(); ids = ids.Replace("[", "").Replace("]", ""); string[] idarray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); string sucessids = "", failids = ""; int success = 0, fail = 0; for (int i = 0; i < idarray.Length; i++) { var plist = new List(); plist.Add(GlobalDataHelper.NewSqlParameter("@id", idarray[i])); plist.Add(GlobalDataHelper.NewSqlParameter("@type", type)); plist.Add(GlobalDataHelper.NewSqlParameter("@UserId", GlobalDataHelper.GetLoginUserNo())); ResultMessage rm = Service.SubmitDataByProc("wp_worklist_audit", plist); if (rm.Count > 0) { sucessids += idarray[i] + ","; success += 1; } else { failids += idarray[i] + ","; fail += 1; } } return new ResultMessage(1, "Ö´Ðнá¹ûΪ¡¾³É¹¦:" + success.ToString() + "±Ê,ID·Ö±ðΪ:" + sucessids + ";Ö´ÐÐʧ°Ü£º" + fail.ToString() + "±Ê,ID·Ö±ðΪ:" + failids + "¡¿"); } #endregion #region ˽ÓгÉÔ± #endregion #region Êý¾ÝÄ£ÐÍ #endregion public Receive GetMyNeedDealt(string Code, int UserId, int pageIndex = 1, int pageSize = 5) { Receive receive = new Receive(); try { using (DBContext db = new DBContext()) { System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@Code", Code), new System.Data.SqlClient.SqlParameter("@UserId", UserId), new System.Data.SqlClient.SqlParameter("@pageIndex", pageIndex), new System.Data.SqlClient.SqlParameter("@pageSize", pageSize), new System.Data.SqlClient.SqlParameter("@Total", 0), }; int index = paramList.Length - 1; paramList[index].Direction = ParameterDirection.Output; receive.rows = db.Database.SqlQuery("EXEC meta.p_myNeedDealt @Code,@UserId,@pageIndex,@pageSize,@Total output ", paramList).ToList(); receive.total = int.Parse(paramList[index].Value.ToString()); receive.Code = 200; receive.Message = "SUCCESS"; } } catch (Exception ex) { receive.Code = 500; receive.Message = ex.Message; } return receive; } public Receive GetInRepair(string Code, int UserId, int pageIndex = 1, int pageSize = 5) { Receive receive = new Receive(); try { using (DBContext db = new DBContext()) { System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@Code", Code), new System.Data.SqlClient.SqlParameter("@UserId", UserId), new System.Data.SqlClient.SqlParameter("@pageIndex", pageIndex), new System.Data.SqlClient.SqlParameter("@pageSize", pageSize), new System.Data.SqlClient.SqlParameter("@Total", 0), }; int index = paramList.Length - 1; paramList[index].Direction = ParameterDirection.Output; receive.rows = db.Database.SqlQuery("EXEC meta.p_myInRepair @Code,@UserId,@pageIndex,@pageSize,@Total output ", paramList).ToList(); receive.total = int.Parse(paramList[index].Value.ToString()); receive.Code = 200; receive.Message = "SUCCESS"; } } catch (Exception ex) { receive.Code = 500; receive.Message = ex.Message; } return receive; } public Receive ApproveAgree(int[] BillflowIdArr, int UserId,string Remark,string AppendixUrl) { Receive record = null; StringBuilder sb = new StringBuilder(); for (int i = 0; i < BillflowIdArr.Length; i++) { sb.Append(BillflowIdArr[i] + ","); } using (DBContext db = new DBContext()) { System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@BillflowIdStr", sb.ToString()), new System.Data.SqlClient.SqlParameter("@UserId", UserId), new System.Data.SqlClient.SqlParameter("@Remark", Remark), new System.Data.SqlClient.SqlParameter("@AppendixUrl", AppendixUrl), }; record = db.Database.SqlQuery("EXEC meta.p_ApproveAgree @BillflowIdStr,@UserId,@Remark,@AppendixUrl ", paramList).FirstOrDefault(); } return record; } public Receive ApproveAgreeAll(int UserId, string Remark, string AppendixUrl) { Receive record = null; using (DBContext db = new DBContext()) { System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@UserId", UserId), new System.Data.SqlClient.SqlParameter("@Remark", Remark), new System.Data.SqlClient.SqlParameter("@AppendixUrl", AppendixUrl), }; record = db.Database.SqlQuery("EXEC meta.p_ApproveAgreeAll @UserId,@Remark,@AppendixUrl ", paramList).FirstOrDefault(); } return record; } public Receive ApproveRefuse(int[] BillflowIdArr, int UserId,string Remark) { Receive record = null; StringBuilder sb = new StringBuilder(); for (int i = 0; i < BillflowIdArr.Length; i++) { sb.Append(BillflowIdArr[i] + ","); } using (DBContext db = new DBContext()) { System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@BillflowIdStr", sb.ToString()), new System.Data.SqlClient.SqlParameter("@UserId", UserId), new System.Data.SqlClient.SqlParameter("@Remark", Remark), }; record = db.Database.SqlQuery("EXEC meta.p_ApproveRefuse @BillflowIdStr,@UserId,@Remark ", paramList).FirstOrDefault(); } return record; } public Receive ApproveKeepRemart(int[] BillflowIdArr, int UserId, string Remark) { Receive record = null; StringBuilder sb = new StringBuilder(); for (int i = 0; i < BillflowIdArr.Length; i++) { sb.Append(BillflowIdArr[i] + ","); } using (DBContext db = new DBContext()) { System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@BillflowIdStr", sb.ToString()), new System.Data.SqlClient.SqlParameter("@UserId", UserId), new System.Data.SqlClient.SqlParameter("@Remark", Remark), }; record = db.Database.SqlQuery("EXEC meta.p_ApproveKeepRemart @BillflowIdStr,@UserId,@Remark ", paramList).FirstOrDefault(); } return record; } public List GetBillProcess(int BillId) { List list = null; using (DBContext db = new DBContext()) { System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@BillId", BillId), }; list = db.Database.SqlQuery("EXEC meta.p_getBillProcess @BillId ", paramList).ToList(); } return list; } public Receive GetMyApproved(string Code, int UserId, int pageIndex = 1, int pageSize = 5) { Receive receive = new Receive(); try { using (DBContext db = new DBContext()) { System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@Code", Code), new System.Data.SqlClient.SqlParameter("@UserId", UserId), new System.Data.SqlClient.SqlParameter("@pageIndex", pageIndex), new System.Data.SqlClient.SqlParameter("@pageSize", pageSize), new System.Data.SqlClient.SqlParameter("@Total", 0), }; int index = paramList.Length - 1; paramList[index].Direction = ParameterDirection.Output; receive.rows = db.Database.SqlQuery("EXEC meta.p_myApproved @Code,@UserId,@pageIndex,@pageSize,@Total output ", paramList).ToList(); receive.total = int.Parse(paramList[index].Value.ToString()); receive.Code = 200; receive.Message = "SUCCESS"; } } catch (Exception ex) { receive.Code = 500; receive.Message = ex.Message; } return receive; } } public class WorkListModel : WorkList { public string BillCode { get; set; } public string BizDataIds { get; set; } public int ViewType { get; set; } } }