PersonBuiness.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. using PMS.Interface.PresonManager;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using PMS.EntityModels.PersonManager;
  7. using PMS.DBService.PersonManager;
  8. using QWPlatform.IService;
  9. using QWPlatform.SystemLibrary;
  10. using PMS.BusinessModels.SysManager;
  11. using System.Data;
  12. using PMS.BusinessModels.Person;
  13. using PMS.BusinessModels.Account;
  14. namespace PMS.BusinessService.PersonManager
  15. {
  16. public class PersonBuiness : IPersonModule
  17. {
  18. //提供ProService的数据服务
  19. private PersonService DB_PersonService = DataServiceBase.Instance<PersonService>();
  20. /// <summary>
  21. /// 获取全部渠道
  22. /// </summary>
  23. /// <param name="model"></param>
  24. /// <returns></returns>
  25. public string GetAll_Channel(string channelID)
  26. {
  27. var dt = DB_PersonService.GetAll_Channel(channelID);
  28. return dt.ToJson();
  29. }
  30. /// <summary>
  31. /// 根据渠道ID获取人员信息
  32. /// </summary>
  33. /// <param name="id"></param>
  34. /// <param name="page"></param>
  35. /// <param name="rows"></param>
  36. /// <returns></returns>
  37. public string GetAll_PersonInfo(string id, int page, int rows, string query, string nature, string project)
  38. {
  39. int defaultrow = 15;
  40. int startnumber = Startnumber(page, rows, defaultrow);
  41. int endnumber = Endnumbers(page, rows, defaultrow);
  42. var dt = DB_PersonService.GetAll_PersonInfo(id, startnumber, endnumber, query, nature, project);
  43. return dt;
  44. }
  45. /// <summary>
  46. /// 获取性别
  47. /// </summary>
  48. /// <returns></returns>
  49. public string GetSex()
  50. {
  51. return DB_PersonService.GetSex().ToJson();
  52. }
  53. /// <summary>
  54. /// 获取职务
  55. /// </summary>
  56. /// <returns></returns>
  57. public string GetJob(UserInfo user)
  58. {
  59. return DB_PersonService.GetJob(user).ToJson();
  60. }
  61. /// <summary>
  62. /// 获取项目
  63. /// </summary>
  64. /// <returns></returns>
  65. public string GetProject(string ChannelID, string query, string project)
  66. {
  67. return DB_PersonService.GetProject(ChannelID, query, project).ToJson();
  68. }
  69. /// <summary>
  70. /// 获取项目机构树
  71. /// </summary>
  72. /// <param name="ChannelID"></param>
  73. /// <param name="project"></param>
  74. /// <returns></returns>
  75. public string GetProjectTree(string project)
  76. {
  77. var dt = DB_PersonService.GetProjectTree(project);
  78. return dt.ToEasyUITreeJson("ID", "名称", "上级ID", null, "");
  79. }
  80. public string GetProjectTreeByCode(string project, string Code)
  81. {
  82. var dt = DB_PersonService.GetProjectTreeByCode(project, Code);
  83. return dt.ToEasyUITreeJson("ID", "名称", "上级ID", null, "");
  84. }
  85. /// <summary>
  86. /// 获取项目Combobox
  87. /// </summary>
  88. /// <returns></returns>
  89. public string GetProjectCobo(string ChannelID, string project)
  90. {
  91. return DB_PersonService.GetProjectCobo(ChannelID, project).ToJson();
  92. }
  93. public string GetAllProject(string project)
  94. {
  95. return DB_PersonService.GetAllProject(project).ToJson();
  96. }
  97. /// <summary>
  98. /// 获取角色
  99. /// </summary>
  100. /// <returns></returns>
  101. public string GetRole(int personproperty)
  102. {
  103. return DB_PersonService.GetRole(personproperty).ToJson();
  104. }
  105. /// <summary>
  106. /// 获取机构
  107. /// </summary>
  108. /// <returns></returns>
  109. public string GetStation(string ProjectID)
  110. {
  111. return DB_PersonService.GetStation(ProjectID).ToJson();
  112. }
  113. /// <summary>
  114. /// 获取人员性质
  115. /// </summary>
  116. /// <returns></returns>
  117. public string GetXZ(int PersonProperty)
  118. {
  119. return DB_PersonService.GetXZ(PersonProperty).ToJson();
  120. }
  121. private int Endnumbers(int page, int row, int defaultrow)
  122. {
  123. if (page == 0 && row == 0)
  124. {
  125. row = defaultrow;
  126. page = 1;
  127. }
  128. return (page) * row;
  129. }
  130. private int Startnumber(int page, int row, int defaultrow)
  131. {
  132. if (page == 0 && row == 0)
  133. {
  134. row = defaultrow;
  135. page = 1;
  136. }
  137. return (page - 1) * row + 1;
  138. }
  139. public string GetPerson(List<account_authdata_model> model)
  140. {
  141. string Channel = "";
  142. //string Item = "";
  143. if (model.Count > 0)
  144. {
  145. //便利渠道
  146. foreach (account_authdata_model m in model)
  147. {
  148. if (!String.IsNullOrEmpty(m.orgid))
  149. {
  150. Channel += m.orgid + ",";
  151. }
  152. ////便利项目
  153. //if (m.items.Count > 0)
  154. //{
  155. // foreach(string s in m.items)
  156. // {
  157. // if (!String.IsNullOrEmpty(s))
  158. // {
  159. // Item += s + ",";
  160. // }
  161. // }
  162. //}
  163. }
  164. }
  165. var dt = DB_PersonService.GetPersonByChannel(Channel);
  166. return dt.ToJson();
  167. }
  168. public string GetPersonByChannel(string id)
  169. {
  170. var dt = DB_PersonService.GetPersonByChannel(id);
  171. return dt.ToJson();
  172. }
  173. /// <summary>
  174. /// 添加人员
  175. /// </summary>
  176. /// <param name="model"></param>
  177. /// <returns></returns>
  178. public int SaveAddPerson(PersonBusinessModel model)
  179. {
  180. return DB_PersonService.SaveAddPerson(model);
  181. }
  182. /// <summary>
  183. /// 修改人员
  184. /// </summary>
  185. /// <param name="model"></param>
  186. /// <returns></returns>
  187. public int SaveUpdatePerson(PersonBusinessModel model)
  188. {
  189. return DB_PersonService.SaveUpdatePerson(model);
  190. }
  191. public string GetPersonByJob(string Nature, string job)
  192. {
  193. var dt = DB_PersonService.GetPersonByJob(Nature, job);
  194. return dt.ToJson();
  195. }
  196. /// <summary>
  197. /// 根据人员ID获取人员信息
  198. /// </summary>
  199. /// <param name="id"></param>
  200. /// <returns></returns>
  201. public string GetInfoByID(string id)
  202. {
  203. return DB_PersonService.GetInfoByID(id).ToJson();
  204. }
  205. /// <summary>
  206. /// 根据人员ID获取系统账户的信息
  207. /// </summary>
  208. /// <returns></returns>
  209. public string GetSysAccountInfo(string id)
  210. {
  211. return DB_PersonService.GetSysAccountInfo(id).ToJson();
  212. }
  213. /// <summary>
  214. /// 根据账户ID获取系统账户的角色信息
  215. /// </summary>
  216. /// <returns></returns>
  217. public string GetRoleInfo(string id)
  218. {
  219. return DB_PersonService.GetRoleInfo(id).ToJson();
  220. }
  221. /// <summary>
  222. /// 删除人员
  223. /// </summary>
  224. /// <param name="id"></param>
  225. /// <returns></returns>
  226. public int Delete_Person(string id)
  227. {
  228. return DB_PersonService.Delete_Person(id);
  229. }
  230. /// <summary>
  231. /// 生成单个账号
  232. /// </summary>
  233. /// <param name="id"></param>
  234. /// <returns></returns>
  235. public int Add_Account(PersonBusinessModel model, string role)
  236. {
  237. return DB_PersonService.Add_Account(model,role);
  238. }
  239. /// <summary>
  240. /// 执行修改操作
  241. /// </summary>
  242. /// <param name="model"></param>
  243. /// <returns></returns>
  244. public int Update_Account(PersonBusinessModel model, string role)
  245. {
  246. return DB_PersonService.Update_Account(model,role);
  247. }
  248. public string GetCurrentProject(string id)
  249. {
  250. return DB_PersonService.GetCurrentProject(id).ToJson();
  251. }
  252. public DataTable GetCurrentProjectInfo(string id)
  253. {
  254. return DB_PersonService.GetCurrentProject(id);
  255. }
  256. public DataTable GetChannelID(string id)
  257. {
  258. return DB_PersonService.GetChannelID(id);
  259. }
  260. /// <summary>
  261. /// 传人员ID字符串进行批量创建账户
  262. /// </summary>
  263. /// <param name="id"></param>
  264. /// <returns></returns>
  265. public int Add_Account_Batch(string id)
  266. {
  267. return DB_PersonService.Add_Account_Batch(id);
  268. }
  269. //批量删除
  270. public int Delete_Batch(string id)
  271. {
  272. return DB_PersonService.Delete_Batch(id);
  273. }
  274. //判断是否有账号
  275. public int CheckAccount(string id)
  276. {
  277. return DB_PersonService.CheckAccount(id);
  278. }
  279. /// <summary>
  280. /// 给账户添加数据权限
  281. /// </summary>
  282. /// <param name="AccountId"></param>
  283. /// <param name="PersonId"></param>
  284. /// <returns></returns>
  285. public bool addAccountAuthod(int AccountId, string PersonId)
  286. {
  287. return DB_PersonService.addAccountAuthod(AccountId, PersonId);
  288. }
  289. /// <summary>
  290. /// 创建人员时勾选自动生成账户
  291. /// </summary>
  292. /// <param name="model"></param>
  293. /// <returns></returns>
  294. public int AutoAccount(PersonBusinessModel model)
  295. {
  296. return DB_PersonService.AutoAccount(model);
  297. }
  298. /// <summary>
  299. /// 批量修改
  300. /// </summary>
  301. /// <param name="model"></param>
  302. /// <param name="RYID"></param>
  303. /// <returns></returns>
  304. public int Batch_Save(PersonBusinessModel model,string RYID)
  305. {
  306. int count = 0;
  307. string[] Data = RYID.Split(',');
  308. foreach(var item in Data)
  309. {
  310. count= DB_PersonService.Batch_Save(model, item)>0?(++count):count;
  311. }
  312. return count;
  313. }
  314. public int ChangeActive(string id)
  315. {
  316. return DB_PersonService.ChangeActive(id);
  317. }
  318. }
  319. }