GroupStepForDelegation.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. using Google.Protobuf.WellKnownTypes;
  2. using Microsoft.AspNetCore.DataProtection.KeyManagement;
  3. using OASystem.Domain.Common;
  4. using OASystem.Domain.Dtos.Groups;
  5. using OASystem.Domain.Entities.Groups;
  6. using OASystem.Domain.Enums;
  7. using OASystem.Domain.ViewModels.Groups;
  8. using OASystem.Infrastructure.Repositories.Groups;
  9. using System.Configuration;
  10. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  11. namespace OASystem.API.OAMethodLib
  12. {
  13. /// <summary>
  14. /// 团组流程管控
  15. /// </summary>
  16. public static class GroupStepForDelegation
  17. {
  18. private readonly static GrpScheduleRepository _grpScheduleRep = AutofacIocManager.Instance.GetService<GrpScheduleRepository>();
  19. /// <summary>
  20. /// 创建流程管控
  21. /// </summary>
  22. /// <param name="DiId">团组Id</param>
  23. public static async void CreateWorkStep(int DiId)
  24. {
  25. //var _grpScheduleRep = AutofacIocManager.Instance.GetService<GrpScheduleRepository>();
  26. //判断是否已存在团组的流程管控
  27. Grp_ScheduleInfo check = _grpScheduleRep.Query(s => s.DiId == DiId).First();
  28. if (check == null)
  29. {
  30. _grpScheduleRep.BeginTran();
  31. GroupsConfig _groupConfig = AutofacIocManager.Instance.GetService<GroupsConfig>();
  32. DateTime dftBeginDt = DateTime.Now.AddDays(_groupConfig.ExBeginDays);//默认预计开始时间
  33. DateTime dftEndDt = DateTime.Now.AddDays(_groupConfig.ExEndDays);//默认预计结束时间
  34. #region 主流程
  35. Grp_ScheduleInfo _primary = new Grp_ScheduleInfo();
  36. _primary.CreateUserId = _groupConfig.AutoCreate;
  37. _primary.DiId = DiId;
  38. _primary.Exception = 0;
  39. _primary.ExpectBeginDt = dftBeginDt;
  40. _primary.ExpectEndDt = dftEndDt;
  41. _primary.Leader = _groupConfig.Leader;
  42. _primary.PrimaryStep = GrpSchedulePrimaryStepEnum.Wait;
  43. _primary.Remark = "请设置各流程负责人、预计开始/结束时间";
  44. int _primaryId = await _grpScheduleRep.AddAsyncReturnId(_primary);
  45. if (_primaryId > 0)
  46. {
  47. #region 子流程
  48. List<Grp_ScheduleDetailInfo> entityList = new List<Grp_ScheduleDetailInfo>();
  49. #region 模板
  50. Grp_ScheduleDetailInfo _model = new Grp_ScheduleDetailInfo();
  51. _model.CreateUserId = _groupConfig.AutoCreate;
  52. _model.Duty = _groupConfig.DefaultUser;
  53. _model.Exception = 0;
  54. _model.ExpectBeginDt = dftBeginDt;
  55. _model.ExpectEndDt = dftEndDt;
  56. _model.Remark = "未设置负责人";
  57. _model.ScheduleId = _primaryId;
  58. _model.StepStatus = 0;
  59. #endregion
  60. #region 经费预算
  61. Grp_ScheduleDetailInfo grp_budget202 = _model.DeepClone();
  62. grp_budget202.JobContent = GrpSchedulePrimaryStepEnum.BudgetChild02.GetEnumDescription();
  63. grp_budget202.ParentStep = (int)GrpSchedulePrimaryStepEnum.Budget;
  64. grp_budget202.Step = (int)GrpSchedulePrimaryStepEnum.BudgetChild02;
  65. grp_budget202.SLevel = 2;
  66. entityList.Add(grp_budget202);
  67. #endregion
  68. #region 市场部人员报价对接/反馈
  69. //上传明细单
  70. Grp_ScheduleDetailInfo grp_feedback302 = _model.DeepClone();
  71. grp_feedback302.JobContent = GrpSchedulePrimaryStepEnum.FeedbackChild02.GetEnumDescription();
  72. grp_feedback302.ParentStep = (int)GrpSchedulePrimaryStepEnum.Feedback;
  73. grp_feedback302.Step = (int)GrpSchedulePrimaryStepEnum.FeedbackChild02;
  74. grp_feedback302.SLevel = 2;
  75. entityList.Add(grp_feedback302);
  76. //录入最终总经费预算
  77. Grp_ScheduleDetailInfo grp_feedback303 = _model.DeepClone();
  78. grp_feedback303.JobContent = GrpSchedulePrimaryStepEnum.FeedbackChild03.GetEnumDescription();
  79. grp_feedback303.ParentStep = (int)GrpSchedulePrimaryStepEnum.Feedback;
  80. grp_feedback303.Step = (int)GrpSchedulePrimaryStepEnum.FeedbackChild03;
  81. grp_feedback303.SLevel = 2;
  82. entityList.Add(grp_feedback303);
  83. //完成报价对接/反馈
  84. Grp_ScheduleDetailInfo grp_feedback304 = _model.DeepClone();
  85. grp_feedback304.JobContent = GrpSchedulePrimaryStepEnum.FeedbackChild04.GetEnumDescription();
  86. grp_feedback304.ParentStep = (int)GrpSchedulePrimaryStepEnum.Feedback;
  87. grp_feedback304.Step = (int)GrpSchedulePrimaryStepEnum.FeedbackChild04;
  88. grp_feedback304.SLevel = 2;
  89. entityList.Add(grp_feedback304);
  90. #endregion
  91. #region (目前为空)报批流程
  92. #endregion
  93. #region 护照/签证
  94. //收集资料
  95. Grp_ScheduleDetailInfo grp_visa502 = _model.DeepClone();
  96. grp_visa502.JobContent = GrpSchedulePrimaryStepEnum.VisaChild02.GetEnumDescription();
  97. grp_visa502.ParentStep = (int)GrpSchedulePrimaryStepEnum.Visa;
  98. grp_visa502.Step = (int)GrpSchedulePrimaryStepEnum.VisaChild02;
  99. grp_visa502.SLevel = 2;
  100. entityList.Add(grp_visa502);
  101. //取护照资料
  102. Grp_ScheduleDetailInfo grp_visa503 = _model.DeepClone();
  103. grp_visa503.JobContent = GrpSchedulePrimaryStepEnum.VisaChild03.GetEnumDescription();
  104. grp_visa503.ParentStep = (int)GrpSchedulePrimaryStepEnum.Visa;
  105. grp_visa503.Step = (int)GrpSchedulePrimaryStepEnum.VisaChild03;
  106. grp_visa503.SLevel = 2;
  107. entityList.Add(grp_visa503);
  108. //填资料
  109. Grp_ScheduleDetailInfo grp_visa504 = _model.DeepClone();
  110. grp_visa504.JobContent = GrpSchedulePrimaryStepEnum.VisaChild04.GetEnumDescription();
  111. grp_visa504.ParentStep = (int)GrpSchedulePrimaryStepEnum.Visa;
  112. grp_visa504.Step = (int)GrpSchedulePrimaryStepEnum.VisaChild04;
  113. grp_visa504.SLevel = 2;
  114. entityList.Add(grp_visa504);
  115. //送签
  116. Grp_ScheduleDetailInfo grp_visa505 = _model.DeepClone();
  117. grp_visa505.JobContent = GrpSchedulePrimaryStepEnum.VisaChild05.GetEnumDescription();
  118. grp_visa505.ParentStep = (int)GrpSchedulePrimaryStepEnum.Visa;
  119. grp_visa505.Step = (int)GrpSchedulePrimaryStepEnum.VisaChild05;
  120. grp_visa505.SLevel = 2;
  121. entityList.Add(grp_visa505);
  122. //出签+取护照
  123. Grp_ScheduleDetailInfo grp_visa506 = _model.DeepClone();
  124. grp_visa506.JobContent = GrpSchedulePrimaryStepEnum.VisaChild06.GetEnumDescription();
  125. grp_visa506.ParentStep = (int)GrpSchedulePrimaryStepEnum.Visa;
  126. grp_visa506.Step = (int)GrpSchedulePrimaryStepEnum.VisaChild06;
  127. grp_visa506.SLevel = 2;
  128. entityList.Add(grp_visa506);
  129. //归还护照
  130. Grp_ScheduleDetailInfo grp_visa507 = _model.DeepClone();
  131. grp_visa507.JobContent = GrpSchedulePrimaryStepEnum.VisaChild07.GetEnumDescription();
  132. grp_visa507.ParentStep = (int)GrpSchedulePrimaryStepEnum.Visa;
  133. grp_visa507.Step = (int)GrpSchedulePrimaryStepEnum.VisaChild07;
  134. grp_visa507.SLevel = 2;
  135. entityList.Add(grp_visa507);
  136. //签证费用录入
  137. Grp_ScheduleDetailInfo grp_visa508 = _model.DeepClone();
  138. grp_visa508.JobContent = GrpSchedulePrimaryStepEnum.VisaChild08.GetEnumDescription();
  139. grp_visa508.ParentStep = (int)GrpSchedulePrimaryStepEnum.Visa;
  140. grp_visa508.Step = (int)GrpSchedulePrimaryStepEnum.VisaChild08;
  141. grp_visa508.SLevel = 2;
  142. entityList.Add(grp_visa508);
  143. #endregion
  144. #region 业务操作
  145. //机票
  146. Grp_ScheduleDetailInfo grp_busJP601 = _model.DeepClone();
  147. grp_busJP601.JobContent = GrpSchedulePrimaryStepEnum.BusinessJP.GetEnumDescription();
  148. grp_busJP601.ParentStep = (int)GrpSchedulePrimaryStepEnum.Business;
  149. grp_busJP601.Step = (int)GrpSchedulePrimaryStepEnum.BusinessJP;
  150. grp_busJP601.SLevel = 2;
  151. entityList.Add(grp_busJP601);
  152. //机票-询价并导入黑屏代码
  153. Grp_ScheduleDetailInfo grp_busJP6012 = _model.DeepClone();
  154. grp_busJP6012.JobContent = GrpSchedulePrimaryStepEnum.BusinessJPChild02.GetEnumDescription();
  155. grp_busJP6012.ParentStep = (int)GrpSchedulePrimaryStepEnum.BusinessJP;
  156. grp_busJP6012.Step = (int)GrpSchedulePrimaryStepEnum.BusinessJPChild02;
  157. grp_busJP6012.SLevel = 3;
  158. entityList.Add(grp_busJP6012);
  159. //机票-机票已占位
  160. Grp_ScheduleDetailInfo grp_busJP6013 = _model.DeepClone();
  161. grp_busJP6013.JobContent = GrpSchedulePrimaryStepEnum.BusinessJPChild03.GetEnumDescription();
  162. grp_busJP6013.ParentStep = (int)GrpSchedulePrimaryStepEnum.BusinessJP;
  163. grp_busJP6013.Step = (int)GrpSchedulePrimaryStepEnum.BusinessJPChild03;
  164. grp_busJP6013.SLevel = 3;
  165. entityList.Add(grp_busJP6013);
  166. //机票-已出票
  167. Grp_ScheduleDetailInfo grp_busJP6014 = _model.DeepClone();
  168. grp_busJP6014.JobContent = GrpSchedulePrimaryStepEnum.BusinessJPChild04.GetEnumDescription();
  169. grp_busJP6014.ParentStep = (int)GrpSchedulePrimaryStepEnum.BusinessJP;
  170. grp_busJP6014.Step = (int)GrpSchedulePrimaryStepEnum.BusinessJPChild04;
  171. grp_busJP6014.SLevel = 3;
  172. entityList.Add(grp_busJP6014);
  173. //机票-机票费用录入
  174. Grp_ScheduleDetailInfo grp_busJP6015 = _model.DeepClone();
  175. grp_busJP6015.JobContent = GrpSchedulePrimaryStepEnum.BusinessJPChild05.GetEnumDescription();
  176. grp_busJP6015.ParentStep = (int)GrpSchedulePrimaryStepEnum.BusinessJP;
  177. grp_busJP6015.Step = (int)GrpSchedulePrimaryStepEnum.BusinessJPChild05;
  178. grp_busJP6015.SLevel = 3;
  179. entityList.Add(grp_busJP6015);
  180. //酒店
  181. Grp_ScheduleDetailInfo grp_busJD602 = _model.DeepClone();
  182. grp_busJD602.JobContent = GrpSchedulePrimaryStepEnum.BusinessJD.GetEnumDescription();
  183. grp_busJD602.ParentStep = (int)GrpSchedulePrimaryStepEnum.Business;
  184. grp_busJD602.Step = (int)GrpSchedulePrimaryStepEnum.BusinessJD;
  185. grp_busJD602.SLevel = 2;
  186. entityList.Add(grp_busJD602);
  187. //酒店-酒店费用录入
  188. Grp_ScheduleDetailInfo grp_busJD6022 = _model.DeepClone();
  189. grp_busJD6022.JobContent = GrpSchedulePrimaryStepEnum.BusinessJDChild02.GetEnumDescription();
  190. grp_busJD6022.ParentStep = (int)GrpSchedulePrimaryStepEnum.BusinessJD;
  191. grp_busJD6022.Step = (int)GrpSchedulePrimaryStepEnum.BusinessJDChild02;
  192. grp_busJD6022.SLevel = 3;
  193. entityList.Add(grp_busJD6022);
  194. //OP
  195. Grp_ScheduleDetailInfo grp_busOP603 = _model.DeepClone();
  196. grp_busOP603.JobContent = GrpSchedulePrimaryStepEnum.BusinessOP.GetEnumDescription();
  197. grp_busOP603.ParentStep = (int)GrpSchedulePrimaryStepEnum.Business;
  198. grp_busOP603.Step = (int)GrpSchedulePrimaryStepEnum.BusinessOP;
  199. grp_busOP603.SLevel = 2;
  200. entityList.Add(grp_busOP603);
  201. //OP-OP询价
  202. Grp_ScheduleDetailInfo grp_busOP6032 = _model.DeepClone();
  203. grp_busOP6032.JobContent = GrpSchedulePrimaryStepEnum.BusinessOPChild02.GetEnumDescription();
  204. grp_busOP6032.ParentStep = (int)GrpSchedulePrimaryStepEnum.BusinessOP;
  205. grp_busOP6032.Step = (int)GrpSchedulePrimaryStepEnum.BusinessOPChild02;
  206. grp_busOP6032.SLevel = 3;
  207. entityList.Add(grp_busOP6032);
  208. //OP-OP费用录入
  209. Grp_ScheduleDetailInfo grp_busOP6033 = _model.DeepClone();
  210. grp_busOP6033.JobContent = GrpSchedulePrimaryStepEnum.BusinessOPChild03.GetEnumDescription();
  211. grp_busOP6033.ParentStep = (int)GrpSchedulePrimaryStepEnum.BusinessOP;
  212. grp_busOP6033.Step = (int)GrpSchedulePrimaryStepEnum.BusinessOPChild03;
  213. grp_busOP6033.SLevel = 3;
  214. entityList.Add(grp_busOP6032);
  215. //商邀
  216. Grp_ScheduleDetailInfo grp_busSY604 = _model.DeepClone();
  217. grp_busSY604.JobContent = GrpSchedulePrimaryStepEnum.BusinessSY.GetEnumDescription();
  218. grp_busSY604.ParentStep = (int)GrpSchedulePrimaryStepEnum.Business;
  219. grp_busSY604.Step = (int)GrpSchedulePrimaryStepEnum.BusinessSY;
  220. grp_busSY604.SLevel = 2;
  221. entityList.Add(grp_busSY604);
  222. //商邀-商邀报批
  223. Grp_ScheduleDetailInfo grp_busSY6042 = _model.DeepClone();
  224. grp_busSY6042.JobContent = GrpSchedulePrimaryStepEnum.BusinessSYChild02.GetEnumDescription();
  225. grp_busSY6042.ParentStep = (int)GrpSchedulePrimaryStepEnum.BusinessSY;
  226. grp_busSY6042.Step = (int)GrpSchedulePrimaryStepEnum.BusinessSYChild02;
  227. grp_busSY6042.SLevel = 3;
  228. entityList.Add(grp_busSY6042);
  229. //商邀-商邀费用录入
  230. Grp_ScheduleDetailInfo grp_busSY6043 = _model.DeepClone();
  231. grp_busSY6043.JobContent = GrpSchedulePrimaryStepEnum.BusinessSYChild03.GetEnumDescription();
  232. grp_busSY6043.ParentStep = (int)GrpSchedulePrimaryStepEnum.BusinessSY;
  233. grp_busSY6043.Step = (int)GrpSchedulePrimaryStepEnum.BusinessSYChild03;
  234. grp_busSY6043.SLevel = 3;
  235. entityList.Add(grp_busSY6043);
  236. #endregion
  237. #region 费用审批
  238. //机票费用审批
  239. Grp_ScheduleDetailInfo grp_cost702 = _model.DeepClone();
  240. grp_cost702.JobContent = GrpSchedulePrimaryStepEnum.CostAuditChild02.GetEnumDescription();
  241. grp_cost702.ParentStep = (int)GrpSchedulePrimaryStepEnum.CostAudit;
  242. grp_cost702.Step = (int)GrpSchedulePrimaryStepEnum.CostAuditChild02;
  243. grp_cost702.Duty = _groupConfig.Boss;
  244. grp_cost702.SLevel = 2;
  245. entityList.Add(grp_cost702);
  246. //酒店费用审批
  247. Grp_ScheduleDetailInfo grp_cost703 = _model.DeepClone();
  248. grp_cost703.JobContent = GrpSchedulePrimaryStepEnum.CostAuditChild03.GetEnumDescription();
  249. grp_cost703.ParentStep = (int)GrpSchedulePrimaryStepEnum.CostAudit;
  250. grp_cost703.Step = (int)GrpSchedulePrimaryStepEnum.CostAuditChild03;
  251. grp_cost703.Duty = _groupConfig.Boss;
  252. grp_cost703.SLevel = 2;
  253. entityList.Add(grp_cost703);
  254. //OP费用审批
  255. Grp_ScheduleDetailInfo grp_cost704 = _model.DeepClone();
  256. grp_cost704.JobContent = GrpSchedulePrimaryStepEnum.CostAuditChild04.GetEnumDescription();
  257. grp_cost704.ParentStep = (int)GrpSchedulePrimaryStepEnum.CostAudit;
  258. grp_cost704.Step = (int)GrpSchedulePrimaryStepEnum.CostAuditChild04;
  259. grp_cost704.Duty = _groupConfig.Boss;
  260. grp_cost704.SLevel = 2;
  261. entityList.Add(grp_cost704);
  262. //OP费用审批
  263. Grp_ScheduleDetailInfo grp_cost705 = _model.DeepClone();
  264. grp_cost705.JobContent = GrpSchedulePrimaryStepEnum.CostAuditChild05.GetEnumDescription();
  265. grp_cost705.ParentStep = (int)GrpSchedulePrimaryStepEnum.CostAudit;
  266. grp_cost705.Step = (int)GrpSchedulePrimaryStepEnum.CostAuditChild05;
  267. grp_cost705.Duty = _groupConfig.Boss;
  268. grp_cost705.SLevel = 2;
  269. entityList.Add(grp_cost705);
  270. //增减款项审批
  271. Grp_ScheduleDetailInfo grp_cost706 = _model.DeepClone();
  272. grp_cost706.JobContent = GrpSchedulePrimaryStepEnum.CostAuditChild06.GetEnumDescription();
  273. grp_cost706.ParentStep = (int)GrpSchedulePrimaryStepEnum.CostAudit;
  274. grp_cost706.Step = (int)GrpSchedulePrimaryStepEnum.CostAuditChild06;
  275. grp_cost706.Duty = _groupConfig.Boss;
  276. grp_cost706.SLevel = 2;
  277. entityList.Add(grp_cost706);
  278. #endregion
  279. #region 付款给供应商
  280. //OP费用付款
  281. Grp_ScheduleDetailInfo grp_pay802 = _model.DeepClone();
  282. grp_pay802.JobContent = GrpSchedulePrimaryStepEnum.PayChild02.GetEnumDescription();
  283. grp_pay802.ParentStep = (int)GrpSchedulePrimaryStepEnum.Pay;
  284. grp_pay802.Step = (int)GrpSchedulePrimaryStepEnum.PayChild02;
  285. grp_pay802.SLevel = 2;
  286. entityList.Add(grp_pay802);
  287. //商邀费用付款
  288. Grp_ScheduleDetailInfo grp_pay803 = _model.DeepClone();
  289. grp_pay803.JobContent = GrpSchedulePrimaryStepEnum.PayChild03.GetEnumDescription();
  290. grp_pay803.ParentStep = (int)GrpSchedulePrimaryStepEnum.Pay;
  291. grp_pay803.Step = (int)GrpSchedulePrimaryStepEnum.PayChild03;
  292. grp_pay803.SLevel = 2;
  293. entityList.Add(grp_pay803);
  294. //增减款项付款
  295. Grp_ScheduleDetailInfo grp_pay804 = _model.DeepClone();
  296. grp_pay804.JobContent = GrpSchedulePrimaryStepEnum.PayChild04.GetEnumDescription();
  297. grp_pay804.ParentStep = (int)GrpSchedulePrimaryStepEnum.Pay;
  298. grp_pay804.Step = (int)GrpSchedulePrimaryStepEnum.PayChild04;
  299. grp_pay804.SLevel = 2;
  300. entityList.Add(grp_pay804);
  301. #endregion
  302. #region (目前为空)出行事项会议
  303. #endregion
  304. #region (目前为空)送机
  305. #endregion
  306. #region (目前为空)接机
  307. #endregion
  308. #region 收款
  309. //收款完成
  310. Grp_ScheduleDetailInfo grp_col01 = _model.DeepClone();
  311. grp_col01.JobContent = GrpSchedulePrimaryStepEnum.CollectChild01.GetEnumDescription();
  312. grp_col01.ParentStep = (int)GrpSchedulePrimaryStepEnum.Collect;
  313. grp_col01.Step = (int)GrpSchedulePrimaryStepEnum.CollectChild01;
  314. grp_col01.ExpectBeginDt = dftEndDt;
  315. grp_col01.ExpectEndDt = dftEndDt.AddMonths(3);
  316. grp_col01.SLevel = 2;
  317. entityList.Add(grp_col01);
  318. #endregion
  319. #region (目前为空)团组完成
  320. #endregion
  321. //SqlSugar批量添加
  322. _grpScheduleRep.bulkInsert(entityList);
  323. #endregion
  324. #region 流程管控成员
  325. string sqlPerson = string.Format(@"Select u.Id As SysUserId,u.CnName As SysUserName,JobName as JobStr
  326. From Sys_Users As u With(Nolock)
  327. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id
  328. Inner Join Sys_JobPost as j With(Nolock) On u.JobPostId=j.Id
  329. Where d.Id={0} And u.Id not in({1})", DepartmentCode.IC, _groupConfig.FilterUser);
  330. List<Grp_SchedulePersonInfo> personList = await _grpScheduleRep.GetEntityList_SchedulePersonBySql(sqlPerson);
  331. if (personList.Count > 0)
  332. {
  333. foreach (var item in personList)
  334. {
  335. item.CreateUserId = _groupConfig.DefaultUser;
  336. item.ScheduleId = _primaryId;
  337. }
  338. _grpScheduleRep.bulkInsert(personList);
  339. }
  340. #endregion
  341. }
  342. else
  343. {
  344. _grpScheduleRep.RollbackTran();
  345. }
  346. #endregion
  347. _grpScheduleRep.CommitTran();
  348. }
  349. }
  350. public static async void ChangeStepForPrimary(int DiId, GrpSchedulePrimaryStepEnum primary, int isDel, int exception, string remark)
  351. {
  352. //var _grpScheduleRep = AutofacIocManager.Instance.GetService<GrpScheduleRepository>();
  353. string sqlPrimary = string.Format(@" Select * From Grp_Schedule With(Nolock) Where IsDel=0 And DiId={0} ", DiId);
  354. Grp_ScheduleInfo _grpPrimaryInfo = _grpScheduleRep.GetSingleInfoBySqlWithNolock(sqlPrimary);
  355. if (_grpPrimaryInfo != null)
  356. {
  357. _grpPrimaryInfo.PrimaryStep = primary;
  358. _grpPrimaryInfo.IsDel = isDel;
  359. _grpPrimaryInfo.Exception = exception;
  360. _grpPrimaryInfo.Remark += ";" + remark;
  361. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleInfo>()
  362. .Where(s => s.Id == _grpPrimaryInfo.Id)
  363. .UpdateColumns(s => new { s.PrimaryStep, s.IsDel, s.Exception, s.Remark })
  364. .ExecuteCommandAsync();
  365. }
  366. }
  367. #region 流程管控步骤推进
  368. /// <summary>
  369. /// 刷新团组管控最新状态,或推进流程到下一节点
  370. /// </summary>
  371. /// <param name="scheduleId">团组流程Id</param>
  372. public static async void RefreshWorkStep(int scheduleId, bool auto = false)
  373. {
  374. //var _grpScheduleRep = AutofacIocManager.Instance.GetService<GrpScheduleRepository>();
  375. string sqlPrimary = string.Format(@" Select * From Grp_Schedule With(Nolock) Where IsDel=0 And Id={0} ", scheduleId);
  376. Grp_ScheduleInfo _grpPrimaryInfo = _grpScheduleRep.GetSingleInfoBySqlWithNolock(sqlPrimary);
  377. if (_grpPrimaryInfo != null)
  378. {
  379. List<Grp_ScheduleDetailInfo> _list = _grpScheduleRep._sqlSugar.Queryable<Grp_ScheduleDetailInfo>()
  380. .Where(s => s.ScheduleId == scheduleId && s.IsDel != 1 && s.ParentStep == (int)_grpPrimaryInfo.PrimaryStep && s.StepStatus != 2)
  381. .ToList();
  382. if (_list.Count > 0)
  383. {
  384. //未完成主流程节点下所有步骤任务
  385. }
  386. else
  387. {
  388. //可推进节点
  389. if (auto)
  390. {
  391. int nextPrimaryStep = (int)_grpPrimaryInfo.PrimaryStep + 1;
  392. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleInfo>()
  393. .Where(s => s.Id == _grpPrimaryInfo.Id)
  394. .UpdateColumns(s => new { nextPrimaryStep })
  395. .ExecuteCommandAsync();
  396. }
  397. }
  398. //eg:CheckStep_Budget
  399. //switch (_grpPrimaryInfo.PrimaryStep)
  400. //{
  401. // case GrpSchedulePrimaryStepEnum.Budget: CheckStep_Budget(scheduleId); break;
  402. //}
  403. }
  404. }
  405. /// <summary>
  406. /// 暂无需求,先保存,可扩展至查询验证主流程下每一个详细流程步骤对应的业务操作是否完成,需要其他业务提供验证方法
  407. /// 查看流程-经费预算
  408. /// </summary>
  409. /// <param name="scheduleId"></param>
  410. /// <returns>true:已完成所有步骤,false:存在未完成的步骤(Grp_ScheduleDetail.StepStatus:0/1/2)</returns>
  411. private static bool CheckStep_Budget(int scheduleId)
  412. {
  413. List<Grp_ScheduleDetailInfo> _list = _grpScheduleRep._sqlSugar.Queryable<Grp_ScheduleDetailInfo>()
  414. .Where(s => s.ScheduleId == scheduleId && s.IsDel != 1 && s.ParentStep == (int)GrpSchedulePrimaryStepEnum.Budget)
  415. .ToList();
  416. foreach (var item in _list)
  417. {
  418. switch (item.Step)
  419. {
  420. case (int)GrpSchedulePrimaryStepEnum.BudgetChild01:
  421. //验证方法
  422. break;
  423. case (int)GrpSchedulePrimaryStepEnum.BudgetChild02: break;
  424. }
  425. }
  426. return false;
  427. }
  428. #endregion
  429. }
  430. }