GroupStepForDelegation.cs 25 KB

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