1
duan
2024-08-21 f71a02229c1ba00fbecaead19256593ffb052753
提交 | 用户 | age
5e4ef3 1 using DIXWeb.DAL;
90c6eb 2 using DIXWeb.DataRepository;
J 3 using DIXWeb.Entity.GlobalM;
5e4ef3 4 using DIXWeb.Entity.Workflow;
90c6eb 5 using DIXWeb.Util;
J 6 using System;
7 using System.Collections.Generic;
7b83a6 8 using System.Data;
90c6eb 9 using System.Linq;
J 10 using System.Linq.Dynamic;
5e4ef3 11 using System.Text;
90c6eb 12
J 13 namespace DIXWeb.Business.GlobalM
14 {
15     public class WorkListBusiness : BaseBusiness<WorkList>
16     {
17         #region 外部接口
18
19         /// <summary>
20         /// 获取数据列表
21         /// </summary>
22         /// <param name="condition">查询类型</param>
23         /// <param name="keyword">关键字</param>
24         /// <returns></returns>
25         public List<WorkListModel> GetDataList(int viewType, string subject, string billno, Pagination pagination)
26         {
27             var plist = new List<System.Data.Common.DbParameter>();
28             plist.Add(GlobalDataHelper.NewSqlParameter("@Subject", subject));
29             plist.Add(GlobalDataHelper.NewSqlParameter("@BillNo", billno));
30             plist.Add(GlobalDataHelper.NewSqlParameter("@viewType", viewType));
7b83a6 31             plist.Add(GlobalDataHelper.NewSqlParameter("@UserId", GlobalDataHelper.GetLoginUserNo()));
90c6eb 32             List<WorkListModel> rlist = Service.GetListByProcNew<WorkListModel>("wp_wf_getMyworklist", plist);
7b83a6 33
90c6eb 34             return rlist.GetPagination(pagination).ToList();
J 35         }
7b83a6 36
90c6eb 37         /// <summary>
J 38         /// 获取指定的单条数据
39         /// </summary>
40         /// <param name="id">主键</param>
41         /// <returns></returns>
7b83a6 42         public WorkListModel GetWorkListInst(int btid, string bizdataids)
90c6eb 43         {
J 44             WorkListModel rm = null;
7b83a6 45             List<WorkListModel> rlist = Service.GetListByProcNew<WorkListModel>("wp_wf_getworklist", new List<System.Data.Common.DbParameter>() { new System.Data.SqlClient.SqlParameter("@btid", btid) });
90c6eb 46             if (rlist != null && rlist.Count > 0)
7b83a6 47             {
A 48                 rm = rlist[0];
955cd4 49                 string userindex = GlobalDataHelper.GetLoginUser().Id.ToString().PadLeft(3, '0');
90c6eb 50                 userindex = userindex.Substring(0, 3);
J 51                 if (rm.Id == 0) rm.BillNo = rm.BillCode + userindex + System.DateTime.Now.ToString("yyMMddHHmmssfff");
52             }
53             else rm = new WorkListModel();
54             rm.BizDataIds = bizdataids;
55             return rm;
56         }
57
58         /// <summary>
59         /// 获取指定的单条数据
60         /// </summary>
61         /// <param name="id">主键</param>
62         /// <returns></returns>
7b83a6 63         public WorkListModel GetWorkListInstNew(int instid, string billno, int btid)
90c6eb 64         {
J 65             WorkListModel rm = null;
66             List<WorkListModel> rlist = Service.GetListByProcNew<WorkListModel>("wp_workflow_getworklist", new List<System.Data.Common.DbParameter>()
67             { new System.Data.SqlClient.SqlParameter("@id", instid),
68             new System.Data.SqlClient.SqlParameter("@billno", billno) ,
69             new System.Data.SqlClient.SqlParameter("@btid", btid) });
7b83a6 70             if (rlist != null && rlist.Count > 0)
90c6eb 71             {
J 72                 rm = rlist[0];
73                 if (billno == "")
74                 {
7b83a6 75
955cd4 76                     string userindex = GlobalDataHelper.GetLoginUser().Id.ToString().PadLeft(3, '0');
90c6eb 77                     userindex = userindex.Substring(0, 3);
J 78                     if (rm.Id == 0) rm.BillNo = rm.BillCode + userindex + System.DateTime.Now.ToString("yyMMddHHmmssfff");
79                 }
80             }
7b83a6 81             else rm = new WorkListModel();
90c6eb 82             return rm;
J 83         }
84         void SetupSysInfo(WorkList data, bool isCreate)
85         {
86             if (isCreate)
87             {
88                 data.CreateTime = DateTime.Now;
89                 data.CreateUserId = GlobalDataHelper.GetLoginUserNo();
90             }
7b83a6 91             data.CHtime = DateTime.Now;
90c6eb 92             data.ChUserId = GlobalDataHelper.GetLoginUserNo();
J 93         }
94         /// <summary>
95         /// 添加数据
96         /// </summary>
97         /// <param name="newData">数据</param>
98         public ResultMessage SubmitBill(WorkListModel newData)
99         {
100             SetupSysInfo(newData, true);
101             var plist = new List<System.Data.Common.DbParameter>();
102             plist.Add(GlobalDataHelper.NewSqlParameter("@Subject", newData.Subject));
103             plist.Add(GlobalDataHelper.NewSqlParameter("@BillNo", newData.BillNo));
104             plist.Add(GlobalDataHelper.NewSqlParameter("@BillTypeId", newData.BillTypeId));
7b83a6 105             plist.Add(GlobalDataHelper.NewSqlParameter("@UserId", GlobalDataHelper.GetLoginUserNo()));
90c6eb 106
J 107
108             ResultMessage rm = Service.SubmitDataByProc("wp_worklist_submitbill", plist);
109             return rm;
110         }
7b83a6 111
90c6eb 112         /// <summary>
J 113         /// 添加数据
114         /// </summary>
115         /// <param name="newData">数据</param>
116         public ResultMessage AddData(WorkListModel newData)
117         {
118             SetupSysInfo(newData, true);
119             var plist = new List<System.Data.Common.DbParameter>();
120             plist.Add(GlobalDataHelper.NewSqlParameter("@Subject", newData.Subject));
121             plist.Add(GlobalDataHelper.NewSqlParameter("@BillNo", newData.BillNo));
122             plist.Add(GlobalDataHelper.NewSqlParameter("@BillTypeId", newData.BillTypeId));
7b83a6 123             plist.Add(GlobalDataHelper.NewSqlParameter("@UserId", GlobalDataHelper.GetLoginUserNo()));
90c6eb 124             plist.Add(GlobalDataHelper.NewSqlParameter("@BizDataIds", newData.BizDataIds));
J 125
126
7b83a6 127             ResultMessage rm = Service.SubmitDataByProc("wp_worklist_newdata", plist);
90c6eb 128             return rm;
J 129         }
130
131         /// <summary>
132         /// 更新数据
133         /// </summary>
134         public ResultMessage UpdateData(WorkListModel theData)
135         {
136             SetupSysInfo(theData, false);
137             return null;
138         }
ef7699 139         
90c6eb 140         /// <summary>
J 141         /// 删除数据
142         /// </summary>
143         /// <param name="theData">删除的数据</param>
144         public void DeleteData(List<string> ids)
145         {
146             Delete(ids);
147         }
7b83a6 148         public ResultMessage HandleBill(string ids, int type)
A 149         {
90c6eb 150             ids = string.IsNullOrEmpty(ids) ? "" : ids.Trim();
7b83a6 151             ids = ids.Replace("[", "").Replace("]", "");
90c6eb 152             string[] idarray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
J 153             string sucessids = "", failids = "";
7b83a6 154             int success = 0, fail = 0;
A 155             for (int i = 0; i < idarray.Length; i++)
156             {
90c6eb 157                 var plist = new List<System.Data.Common.DbParameter>();
J 158                 plist.Add(GlobalDataHelper.NewSqlParameter("@id", idarray[i]));
159                 plist.Add(GlobalDataHelper.NewSqlParameter("@type", type));
7b83a6 160                 plist.Add(GlobalDataHelper.NewSqlParameter("@UserId", GlobalDataHelper.GetLoginUserNo()));
90c6eb 161                 ResultMessage rm = Service.SubmitDataByProc("wp_worklist_audit", plist);
J 162                 if (rm.Count > 0) { sucessids += idarray[i] + ","; success += 1; }
163                 else { failids += idarray[i] + ","; fail += 1; }
164             }
7b83a6 165
A 166             return new ResultMessage(1, "执行结果为【成功:" + success.ToString() + "笔,ID分别为:" + sucessids + ";执行失败:" + fail.ToString() + "笔,ID分别为:" + failids + "】");
90c6eb 167         }
J 168         #endregion
169
170         #region 私有成员
171
172         #endregion
173
174         #region 数据模型
175
176         #endregion
5e4ef3 177
A 178
7b83a6 179         public Receive GetMyNeedDealt(string Code, int UserId, int pageIndex = 1, int pageSize = 5)
5e4ef3 180         {
7b83a6 181             Receive receive = new Receive();
A 182             try
5e4ef3 183             {
7b83a6 184                 using (DBContext db = new DBContext())
A 185                 {
186                     System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
187                         new System.Data.SqlClient.SqlParameter("@Code", Code),
188                         new System.Data.SqlClient.SqlParameter("@UserId", UserId),
189                         new System.Data.SqlClient.SqlParameter("@pageIndex", pageIndex),
190                         new System.Data.SqlClient.SqlParameter("@pageSize", pageSize),
191                         new System.Data.SqlClient.SqlParameter("@Total", 0),
192                     };
193                     int index = paramList.Length - 1;
194                     paramList[index].Direction = ParameterDirection.Output;
195                     receive.rows = db.Database.SqlQuery<ReceiveNeedDealt>("EXEC meta.p_myNeedDealt @Code,@UserId,@pageIndex,@pageSize,@Total output ", paramList).ToList();
196                     receive.total = int.Parse(paramList[index].Value.ToString());
197                     receive.Code = 200;
85804c 198                     receive.Message = "SUCCESS"; 
A 199                 }
200             }
201             catch (Exception ex)
202             {
203                 receive.Code = 500;
204                 receive.Message = ex.Message;
205             }
206             return receive;
207         }
208
209         public Receive GetInRepair(string Code, int UserId, int pageIndex = 1, int pageSize = 5)
210         {
211             Receive receive = new Receive();
212             try
213             {
214                 using (DBContext db = new DBContext())
215                 {
216                     System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
217                         new System.Data.SqlClient.SqlParameter("@Code", Code),
218                         new System.Data.SqlClient.SqlParameter("@UserId", UserId),
219                         new System.Data.SqlClient.SqlParameter("@pageIndex", pageIndex),
220                         new System.Data.SqlClient.SqlParameter("@pageSize", pageSize),
221                         new System.Data.SqlClient.SqlParameter("@Total", 0),
222                     };
223                     int index = paramList.Length - 1;
224                     paramList[index].Direction = ParameterDirection.Output;
225                     receive.rows = db.Database.SqlQuery<ReceiveNeedDealt>("EXEC meta.p_myInRepair @Code,@UserId,@pageIndex,@pageSize,@Total output ", paramList).ToList();
226                     receive.total = int.Parse(paramList[index].Value.ToString());
227                     receive.Code = 200;
7b83a6 228                     receive.Message = "SUCCESS";
A 229                 }
5e4ef3 230             }
7b83a6 231             catch (Exception ex)
A 232             {
233                 receive.Code = 500;
234                 receive.Message = ex.Message;
235             }
236             return receive;
5e4ef3 237         }
85804c 238
A 239         public Receive ApproveAgree(int[] BillflowIdArr, int UserId,string Remark,string AppendixUrl)
5e4ef3 240         {
A 241             Receive record = null;
242             StringBuilder sb = new StringBuilder();
243             for (int i = 0; i < BillflowIdArr.Length; i++)
244             {
245                 sb.Append(BillflowIdArr[i] + ",");
246             }
247             using (DBContext db = new DBContext())
248             {
249                 System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
250                     new System.Data.SqlClient.SqlParameter("@BillflowIdStr", sb.ToString()),
251                     new System.Data.SqlClient.SqlParameter("@UserId", UserId),
ef7699 252                     new System.Data.SqlClient.SqlParameter("@Remark", Remark),
85804c 253                     new System.Data.SqlClient.SqlParameter("@AppendixUrl", AppendixUrl),
5e4ef3 254                 };
85804c 255                 record = db.Database.SqlQuery<Receive>("EXEC meta.p_ApproveAgree @BillflowIdStr,@UserId,@Remark,@AppendixUrl ", paramList).FirstOrDefault();
5e4ef3 256             }
A 257             return record;
258         }
259
1bf8ef 260         public Receive ApproveAgreeAll(int UserId, string Remark, string AppendixUrl)
A 261         {
262             Receive record = null;
263             using (DBContext db = new DBContext())
264             {
265                 System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
266                     new System.Data.SqlClient.SqlParameter("@UserId", UserId),
267                     new System.Data.SqlClient.SqlParameter("@Remark", Remark),
268                     new System.Data.SqlClient.SqlParameter("@AppendixUrl", AppendixUrl),
269                 };
270                 record = db.Database.SqlQuery<Receive>("EXEC meta.p_ApproveAgreeAll @UserId,@Remark,@AppendixUrl ", paramList).FirstOrDefault();
271             }
272             return record;
273         }
274
ef7699 275         public Receive ApproveRefuse(int[] BillflowIdArr, int UserId,string Remark)
5e4ef3 276         {
A 277             Receive record = null;
278             StringBuilder sb = new StringBuilder();
279             for (int i = 0; i < BillflowIdArr.Length; i++)
280             {
281                 sb.Append(BillflowIdArr[i] + ",");
282             }
283             using (DBContext db = new DBContext())
284             {
285                 System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
286                     new System.Data.SqlClient.SqlParameter("@BillflowIdStr", sb.ToString()),
287                     new System.Data.SqlClient.SqlParameter("@UserId", UserId),
ef7699 288                     new System.Data.SqlClient.SqlParameter("@Remark", Remark),
5e4ef3 289                 };
ef7699 290                 record = db.Database.SqlQuery<Receive>("EXEC meta.p_ApproveRefuse @BillflowIdStr,@UserId,@Remark ", paramList).FirstOrDefault();
5e4ef3 291             }
A 292             return record;
293         }
ef7699 294         public Receive ApproveKeepRemart(int[] BillflowIdArr, int UserId, string Remark)
A 295         {
296             Receive record = null;
297             StringBuilder sb = new StringBuilder();
298             for (int i = 0; i < BillflowIdArr.Length; i++)
299             {
300                 sb.Append(BillflowIdArr[i] + ",");
301             }
302             using (DBContext db = new DBContext())
303             {
304                 System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
305                     new System.Data.SqlClient.SqlParameter("@BillflowIdStr", sb.ToString()),
306                     new System.Data.SqlClient.SqlParameter("@UserId", UserId),
307                     new System.Data.SqlClient.SqlParameter("@Remark", Remark),
308                 };
309                 record = db.Database.SqlQuery<Receive>("EXEC meta.p_ApproveKeepRemart @BillflowIdStr,@UserId,@Remark ", paramList).FirstOrDefault();
310             }
311             return record;
312         }
5e4ef3 313         public List<ReceiveBillProcess> GetBillProcess(int BillId)
A 314         {
7b83a6 315             List<ReceiveBillProcess> list = null;
5e4ef3 316             using (DBContext db = new DBContext())
A 317             {
318                 System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
319                     new System.Data.SqlClient.SqlParameter("@BillId", BillId),
320                 };
321                 list = db.Database.SqlQuery<ReceiveBillProcess>("EXEC meta.p_getBillProcess @BillId ", paramList).ToList();
322             }
323             return list;
324         }
f50d3c 325
7b83a6 326         public Receive GetMyApproved(string Code, int UserId, int pageIndex = 1, int pageSize = 5)
f50d3c 327         {
7b83a6 328             Receive receive = new Receive();
A 329             try
f50d3c 330             {
7b83a6 331                 using (DBContext db = new DBContext())
A 332                 {
333                     System.Data.SqlClient.SqlParameter[] paramList = new System.Data.SqlClient.SqlParameter[] {
334                         new System.Data.SqlClient.SqlParameter("@Code", Code),
335                         new System.Data.SqlClient.SqlParameter("@UserId", UserId),
336                         new System.Data.SqlClient.SqlParameter("@pageIndex", pageIndex),
337                         new System.Data.SqlClient.SqlParameter("@pageSize", pageSize),
338                         new System.Data.SqlClient.SqlParameter("@Total", 0),
339                     };
340                     int index = paramList.Length - 1;
341                     paramList[index].Direction = ParameterDirection.Output;
342                     receive.rows = db.Database.SqlQuery<ReceiveNeedDealt>("EXEC meta.p_myApproved @Code,@UserId,@pageIndex,@pageSize,@Total output ", paramList).ToList();
343                     receive.total = int.Parse(paramList[index].Value.ToString());
344                     receive.Code = 200;
345                     receive.Message = "SUCCESS";
346                 }
f50d3c 347             }
7b83a6 348             catch (Exception ex)
A 349             {
350                 receive.Code = 500;
351                 receive.Message = ex.Message;
352             }
353             return receive;
f50d3c 354         }
90c6eb 355     }
7b83a6 356     public class WorkListModel : WorkList
A 357     {
358         public string BillCode { get; set; }
90c6eb 359         public string BizDataIds { get; set; }
J 360         public int ViewType { get; set; }
7b83a6 361     }
90c6eb 362 }