商丘12345 后端

WebController.cs 55KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.DB;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using CallCenterApi.Interface.Controllers.workorder;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Transactions;
  13. using System.Web;
  14. using System.Web.Mvc;
  15. namespace CallCenterApi.Interface.Controllers
  16. {
  17. public class WebController : BaseController
  18. {
  19. private BLL.T_Web_Link linkBLL = new BLL.T_Web_Link();
  20. private BLL.T_Web_News newsBLL = new BLL.T_Web_News();
  21. private BLL.T_Web_SurveyResult resBLL = new BLL.T_Web_SurveyResult();
  22. private BLL.T_Web_WorkRelease fbBLL = new BLL.T_Web_WorkRelease();
  23. #region 链接地址
  24. /// <summary>
  25. /// 获取链接列表
  26. /// </summary>
  27. /// <returns></returns>
  28. [Authority]
  29. public ActionResult GetLinkList()
  30. {
  31. string name = RequestString.GetQueryString("name");
  32. string strpageindex = RequestString.GetQueryString("page");
  33. int pageindex = 1;
  34. string strpagesize = RequestString.GetQueryString("pagesize");
  35. int pagesize = 10;
  36. var sql = " and 1=1 ";
  37. if (!string.IsNullOrEmpty(name))
  38. {
  39. sql += " and LinkName like '%" + name + "%'";
  40. }
  41. if (strpageindex.Trim() != "")
  42. {
  43. pageindex = Convert.ToInt32(strpageindex);
  44. }
  45. if (strpagesize.Trim() != "")
  46. {
  47. pagesize = Convert.ToInt32(strpagesize);
  48. }
  49. var recordCount = 0;
  50. var dt = BLL.PagerBLL.GetListPager(
  51. "T_Web_Link",
  52. "Id",
  53. "*",
  54. sql,
  55. "ORDER BY Id ",
  56. pagesize,
  57. pageindex,
  58. true,
  59. out recordCount);
  60. var obj = new
  61. {
  62. rows = dt,
  63. total = recordCount
  64. };
  65. return Content(obj.ToJson());
  66. }
  67. /// <summary>
  68. /// 获取链接
  69. /// </summary>
  70. /// <param name=""></param>
  71. /// <returns></returns>
  72. [Authority]
  73. public ActionResult GetLink()
  74. {
  75. int id = RequestString.GetInt("id", 0);
  76. Model.T_Web_Link baseModel = linkBLL.GetModel(id);
  77. if (baseModel != null)
  78. return Success("加载成功", baseModel);
  79. else
  80. return Error("加载失败");
  81. }
  82. /// <summary>
  83. /// 添加/编辑链接
  84. /// </summary>
  85. /// <param name="input"></param>
  86. /// <returns></returns>
  87. [Authority]
  88. public ActionResult AddLink()
  89. {
  90. int id = RequestString.GetInt("id", 0);
  91. string name = RequestString.GetFormString("name");
  92. string url = RequestString.GetFormString("url");
  93. Model.T_Web_Link orderModel = new Model.T_Web_Link();
  94. if (id == 0)
  95. {
  96. var list = linkBLL.GetModelList("LinkName='" + name + "' ");
  97. if (list.Count > 0)
  98. {
  99. return Error("此链接名称已经存在");
  100. }
  101. else
  102. {
  103. orderModel.LinkName = name;
  104. orderModel.LinkUrl = url;
  105. if (linkBLL.Add(orderModel) > 0)
  106. return Success("链接添加成功");
  107. else
  108. return Error("链接添加失败");
  109. }
  110. }
  111. else
  112. {
  113. orderModel = linkBLL.GetModel(id);
  114. if (orderModel != null)
  115. {
  116. var list = linkBLL.GetModelList("LinkName='" + name + "' and Id!='" + id + "' ");
  117. if (list.Count > 0)
  118. {
  119. return Error("此链接名称已经存在");
  120. }
  121. else
  122. {
  123. orderModel.LinkName = name;
  124. orderModel.LinkUrl = url;
  125. if (linkBLL.Update(orderModel))
  126. return Success("链接修改成功");
  127. else
  128. return Error("链接修改失败");
  129. }
  130. }
  131. else
  132. {
  133. return Success("链接修改成功");
  134. }
  135. }
  136. }
  137. /// <summary>
  138. /// 删除链接
  139. /// </summary>
  140. /// <param name="ids"></param>
  141. /// <returns></returns>
  142. [Authority]
  143. public ActionResult DelLink(string[] ids)
  144. {
  145. if (ids == null || ids.Length <= 0)
  146. return Error("获取参数失败");
  147. StringBuilder sb = new StringBuilder();
  148. foreach (var item in ids)
  149. {
  150. sb.Append("'" + item + "',");
  151. }
  152. if (linkBLL.DeleteList(sb.ToString().Trim(',')))
  153. return Success("删除成功");
  154. else
  155. return Error("删除失败");
  156. }
  157. #endregion
  158. #region 新闻
  159. /// <summary>
  160. /// 上传图片
  161. /// </summary>
  162. /// <returns></returns>
  163. [Authority]
  164. public ActionResult UploadImage()
  165. {
  166. string path = string.Empty;
  167. //HttpPostedFile _upfile = RequestString.GetFile("upFile");
  168. string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
  169. if (!string.IsNullOrEmpty(dataurl))
  170. {
  171. path = "/Upload/News/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  172. ImageUpload iu = new ImageUpload();
  173. iu.SavePath = path;
  174. iu.DataUrl = dataurl;
  175. iu.Upload64();
  176. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  177. int n = iu.Error;
  178. if (n == 0)
  179. {
  180. var obj = new
  181. {
  182. ym = configfj != null ? configfj.F_ParamValue : "",
  183. imgurl = path + iu.OutFileName,
  184. smallimgurl = path + iu.OutThumbFileName
  185. };
  186. return Success("成功", obj);
  187. }
  188. else
  189. {
  190. string msg = string.Empty;
  191. switch (n)
  192. {
  193. case 1: msg = "请选择要上传的文件"; break;
  194. case 2: msg = "上传的文件类型不支持"; break;
  195. case 3: msg = "上传的文件过大"; break;
  196. case 4: msg = "未知错误"; break;
  197. }
  198. return Error(msg);
  199. }
  200. }
  201. else
  202. {
  203. return Error("请选择要上传的文件");
  204. }
  205. }
  206. /// <summary>
  207. /// 获取新闻列表
  208. /// </summary>
  209. /// <returns></returns>
  210. [Authority]
  211. public ActionResult GetNewsList()
  212. {
  213. int type = RequestString.GetInt("type", 0);
  214. string name = RequestString.GetQueryString("name");
  215. int iszd = RequestString.GetInt("iszd", -1);
  216. string strpageindex = RequestString.GetQueryString("page");
  217. int pageindex = 1;
  218. string strpagesize = RequestString.GetQueryString("pagesize");
  219. int pagesize = 10;
  220. var sql = " and 1=1 ";
  221. if (type != 0)
  222. {
  223. sql += " and ClassId = '" + type + "'";
  224. }
  225. if (!string.IsNullOrEmpty(name))
  226. {
  227. sql += " and bt like '%" + name + "%'";
  228. }
  229. if (iszd != -1)
  230. {
  231. sql += " and isnull(iszd,0) = '" + iszd + "'";
  232. }
  233. if (strpageindex.Trim() != "")
  234. {
  235. pageindex = Convert.ToInt32(strpageindex);
  236. }
  237. if (strpagesize.Trim() != "")
  238. {
  239. pagesize = Convert.ToInt32(strpagesize);
  240. }
  241. var recordCount = 0;
  242. var dt = BLL.PagerBLL.GetListPager(
  243. "T_Web_News",
  244. "id",
  245. "*",
  246. sql,
  247. "ORDER BY ordernum asc,sj desc ",
  248. pagesize,
  249. pageindex,
  250. true,
  251. out recordCount);
  252. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  253. dt.Columns.Add("UserCode", typeof(string));
  254. foreach (DataRow dr in dt.Rows)
  255. {
  256. string id = (dr["zxbh"] == null ? "" : dr["zxbh"].ToString());
  257. if (id != "")
  258. {
  259. var u = new BLL.T_Sys_UserAccount().GetModel(Int32.Parse(id));
  260. if (u != null)
  261. {
  262. dr["UserCode"] = u.F_UserCode;
  263. }
  264. }
  265. string url = (dr["img"] == null ? "" : dr["img"].ToString());
  266. string smallurl = (dr["urlname"] == null ? "" : dr["urlname"].ToString());
  267. if (!string.IsNullOrEmpty(url) && configfj != null)
  268. {
  269. dr["img"] = configfj.F_ParamValue + url;
  270. }
  271. if (!string.IsNullOrEmpty(smallurl) && configfj != null)
  272. {
  273. dr["urlname"] = configfj.F_ParamValue + smallurl;
  274. }
  275. }
  276. var obj = new
  277. {
  278. rows = dt,
  279. total = recordCount
  280. };
  281. return Content(obj.ToJson());
  282. }
  283. /// <summary>
  284. /// 获取新闻
  285. /// </summary>
  286. /// <param name=""></param>
  287. /// <returns></returns>
  288. [Authority]
  289. public ActionResult GetNews()
  290. {
  291. int id = RequestString.GetInt("id", 0);
  292. Model.T_Web_News baseModel = newsBLL.GetModel(id);
  293. if (baseModel != null)
  294. {
  295. string ym = "";
  296. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  297. if (configfj != null)
  298. {
  299. ym = configfj.F_ParamValue;
  300. }
  301. var obj = new
  302. {
  303. bt = baseModel.bt,
  304. ClassId = baseModel.ClassId,
  305. id = baseModel.id,
  306. img = baseModel.img,
  307. iszd = baseModel.iszd,
  308. nr = baseModel.nr,
  309. ordernum = baseModel.ordernum,
  310. sj = baseModel.sj,
  311. urlname = baseModel.urlname,
  312. zxbh = baseModel.zxbh,
  313. ym = ym
  314. };
  315. return Success("加载成功", obj);
  316. }
  317. else
  318. {
  319. return Error("加载失败");
  320. }
  321. }
  322. /// <summary>
  323. /// 添加/编辑新闻
  324. /// </summary>
  325. /// <param name="input"></param>
  326. /// <returns></returns>
  327. [Authority]
  328. public ActionResult AddNews()
  329. {
  330. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  331. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  332. int id = RequestString.GetInt("id", 0);
  333. int type = RequestString.GetInt("type", 0);
  334. int sort = RequestString.GetInt("sort", 0);
  335. int iszd = RequestString.GetInt("iszd", 0);
  336. string title = RequestString.GetFormString("title");
  337. string cont = WebHelper.UrlDecode(RequestString.GetFormString("cont"));
  338. string img = RequestString.GetFormString("img");
  339. string smallimg = RequestString.GetFormString("smallimg");
  340. Model.T_Web_News orderModel = new Model.T_Web_News();
  341. if (id == 0)
  342. {
  343. orderModel.ClassId = type;
  344. orderModel.bt = title;
  345. orderModel.img = img;
  346. orderModel.urlname = smallimg;
  347. orderModel.nr = cont;
  348. orderModel.ordernum = sort;
  349. orderModel.iszd = iszd;
  350. orderModel.zxbh = userModel.F_UserId;
  351. if (newsBLL.Add(orderModel) > 0)
  352. {
  353. if (iszd > 0)
  354. //CacheHelper.Remove($"ImgNewsList{type}1");
  355. RedisHelper.KeyDelete($"ImgNewsList{type}1");
  356. else
  357. //CacheHelper.Remove($"NewsList{type}");
  358. RedisHelper.KeyDelete($"NewsList{type}");
  359. return Success("新闻添加成功");
  360. }
  361. else
  362. return Error("新闻添加失败");
  363. }
  364. else
  365. {
  366. orderModel = newsBLL.GetModel(id);
  367. if (orderModel != null)
  368. {
  369. orderModel.ClassId = type;
  370. orderModel.bt = title;
  371. orderModel.img = img;
  372. orderModel.urlname = smallimg;
  373. orderModel.nr = cont;
  374. orderModel.ordernum = sort;
  375. orderModel.iszd = iszd;
  376. if (newsBLL.Update(orderModel))
  377. {
  378. if (iszd > 0)
  379. //CacheHelper.Remove($"ImgNewsList{type}1");
  380. RedisHelper.KeyDelete($"ImgNewsList{type}1");
  381. else
  382. //CacheHelper.Remove($"NewsList{type}");
  383. RedisHelper.KeyDelete($"NewsList{type}");
  384. //CacheHelper.Remove($"WebNews{orderModel.id}");
  385. RedisHelper.KeyDelete($"WebNews{orderModel.id}");
  386. return Success("新闻修改成功");
  387. }
  388. else
  389. return Error("新闻修改失败");
  390. }
  391. else
  392. {
  393. return Error("新闻修改失败");
  394. }
  395. }
  396. }
  397. /// <summary>
  398. /// 删除新闻
  399. /// </summary>
  400. /// <param name="ids"></param>
  401. /// <returns></returns>
  402. [Authority]
  403. public ActionResult DelNews(string[] ids)
  404. {
  405. if (ids == null || ids.Length <= 0)
  406. return Error("获取参数失败");
  407. StringBuilder sb = new StringBuilder();
  408. foreach (var item in ids)
  409. {
  410. sb.Append("'" + item + "',");
  411. }
  412. if (newsBLL.DeleteList(sb.ToString().Trim(',')))
  413. {
  414. foreach (var id in ids)
  415. {
  416. //CacheHelper.Remove($"WebNews{id}");
  417. RedisHelper.KeyDelete($"WebNews{id}");
  418. }
  419. //System.Web.Caching.Cache cache = HttpRuntime.Cache;
  420. //IDictionaryEnumerator cacheEnum = cache.GetEnumerator();
  421. //List<string> keys = new List<string>();
  422. //while (cacheEnum.MoveNext())
  423. //{
  424. // keys.Add(cacheEnum.Key.ToString());
  425. //}
  426. //var query = keys.Where(x => x.Contains("ImgNewsList") || x.Contains("NewsList")).ToList();
  427. //foreach (var key in query)
  428. //{
  429. // CacheHelper.Remove(key);
  430. //}
  431. RedisHelper.KeysDelete(RedisHelper.GetKeyList("ImgNewsList"));
  432. RedisHelper.KeysDelete(RedisHelper.GetKeyList("NewsList"));
  433. return Success("删除成功");
  434. }
  435. else
  436. return Error("删除失败");
  437. }
  438. #endregion
  439. #region 发布
  440. /// <summary>
  441. /// 获取发布工单列表
  442. /// </summary>
  443. /// <returns></returns>
  444. [Authority]
  445. public ActionResult GetReleaseList()
  446. {
  447. string title = RequestString.GetQueryString("title");
  448. string cont = RequestString.GetQueryString("cont");
  449. string workorderid = RequestString.GetQueryString("workorderid");
  450. string starttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  451. string endtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  452. int efftstate = RequestString.GetInt("efftstate", 0);
  453. string starttime1 = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime1"));
  454. string endtime1 = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime1"));
  455. int state = RequestString.GetInt("state", 0);
  456. string strpageindex = RequestString.GetQueryString("page");
  457. int pageindex = 1;
  458. string strpagesize = RequestString.GetQueryString("pagesize");
  459. int pagesize = 10;
  460. var sql = " and 1=1 ";
  461. if (!string.IsNullOrEmpty(title))
  462. {
  463. sql += " and F_Title like '%" + title + "%' ";
  464. }
  465. if (!string.IsNullOrEmpty(cont))
  466. {
  467. sql += " and F_Content like '%" + cont + "%' ";
  468. }
  469. if (!string.IsNullOrEmpty(workorderid))
  470. {
  471. sql += " and F_WorkOrderId like '%" + workorderid + "%' ";
  472. }
  473. if (!string.IsNullOrEmpty(starttime))
  474. {
  475. sql += " and datediff(d,F_AcceptTime,'" + starttime + "')<=0 ";
  476. }
  477. if (!string.IsNullOrEmpty(endtime))
  478. {
  479. sql += " and datediff(d,F_AcceptTime,'" + endtime + "')>=0 ";
  480. }
  481. if (efftstate != 0)
  482. {
  483. sql += " and F_EffectiveState=" + efftstate;
  484. if (efftstate == 2)
  485. {
  486. if (!string.IsNullOrEmpty(starttime1))
  487. {
  488. sql += " and datediff(d,F_EffectiveTime,'" + starttime1 + "')<=0 ";
  489. }
  490. if (!string.IsNullOrEmpty(endtime1))
  491. {
  492. sql += " and datediff(d,F_EffectiveTime,'" + endtime1 + "'>=0 ";
  493. }
  494. }
  495. }
  496. if (state != 0)
  497. {
  498. sql += " and F_ReleaseState=" + state;
  499. }
  500. if (strpageindex.Trim() != "")
  501. {
  502. pageindex = Convert.ToInt32(strpageindex);
  503. }
  504. if (strpagesize.Trim() != "")
  505. {
  506. pagesize = Convert.ToInt32(strpagesize);
  507. }
  508. var recordCount = 0;
  509. var dt = BLL.PagerBLL.GetListPager(
  510. "T_Web_WorkRelease",
  511. "F_WorkOrderId",
  512. "*,dbo.GetDeptName(F_Department) as F_DeptName,dbo.GetDictionaryName(F_WorkSort) as F_Value",
  513. sql,
  514. "order by F_WorkOrderId desc",
  515. pagesize,
  516. pageindex,
  517. true,
  518. out recordCount);
  519. var obj = new
  520. {
  521. rows = dt,
  522. total = recordCount
  523. };
  524. return Content(obj.ToJson());
  525. }
  526. /// <summary>
  527. /// 获取发布工单
  528. /// </summary>
  529. /// <param name=""></param>
  530. /// <returns></returns>
  531. [Authority]
  532. public ActionResult GetRelease()
  533. {
  534. string workorderid = RequestString.GetQueryString("workorderid");
  535. Model.T_Web_WorkRelease baseModel = fbBLL.GetModel(workorderid);
  536. if (baseModel != null)
  537. return Success("加载成功", baseModel);
  538. else
  539. return Error("加载失败");
  540. }
  541. /// <summary>
  542. /// 发布
  543. /// </summary>
  544. /// <param name="input"></param>
  545. /// <returns></returns>
  546. [Authority]
  547. public ActionResult EditRelease()
  548. {
  549. string workorderid = RequestString.GetFormString("workorderid");
  550. int state = RequestString.GetInt("state", 0);
  551. int smalltype = RequestString.GetInt("smalltype", 0);
  552. int deptid = RequestString.GetInt("deptid", 0);
  553. string acceptime = RequestString.GetFormString("acceptime");
  554. string backtime = RequestString.GetFormString("backtime");
  555. string result = RequestString.GetFormString("result");
  556. string fbtime = RequestString.GetFormString("fbtime");
  557. string opinion = RequestString.GetFormString("opinion");
  558. Model.T_Web_WorkRelease orderModel = new Model.T_Web_WorkRelease();
  559. orderModel = fbBLL.GetModel(workorderid);
  560. if (orderModel != null)
  561. {
  562. orderModel.F_ReleaseState = state;
  563. if (!string.IsNullOrEmpty(fbtime))
  564. {
  565. orderModel.F_ReleaseTime = DateTime.Parse(fbtime);
  566. }
  567. orderModel.F_Department = deptid;
  568. orderModel.F_WorkSort = smalltype;
  569. if (!string.IsNullOrEmpty(acceptime))
  570. {
  571. orderModel.F_AcceptTime = DateTime.Parse(acceptime);
  572. }
  573. if (!string.IsNullOrEmpty(backtime))
  574. {
  575. orderModel.F_BackDate = DateTime.Parse(backtime);
  576. }
  577. orderModel.F_Result = result;
  578. orderModel.F_Opinion = opinion;
  579. if (fbBLL.Update(orderModel))
  580. return Success("成功");
  581. else
  582. return Error("失败");
  583. }
  584. else
  585. {
  586. return Success("成功");
  587. }
  588. }
  589. /// <summary>
  590. /// 更新状态
  591. /// </summary>
  592. /// <returns></returns>
  593. [Authority]
  594. public ActionResult UpdateReleaseState()
  595. {
  596. string workid = RequestString.GetFormString("workid");
  597. int ste = RequestString.GetInt("state", 0);
  598. var model = new BLL.T_Web_WorkRelease().GetModel(workid);
  599. if (model != null && ste != 0)
  600. {
  601. model.F_ReleaseState = ste;
  602. if (new BLL.T_Web_WorkRelease().Update(model))
  603. {
  604. return Success("成功");
  605. }
  606. else
  607. {
  608. return Error("操作失败");
  609. }
  610. }
  611. else
  612. {
  613. return Error("操作失败");
  614. }
  615. }
  616. /// <summary>
  617. /// 删除发布
  618. /// </summary>
  619. /// <param name="ids"></param>
  620. /// <returns></returns>
  621. [Authority]
  622. public ActionResult DelRelease(string[] ids)
  623. {
  624. if (ids == null || ids.Length <= 0)
  625. return Error("获取参数失败");
  626. StringBuilder sb = new StringBuilder();
  627. foreach (var item in ids)
  628. {
  629. sb.Append("'" + item + "',");
  630. }
  631. if (new BLL.T_Web_WorkRelease().DeleteList(sb.ToString().Trim(',')))
  632. return Success("删除成功");
  633. else
  634. return Error("删除失败");
  635. }
  636. #endregion
  637. #region 官网
  638. /// <summary>
  639. /// 获取最新新闻列表
  640. /// </summary>
  641. /// <returns></returns>
  642. public ActionResult GetTopImgNewsList()
  643. {
  644. int type = RequestString.GetInt("type", 0);
  645. int num = RequestString.GetInt("num", 6);
  646. //var dtCache = CacheHelper.Get<DataTable>($"ImgNewsList{type}1");
  647. var dtCache = RedisHelper.StringGet($"ImgNewsList{type}1");
  648. if (dtCache != null)
  649. {
  650. return Success("成功", dtCache.ToString().ToObject<DataTable>());
  651. }
  652. var sql = " select top " + num + " * from T_Web_News where iszd=1 ";
  653. Dictionary<string, string> paras = new Dictionary<string, string>();
  654. if (type != 0)
  655. {
  656. sql += " and ClassId = @ClassId";
  657. paras.Add("@ClassId", type.ToString());
  658. }
  659. sql += " order by ordernum asc,sj desc";
  660. var dt = DbHelperSQL.Query(sql, paras).Tables[0];
  661. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  662. foreach (DataRow dr in dt.Rows)
  663. {
  664. string url = (dr["img"] == null ? "" : dr["img"].ToString());
  665. string smallurl = (dr["urlname"] == null ? "" : dr["urlname"].ToString());
  666. if (!string.IsNullOrEmpty(url) && configfj != null)
  667. {
  668. dr["img"] = configfj.F_ParamValue + url;
  669. }
  670. if (!string.IsNullOrEmpty(smallurl) && configfj != null)
  671. {
  672. dr["urlname"] = configfj.F_ParamValue + smallurl;
  673. }
  674. }
  675. //// key=ImgNewsList+type+iszd
  676. //CacheHelper.Insert($"ImgNewsList{type}1", dt, 10);
  677. RedisHelper.StringSet($"ImgNewsList{type}1", dt.ToJson(), new TimeSpan(0, 10, 0));
  678. return Success("成功", dt);
  679. }
  680. /// <summary>
  681. /// 获取最新新闻列表
  682. /// </summary>
  683. /// <returns></returns>
  684. public ActionResult GetTopNewsList()
  685. {
  686. int type = RequestString.GetInt("type", 0);
  687. int num = RequestString.GetInt("num", 8);
  688. //var dtCache = CacheHelper.Get<DataTable>($"NewsList{type}");
  689. var dtCache = RedisHelper.StringGet($"NewsList{type}");
  690. if (dtCache != null)
  691. {
  692. return Success("成功", dtCache.ToString().ToObject<DataTable>());
  693. }
  694. var sql = " select top " + num + " * from T_Web_News where 1=1 ";
  695. Dictionary<string, string> paras = new Dictionary<string, string>();
  696. if (type != 0)
  697. {
  698. sql += " and ClassId = @ClassId";
  699. paras.Add("@ClassId", type.ToString());
  700. }
  701. sql += " order by ordernum asc,sj desc";
  702. var dt = DbHelperSQL.Query(sql, paras).Tables[0];
  703. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  704. foreach (DataRow dr in dt.Rows)
  705. {
  706. string url = (dr["img"] == null ? "" : dr["img"].ToString());
  707. string smallurl = (dr["urlname"] == null ? "" : dr["urlname"].ToString());
  708. if (!string.IsNullOrEmpty(url) && configfj != null)
  709. {
  710. dr["img"] = configfj.F_ParamValue + url;
  711. }
  712. if (!string.IsNullOrEmpty(smallurl) && configfj != null)
  713. {
  714. dr["urlname"] = configfj.F_ParamValue + smallurl;
  715. }
  716. }
  717. //// key=NewsList+type
  718. //CacheHelper.Insert($"NewsList{type}", dt, 10);
  719. RedisHelper.StringSet($"NewsList{type}",dt.ToJson(), new TimeSpan(0, 10, 0));
  720. return Success("成功", dt);
  721. }
  722. /// <summary>
  723. /// 获取新闻
  724. /// </summary>
  725. /// <param name=""></param>
  726. /// <returns></returns>
  727. public ActionResult GetWebNews()
  728. {
  729. int id = RequestString.GetInt("id", 0);
  730. //var newsCache = CacheHelper.Get<Model.T_Web_News>($"WebNews{id}");
  731. var newsCache = RedisHelper.StringGet($"WebNews{id}");
  732. if (newsCache != null)
  733. {
  734. return Success("成功", newsCache.ToString().ToObject<Model.T_Web_News>());
  735. }
  736. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  737. var configfjedit = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='EditFilePath' ").FirstOrDefault();
  738. Model.T_Web_News baseModel = newsBLL.GetModel(id);
  739. if (baseModel != null)
  740. {
  741. if (!string.IsNullOrEmpty(baseModel.img) && configfj != null)
  742. {
  743. baseModel.img = configfj.F_ParamValue + baseModel.img;
  744. }
  745. if (!string.IsNullOrEmpty(baseModel.urlname) && configfj != null)
  746. {
  747. baseModel.urlname = configfj.F_ParamValue + baseModel.urlname;
  748. }
  749. if (!string.IsNullOrEmpty(baseModel.nr) && configfjedit != null)
  750. {
  751. Uri uri = new Uri(configfjedit.F_ParamValue);
  752. baseModel.nr = baseModel.nr.Replace("\"/js/kindeditor", "\"" + uri.Scheme + "://" + uri.Authority + "/js/kindeditor");
  753. }
  754. //// key=action+id
  755. //CacheHelper.Insert($"WebNews{id}", baseModel, 10);
  756. RedisHelper.StringSet($"WebNews{id}",baseModel.ToJson(), new TimeSpan(0, 10, 0));
  757. return Success("加载成功", baseModel);
  758. }
  759. else
  760. {
  761. return Error("加载失败");
  762. }
  763. }
  764. /// <summary>
  765. /// 获取新闻列表
  766. /// </summary>
  767. /// <returns></returns>
  768. public ActionResult GetWebNewsList()
  769. {
  770. int type = RequestString.GetInt("type", 0);
  771. string name = RequestString.GetQueryString("name");
  772. string strpageindex = RequestString.GetQueryString("page");
  773. int pageindex = 1;
  774. string strpagesize = RequestString.GetQueryString("pagesize");
  775. int pagesize = 10;
  776. var sql = " and 1=1 ";
  777. if (type != 0)
  778. {
  779. sql += " and ClassId = '" + type + "'";
  780. }
  781. if (!string.IsNullOrEmpty(name))
  782. {
  783. sql += " and bt like '%" + name + "%'";
  784. }
  785. if (strpageindex.Trim() != "")
  786. {
  787. pageindex = Convert.ToInt32(strpageindex);
  788. }
  789. if (strpagesize.Trim() != "")
  790. {
  791. pagesize = Convert.ToInt32(strpagesize);
  792. }
  793. var recordCount = 0;
  794. var dt = BLL.PagerBLL.GetListPager(
  795. "T_Web_News",
  796. "id",
  797. "*",
  798. sql,
  799. "ORDER BY ordernum asc,sj desc",
  800. pagesize,
  801. pageindex,
  802. true,
  803. out recordCount);
  804. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  805. dt.Columns.Add("UserCode", typeof(string));
  806. foreach (DataRow dr in dt.Rows)
  807. {
  808. string id = (dr["zxbh"] == null ? "" : dr["zxbh"].ToString());
  809. if (id != "")
  810. {
  811. var u = new BLL.T_Sys_UserAccount().GetModel(Int32.Parse(id));
  812. if (u != null)
  813. {
  814. dr["UserCode"] = u.F_UserCode;
  815. }
  816. }
  817. string url = (dr["img"] == null ? "" : dr["img"].ToString());
  818. string smallurl = (dr["urlname"] == null ? "" : dr["urlname"].ToString());
  819. if (!string.IsNullOrEmpty(url) && configfj != null)
  820. {
  821. dr["img"] = configfj.F_ParamValue + url;
  822. }
  823. if (!string.IsNullOrEmpty(smallurl) && configfj != null)
  824. {
  825. dr["urlname"] = configfj.F_ParamValue + smallurl;
  826. }
  827. }
  828. var obj = new
  829. {
  830. state = ResultTypes.success.ToString(),
  831. rows = dt,
  832. total = recordCount
  833. };
  834. return Content(obj.ToJson());
  835. }
  836. /// <summary>
  837. /// 获取新闻列表
  838. /// </summary>
  839. /// <returns></returns>
  840. public ActionResult GetAllWebNews()
  841. {
  842. int type = RequestString.GetInt("type", 0);
  843. string name = RequestString.GetQueryString("name");
  844. var sql = " 1=1 ";
  845. if (type != 0)
  846. {
  847. sql += " and ClassId = '" + type + "'";
  848. }
  849. if (!string.IsNullOrEmpty(name))
  850. {
  851. sql += " and bt like '%" + name + "%'";
  852. }
  853. var dt = new BLL.T_Web_News().GetList(0, sql, " ordernum asc,sj desc ").Tables[0];
  854. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  855. dt.Columns.Add("UserCode", typeof(string));
  856. foreach (DataRow dr in dt.Rows)
  857. {
  858. string id = (dr["zxbh"] == null ? "" : dr["zxbh"].ToString());
  859. if (id != "")
  860. {
  861. var u = new BLL.T_Sys_UserAccount().GetModel(Int32.Parse(id));
  862. if (u != null)
  863. {
  864. dr["UserCode"] = u.F_UserCode;
  865. }
  866. }
  867. string url = (dr["img"] == null ? "" : dr["img"].ToString());
  868. string smallurl = (dr["urlname"] == null ? "" : dr["urlname"].ToString());
  869. if (!string.IsNullOrEmpty(url) && configfj != null)
  870. {
  871. dr["img"] = configfj.F_ParamValue + url;
  872. }
  873. if (!string.IsNullOrEmpty(smallurl) && configfj != null)
  874. {
  875. dr["urlname"] = configfj.F_ParamValue + smallurl;
  876. }
  877. }
  878. return Success("成功",dt);
  879. }
  880. /// <summary>
  881. /// 获取发布工单列表
  882. /// </summary>
  883. /// <returns></returns>
  884. public ActionResult GetWebReleaseList()
  885. {
  886. string title = RequestString.GetQueryString("title");
  887. string cont = RequestString.GetQueryString("cont");
  888. string workorderid = RequestString.GetQueryString("workorderid");
  889. string starttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  890. string endtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  891. int type = RequestString.GetInt("type", 0);
  892. int deptid = RequestString.GetInt("deptid", 0);
  893. int keyid = RequestString.GetInt("keyid", 0);
  894. string strpageindex = RequestString.GetQueryString("page");
  895. int pageindex = 1;
  896. string strpagesize = RequestString.GetQueryString("pagesize");
  897. int pagesize = 10;
  898. var sql = " and isnull(F_IsRelease,0) = 1 and F_IsDelete=0 ";
  899. if (!string.IsNullOrEmpty(title))
  900. {
  901. sql += " and F_Title like '%" + title + "%' ";
  902. }
  903. if (!string.IsNullOrEmpty(cont))
  904. {
  905. sql += " and F_Content like '%" + cont + "%' ";
  906. }
  907. if (!string.IsNullOrEmpty(workorderid))
  908. {
  909. sql += " and F_WorkOrderId like '%" + workorderid + "%' ";
  910. }
  911. if (!string.IsNullOrEmpty(starttime))
  912. {
  913. sql += " and datediff(d,F_CreateTime,'" + starttime + "')<=0 ";
  914. }
  915. if (!string.IsNullOrEmpty(endtime))
  916. {
  917. sql += " and datediff(d,F_CreateTime,'" + endtime + "')>=0 ";
  918. }
  919. if (type != 0)
  920. {
  921. sql += " and F_InfoType = '" + type + "' ";
  922. }
  923. if (deptid != 0)
  924. {
  925. sql += " and F_Department=" + deptid;
  926. }
  927. if (keyid != 0)
  928. {
  929. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  930. }
  931. if (deptid != 0)
  932. {
  933. string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
  934. sql += " and F_WorkOrderID in(" + sqlwhere + ")";
  935. }
  936. if (strpageindex.Trim() != "")
  937. {
  938. pageindex = Convert.ToInt32(strpageindex);
  939. }
  940. if (strpagesize.Trim() != "")
  941. {
  942. pagesize = Convert.ToInt32(strpagesize);
  943. }
  944. var recordCount = 0;
  945. string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetOverState(F_WorkOrderId) as OverState,"
  946. + "dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetWorkOrderAssign(F_WorkOrderId) as DeptName ,dbo.GetLimitTime(F_WorkOrderId) as LimitTime";
  947. var dt = BLL.PagerBLL.GetListPager(
  948. "T_Bus_WorkOrder",
  949. "F_WorkOrderId",
  950. cols,
  951. sql,
  952. "ORDER BY F_CreateTime DESC",
  953. pagesize,
  954. pageindex,
  955. true,
  956. out recordCount);
  957. var obj = new
  958. {
  959. state = ResultTypes.success.ToString(),
  960. rows = dt,
  961. total = recordCount
  962. };
  963. return Content(obj.ToJson());
  964. }
  965. /// <summary>
  966. /// 获取发布工单详情
  967. /// </summary>
  968. /// <param name=""></param>
  969. /// <returns></returns>
  970. public ActionResult GetWebRelease()
  971. {
  972. string workorderid = RequestString.GetQueryString("workorderid");
  973. Model.T_Web_WorkRelease baseModel = fbBLL.GetModel(workorderid);
  974. if (baseModel != null)
  975. {
  976. string where = " F_WorkOrderId=@F_WorkOrderId";
  977. Dictionary<string, string> paras = new Dictionary<string, string>();
  978. paras.Add("@F_WorkOrderId", workorderid);
  979. DbHelperSQL.ExecuteSql("update T_Web_WorkRelease set F_ViewCount=F_ViewCount+1 where " + where, paras);
  980. var obj = new
  981. {
  982. data = baseModel,
  983. deptname = DbHelperSQL.GetSingle(" select dbo.GetDeptName(" + baseModel.F_Department + ")"),
  984. classname = DbHelperSQL.GetSingle(" select dbo.GetDictionaryName(" + baseModel.F_WorkSort + ")")
  985. };
  986. return Success("加载成功", obj);
  987. }
  988. else
  989. {
  990. return Success("加载失败");
  991. }
  992. }
  993. /// <summary>
  994. /// 获取链接列表
  995. /// </summary>
  996. /// <returns></returns>
  997. public ActionResult GetWebLinkList()
  998. {
  999. string name = RequestString.GetQueryString("name");
  1000. string where = " select * from T_Web_Link where 1=1 ";
  1001. Dictionary<string, string> paras = new Dictionary<string, string>();
  1002. if (!string.IsNullOrEmpty(name))
  1003. {
  1004. where += " and LinkName like @LinkName";
  1005. paras.Add("@LinkName", "%" + name + "%");
  1006. }
  1007. var dt = DbHelperSQL.Query(where, paras).Tables[0];
  1008. return Success("列表加载成功", dt);
  1009. }
  1010. /// <summary>
  1011. /// 获取工单类型列表
  1012. /// </summary>
  1013. /// <returns></returns>
  1014. public ActionResult GetWebTypeList()
  1015. {
  1016. string sql = "select * from T_Sys_DictionaryValue where F_ItemId=2 and F_State=0 ";
  1017. var dt = DbHelperSQL.Query(sql).Tables[0];
  1018. return Success("列表加载成功", dt);
  1019. }
  1020. /// <summary>
  1021. /// 获取事发地域列表
  1022. /// </summary>
  1023. /// <returns></returns>
  1024. public ActionResult GetWebAreaList()
  1025. {
  1026. string sql = "select * from T_Sys_Area where isnull(F_PrentId,0)=0 and F_State=0 ";
  1027. var dt = DbHelperSQL.Query(sql).Tables[0];
  1028. return Success("列表加载成功", dt);
  1029. }
  1030. /// <summary>
  1031. /// 获取事发地域列表
  1032. /// </summary>
  1033. /// <param name="id"></param>
  1034. /// <returns></returns>
  1035. public ActionResult GetWebAreaListById(int id = 0)
  1036. {
  1037. Dictionary<string, string> paras = new Dictionary<string, string>();
  1038. paras.Add("@Id", id.ToString());
  1039. DataTable dt = DbHelperSQL.Query(" select * from T_Sys_Area where isnull(F_PrentId,0)=@id and F_State=0 ", paras).Tables[0];
  1040. return Success("列表加载成功", dt);
  1041. }
  1042. /// <summary>
  1043. /// 获取工单类型列表
  1044. /// </summary>
  1045. /// <returns></returns>
  1046. public ActionResult GetWebKeyList()
  1047. {
  1048. string sql = "select * from T_Sys_DictionaryValue where F_ItemId=3 and F_State=0 ";
  1049. var dt = DbHelperSQL.Query(sql).Tables[0];
  1050. return Success("列表加载成功", dt);
  1051. }
  1052. /// <summary>
  1053. /// 获取部门列表
  1054. /// </summary>
  1055. /// <returns></returns>
  1056. public ActionResult GetWebDeptList()
  1057. {
  1058. DataTable dt = new DataTable();
  1059. dt = new BLL.T_Sys_Department().GetList(0, "F_State=0", " F_Sort").Tables[0];
  1060. return Success("加载成功", dt);
  1061. }
  1062. /// <summary>
  1063. /// 上传附件
  1064. /// </summary>
  1065. /// <returns></returns>
  1066. public ActionResult UploadFile()
  1067. {
  1068. #region no use
  1069. //string path = string.Empty;
  1070. //HttpPostedFile _upfile = RequestString.GetFile("upFile");
  1071. //if (_upfile != null)
  1072. //{
  1073. // //byte[] buffer = new Byte[(int)_upfile.InputStream.Length]; //声明文件长度的二进制类型
  1074. // //_upfile.InputStream.Read(buffer, 0, buffer.Length); //将文件转成二进制
  1075. // string name = string.Empty;
  1076. // FileUp fu = new FileUp();
  1077. // var model = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FilePath' ").FirstOrDefault();
  1078. // if (model != null)
  1079. // {
  1080. // name = fu.Upload(_upfile, model.F_ParamValue);
  1081. // return Success("成功", name);
  1082. // }
  1083. // else
  1084. // {
  1085. // return Error("上传失败");
  1086. // }
  1087. //}
  1088. //else
  1089. //{
  1090. // return Error("请选择要上传的文件");
  1091. //}
  1092. #endregion
  1093. #region 多个上传
  1094. HttpFileCollection files = RequestString.GetFiles();
  1095. if (files.Count > 0)
  1096. {
  1097. List<Model.T_Sys_Accessories> acs = new List<Model.T_Sys_Accessories>();
  1098. string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  1099. for (int i = 0; i < files.Count; i++)
  1100. {
  1101. HttpPostedFile file = files[i];
  1102. FileUp fu = new FileUp();
  1103. string name = fu.Upload(file, path);
  1104. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  1105. model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  1106. model_T_Sys_Accessories.F_FileName = name;//附件名称
  1107. model_T_Sys_Accessories.F_FileType = System.IO.Path.GetExtension(file.FileName);//附件类型
  1108. model_T_Sys_Accessories.F_FileUrl = path + name;//附件地址
  1109. model_T_Sys_Accessories.F_Size = file.ContentLength;
  1110. //model_T_Sys_Accessories.F_UserCode = userModel.F_UserCode;//上传人
  1111. int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  1112. model_T_Sys_Accessories.F_FileId = id;
  1113. acs.Add(model_T_Sys_Accessories);
  1114. }
  1115. return Success("成功", acs);
  1116. }
  1117. else
  1118. {
  1119. return Error("请选择要上传的文件");
  1120. }
  1121. #endregion
  1122. }
  1123. /// <summary>
  1124. /// 上传base64图片
  1125. /// </summary>
  1126. /// <returns></returns>
  1127. public ActionResult Upload64()
  1128. {
  1129. //string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
  1130. string dataurl = RequestString.GetFormString("dataurl");
  1131. string filename = RequestString.GetFormString("filename");
  1132. if (!string.IsNullOrEmpty(dataurl))
  1133. {
  1134. string path = "/Upload/APP/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  1135. ImageUpload iu = new ImageUpload();
  1136. iu.SavePath = path;
  1137. iu.DataUrl = dataurl;
  1138. if (!string.IsNullOrEmpty(filename))
  1139. {
  1140. iu.SaveType = 1;
  1141. iu.InFileName = filename;
  1142. }
  1143. iu.Upload64();
  1144. int n = iu.Error;
  1145. if (n == 0)
  1146. {
  1147. path = path + iu.OutFileName;
  1148. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  1149. model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  1150. model_T_Sys_Accessories.F_FileName = iu.OutFileName;//附件名称
  1151. model_T_Sys_Accessories.F_FileType = ".jpg";//附件类型
  1152. model_T_Sys_Accessories.F_FileUrl = path;//附件地址
  1153. model_T_Sys_Accessories.F_Size = iu.FileSize;
  1154. //model_T_Sys_Accessories.F_UserCode = userModel.F_UserCode;//上传人
  1155. int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  1156. model_T_Sys_Accessories.F_FileId = id;
  1157. return Success("成功", model_T_Sys_Accessories);
  1158. }
  1159. else
  1160. {
  1161. string msg = string.Empty;
  1162. switch (n)
  1163. {
  1164. case 1: msg = "请选择要上传的文件"; break;
  1165. case 2: msg = "上传的文件类型不支持"; break;
  1166. case 3: msg = "上传的文件过大"; break;
  1167. case 4: msg = "未知错误"; break;
  1168. }
  1169. return Error(msg);
  1170. }
  1171. }
  1172. else
  1173. {
  1174. return Error("请选择要上传的文件");
  1175. }
  1176. }
  1177. /// <summary>
  1178. /// 添加工单信息(网上受理)
  1179. /// </summary>
  1180. /// <returns></returns>
  1181. public ActionResult AddWebWorkOrder()
  1182. {
  1183. int source = RequestString.GetInt("source", 4);
  1184. string cusname = RequestString.GetFormString("cusname");
  1185. string cussex = RequestString.GetFormString("cussex");
  1186. string cusphone = RequestString.GetFormString("cusphone");
  1187. string cusaddress = RequestString.GetFormString("cusaddress");
  1188. string email = RequestString.GetFormString("email");
  1189. string zipcode = RequestString.GetFormString("zipcode");
  1190. string conname = RequestString.GetFormString("conname");
  1191. string conphone = RequestString.GetFormString("conphone");
  1192. string title = RequestString.GetFormString("title");
  1193. string content = RequestString.GetFormString("content");
  1194. string files = RequestString.GetFormString("files");
  1195. int sourcearea = RequestString.GetInt("sourcearea", 0);
  1196. string sourceaddress = RequestString.GetFormString("sourceaddress");
  1197. string keys = RequestString.GetFormString("keys");
  1198. string splituser = RequestString.GetFormString("splituser");
  1199. int type = RequestString.GetInt("type", 0);
  1200. int bigtype = RequestString.GetInt("bigtype", 0);
  1201. int smalltype = RequestString.GetInt("smalltype", 0);
  1202. int isprotect = RequestString.GetInt("isprotect", 0);
  1203. int level = RequestString.GetInt("level", 0);
  1204. string workid = string.Empty;
  1205. string pwd = string.Empty; ;
  1206. using (TransactionScope trans = new TransactionScope())
  1207. {
  1208. #region 保存工单信息
  1209. WorkOrderController wo = new WorkOrderController();
  1210. string workorderid = wo.AddWorkOrderBySource(source, cusname, cussex, cusphone, cusaddress, email, zipcode, conname, conphone, title,
  1211. content, sourcearea, sourceaddress, keys, splituser, type, bigtype, smalltype, isprotect, level, files);
  1212. #endregion
  1213. if (source == 4)
  1214. {
  1215. #region 保存密码
  1216. BLL.T_Web_WorkAccountSearch WorkAccount = new BLL.T_Web_WorkAccountSearch();
  1217. Model.T_Web_WorkAccountSearch WorkAccountInfo = new Model.T_Web_WorkAccountSearch();
  1218. WorkAccountInfo.F_WorkOrderId = workorderid;
  1219. pwd = Utils.Number(4);
  1220. WorkAccountInfo.F_SearchPassword = pwd;
  1221. WorkAccountInfo.F_AddTime = DateTime.Now;
  1222. WorkAccount.Add(WorkAccountInfo);
  1223. #endregion
  1224. }
  1225. workid = workorderid;
  1226. trans.Complete();
  1227. }
  1228. var obj = new
  1229. {
  1230. workorderid = workid,
  1231. password = pwd
  1232. };
  1233. return Success("成功", obj);
  1234. }
  1235. /// <summary>
  1236. /// 检查密码
  1237. /// </summary>
  1238. /// <param name=""></param>
  1239. /// <returns></returns>
  1240. public ActionResult CheckWebPassword()
  1241. {
  1242. string workorderid = RequestString.GetQueryString("workorderid");
  1243. string password = RequestString.GetQueryString("password");
  1244. string sql = " select * from T_Web_WorkAccountSearch where F_WorkOrderId=@F_WorkOrderId and F_SearchPassword=@F_SearchPassword";
  1245. Dictionary<string, string> paras = new Dictionary<string, string>();
  1246. paras.Add("@F_WorkOrderId", workorderid);
  1247. paras.Add("@F_SearchPassword", password);
  1248. var dt = DbHelperSQL.Query(sql, paras).Tables[0];
  1249. if (dt.Rows.Count > 0)
  1250. {
  1251. string sqlwork = "select top 1 *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName1,"
  1252. //+ "dbo.GetDictionaryName(F_InfoConBigType) as TypeName2,dbo.GetDictionaryName(F_InfoConSmallType) as TypeName3,"
  1253. + "dbo.GetWorkOrderAssign(F_WorkOrderId) as DeptName,dbo.GetDictionaryName(F_InfoSource) as SourceName ,"
  1254. + "dbo.GetAreaName(F_SourceArea) as AreaName "
  1255. + " from T_Bus_WorkOrder where F_WorkOrderId =@F_WorkOrderId ";
  1256. Dictionary<string, string> paraswork = new Dictionary<string, string>();
  1257. paraswork.Add("@F_WorkOrderId", workorderid);
  1258. var dtwork = DbHelperSQL.Query(sqlwork, paraswork).Tables[0];
  1259. if (dtwork.Rows.Count > 0)
  1260. {
  1261. dtwork.Columns.Add("StateName", typeof(string));
  1262. if (dtwork.Rows[0]["F_IsEnabled"] != null)
  1263. {
  1264. if (dtwork.Rows[0]["F_IsDelete"].ToString() == "1" && dtwork.Rows[0]["F_IsEnabled"].ToString() == "0")
  1265. {
  1266. dtwork.Rows[0]["StateName"] = "受理中";
  1267. }
  1268. else if (dtwork.Rows[0]["F_WorkState"].ToString() != "9")
  1269. {
  1270. dtwork.Rows[0]["StateName"] = "办理中";
  1271. }
  1272. else if (dtwork.Rows[0]["F_WorkState"].ToString() == "9")
  1273. {
  1274. dtwork.Rows[0]["StateName"] = "已结案";
  1275. }
  1276. }
  1277. }
  1278. return Success("加载成功", dtwork);
  1279. }
  1280. else
  1281. {
  1282. return Error("受理编号或密码错误");
  1283. }
  1284. }
  1285. /// <summary>
  1286. /// 获取来源受理数
  1287. /// </summary>
  1288. /// <returns></returns>
  1289. public ActionResult GetWebSourceCount()
  1290. {
  1291. string sql = " select F_Value Source,(select COUNT(1) from T_Bus_WorkOrder where F_IsDelete=0 "
  1292. + " and F_InfoSource=F_ValueId) Count from dbo.T_Sys_DictionaryValue where F_ItemId=1 and F_State=0 ";
  1293. DataTable dt = DbHelperSQL.Query(sql).Tables[0];
  1294. string sqlday = " select F_Value Source,(select COUNT(1) from T_Bus_WorkOrder where datediff(day,F_CreateTime,getdate())=0 and F_IsDelete=0 "
  1295. + " and F_InfoSource=F_ValueId) Count from dbo.T_Sys_DictionaryValue where F_ItemId=1 and F_State=0 ";
  1296. DataTable dtday = DbHelperSQL.Query(sqlday).Tables[0];
  1297. var obj = new
  1298. {
  1299. total = dt,
  1300. day = dtday,
  1301. dayaccept = DbHelperSQL.GetSingle("select COUNT(1) from T_Bus_WorkOrder where datediff(day,F_CreateTime,getdate())=0 and F_IsDelete=0").ToString(),
  1302. dayassign= DbHelperSQL.GetSingle("select COUNT(1) from T_Bus_WorkOrder where datediff(day,F_CreateTime,getdate())=0 and F_IsDelete=0 and isnull(F_IsResult,0)=0 and F_WorkState>1").ToString()
  1303. };
  1304. return Success("加载成功", obj);
  1305. }
  1306. /// <summary>
  1307. /// 获取类型比例
  1308. /// </summary>
  1309. /// <returns></returns>
  1310. public ActionResult GetWebTypePercent()
  1311. {
  1312. var typelist = new BLL.T_Sys_DictionaryValue().GetModelList(" F_ItemId=2 ");
  1313. string sql = " select count(1) from dbo.T_Bus_WorkOrder where F_IsDelete = 0 ";
  1314. var tl = Int32.Parse(DbHelperSQL.GetSingle(sql).ToString());
  1315. var obj = typelist.Select(p =>
  1316. {
  1317. string sqltype = " select count(1) from dbo.T_Bus_WorkOrder where F_IsDelete = 0 and F_InfoType=" + p.F_ValueId;
  1318. var cl = Int32.Parse(DbHelperSQL.GetSingle(sqltype).ToString());
  1319. return new
  1320. {
  1321. typename = p.F_Value,
  1322. percent = tl > 0 ? Math.Round(((double)cl * 100 / tl), 2) : 0
  1323. };
  1324. });
  1325. return Success("加载成功", obj);
  1326. }
  1327. /// <summary>
  1328. /// 获取类型比例
  1329. /// </summary>
  1330. /// <returns></returns>
  1331. public ActionResult GetWebKeyCount(int isscqt = 0)
  1332. {
  1333. string strwhere = " F_ItemId=3 ";
  1334. if (isscqt > 0)
  1335. {
  1336. strwhere += " and F_Value != '其他' ";
  1337. }
  1338. var typelist = new BLL.T_Sys_DictionaryValue().GetModelList(strwhere);
  1339. var obj = typelist.Select(p =>
  1340. {
  1341. string sqltype = " select count(1) from dbo.T_Bus_WorkOrder where F_IsDelete = 0 and ','+F_Key+',' like '%," + p.F_ValueId + ",%'";
  1342. var cl = Int32.Parse(DbHelperSQL.GetSingle(sqltype).ToString());
  1343. return new
  1344. {
  1345. keyname = p.F_Value,
  1346. count = cl
  1347. };
  1348. }).OrderByDescending(p => p.count).Take(7);
  1349. return Success("加载成功", obj);
  1350. }
  1351. #endregion
  1352. }
  1353. }