郑许地铁

SystemManageController.cs 60KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. using ZXDT.CallCenter.Model;
  12. using ZXDT.CallCenter.MVCWeb.Commons;
  13. using ZXDT.CallCenter.MVCWeb.Models;
  14. using ZXDT.Common;
  15. using ZXDT.DBUtility;
  16. namespace ZXDT.CallCenter.MVCWeb.Controllers
  17. {
  18. public class SystemManageController : BaseController
  19. {
  20. #region 部门管理
  21. BLL.T_Sys_Department deptBLL = new BLL.T_Sys_Department();
  22. BLL.T_SYS_Time timeBLL = new BLL.T_SYS_Time();
  23. BLL.T_Sys_UserAccount userbll = new BLL.T_Sys_UserAccount();
  24. /// <summary>
  25. /// 部门列表
  26. /// </summary>
  27. /// <returns></returns>
  28. public ActionResult DepartmentList()
  29. {
  30. WorkOrderMyModel model = new WorkOrderMyModel();
  31. return View(model);
  32. }
  33. ///通过部门父级节点获取数据
  34. /// </summary>
  35. /// <param name="fid"></param>
  36. /// <returns></returns>
  37. public string GetDepartmentJsonModel(int parentId)
  38. {
  39. AddAction("t_sys_department", parentId.ToMyString(), "获取父级树结构", "");
  40. return Newtonsoft.Json.JsonConvert.SerializeObject(deptBLL.GetDepartmentJsonModel(parentId));
  41. }
  42. /// <summary>
  43. /// 部门编辑
  44. /// </summary>
  45. /// <param name="editType">类型1、新增 2、修改</param>
  46. /// /// <returns></returns>
  47. public ActionResult DepartmentEdit(int deptId, int editType)
  48. {
  49. AddAction("t_sys_department", deptId.ToMyString(), "打开部门编辑页面", "");
  50. Model.T_Sys_Department viewModel = new Model.T_Sys_Department();
  51. //当前对象实体
  52. if (editType == 1)
  53. {
  54. viewModel.F_ParentId = deptId;
  55. viewModel.F_Sort = 1;
  56. }
  57. else
  58. {
  59. Model.T_Sys_Department deptModel = deptBLL.GetModel(deptId);
  60. viewModel = deptModel;
  61. }
  62. return View(viewModel);
  63. }
  64. /// <summary>
  65. /// 保存编辑
  66. /// </summary>
  67. /// <param name="workOrderBaseModel"></param>
  68. /// <returns></returns>
  69. [AcceptVerbs(HttpVerbs.Post)]
  70. public bool SaveDeptData(T_Sys_Department deptModel)
  71. {
  72. if (deptModel.F_DeptId > 0)
  73. {
  74. AddAction("t_sys_department", deptModel.F_DeptId.ToMyString(), "更新部门", deptModel.F_DeptName);
  75. return deptBLL.Update(deptModel);
  76. }
  77. else
  78. {
  79. int id = deptBLL.Add(deptModel);
  80. AddAction("t_sys_department", id.ToMyString(), "添加部门", deptModel.F_DeptName);
  81. return id> 0;
  82. }
  83. }
  84. /// <summary>
  85. /// 删除部门
  86. /// </summary>
  87. /// <param name="workOrderBaseModel"></param>
  88. /// <returns></returns>
  89. [AcceptVerbs(HttpVerbs.Get)]
  90. public bool DeleteDeptData(int deptId)
  91. {
  92. AddAction("t_sys_department", deptId.ToMyString(), "删除部门");
  93. return deptBLL.Delete(deptId);
  94. }
  95. /// <summary>
  96. /// 获取部门数据
  97. /// </summary>
  98. /// <param name="page">当前页码</param>
  99. /// <param name="limit">每页数据量</param>
  100. /// <returns></returns>
  101. [ActionName("DeptDate")]
  102. [HttpGet]
  103. public string DeptDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  104. {
  105. //数据结果集
  106. ResponseData dataModel = new ResponseData();
  107. string sql = "";
  108. if (parentId != null)
  109. {
  110. sql += " and F_ParentId=" + parentId;
  111. }
  112. DataTable dt = new DataTable();
  113. int recordCount = 0;
  114. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  115. dt = BLL.PagerBLL.GetListPager(
  116. "T_Sys_Department",
  117. "F_DeptId",
  118. "*",
  119. sql,
  120. "ORDER BY F_Sort asc ",
  121. limit,
  122. page,
  123. true,
  124. out recordCount);
  125. dataModel.code = 0;
  126. dataModel.count = recordCount;
  127. dataModel.data = dt;
  128. AddAction("t_sys_department", parentId.ToMyString(), "获取部门列表", "");
  129. return JsonConvert.SerializeObject(dataModel);
  130. }
  131. #endregion
  132. #region 角色管理
  133. BLL.T_Sys_RoleInfo roleBLL = new BLL.T_Sys_RoleInfo();
  134. public ActionResult RoleList()
  135. {
  136. WorkOrderMyModel model = new WorkOrderMyModel();
  137. return View(model);
  138. }
  139. /// <summary>
  140. /// 获取角色列表
  141. /// </summary>
  142. /// <param name="page">当前页码</param>
  143. /// <param name="limit">每页数据量</param>
  144. /// <returns></returns>
  145. [ActionName("RoleDate")]
  146. [HttpGet]
  147. public string RoleDate(DateTime? NowDateTime, int page, int limit)
  148. {
  149. AddAction("t_sys_roleinfo", "page", "查询角色列表",page.ToMyString()+"-"+ limit.ToMyString());
  150. //数据结果集
  151. ResponseData dataModel = new ResponseData();
  152. string sql = "";
  153. DataTable dt = new DataTable();
  154. int recordCount = 0;
  155. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  156. dt = BLL.PagerBLL.GetListPager(
  157. "T_Sys_RoleInfo",
  158. "F_RoleId",
  159. "*",
  160. sql,
  161. "ORDER BY F_RoleId",
  162. limit,
  163. page,
  164. true,
  165. out recordCount);
  166. dataModel.code = 0;
  167. dataModel.count = recordCount;
  168. dataModel.data = dt;
  169. return JsonConvert.SerializeObject(dataModel);
  170. }
  171. /// <summary>
  172. /// 编辑角色
  173. /// </summary>
  174. /// <returns></returns>
  175. public ActionResult RoleEdit(int? roleId)
  176. {
  177. Model.T_Sys_RoleInfo viewModel = new Model.T_Sys_RoleInfo();
  178. if (roleId != null && roleId > 0)
  179. {
  180. viewModel = roleBLL.GetModel(int.Parse(roleId.ToString()));
  181. AddAction("t_sys_roleinfo", roleId.ToMyString(), "打开角色编辑页", "角色名称:"+ viewModel.F_RoleName, "敏感信息");
  182. }
  183. return View(viewModel);
  184. }
  185. /// <summary>
  186. /// 保存编辑
  187. /// </summary>
  188. /// <param name="workOrderBaseModel"></param>
  189. /// <returns></returns>
  190. [AcceptVerbs(HttpVerbs.Post)]
  191. public bool SaveRoleEdit(T_Sys_RoleInfo roleInfoModel)
  192. {
  193. roleInfoModel.F_RoleCode = roleInfoModel.F_RoleCode.ToMyString();
  194. if (roleInfoModel.F_RoleId > 0)
  195. {
  196. AddAction("t_sys_roleinfo", roleInfoModel.F_RoleId.ToMyString(), "更新角色", roleInfoModel.F_RoleName);
  197. AddAction("t_sys_roleinfo", roleInfoModel.F_RoleId.ToMyString(), "更新角色", "数据:" + JsonConvert.SerializeObject(roleInfoModel), "敏感信息");
  198. return roleBLL.Update(roleInfoModel);
  199. }
  200. else
  201. {
  202. int id = roleBLL.Add(roleInfoModel);
  203. AddAction("t_sys_roleinfo", id.ToMyString(), "添加角色", roleInfoModel.F_RoleName);
  204. AddAction("t_sys_roleinfo", id.ToMyString(), "添加角色", "数据:" +JsonConvert.SerializeObject(roleInfoModel), "敏感信息");
  205. return id > 0;
  206. }
  207. }
  208. /// <summary>
  209. /// 删除数据
  210. /// </summary>
  211. /// <param name="workOrderBaseModel"></param>
  212. /// <returns></returns>
  213. [AcceptVerbs(HttpVerbs.Get)]
  214. public bool DeleteRoleData(string roleId)
  215. {
  216. AddAction("t_sys_roleinfo", roleId.ToMyString(), "删除角色");
  217. AddAction("t_sys_roleinfo", roleId.ToMyString(), "删除角色", "数据:" + roleId.ToMyString(), "敏感信息");
  218. return roleBLL.DeleteList(roleId);
  219. }
  220. #endregion
  221. #region 获取菜单树
  222. public class DicSeaarchModel
  223. {
  224. public string RootCode
  225. {
  226. get;
  227. set;
  228. }
  229. }
  230. /// <summary>
  231. /// 初始化字典结构
  232. /// </summary>
  233. /// <param name="rootCode"></param>
  234. /// <returns></returns>
  235. public ActionResult MenuTree(string rootCode)
  236. {
  237. DicSeaarchModel model = new DicSeaarchModel();
  238. model.RootCode = rootCode;
  239. return View(model);
  240. }
  241. /// <summary>
  242. /// 获取字典数据
  243. /// </summary>
  244. /// <param name="rootCode"></param>
  245. /// <returns></returns>
  246. public string GetMenuTreeData(int roleId)
  247. {
  248. try
  249. {
  250. AddAction("T_Sys_ModuleFunctions".ToLower(), roleId.ToMyString(), "获取角色字典", "角色id"+ roleId.ToMyString());
  251. return "[" + Newtonsoft.Json.JsonConvert.SerializeObject(roleBLL.GetMenuTree(roleId)).Replace("Checked", "checked") + "]";
  252. }
  253. catch (Exception ex)
  254. {
  255. return "";
  256. }
  257. }
  258. /// <summary>
  259. ///授权
  260. /// </summary>
  261. /// <returns></returns>
  262. [AcceptVerbs(HttpVerbs.Get)]
  263. public bool AcceptList(int roleId, string MenuIdStr)
  264. {
  265. bool accRersult = false;
  266. AddAction("T_Sys_ModuleFunctions", roleId.ToMyString(), "授权", "角色id" + roleId.ToMyString()+"功能菜单"+ MenuIdStr);
  267. if (roleBLL.AddRolesMenuList(roleId, MenuIdStr))
  268. {
  269. AddAction("T_Sys_ModuleFunctions", roleId.ToMyString(), "授权角色功能", string.Format("给角色{0}授权菜单功能{1}", roleId, MenuIdStr), "敏感信息");
  270. accRersult = true;
  271. }
  272. return accRersult;
  273. }
  274. #endregion
  275. #region 业务类型管理
  276. BLL.T_Wo_WorkOrderType dicTittleBLL = new BLL.T_Wo_WorkOrderType();
  277. public ActionResult BusinessTypeList()
  278. {
  279. WorkOrderMyModel model = new WorkOrderMyModel();
  280. return View(model);
  281. }
  282. ///通过dic编码获取dic值
  283. /// </summary>
  284. /// <param name="fid"></param>
  285. /// <returns></returns>
  286. public string GetDicTittleJson(int parentId)
  287. {
  288. AddAction("t_wo_workordertype".ToLower(), parentId.ToMyString(), "获取业务类型");
  289. return Newtonsoft.Json.JsonConvert.SerializeObject(dicTittleBLL.GetDicTittleJsonModel(parentId));
  290. }
  291. /// <summary>
  292. /// 获取业务类型数据
  293. /// </summary>
  294. /// <param name="page">当前页码</param>
  295. /// <param name="limit">每页数据量</param>
  296. /// <returns></returns>
  297. [ActionName("OrderTypeDate")]
  298. [HttpGet]
  299. public string OrderTypeDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  300. {
  301. AddAction("t_wo_workordertype".ToLower(),"page", "获取业务类型列表", page.ToMyString() + "-" + limit.ToMyString());
  302. //数据结果集
  303. ResponseData dataModel = new ResponseData();
  304. string sql = "";
  305. if (parentId != null && parentId > 0)
  306. {
  307. sql += " and F_ParentId=" + parentId;
  308. }
  309. DataTable dt = new DataTable();
  310. int recordCount = 0;
  311. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  312. dt = BLL.PagerBLL.GetListPager(
  313. "T_Wo_WorkOrderType",
  314. "F_WorkOrderTypeId",
  315. "*",
  316. sql,
  317. "ORDER BY F_Sort asc ",
  318. limit,
  319. page,
  320. true,
  321. out recordCount);
  322. dataModel.code = 0;
  323. dataModel.count = recordCount;
  324. dataModel.data = dt;
  325. return JsonConvert.SerializeObject(dataModel);
  326. }
  327. /// <summary>
  328. /// 编辑业务类型
  329. /// </summary>
  330. /// <param name="F_WorkOrderTypeId">当前选中id</param>
  331. /// <param name="editType">类型1、新增 2、修改</param>
  332. /// <returns></returns>
  333. public ActionResult BussinessTypeEdit(int F_WorkOrderTypeId, int editType)
  334. {
  335. AddAction("t_wo_workordertype".ToLower(), F_WorkOrderTypeId.ToMyString(), "打开业务类型编辑页");
  336. Model.T_Wo_WorkOrderType viewModel = new Model.T_Wo_WorkOrderType();
  337. //当前对象实体
  338. Model.T_Wo_WorkOrderType orderTypeModel = dicTittleBLL.GetModel(F_WorkOrderTypeId);
  339. if (editType == 1)
  340. {
  341. viewModel.F_ParentId = orderTypeModel.F_WorkOrderTypeId;
  342. viewModel.F_ParentName = orderTypeModel.F_ParentName;
  343. viewModel.F_Sort = 1;
  344. }
  345. else
  346. {
  347. viewModel = orderTypeModel;
  348. }
  349. return View(viewModel);
  350. }
  351. /// <summary>
  352. /// 保存编辑
  353. /// </summary>
  354. /// <param name="workOrderBaseModel"></param>
  355. /// <returns></returns>
  356. [AcceptVerbs(HttpVerbs.Post)]
  357. public bool SaveBussiTypeData(T_Wo_WorkOrderType WorkOrderTypeModel)
  358. {
  359. ////当前用户信息
  360. //workOrderBaseModel.F_USERID = F_UserID;//id
  361. //workOrderBaseModel.F_LINKMAN = F_UserCode;//工号
  362. //workOrderBaseModel.F_REPAIRMANNAME = "12";//姓名
  363. if (WorkOrderTypeModel.F_WorkOrderTypeId > 0)
  364. {
  365. AddAction("t_wo_workordertype", WorkOrderTypeModel.F_WorkOrderTypeId.ToMyString(), "更新工单分类",WorkOrderTypeModel.F_Name);
  366. return dicTittleBLL.Update(WorkOrderTypeModel) > 0;
  367. }
  368. else
  369. {
  370. int id = dicTittleBLL.Add(WorkOrderTypeModel);
  371. AddAction("t_wo_workordertype", id.ToMyString(), "添加工单分类", WorkOrderTypeModel.F_Name);
  372. return id > 0;
  373. }
  374. }
  375. /// <summary>
  376. /// 删除数据
  377. /// </summary>
  378. /// <param name="workOrderBaseModel"></param>
  379. /// <returns></returns>
  380. [AcceptVerbs(HttpVerbs.Get)]
  381. public bool DeleteBussiTypeData(int WorkOrderTypeId)
  382. {
  383. AddAction("T_Sys_ModuleFunctions", WorkOrderTypeId.ToMyString(), "删除工单分类","", "敏感信息");
  384. AddAction("t_wo_workordertype", WorkOrderTypeId.ToMyString(), "删除工单分类");
  385. return dicTittleBLL.Delete(WorkOrderTypeId);
  386. }
  387. #endregion
  388. #region 字典管理
  389. BLL.T_Sys_DictionaryValue dicValueBLL = new BLL.T_Sys_DictionaryValue();
  390. BLL.T_Sys_DictionaryBase dicBaseBLL = new BLL.T_Sys_DictionaryBase();
  391. /// <summary>
  392. /// 字典列表
  393. /// </summary>
  394. /// <returns></returns>
  395. public ActionResult DictionaryList()
  396. {
  397. WorkOrderMyModel model = new WorkOrderMyModel();
  398. return View(model);
  399. }
  400. ///通过字典获取数据
  401. /// </summary>
  402. /// <param name="fid"></param>
  403. /// <returns></returns>
  404. public string GetDictionaryJsonModel(int parentId)
  405. {
  406. return Newtonsoft.Json.JsonConvert.SerializeObject(dicBaseBLL.GetDictionaryJsonModel());
  407. }
  408. /// <summary>
  409. /// 获取字典值数据
  410. /// </summary>
  411. /// <param name="page">当前页码</param>
  412. /// <param name="limit">每页数据量</param>
  413. /// <returns></returns>
  414. [ActionName("DictionaryDate")]
  415. [HttpGet]
  416. public string DictionaryDate(DateTime? NowDateTime, int page, int limit, string dictionaryFlag)
  417. {
  418. AddAction("t_sys_dictionarybase".ToLower(),"page", "获取字典列表", page+"-"+ limit);
  419. //数据结果集
  420. ResponseData dataModel = new ResponseData();
  421. string sql = "";
  422. if (!string.IsNullOrEmpty(dictionaryFlag) && dictionaryFlag != "0")
  423. {
  424. sql += " and F_DictionaryFlag='" + dictionaryFlag + "'";
  425. }
  426. DataTable dt = new DataTable();
  427. int recordCount = 0;
  428. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  429. if (string.IsNullOrEmpty(dictionaryFlag) || dictionaryFlag != "0")
  430. {
  431. dt = BLL.PagerBLL.GetListPager(
  432. "T_Sys_DictionaryValue",
  433. "F_DictionaryValueId",
  434. "*",
  435. sql,
  436. "ORDER BY F_Sort asc ",
  437. limit,
  438. page,
  439. true,
  440. out recordCount);
  441. }
  442. else
  443. {
  444. dt = BLL.PagerBLL.GetListPager(
  445. "T_Sys_DictionaryBase",
  446. "F_DictionaryName",
  447. "*,F_DictionaryName as F_Name",
  448. sql,
  449. "ORDER BY F_Sort asc ",
  450. limit,
  451. page,
  452. true,
  453. out recordCount);
  454. }
  455. dataModel.code = 0;
  456. dataModel.count = recordCount;
  457. dataModel.data = dt;
  458. return JsonConvert.SerializeObject(dataModel);
  459. }
  460. /// <summary>
  461. /// 获取字典值数据
  462. /// </summary>
  463. /// <param name="page">当前页码</param>
  464. /// <param name="limit">每页数据量</param>
  465. /// <returns></returns>
  466. [ActionName("DictionaryDateOut")]
  467. [HttpGet]
  468. public string DictionaryDateOut(DateTime? NowDateTime, int page, int limit, string dictionaryFlag)
  469. {
  470. AddAction("t_sys_dictionarybase".ToLower(), "page", "获取字典列表", page + "-" + limit);
  471. //数据结果集
  472. ResponseData dataModel = new ResponseData();
  473. string sql = "and (F_DictionaryFlag='ZDXX' OR F_DictionaryFlag='ZDXX2')";
  474. DataTable dt = new DataTable();
  475. int recordCount = 0;
  476. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  477. dt = BLL.PagerBLL.GetListPager(
  478. "T_Sys_DictionaryValue",
  479. "F_DictionaryValueId",
  480. "*",
  481. sql,
  482. "ORDER BY F_Sort asc ",
  483. limit,
  484. page,
  485. true,
  486. out recordCount);
  487. dataModel.code = 0;
  488. dataModel.count = recordCount;
  489. dataModel.data = dt;
  490. return JsonConvert.SerializeObject(dataModel);
  491. }
  492. /// <summary>
  493. /// 字典项编辑
  494. /// </summary>
  495. /// <param name="editType">类型1、新增 2、修改</param>
  496. /// /// <returns></returns>
  497. public ActionResult DictionaryBaseEdit(string dicCode, int editType)
  498. {
  499. AddAction("t_sys_dictionarybase".ToLower(), dicCode, "打开字典编辑页");
  500. Model.T_Sys_DictionaryBase viewModel = new Model.T_Sys_DictionaryBase();
  501. //当前对象实体
  502. if (editType == 1)
  503. {
  504. viewModel.F_Sort = 1;
  505. }
  506. else
  507. {
  508. Model.T_Sys_DictionaryBase dicBaseModel = dicBaseBLL.GetModel(dicCode);
  509. viewModel = dicBaseModel;
  510. }
  511. return View(viewModel);
  512. }
  513. /// <summary>
  514. /// 保存字典项编辑
  515. /// </summary>
  516. /// <param name="workOrderBaseModel"></param>
  517. /// <returns></returns>
  518. [AcceptVerbs(HttpVerbs.Post)]
  519. public bool SaveDictionaryBaseData(T_Sys_DictionaryBase dicBaseModel)
  520. {
  521. try
  522. {
  523. if (!string.IsNullOrEmpty(dicBaseModel.F_DictionaryFlagType))
  524. {
  525. AddAction("t_sys_dictionarybase", dicBaseModel.F_DictionaryFlagType, "更新字典项");
  526. return dicBaseBLL.Update(dicBaseModel);
  527. }
  528. else
  529. {
  530. AddAction("t_sys_dictionarybase", dicBaseModel.F_DictionaryFlagType, "添加字典项");
  531. return dicBaseBLL.Add(dicBaseModel);
  532. }
  533. }
  534. catch (Exception ex)
  535. {
  536. LogHelper.Default.WriteError("字典操作失败",ex);
  537. return false;
  538. }
  539. }
  540. /// <summary>
  541. /// 删除字典项
  542. /// </summary>
  543. /// <param name="workOrderBaseModel"></param>
  544. /// <returns></returns>
  545. [AcceptVerbs(HttpVerbs.Get)]
  546. public bool DeleteBaseData(string baseCode)
  547. {
  548. AddAction("t_sys_dictionarybase", baseCode,"删除字典项");
  549. return dicBaseBLL.Delete(baseCode);
  550. }
  551. /// <summary>
  552. /// 字典值编辑
  553. /// </summary>
  554. /// <param name="editType">类型1、新增 2、修改</param>
  555. /// /// <returns></returns>
  556. public ActionResult DictionaryValueEdit(int? valueId, string parentCode, int editType)
  557. {
  558. AddAction("t_sys_dictionarybase".ToLower(), valueId.ToMyString(), "打开字典值编辑页");
  559. Model.T_Sys_DictionaryValue viewModel = new Model.T_Sys_DictionaryValue();
  560. //当前对象实体
  561. if (editType == 1)
  562. {
  563. viewModel.F_Sort = 1;
  564. viewModel.F_DictionaryFlag = parentCode;
  565. }
  566. else
  567. {
  568. Model.T_Sys_DictionaryValue dicValueModel = dicValueBLL.GetModel(int.Parse(valueId.ToString()));
  569. viewModel = dicValueModel;
  570. }
  571. return View(viewModel);
  572. }
  573. /// <summary>
  574. /// 保存字典值
  575. /// </summary>
  576. /// <param name="workOrderBaseModel"></param>
  577. /// <returns></returns>
  578. [AcceptVerbs(HttpVerbs.Post)]
  579. public bool SaveDictionaryValueData(T_Sys_DictionaryValue dicBaseModel)
  580. {
  581. if (dicBaseModel.F_DictionaryValueId > 0)
  582. {
  583. AddAction("t_sys_dictionaryvalue", dicBaseModel.F_DictionaryValueId.ToMyString(), "更新字典值");
  584. return dicValueBLL.Update(dicBaseModel);
  585. }
  586. else
  587. {
  588. int id = dicValueBLL.Add(dicBaseModel);
  589. AddAction("t_sys_dictionaryvalue", id.ToMyString(), "添加字典值");
  590. return id > 0;
  591. }
  592. }
  593. /// <summary>
  594. /// 删除字典值
  595. /// </summary>
  596. /// <param name="workOrderBaseModel"></param>
  597. /// <returns></returns>
  598. [AcceptVerbs(HttpVerbs.Get)]
  599. public bool DeleteValueData(int id)
  600. {
  601. AddAction("t_sys_dictionaryvalue", id.ToMyString(), "删除字典值");
  602. return dicValueBLL.Delete(id);
  603. }
  604. #endregion
  605. #region 菜单管理
  606. BLL.T_Sys_ModuleFunctions menuBLL = new BLL.T_Sys_ModuleFunctions();
  607. /// <summary>
  608. /// 部门列表
  609. /// </summary>
  610. /// <returns></returns>
  611. public ActionResult MenuList()
  612. {
  613. WorkOrderMyModel model = new WorkOrderMyModel();
  614. return View(model);
  615. }
  616. ///通过部门父级节点获取数据
  617. /// </summary>
  618. /// <param name="fid"></param>
  619. /// <returns></returns>
  620. public string GetMenuJsonModel(int parentId)
  621. {
  622. AddAction("t_sys_modulefunctions", parentId.ToMyString(), "获取父级下菜单","父级id:"+ parentId);
  623. return Newtonsoft.Json.JsonConvert.SerializeObject(menuBLL.GetMenuJsonModel(parentId));
  624. }
  625. /// <summary>
  626. /// 获取部门数据
  627. /// </summary>
  628. /// <param name="page">当前页码</param>
  629. /// <param name="limit">每页数据量</param>
  630. /// <returns></returns>
  631. [ActionName("MenuDate")]
  632. [HttpGet]
  633. public string MenuDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  634. {
  635. AddAction("t_sys_modulefunctions", "page", "获取菜单列表",page+"-"+limit);
  636. //数据结果集
  637. ResponseData dataModel = new ResponseData();
  638. string sql = "";
  639. if (parentId != null)
  640. {
  641. sql += " and F_ParentId=" + parentId;
  642. }
  643. DataTable dt = new DataTable();
  644. int recordCount = 0;
  645. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  646. dt = BLL.PagerBLL.GetListPager(
  647. "T_Sys_ModuleFunctions",
  648. "F_FunctionId",
  649. "* ,(CASE F_StateFlag WHEN 1 THEN '启用' WHEN 0 THEN '禁用' ELSE NULL END ) as F_StateFlagName",
  650. sql,
  651. "ORDER BY F_Sort asc ",
  652. limit,
  653. page,
  654. true,
  655. out recordCount);
  656. dataModel.code = 0;
  657. dataModel.count = recordCount;
  658. dataModel.data = dt;
  659. return JsonConvert.SerializeObject(dataModel);
  660. }
  661. /// <summary>
  662. /// 功能编辑
  663. /// </summary>
  664. /// <param name="editType">类型1、新增 2、修改</param>
  665. /// /// <returns></returns>
  666. public ActionResult MenuEdit(int menuId, int editType)
  667. {
  668. Model.T_Sys_ModuleFunctions viewModel = new Model.T_Sys_ModuleFunctions();
  669. AddAction("t_sys_modulefunctions", menuId.ToMyString(), "打开功能编辑页", "菜单编号"+ menuId);
  670. //当前对象实体
  671. if (editType == 1)
  672. {
  673. viewModel.F_ParentId = menuId;
  674. viewModel.F_Sort = 1;
  675. }
  676. else
  677. {
  678. Model.T_Sys_ModuleFunctions deptModel = menuBLL.GetModel(menuId);
  679. viewModel = deptModel;
  680. }
  681. return View(viewModel);
  682. }
  683. /// <summary>
  684. /// 保存编辑
  685. /// </summary>
  686. /// <param name="workOrderBaseModel"></param>
  687. /// <returns></returns>
  688. [AcceptVerbs(HttpVerbs.Post)]
  689. public bool SaveMenuData(T_Sys_ModuleFunctions menuModel)
  690. {
  691. if (menuModel.F_FunctionId > 0)
  692. {
  693. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "更新菜单", menuModel.F_Name);
  694. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "更新菜单", "数据:"+JsonConvert.SerializeObject(menuModel), "主要设置");
  695. return menuBLL.Update(menuModel);
  696. }
  697. else
  698. {
  699. int id = menuBLL.Add(menuModel);
  700. AddAction("t_sys_modulefunctions", id.ToMyString(), "添加菜单", menuModel.F_Name);
  701. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "添加菜单", "数据:" + JsonConvert.SerializeObject(menuModel), "主要设置");
  702. return id > 0;
  703. }
  704. }
  705. /// <summary>
  706. /// 删除功能
  707. /// </summary>
  708. /// <param name="workOrderBaseModel"></param>
  709. /// <returns></returns>
  710. [AcceptVerbs(HttpVerbs.Get)]
  711. public bool DeleteMenuData(int menuId)
  712. {
  713. Model.T_Sys_ModuleFunctions deptModel = menuBLL.GetModel(menuId);
  714. AddAction("t_sys_modulefunctions", deptModel.F_FunctionId.ToMyString(), "删除菜单", "数据:" + JsonConvert.SerializeObject(deptModel), "主要设置");
  715. AddAction("t_sys_modulefunctions", menuId.ToMyString(), "删除菜单");
  716. return menuBLL.Delete(menuId);
  717. }
  718. #endregion
  719. #region 用户管理
  720. BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
  721. /// <summary>
  722. /// 部门列表
  723. /// </summary>
  724. /// <returns></returns>
  725. public ActionResult UserList()
  726. {
  727. WorkOrderMyModel model = new WorkOrderMyModel();
  728. return View(model);
  729. }
  730. /// <summary>
  731. /// 用户编辑
  732. /// </summary>
  733. /// <param name="editType">类型1、新增 2、修改</param>
  734. /// /// <returns></returns>
  735. public ActionResult UserEdit(int? userId, int? deptId, int editType)
  736. {
  737. AddAction("t_sys_useraccount", userId.ToMyString(), "打开用户编辑页", "用户编号/部门" + userId+"-"+ deptId);
  738. Model.T_Sys_UserAccount viewModel = new Model.T_Sys_UserAccount();
  739. //当前对象实体
  740. if (editType == 1)
  741. {
  742. viewModel.F_DeptId = int.Parse(deptId.ToString());
  743. AddAction("t_sys_useraccount", deptId.ToMyString(), "打开用户添加页", "", "敏感信息");
  744. }
  745. else
  746. {
  747. Model.T_Sys_UserAccount userModel = userBLL.GetModel(int.Parse(userId.ToString()));
  748. viewModel = userModel;
  749. AddAction("t_sys_useraccount", userId.ToMyString(), "打开用户编辑页", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  750. }
  751. //获取部门列表
  752. viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
  753. //获取角色列表
  754. viewModel.RoleInfoList = roleBLL.GetModelList("");
  755. return View(viewModel);
  756. }
  757. /// <summary>
  758. /// 保存编辑
  759. /// </summary>
  760. /// <param name="workOrderBaseModel"></param>
  761. /// <returns></returns>
  762. [AcceptVerbs(HttpVerbs.Post)]
  763. public bool SaveUserData(T_Sys_UserAccount userModel)
  764. {
  765. BLL.T_Sys_RoleInfo bll = new BLL.T_Sys_RoleInfo();
  766. BLL.T_Sys_UserAccount blluser = new BLL.T_Sys_UserAccount();
  767. if (userModel.F_UserId > 0)
  768. {
  769. Model.T_Sys_UserAccount oldusermodel = blluser.GetModel(userModel.F_UserId);
  770. Model.T_Sys_RoleInfo role2 = bll.GetModel(F_RoleID); //当前登录人的角色
  771. Model.T_Sys_RoleInfo role = bll.GetModel(oldusermodel.F_RoleId);//要修改账户的角色
  772. //要修改de账号 角色代码,登录人不是系统管理员,返回false
  773. if (role.F_RoleCode == "XTGLY" || role.F_RoleCode == "YWGLY")
  774. {
  775. if (role2.F_RoleCode != "XTGLY")
  776. {
  777. return false;
  778. }
  779. }
  780. Model.T_Sys_RoleInfo rolenew = bll.GetModel(userModel.F_RoleId);//要修改账户的改了之后的角色
  781. if (rolenew.F_RoleCode == "XTGLY" || rolenew.F_RoleCode == "YWGLY")
  782. {
  783. if (role2.F_RoleCode != "XTGLY")
  784. {
  785. return false;
  786. }
  787. }
  788. }
  789. userModel.F_WorkNumber = userModel.F_UserCode;
  790. if (userModel.F_UserId > 0)
  791. {
  792. T_Sys_UserAccount oldUserModel = userBLL.GetModel(userModel.F_UserId);
  793. oldUserModel.F_WorkNumber = userModel.F_WorkNumber;
  794. oldUserModel.F_UserName = userModel.F_UserName;
  795. oldUserModel.F_UserCode = userModel.F_UserCode;
  796. oldUserModel.F_DeptId = userModel.F_DeptId;
  797. oldUserModel.F_RoleId = userModel.F_RoleId;
  798. oldUserModel.F_SexFlag = userModel.F_SexFlag;
  799. oldUserModel.F_Telephone = userModel.F_Telephone;
  800. oldUserModel.F_SeatFlag = userModel.F_SeatFlag;
  801. oldUserModel.F_SeatRight = userModel.F_SeatRight;
  802. oldUserModel.F_Password = userModel.F_Password;
  803. oldUserModel.F_Remark = userModel.F_Remark;
  804. oldUserModel.F_ExtensionNumber = userModel.F_ExtensionNumber.ToMyString();
  805. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", userModel.F_UserName);
  806. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
  807. return userBLL.Update(oldUserModel);
  808. }
  809. else
  810. {
  811. Model.T_Sys_RoleInfo role2 = bll.GetModel(F_RoleID); //当前登录人的角色
  812. Model.T_Sys_RoleInfo rolenew = bll.GetModel(userModel.F_RoleId);//要添加账户的的角色
  813. if (rolenew.F_RoleCode == "XTGLY" || rolenew.F_RoleCode == "YWGLY")
  814. {
  815. if (role2.F_RoleCode != "XTGLY")
  816. {
  817. return false;
  818. }
  819. }
  820. userModel.F_HJType = 0;
  821. userModel.F_GroupId = 1;
  822. if (userModel.F_SeatFlag)//&&false)
  823. {
  824. #region 调用接口插入用户信息
  825. try
  826. {
  827. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "rexian.zzmetro.com用户编号" + userModel.F_UserCode);
  828. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  829. StringBuilder returnStr = new StringBuilder();
  830. string wxAddUrl = "http://rexian.zzmetro.com/api/customer/insert";
  831. UserInfo model = new UserInfo();
  832. model.name = userModel.F_UserCode;
  833. object userInfo = JObject.Parse(JsonConvert.SerializeObject(model));
  834. string addWxResult = HttpHelper.HttpPost(wxAddUrl, userInfo);
  835. ResponseResult ResultModel = JsonConvert.DeserializeObject<ResponseResult>(addWxResult);
  836. userModel.F_PId = ResultModel.data;
  837. }
  838. catch (Exception ex)
  839. {
  840. }
  841. #endregion
  842. }
  843. int userid = userBLL.Add(userModel);
  844. AddAction("t_sys_useraccount", userid.ToMyString(), "新增用户", userModel.F_UserName);
  845. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "新增用户", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  846. return userid > 0;
  847. }
  848. }
  849. /// <summary>
  850. /// 删除用户
  851. /// </summary>
  852. /// <param name="workOrderBaseModel"></param>
  853. /// <returns></returns>
  854. [AcceptVerbs(HttpVerbs.Get)]
  855. public bool DeleteUserData(int userId)
  856. {
  857. T_Sys_UserAccount oldUserModel = userBLL.GetModel(userId);
  858. if (F_RoleID != 17 &&(oldUserModel.F_RoleId==17 || oldUserModel.F_RoleId == 57))
  859. {
  860. return false;
  861. }
  862. AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户");
  863. AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
  864. return userBLL.Delete(userId);
  865. }
  866. /// <summary>
  867. /// 获取用户数据
  868. /// </summary>
  869. /// <param name="page">当前页码</param>
  870. /// <param name="limit">每页数据量</param>
  871. /// <returns></returns>
  872. [ActionName("UserDate")]
  873. [HttpGet]
  874. public string UserDate(DateTime? NowDateTime, int page, int limit, int? deptId)
  875. {
  876. AddAction("t_sys_useraccount", "page", "获取用户列表", "部门编号" + deptId.ToMyString());
  877. //数据结果集
  878. ResponseData dataModel = new ResponseData();
  879. string sql = "";
  880. if (deptId != null && deptId > 0)
  881. {
  882. sql += " and F_DeptId=" + deptId;
  883. }
  884. DataTable dt = new DataTable();
  885. int recordCount = 0;
  886. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  887. dt = BLL.PagerBLL.GetListPager(
  888. "T_Sys_UserAccount",
  889. "F_UserId",
  890. "*"
  891. + ",(select top 1 t.F_DeptName from T_Sys_Department t where t.F_DeptId=T_Sys_UserAccount.F_DeptId) as F_DeptName "
  892. + ",(select top 1 t.F_RoleName from T_Sys_RoleInfo t where t.F_RoleId=T_Sys_UserAccount.F_RoleId) as F_RoleName "
  893. + ",(CASE F_SeatFlag WHEN 1 THEN '使用' WHEN 0 THEN '不使用' ELSE NULL END ) as F_SeatFlagName"
  894. + ",(CASE F_SeatRight WHEN 1 THEN '班长坐席' WHEN 0 THEN '普通坐席' ELSE NULL END ) as F_SeatRightName"
  895. ,
  896. sql,
  897. "ORDER BY F_UserCode asc ",
  898. limit,
  899. page,
  900. true,
  901. out recordCount);
  902. dataModel.code = 0;
  903. dataModel.count = recordCount;
  904. dataModel.data = dt;
  905. return JsonConvert.SerializeObject(dataModel);
  906. }
  907. #endregion
  908. #region 修改密码
  909. /// <summary>
  910. ///用户修改个人密码
  911. /// </summary>
  912. /// <param name="id"></param>
  913. /// <returns></returns>
  914. public ActionResult UserPwdEdit()
  915. {
  916. AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开修改密码页");
  917. Model.T_Sys_UserAccount model = new Model.T_Sys_UserAccount();
  918. if (F_UserID > 0)
  919. {
  920. model = userBLL.GetModel(F_UserID);
  921. }
  922. return View(model);
  923. }
  924. /// </summary>
  925. [AcceptVerbs(HttpVerbs.Post)]
  926. public ActionResult CheckPwd(string pwd)
  927. {
  928. checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(pwd);
  929. return Json(new
  930. {
  931. code = chkrslt.RSL ? 0 : 1,
  932. msg = chkrslt.MSG
  933. });
  934. }
  935. /// <summary>
  936. ///保存修改密码
  937. /// </summary>
  938. [AcceptVerbs(HttpVerbs.Post)]
  939. public string UpdateUserPwd(Model.T_Sys_UserAccount model)
  940. {
  941. //checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(model.password);
  942. //if(!chkrslt.RSL)
  943. //{
  944. // return chkrslt.MSG;
  945. //}
  946. string AddRersult = "false";
  947. if (model.F_UserId > 0)
  948. {
  949. Model.T_Sys_UserAccount newModel = userBLL.GetModel(model.F_UserId);
  950. if (newModel != null && newModel.F_Password == model.oldPwd)
  951. {
  952. newModel.F_Password = model.password;
  953. if (userBLL.Update(newModel))
  954. {
  955. AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码");
  956. AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码", "数据:" + JsonConvert.SerializeObject(newModel), "敏感信息");
  957. AddRersult = "True";
  958. }
  959. }
  960. else
  961. {
  962. AddRersult = "旧密码不正确!";
  963. }
  964. }
  965. return AddRersult;
  966. }
  967. #endregion
  968. #region 基本信息
  969. /// <summary>
  970. /// 用户编辑
  971. /// </summary>
  972. /// <param name="editType">类型1、新增 2、修改</param>
  973. /// /// <returns></returns>
  974. public ActionResult UserView()
  975. {
  976. Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
  977. AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开用户编辑页", "用户:"+userModel.F_UserName);
  978. if (string.IsNullOrEmpty(userModel.F_HomePhone))
  979. {
  980. userModel.F_HomePhone = "/Content/images/face.jpg";
  981. }
  982. else
  983. {
  984. if (!System.IO.File.Exists(Server.MapPath(userModel.F_HomePhone)))
  985. {
  986. userModel.F_HomePhone = "/Content/images/face.jpg";
  987. }
  988. }
  989. return View(userModel);
  990. }
  991. #endregion
  992. #region 图片上传
  993. /// <summary>
  994. /// 图片上传
  995. /// </summary>
  996. /// <returns></returns>
  997. [AcceptVerbs(HttpVerbs.Post)]
  998. public ActionResult UploadFile()
  999. {
  1000. try
  1001. {
  1002. if (Request.Files.Count > 0)
  1003. {
  1004. string uppath = string.Empty;
  1005. string savepath = string.Empty;
  1006. HttpPostedFileBase imgFile = Request.Files[0];
  1007. if (imgFile != null)
  1008. {
  1009. //创建图片新的名称
  1010. string nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff");
  1011. //获得上传图片的路径
  1012. string strPath = imgFile.FileName;
  1013. //获得上传图片的类型(后缀名)
  1014. string type = strPath.Substring(strPath.LastIndexOf(".") + 1).ToLower();
  1015. //拼写数据库保存的相对路径字符串
  1016. savepath = "/Content/HeadImg/images/";
  1017. //拼写上传图片的路径
  1018. uppath = Server.MapPath("~/Content/HeadImg/images/");
  1019. if (!Directory.Exists(Path.GetDirectoryName(uppath)))
  1020. {
  1021. Directory.CreateDirectory(Path.GetDirectoryName(uppath));
  1022. }
  1023. uppath += nameImg + "." + type;
  1024. savepath += nameImg + "." + type;
  1025. //上传图片
  1026. imgFile.SaveAs(uppath); //原图片路径
  1027. }
  1028. Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
  1029. userModel.F_HomePhone = savepath;
  1030. if (userBLL.Update(userModel))
  1031. {
  1032. return Json(new
  1033. {
  1034. code = 0,
  1035. src = savepath,
  1036. msg = "上传成功"
  1037. });
  1038. }
  1039. else
  1040. {
  1041. return Json(new
  1042. {
  1043. code = 1,
  1044. src = "",
  1045. msg = "上传出错 请检查图片名称或图片内容"
  1046. });
  1047. }
  1048. }
  1049. else
  1050. {
  1051. return Json(new
  1052. {
  1053. code = 1,
  1054. src = "",
  1055. msg = "上传出错 请检查图片名称或图片内容"
  1056. });
  1057. }
  1058. }
  1059. catch (Exception ex)
  1060. {
  1061. return Json(new
  1062. {
  1063. code = 1,
  1064. src = "",
  1065. msg = "上传出错: " + ex.Message
  1066. });
  1067. }
  1068. }
  1069. #endregion
  1070. #region 公告管理
  1071. /// <summary>
  1072. /// 公告管理
  1073. /// </summary>
  1074. /// <returns></returns>
  1075. public ActionResult noticeManage()
  1076. {
  1077. Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
  1078. return View(noticeModel);
  1079. }
  1080. public ActionResult test()
  1081. {
  1082. Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
  1083. return View(noticeModel);
  1084. }
  1085. /// <summary>
  1086. /// 获取公告数据
  1087. /// </summary>
  1088. /// <param name="page">当前页码</param>
  1089. /// <param name="limit">每页数据量</param>
  1090. /// <returns></returns>
  1091. [ActionName("NoticeListDate")]
  1092. [HttpGet]
  1093. public string NoticeListDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  1094. {
  1095. AddAction("t_msg_noticeinfo", parentId.ToMyString(), "获取公告列表", page+"-"+ limit);
  1096. //数据结果集
  1097. ResponseData dataModel = new ResponseData();
  1098. string sql = "";
  1099. if (parentId != null)
  1100. {
  1101. sql += " and F_ParentId=" + parentId;
  1102. }
  1103. DataTable dt = new DataTable();
  1104. int recordCount = 0;
  1105. Model.PageData<Model.T_Msg_NoticeInfo> pageModel = new Model.PageData<Model.T_Msg_NoticeInfo>();
  1106. dt = BLL.PagerBLL.GetListPager(
  1107. "T_Msg_NoticeInfo",
  1108. "F_NoticeId",
  1109. "*,CONVERT(varchar,F_CreateOn, 120 ) as F_CreateOnNew,isnull( CONVERT(varchar,F_ModifyDate, 120 ) ,CONVERT(varchar,F_CreateOn, 120 ) )as F_ModifyDateNew ",
  1110. sql,
  1111. "ORDER BY isnull( CONVERT(varchar,F_ModifyDate, 120 ) ,CONVERT(varchar,F_CreateOn, 120 ) ) desc ",
  1112. limit,
  1113. page,
  1114. true,
  1115. out recordCount);
  1116. dataModel.code = 0;
  1117. dataModel.count = recordCount;
  1118. dataModel.data = dt;
  1119. return JsonConvert.SerializeObject(dataModel);
  1120. }
  1121. BLL.T_Msg_NoticeInfo noticeBLL = new BLL.T_Msg_NoticeInfo();
  1122. BLL.T_Msg_NoticeUsers noticeuserBLL = new BLL.T_Msg_NoticeUsers();
  1123. BLL.T_Sys_UserAccount usersBLL = new BLL.T_Sys_UserAccount();
  1124. /// <summary>
  1125. /// 编辑公告
  1126. /// </summary>
  1127. /// <param name="editType">类型1、新增 2、修改</param>
  1128. /// /// <returns></returns>
  1129. public ActionResult NoticeEdit(int? noticeId, int editType)
  1130. {
  1131. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "打开公告编辑页");
  1132. Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
  1133. //当前对象实体
  1134. if (editType == 1)
  1135. {
  1136. viewModel.F_NoticeId = int.Parse(noticeId.ToString());
  1137. //viewModel.UseList = userBLL.GetModelList("");
  1138. }
  1139. else
  1140. {
  1141. Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
  1142. viewModel = userModel;
  1143. if (!string.IsNullOrEmpty(userModel.F_ReceiveInfo))
  1144. {
  1145. int deviceid = userModel.F_DeviceId == null ? 0 : (int)userModel.F_DeviceId;
  1146. viewModel.UseList = userBLL.GetModelList("F_UserId=" + deviceid);
  1147. viewModel.DepartmentList = deptBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
  1148. }
  1149. }
  1150. //获取部门列表
  1151. return View(viewModel);
  1152. }
  1153. /// <summary>
  1154. /// 查看公告
  1155. /// </summary>
  1156. /// <param name="editType">类型1、新增 2、修改</param>
  1157. /// /// <returns></returns>
  1158. public ActionResult NoticeView(int? noticeId)
  1159. {
  1160. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "查看公告详情");
  1161. Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
  1162. viewModel.F_NoticeId = int.Parse(noticeId.ToString());
  1163. viewModel.UseList = userBLL.GetModelList("");
  1164. Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
  1165. viewModel = userModel;
  1166. viewModel.UseList = userBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
  1167. //获取部门列表
  1168. viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
  1169. return View(viewModel);
  1170. }
  1171. /// <summary>
  1172. /// 保存编辑公告
  1173. /// </summary>
  1174. /// <param name="workOrderBaseModel"></param>
  1175. /// <returns></returns>
  1176. [AcceptVerbs(HttpVerbs.Post)]
  1177. public bool SaveNoticeData(T_Msg_NoticeInfo noticeinfoModel)
  1178. {
  1179. bool result = false;
  1180. DataTable dt = new DataTable();
  1181. DataTable dtuser = new DataTable();
  1182. int noticeid = 0;
  1183. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1184. DateTime? readdate =null;
  1185. try
  1186. {
  1187. //获取当前用户
  1188. noticeinfoModel.F_CreateBy = F_UserID;
  1189. noticeinfoModel.F_CreateName = HttpUtility.UrlDecode(F_UserName);
  1190. if (noticeinfoModel.F_NoticeId > 0)
  1191. {
  1192. noticeid = noticeinfoModel.F_NoticeId;
  1193. Model.T_Msg_NoticeInfo oldnoticeinfoModel = noticeBLL.GetModel(int.Parse(noticeid.ToString())); ;
  1194. dt = new ZXDT.CallCenter.BLL.T_Msg_NoticeInfo().GetList("1=1 and F_NoticeId= " + noticeid).Tables[0];
  1195. if (dt.Rows.Count > 0)
  1196. {
  1197. dtuser = new ZXDT.CallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32(dt.Rows[0]["F_ReceiveInfo"].ToString())).Tables[0];
  1198. foreach (DataRow dr in dtuser.Rows)
  1199. {
  1200. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1201. result = noticeuserBLL.Delete(noticeid, noticeuserModel.F_UserId);
  1202. }
  1203. }
  1204. readdate =Convert.ToDateTime( oldnoticeinfoModel.F_CreateOn);
  1205. oldnoticeinfoModel.F_Code = noticeinfoModel.F_Code;
  1206. oldnoticeinfoModel.F_Title = noticeinfoModel.F_Title;
  1207. oldnoticeinfoModel.F_Resume = noticeinfoModel.F_Resume;
  1208. oldnoticeinfoModel.F_Content = noticeinfoModel.F_Content;
  1209. oldnoticeinfoModel.F_ReceiveInfo = noticeinfoModel.F_ReceiveInfo;
  1210. oldnoticeinfoModel.F_DeviceId = noticeinfoModel.F_DeviceId;
  1211. oldnoticeinfoModel.F_State = 1;
  1212. oldnoticeinfoModel.F_ModifyDate = DateTime.Now;
  1213. oldnoticeinfoModel.F_ModifyBy = F_UserID;
  1214. result = noticeBLL.Update(oldnoticeinfoModel);
  1215. AddAction("t_msg_noticeinfo", oldnoticeinfoModel.F_NoticeId.ToMyString(), "修改公告");
  1216. }
  1217. else
  1218. {
  1219. noticeid = 0;
  1220. noticeinfoModel.F_DeviceId = noticeinfoModel.F_UserId;
  1221. noticeinfoModel.F_State = 1;
  1222. noticeinfoModel.F_CreateOn = DateTime.Now;
  1223. noticeinfoModel.F_ModifyDate = DateTime.Now;
  1224. readdate = noticeinfoModel.F_CreateOn;
  1225. noticeid = noticeBLL.Add(noticeinfoModel);
  1226. if (noticeid > 0)
  1227. {
  1228. result = true;
  1229. }
  1230. AddAction("t_msg_noticeinfo", noticeid.ToMyString(), "添加公告");
  1231. }
  1232. //指定方式发送公告
  1233. if (noticeinfoModel.F_DeviceId > 0)
  1234. {//指定人员发公告
  1235. noticeuserModel.F_NoticeId = noticeid;
  1236. noticeuserModel.F_UserId = Convert.ToInt32(noticeinfoModel.F_UserId);
  1237. noticeuserModel.F_UserName = noticeinfoModel.F_UserName;
  1238. //if (readdate.ToString() != "")
  1239. //{ noticeuserModel.F_ReadDate = readdate; }
  1240. //else
  1241. //{
  1242. // noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
  1243. //}
  1244. noticeuserModel.F_State = 0;
  1245. noticeuserModel.F_Type = 0;
  1246. result = noticeuserBLL.Add(noticeuserModel);
  1247. }
  1248. else
  1249. {//指定部门发公告
  1250. dt = new ZXDT.CallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + noticeinfoModel.F_ReceiveInfo).Tables[0];
  1251. if (dt.Rows.Count > 0)
  1252. {
  1253. noticeuserModel.F_NoticeId = noticeid;
  1254. //if (readdate.ToString()!="")
  1255. //{ noticeuserModel.F_ReadDate = readdate; }
  1256. //else {
  1257. //noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
  1258. //}
  1259. foreach (DataRow dr in dt.Rows)
  1260. {
  1261. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1262. noticeuserModel.F_UserName = dr["F_UserName"].ToString();
  1263. noticeuserModel.F_State = 0;
  1264. noticeuserModel.F_Type = 0;
  1265. result = noticeuserBLL.Add(noticeuserModel);
  1266. }
  1267. }
  1268. }
  1269. }
  1270. catch (Exception) { }
  1271. finally
  1272. {
  1273. dt.Clear();
  1274. dt.Dispose();
  1275. }
  1276. return result;
  1277. }
  1278. /// <summary>
  1279. /// 删除公告
  1280. /// </summary>
  1281. /// <param name="workOrderBaseModel"></param>
  1282. /// <returns></returns>
  1283. [AcceptVerbs(HttpVerbs.Get)]
  1284. public bool DeleteNoticeData(int noticeId)
  1285. {
  1286. bool res = false;
  1287. DataTable dt = new DataTable();
  1288. DataTable dtuser = new DataTable();
  1289. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1290. try
  1291. {
  1292. dt = noticeBLL.GetList("1=1 and F_NoticeId= " + noticeId).Tables[0];
  1293. if (dt.Rows.Count > 0)
  1294. {
  1295. res = noticeBLL.Delete(noticeId);
  1296. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "删除公告");
  1297. //指定部门发公告
  1298. dtuser = new ZXDT.CallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32( dt.Rows[0]["F_ReceiveInfo"].ToString()) ).Tables[0];
  1299. foreach (DataRow dr in dtuser.Rows)
  1300. {
  1301. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1302. noticeuserBLL.Delete(noticeId, noticeuserModel.F_UserId);
  1303. }
  1304. }
  1305. }
  1306. catch (Exception) { }
  1307. finally {
  1308. dt.Clear();
  1309. dt.Dispose();
  1310. dtuser.Clear();
  1311. dtuser.Dispose();
  1312. }
  1313. return res;
  1314. }
  1315. /// <summary>
  1316. /// 未接根据recordid更新回访信息
  1317. /// </summary>
  1318. /// <param name="SetCallRecordHfInfo"></param>
  1319. /// <returns></returns>
  1320. [ActionName("SetNoticeState")]
  1321. [HttpGet]
  1322. public string SetNoticeState(string id, string timeno)
  1323. {
  1324. string res = "";
  1325. try
  1326. {
  1327. Model.T_Msg_NoticeInfo model = new Model.T_Msg_NoticeInfo();
  1328. model.F_State =1;
  1329. model.F_NoticeId = Convert.ToInt32(id);
  1330. bool bl = new BLL.T_Msg_NoticeInfo().UpdateNoticeState(model);
  1331. if (bl)
  1332. {
  1333. res = "success";
  1334. }
  1335. }
  1336. catch
  1337. { }
  1338. return res;
  1339. }
  1340. [ActionName("CookieData")]
  1341. [HttpGet]
  1342. public string CookieData() {
  1343. return F_UserID.ToString();
  1344. }
  1345. #endregion
  1346. /// <summary>
  1347. /// 工作时间管理
  1348. /// </summary>
  1349. /// <returns></returns>
  1350. public ActionResult workTimeManage()
  1351. {
  1352. Model.T_SYS_Time timeModel = new Model.T_SYS_Time();
  1353. return View(timeModel);
  1354. }
  1355. /// <summary>
  1356. /// 获取工作时间数据
  1357. /// </summary>
  1358. /// <param name="page">当前页码</param>
  1359. /// <param name="limit">每页数据量</param>
  1360. /// <returns></returns>
  1361. [ActionName("workTimeListData")]
  1362. [HttpGet]
  1363. public string workTimeListData()
  1364. {
  1365. //数据结果集
  1366. ResponseData dataModel = new ResponseData();
  1367. string sql = " select top 1 * from T_SYS_Time";
  1368. DataTable dt= DbHelperSQL.Query(sql).Tables[0];
  1369. dataModel.code = 0;
  1370. dataModel.count = 1;
  1371. dataModel.data = dt;
  1372. return JsonConvert.SerializeObject(dataModel);
  1373. }
  1374. public ActionResult workTimeEdit(int workTimeId )
  1375. {
  1376. Model.T_SYS_Time viewModel = new Model.T_SYS_Time();
  1377. // Model.T_SYS_Time userModel = timeBLL.GetModel(workTimeId);
  1378. //获取部门列表
  1379. return View(viewModel);
  1380. }
  1381. [AcceptVerbs(HttpVerbs.Post)]
  1382. public bool SaveWorkTimeData(T_SYS_Time systimeModel)
  1383. {
  1384. bool result = false;
  1385. DataTable dt = new DataTable();
  1386. DataTable dtuser = new DataTable();
  1387. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1388. try
  1389. {
  1390. Model.T_SYS_Time oldsystimeModel = timeBLL.GetModel();
  1391. oldsystimeModel.F_WorkEndTimes = systimeModel.F_WorkEndTimes;
  1392. oldsystimeModel.F_WorkStartTimes = systimeModel.F_WorkStartTimes;
  1393. result = timeBLL.Update(oldsystimeModel);
  1394. AddAction("t_sys_time", "1", "修改工作时间", "", F_UserCode + "在" + DateTime.Now.ToString() + "修改工作时间");
  1395. }
  1396. catch (Exception) { }
  1397. finally
  1398. {
  1399. dt.Clear();
  1400. dt.Dispose();
  1401. }
  1402. return result;
  1403. }
  1404. public string GetUnreadData()
  1405. {
  1406. DataTable dt = new ZXDT.CallCenter.BLL.T_Msg_NoticeUsers().GetList("1=1 and F_ReadDate is null and F_UserId= " + F_UserID + "order by F_ReadDate desc").Tables[0];
  1407. DataTable dtinfo = new DataTable();
  1408. if (dt.Rows.Count > 0)
  1409. {
  1410. List<int> noticelist = (from r in dt.AsEnumerable() select r.Field<int>("F_NoticeId")).ToList<int>();
  1411. dtinfo = new ZXDT.CallCenter.BLL.T_Msg_NoticeInfo().GetList("1=1 and F_State=1 and F_NoticeId in ( '" + string.Join("','", noticelist) + "') order by ISNULL(F_ModifyDate,F_CreateOn) desc").Tables[0];
  1412. }
  1413. return JsonConvert.SerializeObject(dtinfo);
  1414. }
  1415. public bool readNoticeData(int noticeid)
  1416. {
  1417. BLL.T_Msg_NoticeUsers noticeUsers = new BLL.T_Msg_NoticeUsers();
  1418. Model.T_Msg_NoticeUsers model= noticeUsers.GetModel(noticeid,F_UserID);
  1419. model.F_ReadDate = DateTime.Now;
  1420. noticeUsers.Update(model);
  1421. return true;
  1422. }
  1423. }
  1424. #region 接口基本信息
  1425. /// <summary>
  1426. /// 用户信息
  1427. /// </summary>
  1428. public class UserInfo
  1429. {
  1430. public int id
  1431. {
  1432. get;
  1433. set;
  1434. }
  1435. public string name
  1436. {
  1437. get;
  1438. set;
  1439. }
  1440. }
  1441. /// <summary>
  1442. /// 返回结果信息
  1443. /// </summary>
  1444. public class ResponseResult
  1445. {
  1446. public int code
  1447. {
  1448. get;
  1449. set;
  1450. }
  1451. public int data
  1452. {
  1453. get;
  1454. set;
  1455. }
  1456. }
  1457. /// <summary>
  1458. /// 返回结果信息
  1459. /// </summary>
  1460. public class WXResponseResult
  1461. {
  1462. public int customer
  1463. {
  1464. get;
  1465. set;
  1466. }
  1467. public int service
  1468. {
  1469. get;
  1470. set;
  1471. }
  1472. public int total
  1473. {
  1474. get;
  1475. set;
  1476. }
  1477. }
  1478. #endregion
  1479. }