足力健后端,使用.netcore版本,合并1个项目使用

TaskManagementController.cs 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Common;
  4. using System.Common.Helpers;
  5. using System.Data;
  6. using System.IRepositories;
  7. using System.Linq;
  8. using System.Model;
  9. using System.Security.Claims;
  10. using System.Threading.Tasks;
  11. using Microsoft.AspNetCore.Mvc;
  12. using SqlSugar;
  13. using TVShoppingCallCenter_ZLJ.Models.Inputs;
  14. namespace TVShoppingCallCenter_ZLJ.Controllers.TaskManagement
  15. {
  16. [Produces("application/json")]
  17. [Route("api/[controller]")]
  18. public class TaskManagementController : BaseController
  19. {
  20. private readonly ISys_UserAccountRepository _sys_useraccountRepository;
  21. private readonly ISys_TaskManagementRepository _sys_taskmanagement_Repository;
  22. private readonly ISys_DepartmentRepository _sys_departmentRepository;
  23. public TaskManagementController(ISys_TaskManagementRepository sys_taskmanagement_Repository, ISys_DepartmentRepository sys_departmentRepository,
  24. ISys_UserAccountRepository sys_useraccountRepository)
  25. {
  26. _sys_taskmanagement_Repository = sys_taskmanagement_Repository;
  27. _sys_departmentRepository = sys_departmentRepository;
  28. _sys_useraccountRepository = sys_useraccountRepository;
  29. }
  30. /// <summary>
  31. /// 添加任务
  32. /// </summary>
  33. /// <param name="input"></param>
  34. /// <returns></returns>
  35. [HttpPost("add")]
  36. public async Task<IActionResult> AddAsync(T_Sys_TaskManagement input)
  37. {
  38. if (string.IsNullOrEmpty(input.F_Name))
  39. return Error("请输入任务名称");
  40. if (string.IsNullOrEmpty(input.F_Content))
  41. return Error("请输入任务内容");
  42. if (input.F_StartTime == null)
  43. return Error("请选择任务开始时间");
  44. if (input.F_EndTime == null)
  45. return Error("请选择任务结束时间");
  46. if (input.F_Type < 0)
  47. return Error("请选择任务类型");
  48. if (string .IsNullOrEmpty (input .F_Deptid ))
  49. return Error("请选择任务部门");
  50. if (input.F_Money < 0)
  51. return Error("请输入目标金额");
  52. // string user = "8000";
  53. if (input.F_Remindertime == null)
  54. input.F_Remindertime = input.F_EndTime.Value.AddDays(-3);
  55. if (input.F_Currentamount > 0)
  56. input.F_Taskprogress = string.Format("{0:f2}", input.F_Currentamount / input.F_Money * 100);
  57. else
  58. input.F_Taskprogress = "0";
  59. string user = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
  60. input.F_CreateTime = DateTime.Now;
  61. input.F_CreateUser = user;
  62. input.F_IsDelete = 0;
  63. var res = await _sys_taskmanagement_Repository.Add(input);
  64. if (res > 0)
  65. {
  66. return Success("添加成功");
  67. }
  68. else
  69. {
  70. return Error("添加失败");
  71. }
  72. }
  73. /// <summary>
  74. /// 修改任务
  75. /// </summary>
  76. [HttpPost("update")]
  77. public async Task<IActionResult> UpdateAsync(T_Sys_TaskManagement input)
  78. {
  79. if (input.F_ID <= 0)
  80. return Error("参数错误");
  81. if (string.IsNullOrEmpty(input.F_Name))
  82. return Error("请输入任务名称");
  83. if (string.IsNullOrEmpty(input.F_Content))
  84. return Error("请输入任务内容");
  85. if (input.F_StartTime == null)
  86. return Error("请选择任务开始时间");
  87. if (input.F_EndTime == null)
  88. return Error("请选择任务结束时间");
  89. if (input.F_Type < 0)
  90. return Error("请选择任务类型");
  91. if (string.IsNullOrEmpty(input.F_Deptid))
  92. return Error("请选择任务部门");
  93. if (input.F_Money < 0)
  94. return Error("请输入目标金额");
  95. var model = await _sys_taskmanagement_Repository.GetSingle(x => x.F_ID == input.F_ID);
  96. if (model == null)
  97. return Error("操作失败");
  98. if (input.F_Remindertime == null)
  99. input.F_Remindertime = input.F_EndTime.Value.AddDays(-3);
  100. if (input.F_Currentamount > 0)
  101. input.F_Taskprogress = string.Format("{0:f2}", input.F_Currentamount / input.F_Money * 100);
  102. else
  103. input.F_Taskprogress = "0";
  104. // string user = "8000";
  105. string user = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
  106. input.F_IsDelete = 0;
  107. input.F_CreateUser = model.F_CreateUser;
  108. input.F_CreateTime = model.F_CreateTime ;
  109. input.F_UpdateTime = DateTime.Now;
  110. input.F_UpdateUser = user;
  111. // model.F_UpdateUser = "8000";
  112. var b = await _sys_taskmanagement_Repository.Update(input);
  113. if (b)
  114. return Success("修改成功");
  115. return Error("修改失败");
  116. }
  117. /// <summary>
  118. /// 删除任务
  119. /// </summary>
  120. /// <param name="ids"></param>
  121. /// <returns></returns>
  122. [HttpPost("delete")]
  123. public async Task<IActionResult> Remove(int[] ids)
  124. {
  125. var res = 0;
  126. if (ids != null && ids.Length > 0)
  127. {
  128. foreach (var item in ids)
  129. {
  130. var model = await _sys_taskmanagement_Repository.GetSingle(x => x.F_ID == item);
  131. model.F_IsDelete = (int)EnumUserCountState.Delete;
  132. model.F_DeleteTime = DateTime.Now.ToLocalTime();
  133. model.F_DeleteUser = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
  134. if (_sys_taskmanagement_Repository.Update(model).Result)
  135. res += 1;
  136. }
  137. if (res == ids.Length)
  138. return Success("删除成功");
  139. else if (res > 0 && res < ids.Length)
  140. return Error("部分删除失败,请查看后重新操作");
  141. else
  142. return Error("删除失败,请查看后重新操作");
  143. }
  144. else
  145. return Error("请选择要删除的记录");
  146. }
  147. /// <summary>
  148. /// 操作任务
  149. /// </summary>
  150. /// <param name="id">id</param>
  151. /// <returns></returns>
  152. [HttpGet("operation")]
  153. public async Task<IActionResult> GetOperationAsync(int id, int state)
  154. {
  155. if (id <= 0)
  156. return Error("参数错误");
  157. var model = await _sys_taskmanagement_Repository.GetSingle(x => x.F_ID == id);
  158. if (model == null)
  159. {
  160. return Error("获取失败");
  161. }
  162. model.F_State = state;
  163. var obj = await _sys_taskmanagement_Repository.Update(model);
  164. if (obj)
  165. return Success("操作成功");
  166. else
  167. return Error("操作失败");
  168. }
  169. /// <summary>
  170. /// 获取任务列表
  171. /// </summary>
  172. /// <param name="keyword"></param>
  173. /// <param name="pageindex"></param>
  174. /// <param name="pagesize"></param>
  175. /// <returns></returns>
  176. [HttpGet("getlist")]
  177. public async Task<IActionResult> GetListMark(string keyword, string name,string parentname, string starttime, string endtime, string tasker,
  178. string deptid , int parentid=0,int type = -1, int pageindex = 1, int pagesize = 20)
  179. {
  180. List<IConditionalModel> conModels = new List<IConditionalModel>();
  181. #region 条件筛选
  182. conModels.Add(new ConditionalModel() { FieldName = "F_IsDelete", ConditionalType = ConditionalType.Equal, FieldValue = ((int)EnumUserCountState.Enabled).ToString() });
  183. if (!string.IsNullOrEmpty(name))
  184. {
  185. conModels.Add(new ConditionalModel() { FieldName = "F_Name", ConditionalType = ConditionalType.Like, FieldValue = name });
  186. }
  187. if (!string.IsNullOrEmpty(tasker))
  188. {
  189. if (_sys_useraccountRepository .GetSingle(x => x.F_UserName == tasker).Result != null)
  190. {
  191. conModels.Add(new ConditionalModel() { FieldName = "F_Tasker", ConditionalType = ConditionalType.Like, FieldValue = _sys_useraccountRepository.GetSingle(x => x.F_UserName == tasker).Result.F_UserId .ToString () });
  192. }
  193. else
  194. {
  195. return Error("请输入正确的任务人");
  196. }
  197. }
  198. if (!string.IsNullOrEmpty(parentname))
  199. {
  200. if (_sys_taskmanagement_Repository.GetSingle (x=>x .F_Name == parentname).Result!=null )
  201. {
  202. conModels.Add(new ConditionalModel() { FieldName = "F_Parentid", ConditionalType = ConditionalType.Like, FieldValue = _sys_taskmanagement_Repository.GetSingle(x => x.F_Name == parentname).Result.F_ID .ToString () });
  203. }
  204. else
  205. {
  206. return Error("请输入正确的父级任务名称");
  207. }
  208. }
  209. if (type > -1)
  210. {
  211. conModels.Add(new ConditionalModel() { FieldName = "F_Type", ConditionalType = ConditionalType.Like, FieldValue = type.ToString() });
  212. }
  213. conModels.Add(new ConditionalModel() { FieldName = "F_Parentid", ConditionalType = ConditionalType.Equal , FieldValue = parentid.ToString() });
  214. if (!string.IsNullOrEmpty(keyword))
  215. {
  216. conModels.Add(new ConditionalCollections()
  217. {
  218. ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
  219. {
  220. new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel() { FieldName = "F_Name", ConditionalType = ConditionalType.Like, FieldValue = keyword }),
  221. new KeyValuePair<WhereType, ConditionalModel>( WhereType.Or , new ConditionalModel() { FieldName = "F_Content", ConditionalType = ConditionalType.Like, FieldValue = keyword })
  222. }
  223. });
  224. }
  225. if (!string.IsNullOrEmpty(starttime))
  226. {
  227. conModels.Add(new ConditionalModel() { FieldName = "F_StartTime", ConditionalType = ConditionalType.GreaterThanOrEqual, FieldValue = starttime });
  228. }
  229. if (!string.IsNullOrEmpty(endtime))
  230. {
  231. conModels.Add(new ConditionalModel() { FieldName = "F_EndTime", ConditionalType = ConditionalType.LessThanOrEqual, FieldValue = endtime });
  232. }
  233. string user = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
  234. var dept = _sys_useraccountRepository.GetSingle(x => x.F_UserCode == user).Result != null ? _sys_useraccountRepository.GetSingle(x => x.F_UserCode == user).Result.F_DeptId : 0;
  235. if (!string .IsNullOrEmpty (deptid))
  236. {
  237. conModels.Add(new ConditionalModel() { FieldName = "F_Deptid", ConditionalType = ConditionalType.Equal, FieldValue = deptid });
  238. }
  239. else
  240. {
  241. conModels.Add(new ConditionalModel() { FieldName = "F_CreateUser", ConditionalType = ConditionalType.Equal , FieldValue = user });
  242. new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel() { FieldName = "F_Deptid", ConditionalType = ConditionalType.Like, FieldValue = dept.ToString() });
  243. }
  244. #endregion
  245. int recordCount = 0;
  246. var list = await _sys_taskmanagement_Repository.GetListByPage(conModels, new MyPageModel() { PageIndex = pageindex, PageSize = pagesize, PageCount = recordCount });
  247. var obj = new
  248. {
  249. state = "success",
  250. message = "成功",
  251. rows = ConvertAsync(list.Rows ),
  252. total = list.Totals,
  253. };
  254. return Content(obj.ToJson());
  255. }
  256. /// <summary>
  257. /// 获取任务详情
  258. /// </summary>
  259. /// <param name="id">id</param>
  260. /// <returns></returns>
  261. [HttpGet("getdetails")]
  262. public async Task<IActionResult> GetDetailsAsync(int id)
  263. {
  264. if (id <= 0)
  265. return Error("参数错误");
  266. var model = await _sys_taskmanagement_Repository.GetSingle(x => x.F_ID == id);
  267. if (model == null)
  268. {
  269. return Error("获取失败");
  270. }
  271. return Success("获取成功!", Convert(model, 1));
  272. }
  273. /// <summary>
  274. /// 修改任务当前金额
  275. /// </summary>
  276. /// <param name="id"></param>
  277. /// <param name="money"></param>
  278. /// <returns></returns>
  279. public int UpdateTaskAmount(T_Bus_Order t_Bus_Order )
  280. {
  281. //0成功1任务暂停2任务终止3修改任务金额失败4任务不存在5父级任务不存在6父级任务修改失败7父级任务暂停8父级任务终止
  282. int n = 0;
  283. var model = _sys_taskmanagement_Repository.GetListALL (x => x.F_Tasker == t_Bus_Order.F_AddUser&& x.F_IsDelete ==0);
  284. if (model == null)
  285. return 4;
  286. foreach (var it in model.Result )
  287. {
  288. if (it.F_State == 0)
  289. {
  290. it.F_Currentamount +=(float ) t_Bus_Order.F_RealPrice;
  291. it.F_Taskprogress = string.Format("{0:f2}", it.F_Currentamount / it.F_Money * 100);
  292. var res = _sys_taskmanagement_Repository.Update(it);
  293. if (!res.Result)
  294. return 3;
  295. if (it.F_Parentid > 0)
  296. {
  297. n = TreeRecursion(it.F_Parentid, (float)t_Bus_Order.F_RealPrice);
  298. }
  299. }
  300. else
  301. n = (int)it .F_State;
  302. }
  303. return n;
  304. }
  305. /// <summary>
  306. /// 递归算法
  307. /// </summary>
  308. /// <param name="data"></param>
  309. /// <param name="parentId"></param>
  310. /// <returns></returns>
  311. private int TreeRecursion( int parentId = 0,float money=0)
  312. {
  313. int n = 0;
  314. var model = _sys_taskmanagement_Repository.GetSingle(x => x.F_ID == parentId).Result;
  315. if (model == null)
  316. return 5;
  317. if (model.F_State == 0)
  318. {
  319. model.F_Currentamount += money;
  320. model.F_Taskprogress = string.Format("{0:f2}", model.F_Currentamount / model.F_Money * 100);
  321. var res = _sys_taskmanagement_Repository.Update(model);
  322. if (!res.Result)
  323. return 6;
  324. if (model.F_Parentid > 0)
  325. {
  326. n = TreeRecursion(model.F_Parentid, money);
  327. }
  328. }
  329. else
  330. n = (int)model.F_State+6;
  331. return n;
  332. }
  333. /// <summary>
  334. /// 上传文件并导入数据库
  335. /// </summary>
  336. /// <returns></returns>
  337. [HttpPost("importexcel")]
  338. public async Task<IActionResult> ImportExcel(int headrow = 0,int parentid=0)
  339. {
  340. Microsoft.AspNetCore.Http.IFormFile _upfile = Request.Form.Files[0];
  341. if (!_upfile.ContentType.Equals("application/vnd.ms-excel") && !_upfile.ContentType.Equals("application/x-xls") && !_upfile.ContentType.Equals("application/x-xlsx") && !_upfile.ContentType.Equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") && !_upfile.ContentType.Equals("application/octet-stream"))
  342. return Error($"请正确上传Excel文件:file.ContentType={_upfile.ContentType}");
  343. NPOIHelper npoi = new NPOIHelper();
  344. var dtExcel = npoi.ExcelToTable1(_upfile, headrow);
  345. int num = dtExcel.Rows.Count;
  346. var cols = dtExcel.Columns;
  347. int colnum = cols.Count;
  348. string errmsg = string.Empty;
  349. if (num > 0)
  350. {
  351. int index = 1;
  352. foreach (DataRow dr in dtExcel.Rows)
  353. {
  354. var model = new T_Sys_TaskManagement();
  355. string user = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
  356. model.F_Name = dr["任务名称"].ToString();
  357. model.F_Content = dr["任务内容"].ToString();
  358. if (string .IsNullOrEmpty (dr["任务开始时间"].ToString()))
  359. {
  360. errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入任务开始时间";
  361. continue;
  362. }
  363. if (string.IsNullOrEmpty(dr["任务结束时间"].ToString()))
  364. {
  365. errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入任务结束时间";
  366. continue;
  367. }
  368. if (string.IsNullOrEmpty(dr["目标金额"].ToString()))
  369. {
  370. errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入目标金额";
  371. continue;
  372. }
  373. try
  374. {
  375. model.F_StartTime = DateTime.Parse(dr["任务开始时间"].ToString());
  376. }
  377. catch
  378. {
  379. errmsg = errmsg + "\r\n第" + index + "行导入失败!任务开始时间格式错误";
  380. continue;
  381. }
  382. try
  383. {
  384. model.F_EndTime = DateTime.Parse(dr["任务结束时间"].ToString());
  385. }
  386. catch
  387. {
  388. errmsg = errmsg + "\r\n第" + index + "行导入失败!任务结束时间格式错误";
  389. continue;
  390. }
  391. if (dr["任务类型"].ToString() == "月")
  392. model.F_Type = 2;
  393. else if (dr["任务类型"].ToString() == "周")
  394. model.F_Type = 1;
  395. else
  396. model.F_Type = 0;
  397. if (_sys_departmentRepository.GetSingle(x => x.F_DeptName == dr["任务部门"].ToString()).Result !=null )
  398. {
  399. model.F_Deptid = _sys_departmentRepository.GetSingle(x => x.F_DeptName == dr["任务部门"].ToString()).Result.F_DeptId.ToString ();
  400. }
  401. else
  402. {
  403. errmsg = errmsg + "\r\n第" + index + "行导入失败!请检查任务部门";
  404. continue;
  405. }
  406. if (_sys_useraccountRepository.GetSingle(x => x.F_UserName == dr["任务人"].ToString()).Result != null)
  407. {
  408. model.F_Tasker = _sys_useraccountRepository.GetSingle(x => x.F_UserName == dr["任务人"].ToString()).Result.F_UserId ;
  409. }
  410. else
  411. {
  412. errmsg = errmsg + "\r\n第" + index + "行导入失败!请检查任务人";
  413. continue;
  414. }
  415. try
  416. {
  417. model.F_Money = float .Parse(dr["目标金额"].ToString());
  418. }
  419. catch
  420. {
  421. errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入正确的目标金额";
  422. continue;
  423. }
  424. if (string.IsNullOrEmpty(dr["当前金额"].ToString()))
  425. model.F_Currentamount = 0;
  426. try
  427. {
  428. model.F_Currentamount = float.Parse(dr["当前金额"].ToString());
  429. }
  430. catch
  431. {
  432. errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入正确的当前金额";
  433. continue;
  434. }
  435. if (!string .IsNullOrEmpty (dr["任务提醒时间"].ToString()))
  436. {
  437. try
  438. {
  439. model.F_Remindertime = DateTime.Parse(dr["任务提醒时间"].ToString());
  440. }
  441. catch
  442. {
  443. errmsg = errmsg + "\r\n第" + index + "行导入失败!任务提醒时间格式错误";
  444. continue;
  445. }
  446. }
  447. else
  448. {
  449. model.F_Remindertime = model.F_EndTime.Value.AddDays(-3);
  450. }
  451. model.F_Taskprogress = string.Format("{0:f2}", model.F_Currentamount / model.F_Money * 100);
  452. if (dr["任务类型"].ToString() == "终止")
  453. model.F_State = 2;
  454. else if (dr["任务类型"].ToString() == "暂停")
  455. model.F_State = 1;
  456. else
  457. model.F_State = 0;
  458. model.F_CreateTime = DateTime.Now;
  459. model.F_CreateUser = user;
  460. model.F_IsDelete = 0;
  461. model.F_Parentid = parentid;
  462. int b = await _sys_taskmanagement_Repository.Add(model);
  463. if (b <= 0)
  464. {
  465. if (!string.IsNullOrEmpty(errmsg))
  466. {
  467. errmsg = errmsg + "\r\n第" + index + "行导入失败!";
  468. }
  469. else
  470. {
  471. errmsg = "第" + index + "行导入失败!";
  472. }
  473. }
  474. index++;
  475. }
  476. }
  477. else
  478. {
  479. return Error("文件中无数据");
  480. }
  481. if (!string.IsNullOrEmpty(errmsg))
  482. {
  483. return Error(errmsg);
  484. }
  485. return Success("导入成功");
  486. }
  487. #region 私有方法
  488. private TaskManagementInput Convert(T_Sys_TaskManagement it, int type = 0)
  489. {
  490. TaskManagementInput task = new TaskManagementInput();
  491. task.F_ID = it.F_ID;
  492. task.F_Name = it.F_Name;
  493. task.F_Content = it.F_Content;
  494. task.F_StartTime = it.F_StartTime;
  495. task.F_EndTime = it.F_EndTime;
  496. task.F_Type = it.F_Type;
  497. task.F_Deptid = it.F_Deptid;
  498. string deptmsg = "";
  499. if (!string.IsNullOrEmpty(it.F_Deptid))
  500. {
  501. try
  502. {
  503. string[] sprit = it.F_Deptid.Split(',');
  504. foreach (var iv in sprit)
  505. {
  506. if (deptmsg == "")
  507. deptmsg = _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result != null ? _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result.F_DeptName : "";
  508. else
  509. deptmsg = deptmsg + "," + _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result != null ? _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result.F_DeptName : "";
  510. }
  511. }
  512. catch
  513. {
  514. }
  515. }
  516. task.F_DeptName = deptmsg;// 部门名称
  517. task.F_Tasker = it.F_Tasker;
  518. task.F_TaskerName = _sys_useraccountRepository.GetSingle(x => x.F_UserId == it.F_Tasker).Result != null ? _sys_useraccountRepository.GetSingle(x => x.F_UserId == it.F_Tasker).Result .F_UserName : "";
  519. task.F_Money = it.F_Money;
  520. task.F_Currentamount = it.F_Currentamount;
  521. task.F_Taskprogress = it.F_Taskprogress;
  522. task.F_State = it.F_State;
  523. task.F_Remindertime = it.F_Remindertime;
  524. if (type ==0)
  525. {
  526. var taskcount = _sys_taskmanagement_Repository.GetListALL(x => x.F_Parentid == it.F_ID&&x.F_IsDelete ==0).Result != null ? _sys_taskmanagement_Repository.GetListALL(x => x.F_Parentid == it.F_ID && x.F_IsDelete == 0).Result: null ;
  527. if (taskcount!=null )
  528. {
  529. task.children = ConvertAsync(taskcount);
  530. }
  531. }
  532. task.F_Parentid = it.F_Parentid;
  533. task.F_ParentName = _sys_taskmanagement_Repository.GetSingle(x => x.F_ID == it.F_Parentid).Result != null ? _sys_taskmanagement_Repository.GetSingle(x => x.F_ID == it.F_Parentid).Result.F_Name : "";// 部门名称
  534. return task;
  535. }
  536. /// model转input
  537. /// </summary>
  538. /// <param name="input"></param>
  539. /// <returns></returns>
  540. private List<TaskManagementInput> ConvertAsync(List<T_Sys_TaskManagement> model)
  541. {
  542. List<TaskManagementInput> input = new List<TaskManagementInput>();
  543. if (model != null)
  544. {
  545. foreach (var it in model)
  546. {
  547. TaskManagementInput marketing = new TaskManagementInput();
  548. marketing = Convert(it);
  549. input.Add(marketing);
  550. }
  551. }
  552. return input;
  553. }
  554. #endregion
  555. }
  556. }