地铁二期项目正式开始

SystemManageController.cs 59KB

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