No Description

APPController.cs 78KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.DB;
  4. using CallCenterApi.Interface.App_Start;
  5. using CallCenterApi.Interface.Controllers.Base;
  6. using CallCenterApi.Interface.Controllers.workorder;
  7. using CallCenterApi.Interface.Models.Common;
  8. using CallCenterApi.Model;
  9. using Newtonsoft.Json;
  10. using Newtonsoft.Json.Linq;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Data;
  14. using System.Linq;
  15. using System.Net;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. using System.Transactions;
  19. using System.Web;
  20. using System.Web.Mvc;
  21. namespace CallCenterApi.Interface.Controllers
  22. {
  23. public class APPController : BaseController
  24. {
  25. // GET: APP
  26. /// <summary>
  27. /// 登录
  28. /// </summary>
  29. /// <returns></returns>
  30. public ActionResult Login(string usercode, string password)
  31. {
  32. DateTime ExpiredTime = DateTime.Now.AddDays(1);
  33. bool appResult = DateTime.Now < ExpiredTime;// Convert.ToDateTime(ReadFile(HttpRuntime.AppDomainAppPath + "tools\\hykj.hy"));
  34. if (appResult)
  35. {
  36. DataTable dt = new DataTable();
  37. try
  38. {
  39. Dictionary<string, string> paras = new Dictionary<string, string>();
  40. string sql = " select * from T_Sys_Users where F_OpenId=@F_OpenId and F_Password=@F_Password";
  41. paras.Add("@F_OpenId", usercode);
  42. paras.Add("@F_Password", password);
  43. dt = DbHelperSQL.Query(sql, paras).Tables[0];
  44. if (dt != null)
  45. {
  46. //写入登录日志
  47. new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  48. {
  49. F_LoginName = dt.Rows[0]["F_OpenId"].ToString(),
  50. F_LoginId = Convert.ToInt32(dt.Rows[0]["F_Id"].ToString()),
  51. F_Result = "APP市民登录成功",
  52. F_LoginIP = Common.DTRequest.GetIP(),
  53. F_Hostname = Common.DTRequest.GetIP(),
  54. F_LoginDate = DateTime.Now,
  55. F_Remark = "",
  56. F_State = 0
  57. });
  58. return Success("登录成功", new
  59. {
  60. usercode = dt.Rows[0]["F_OpenId"].ToString(),
  61. userid = dt.Rows[0]["F_Id"].ToString()
  62. });
  63. }
  64. else
  65. {
  66. //写入登录日志
  67. DataTable dt1 = new CallCenterApi.BLL.T_Sys_Users().GetList("F_OpenId='" + usercode + "'").Tables[0];
  68. if (dt1.Rows.Count > 0)
  69. {
  70. int rr = new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  71. {
  72. F_LoginName = dt1.Rows[0]["F_OpenId"].ToString(),
  73. F_LoginId = Convert.ToInt32(dt1.Rows[0]["F_Id"].ToString()),
  74. F_Result = "APP市民登录失败:帐号-" + usercode,
  75. F_LoginIP = Common.DTRequest.GetIP(),
  76. F_Hostname = Common.DTRequest.GetIP(),
  77. F_LoginDate = DateTime.Now,
  78. F_Remark = "",
  79. F_State = 0
  80. });
  81. }
  82. else
  83. {
  84. int rr = new BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  85. {
  86. F_LoginName = usercode,
  87. F_LoginId = -1,
  88. F_Result = "APP市民登录失败:帐号-" + usercode,
  89. F_LoginIP = Common.DTRequest.GetIP(),
  90. F_Hostname = Common.DTRequest.GetIP(),
  91. F_LoginDate = DateTime.Now,
  92. F_Remark = "",
  93. F_State = 0
  94. });
  95. }
  96. return Error("账号或密码错误,请重新登录");
  97. }
  98. }
  99. catch
  100. {
  101. return Error("账号或密码错误,请重新登录");
  102. }
  103. }
  104. else
  105. {
  106. return Error("授权过期,请联系系统厂家。");
  107. }
  108. }
  109. [HttpPost]
  110. public ActionResult loginNologin()
  111. {
  112. string loginNo = RequestString.GetFormString("loginNo");//登录账号
  113. string loginPassword = RequestString.GetFormString("loginPassword");//登录密码
  114. int type = RequestString.GetInt("type", 0); ;//0自然人注册1法人注册
  115. DataTable dt = new DataTable();
  116. try
  117. {
  118. Dictionary<string, string> paras = new Dictionary<string, string>();
  119. string sql = "";
  120. sql = " select * from T_Sys_Users where F_OpenId=@F_OpenId and F_Password=@F_Password";
  121. paras.Add("@F_OpenId", loginNo);
  122. paras.Add("@F_Password", loginPassword);//login.Password
  123. dt = DbHelperSQL.Query(sql, paras).Tables[0];
  124. if (dt != null)
  125. {
  126. if (dt.Rows.Count > 0)
  127. {
  128. string Smsurl = "https://zwfw.anyang.gov.cn/gsp/uc10002";
  129. string acctType = "10";
  130. if (type == 1)
  131. {
  132. acctType = "20";
  133. Smsurl = "https://zwfw.anyang.gov.cn/gsp/uc20002";
  134. }
  135. var dic = new SortedDictionary<string, string>
  136. {
  137. {"loginNo", loginNo},
  138. {"loginPassword", loginPassword},
  139. {"loginType", "AU01"},
  140. {"acctType", acctType},
  141. };
  142. //序列化参数
  143. var jsonParam = JsonConvert.SerializeObject(dic);
  144. var responseString = HttpMethods.HttpPost(Smsurl, jsonParam, "application/json;charset=UTF-8");
  145. JObject jo = (JObject)JsonConvert.DeserializeObject(responseString);
  146. Dictionary<string, string> Dic = new Dictionary<string, string>();
  147. Dic.Add("F_OpenId", dt.Rows[0]["F_OpenId"].ToString());
  148. Dic.Add("F_Name", dt.Rows[0]["F_Name"].ToString());
  149. Dic.Add("F_Telphone", dt.Rows[0]["F_Telphone"].ToString());
  150. new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  151. {
  152. F_LoginName = dt.Rows[0]["F_OpenId"].ToString(),
  153. F_LoginId = Convert.ToInt32(dt.Rows[0]["F_OpenId"].ToString()),
  154. F_Result = "登录成功",
  155. F_LoginIP = Common.DTRequest.GetIP(),
  156. F_Hostname = Common.DTRequest.GetIP(),
  157. F_LoginDate = DateTime.Now,
  158. F_Remark = "",
  159. F_State = 0
  160. });
  161. var token = FormsPrincipal<Dictionary<string, string>>.GetCookieValue(Dic["F_OpenId"], Dic);
  162. return Success("登录成功", new
  163. {
  164. token = token
  165. });
  166. }
  167. else
  168. {
  169. return Error("账号或密码错误,请重新登录");
  170. }
  171. }
  172. else
  173. {
  174. return Error("账号或密码错误,请重新登录");
  175. }
  176. }
  177. catch (Exception ex)
  178. {
  179. return Error("错误:" + ex.Message);
  180. }
  181. finally
  182. {
  183. dt.Clear();
  184. dt.Dispose();
  185. }
  186. }
  187. private BLL.T_Bus_WorkOrder workorderBLL = new BLL.T_Bus_WorkOrder();
  188. private BLL.T_Bus_Operation operBLL = new BLL.T_Bus_Operation();
  189. /// <summary>
  190. /// 登录用户
  191. /// </summary>
  192. /// <param name="input"></param>
  193. /// <returns></returns>
  194. // [HttpPost]
  195. public ActionResult APPSlogin(string loginNo, string loginPassword, string userMobile, string validateCode)
  196. {
  197. string mobileKey = "";
  198. JObject jObject = GetMobileKey(userMobile, validateCode);
  199. if (jObject["C-API-Status"].ToString() == "00")
  200. {
  201. var Body = jObject["C-Response-Body"].ToString();
  202. var txnBodyComresult = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(Body);
  203. mobileKey = txnBodyComresult["mobileKey"] == null ? "" : txnBodyComresult["mobileKey"].ToString();
  204. }
  205. else
  206. {
  207. return Error(jObject["C-Response-Desc"].ToString());
  208. }
  209. if (mobileKey == "")
  210. return Error("mobileKey获取失败");
  211. string url = appurl + "/gsp/uc11002";
  212. var txnBodyCom = new SortedDictionary<string, string>
  213. {
  214. {"userMobile", userMobile},
  215. {"loginNo",loginNo},
  216. {"acctType", "10"},
  217. {"loginType", "AU09"},
  218. {"loginPassword", loginPassword},
  219. {"mobileKey", mobileKey}
  220. };
  221. var txnCommCom = new SortedDictionary<string, string>
  222. {
  223. {"tRecInPage", "10"},
  224. {"txnIttChnlCgyCode", "D001C004"},
  225. {"tStsTraceId", "110567980"},
  226. {"tPageJump", "1"},
  227. {"txnIttChnlId", "99990001000000000000000"},
  228. };
  229. var sms = new Dictionary<string, string>
  230. {
  231. {"txnBodyCom", txnBodyCom.ToJson ()},
  232. {"txnCommCom", txnCommCom.ToJson ()}
  233. };
  234. //序列化参数
  235. var param = new
  236. {
  237. txnBodyCom = txnBodyCom,
  238. txnCommCom = txnCommCom
  239. };
  240. var jsonParam = JsonConvert.SerializeObject(param);
  241. var responseString = HttpMethods.HttpPost(url, jsonParam, "application/json");
  242. JObject jo = (JObject)JsonConvert.DeserializeObject(responseString);
  243. if (jo["C-API-Status"].ToString() == "00")
  244. { //写入登录日志
  245. Model.T_Sys_Users dModel = new Model.T_Sys_Users();
  246. var list = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + loginNo + "' ");
  247. if (list.Count > 0)
  248. {
  249. dModel = list.First();
  250. }
  251. else
  252. {
  253. dModel.F_OpenId = loginNo;
  254. dModel.F_Password = loginPassword;
  255. dModel.F_Name = loginNo;
  256. dModel.F_Telphone = userMobile;
  257. dModel.F_Type = (int)EnumUserType.app;//4;
  258. dModel.F_CreateTime = DateTime.Now;
  259. long n = new BLL.T_Sys_Users().Add(dModel);
  260. dModel.F_Id = n;
  261. }
  262. new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  263. {
  264. F_LoginName = dModel.F_OpenId .ToString(),
  265. F_LoginId = (int )dModel.F_Id,
  266. F_Result = "市民登录成功",
  267. F_LoginIP = Common.DTRequest.GetIP(),
  268. F_Hostname = Common.DTRequest.GetIP(),
  269. F_LoginDate = DateTime.Now,
  270. F_Remark = "",
  271. F_State = 0
  272. });
  273. return Success("登录成功", new
  274. {
  275. usercode = dModel.F_OpenId.ToString(),
  276. userid = dModel.F_Id.ToString ()
  277. });
  278. }
  279. else
  280. {
  281. DataTable dt1 = new CallCenterApi.BLL.T_Sys_Users().GetList("F_OpenId='" + loginNo + "'").Tables[0];
  282. if (dt1.Rows.Count > 0)
  283. {
  284. int rr = new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  285. {
  286. F_LoginName = dt1.Rows[0]["F_OpenId"].ToString(),
  287. F_LoginId = Convert.ToInt32(dt1.Rows[0]["F_Id"].ToString()),
  288. F_Result = "市民登录失败:帐号-" + loginNo,
  289. F_LoginIP = Common.DTRequest.GetIP(),
  290. F_Hostname = Common.DTRequest.GetIP(),
  291. F_LoginDate = DateTime.Now,
  292. F_Remark = "",
  293. F_State = 0
  294. });
  295. }
  296. else
  297. {
  298. int rr = new BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  299. {
  300. F_LoginName = loginNo,
  301. F_LoginId = -1,
  302. F_Result = "市民登录失败:帐号-" + loginNo,
  303. F_LoginIP = Common.DTRequest.GetIP(),
  304. F_Hostname = Common.DTRequest.GetIP(),
  305. F_LoginDate = DateTime.Now,
  306. F_Remark = "",
  307. F_State = 0
  308. });
  309. }
  310. return Error(jObject["C-Response-Desc"].ToString());
  311. }
  312. }
  313. /// <summary>
  314. /// 添加工单信息
  315. /// </summary>
  316. /// <returns></returns>
  317. //[Authority]
  318. public ActionResult AddWorkOrder()
  319. {
  320. string loginNo = RequestString.GetFormString("loginNo");
  321. int source = RequestString.GetInt("source", 0);
  322. string cusname = RequestString.GetFormString("cusname");
  323. string cussex = RequestString.GetFormString("cussex");
  324. string cusphone = RequestString.GetFormString("cusphone");
  325. string cusaddress = RequestString.GetFormString("cusaddress");
  326. string conname = RequestString.GetFormString("conname");
  327. string conphone = RequestString.GetFormString("conphone");
  328. string title = RequestString.GetFormString("title");
  329. string content = RequestString.GetFormString("content");
  330. string files = RequestString.GetFormString("files");
  331. int sourcearea = RequestString.GetInt("sourcearea", 0);
  332. string sourceaddress = RequestString.GetFormString("sourceaddress");
  333. string keys = RequestString.GetFormString("keys");
  334. string splituser = RequestString.GetFormString("splituser");
  335. int type = RequestString.GetInt("type", 0);
  336. int isprotect = RequestString.GetInt("isprotect", 0);
  337. int level = RequestString.GetInt("level", 0);
  338. int business = RequestString.GetInt("business", 0); ;//
  339. int township = RequestString.GetInt("township", 0);
  340. int village = RequestString.GetInt("village", 0);
  341. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new Model.T_Bus_WorkOrder();
  342. using (TransactionScope trans = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 10, 0)))
  343. {
  344. #region 保存工单信息
  345. string creattime = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
  346. string endtime = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";
  347. modelT_Bus_WorkOrder.F_WorkOrderId = workorderBLL.GetNewWorkOrderID(source, sourcearea, creattime, endtime);
  348. modelT_Bus_WorkOrder.F_InfoSource = source;//信息来源
  349. modelT_Bus_WorkOrder.F_InfoType = type;//信息类别
  350. modelT_Bus_WorkOrder.F_SourceArea = sourcearea;//反映地域
  351. modelT_Bus_WorkOrder.F_SourceAddress = sourceaddress;//事发地址
  352. modelT_Bus_WorkOrder.F_CusName = cusname;//投诉人姓名
  353. modelT_Bus_WorkOrder.F_CusSex = cussex;//性别
  354. modelT_Bus_WorkOrder.F_CusPhone = cusphone;//来电号码
  355. modelT_Bus_WorkOrder.F_CusAddress = cusaddress;//地址
  356. modelT_Bus_WorkOrder.F_ConName = conname;//联系人姓名
  357. modelT_Bus_WorkOrder.F_ConPhone = conphone;//联系人电话
  358. modelT_Bus_WorkOrder.F_ComTitle = title;//标题
  359. modelT_Bus_WorkOrder.F_ComContent = content;//情况摘要(投诉内容)
  360. modelT_Bus_WorkOrder.F_File = files;//附件
  361. modelT_Bus_WorkOrder.F_IsProtect = isprotect;//保密方式0否1是
  362. modelT_Bus_WorkOrder.F_Key = keys;
  363. modelT_Bus_WorkOrder.F_SplitUser = splituser;
  364. modelT_Bus_WorkOrder.F_Level = level;
  365. modelT_Bus_WorkOrder.F_Township = township;
  366. modelT_Bus_WorkOrder.F_Village = village;
  367. Task.Run(() =>
  368. {
  369. saveCus(cusname, cusphone, cusaddress);
  370. });
  371. modelT_Bus_WorkOrder.F_Latitude = 0;//纬度
  372. modelT_Bus_WorkOrder.F_Longitude = 0;//经度
  373. modelT_Bus_WorkOrder.F_IsResult = 0;
  374. modelT_Bus_WorkOrder.F_CreateUser = loginNo;//登记人工号
  375. modelT_Bus_WorkOrder.F_CreateTime = DateTime.Now;//登记时间
  376. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.neworder;// 0;//工单状态0登记中
  377. modelT_Bus_WorkOrder.F_IsClosed = 0;//工单是否关闭
  378. modelT_Bus_WorkOrder.F_IsOverdue = 0;//是否逾期(0:否,1:是)
  379. modelT_Bus_WorkOrder.F_IsDelete = 0;//是否删除(0:否,1:是)
  380. modelT_Bus_WorkOrder.F_ToBereply = 0;
  381. modelT_Bus_WorkOrder.F_Business = business;
  382. //如果选择即刻答复:是,即为直办,工单结束
  383. #region
  384. #endregion
  385. modelT_Bus_WorkOrder.F_Id = workorderBLL.Add(modelT_Bus_WorkOrder);
  386. #endregion
  387. trans.Complete();
  388. }
  389. if (modelT_Bus_WorkOrder.F_Id <= 0)
  390. return Error("添加失败");
  391. else
  392. {
  393. string userinfo = User.depname + "(" + User.F_UserCode + ")";
  394. string message = "";
  395. message = userinfo + " 登记了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
  396. Task.Run(() =>
  397. {
  398. #region 插入操作记录
  399. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  400. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  401. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  402. oper.F_CallRecordId = modelT_Bus_WorkOrder.F_CallRecordId;
  403. oper.F_File = modelT_Bus_WorkOrder.F_File;
  404. oper.F_Message = message;
  405. oper.F_CreateUser = loginNo;
  406. oper.F_CreateTime = DateTime.Now;
  407. oper.F_IsDelete = 0;
  408. operBLL.Add(oper);
  409. string count = "您反映的事项已受理并转交相关部门处理,感谢您拨打市长热线!";
  410. string msg = "";
  411. bool n = SMSController.AddSmS(0, msg, count, modelT_Bus_WorkOrder.F_CusPhone, "197387", "", modelT_Bus_WorkOrder.F_WorkOrderId);
  412. #endregion
  413. }).ContinueWith(p => {
  414. System.Diagnostics.Debug.WriteLine(DateTime.Now);
  415. });
  416. Task.Run(() =>
  417. {
  418. #region 插入推送消息
  419. //推送消息表
  420. if (modelT_Bus_WorkOrder.F_WorkState != (int)EnumWorkState.neworder && modelT_Bus_WorkOrder.F_WorkState != (int)EnumWorkState.audit)
  421. {
  422. var role = new BLL.T_Sys_RoleInfo().GetModelList(" (F_RoleCode='ZXLD' or F_RoleCode='ZXLDGLYGLY' or F_RoleCode='MTDD') ").Select(p => p.F_RoleId);
  423. var users = userBLL.GetModelList(" F_RoleId in (" + string.Join(",", role) + ") ");
  424. }
  425. #endregion
  426. }).ContinueWith(p => {
  427. System.Diagnostics.Debug.WriteLine(DateTime.Now);
  428. });
  429. Task.Run(() =>
  430. {
  431. case_info(modelT_Bus_WorkOrder.F_WorkOrderId, "case_info");
  432. }).ContinueWith(p => {
  433. System.Diagnostics.Debug.WriteLine(DateTime.Now);
  434. });
  435. if (!string.IsNullOrEmpty(files))
  436. {
  437. Task.Run(() =>
  438. {
  439. material_info(modelT_Bus_WorkOrder.F_WorkOrderId, files, modelT_Bus_WorkOrder.F_SourceArea.ToString(), modelT_Bus_WorkOrder.F_Id, "10");
  440. }).ContinueWith(p => {
  441. System.Diagnostics.Debug.WriteLine(DateTime.Now);
  442. });
  443. }
  444. }
  445. return Success("操作成功");
  446. }
  447. /// <summary>
  448. /// 注册用户
  449. /// </summary>
  450. /// <param name="input"></param>
  451. /// <returns></returns>
  452. // [HttpPost]
  453. public ActionResult AddUser(string loginNo,string loginPassword,string userMobile,string validateCode)
  454. {
  455. Model.T_Sys_Users dModel = new Model.T_Sys_Users();
  456. var list = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + loginNo + "' ");
  457. if (list.Count > 0)
  458. {
  459. return Error("已经存在此账号");
  460. }
  461. else
  462. {
  463. string isFirstLogin = "";
  464. string mobileKey = "";
  465. JObject jObject = GetMobileKey(userMobile, validateCode);
  466. if (jObject["C-API-Status"].ToString() == "00")
  467. {
  468. var Body = jObject["C-Response-Body"].ToString ();
  469. var txnBodyComresult = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(Body);
  470. mobileKey = txnBodyComresult["mobileKey"] == null ? "" : txnBodyComresult["mobileKey"].ToString();
  471. isFirstLogin = txnBodyComresult["isFirstLogin"] == null ? "" : txnBodyComresult["isFirstLogin"].ToString();
  472. }
  473. else
  474. {
  475. return Error(jObject["C-Response-Desc"].ToString());
  476. }
  477. if (mobileKey=="")
  478. return Error("mobileKey获取失败");
  479. if (isFirstLogin == ""|| isFirstLogin=="0")
  480. return Error("该手机号码已注册");
  481. string url = appurl + "/gsp/uc10041";
  482. var txnBodyCom = new SortedDictionary<string, string>
  483. {
  484. {"userMobile", userMobile},//用户手机号
  485. {"loginNo",loginNo},//33 自然人注册&登录
  486. {"loginPassword", loginPassword},
  487. {"mobileKey", mobileKey}
  488. };
  489. var txnCommCom = new SortedDictionary<string, string>
  490. {
  491. {"tRecInPage", "10"},
  492. {"txnIttChnlCgyCode", "D001C004"},
  493. {"tStsTraceId", "110567980"},
  494. {"tPageJump", "1"},
  495. {"txnIttChnlId", "99990001000000000000000"},
  496. };
  497. var sms = new Dictionary<string, string>
  498. {
  499. {"txnBodyCom", txnBodyCom.ToJson ()},
  500. {"txnCommCom", txnCommCom.ToJson ()}
  501. };
  502. //序列化参数
  503. var param = new
  504. {
  505. txnBodyCom = txnBodyCom,
  506. txnCommCom = txnCommCom
  507. };
  508. var jsonParam = JsonConvert.SerializeObject(param);
  509. var responseString = HttpMethods.HttpPost(url , jsonParam, "application/json");
  510. JObject jo = (JObject)JsonConvert.DeserializeObject(responseString);
  511. if (jo["C-API-Status"].ToString() == "00")
  512. {
  513. dModel.F_OpenId = loginNo;
  514. dModel.F_Password = loginPassword;
  515. dModel.F_Name = loginNo;
  516. dModel.F_Telphone = userMobile;
  517. dModel.F_Type = (int)EnumUserType.app;//4;
  518. dModel.F_CreateTime = DateTime.Now;
  519. long n = new BLL.T_Sys_Users().Add(dModel);
  520. if (n > 0)
  521. return Success("添加成功");
  522. else
  523. return Error("添加失败");
  524. }
  525. else
  526. {
  527. return Error(jObject["C-Response-Desc"].ToString());
  528. }
  529. }
  530. }
  531. private string appurl = Configs.GetValue("AppUrl");
  532. public JObject GetMobileKey(string userMobile,string validateCode)
  533. {
  534. string Smsurl = appurl + "/gsp/uc00006";
  535. var txnBodyCom = new SortedDictionary<string, string>
  536. {
  537. {"userMobile", userMobile},//用户手机号
  538. {"validateCodeType", "33"},//33 自然人注册&登录
  539. {"validateCode", validateCode}
  540. };
  541. var txnCommCom = new SortedDictionary<string, string>
  542. {
  543. {"tRecInPage", "10"},
  544. {"txnIttChnlCgyCode", "D001C004"},
  545. {"tStsTraceId", "110567980"},
  546. {"tPageJump", "1"},
  547. {"txnIttChnlId", "99990001000000000000000"},
  548. };
  549. var sms = new Dictionary<string, string>
  550. {
  551. {"txnBodyCom", txnBodyCom.ToJson ()},
  552. {"txnCommCom", txnCommCom.ToJson ()}
  553. };
  554. //序列化参数
  555. var param = new
  556. {
  557. txnBodyCom = txnBodyCom,
  558. txnCommCom = txnCommCom
  559. };
  560. var jsonParam = JsonConvert.SerializeObject(param);
  561. var responseString = HttpMethods.HttpPost(Smsurl, jsonParam, "application/json");
  562. JObject jo = (JObject)JsonConvert.DeserializeObject(responseString);
  563. return jo;
  564. }
  565. /// <summary>
  566. /// 发送短信
  567. /// </summary>
  568. /// <param name="input"></param>
  569. /// <returns></returns>
  570. public ActionResult SendSms(string userMobile,string vcodeId,string vcode)
  571. {
  572. string Smsurl = appurl+ "/gsp/uc00001";
  573. var txnBodyCom = new SortedDictionary<string, string >
  574. {
  575. {"userMobile", userMobile},//用户手机号
  576. {"validateCodeType", "33"},
  577. {"vcodeId", vcodeId},
  578. {"vcode", vcode}
  579. };
  580. var txnCommCom = new SortedDictionary<string, string>
  581. {
  582. {"tRecInPage", "10"},
  583. {"txnIttChnlCgyCode", "D001C004"},
  584. {"tStsTraceId", "110567980"},
  585. {"tPageJump", "1"},
  586. {"txnIttChnlId", "99990001000000000000000"},
  587. };
  588. var sms = new Dictionary<string, string >
  589. {
  590. {"txnBodyCom", txnBodyCom.ToJson ()},
  591. {"txnCommCom", txnCommCom.ToJson ()}
  592. };
  593. //序列化参数
  594. var param = new {
  595. txnBodyCom= txnBodyCom,
  596. txnCommCom= txnCommCom
  597. } ;
  598. var jsonParam = JsonConvert.SerializeObject(param);
  599. var responseString = HttpMethods.HttpPost(Smsurl, jsonParam, "application/json");
  600. JObject jo = (JObject)JsonConvert.DeserializeObject(responseString);
  601. if (jo["C-API-Status"].ToString() == "00")
  602. return Success("发送成功", jo["C-Response-Desc"].ToString ());
  603. else
  604. return Error(jo["C-Response-Desc"].ToString());
  605. }
  606. /// <summary>
  607. /// 编辑用户
  608. /// </summary>
  609. /// <param name="input"></param>
  610. /// <returns></returns>
  611. [APPActionFilter]
  612. [HttpPost]
  613. public ActionResult UpdateUser()
  614. {
  615. int id = RequestString.GetInt("id", 0);
  616. string usercode = RequestString.GetFormString("usercode");
  617. string password = RequestString.GetFormString("password");
  618. string name = RequestString.GetFormString("name");
  619. string phone = RequestString.GetFormString("phone");
  620. int sex = RequestString.GetInt("sex", 0);
  621. string province = RequestString.GetFormString("province");
  622. string city = RequestString.GetFormString("city");
  623. string county = RequestString.GetFormString("county");
  624. string address = RequestString.GetFormString("address");
  625. Model.T_Sys_Users dModel = new Model.T_Sys_Users();
  626. if (id == 0)
  627. {
  628. dModel = new BLL.T_Sys_Users().GetModel(id);
  629. if (dModel != null)
  630. {
  631. var list = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + usercode + "' and F_Id!='" + id + "' ");
  632. if (list.Count > 0)
  633. {
  634. return Error("已经存在此账号");
  635. }
  636. else
  637. {
  638. dModel.F_OpenId = usercode;
  639. dModel.F_Name = name;
  640. dModel.F_Telphone = phone;
  641. dModel.F_Sex = sex;
  642. dModel.F_Province = province;
  643. dModel.F_City = city;
  644. dModel.F_County = county;
  645. dModel.F_Address = address;
  646. if (new BLL.T_Sys_Users().Update(dModel))
  647. return Success("修改成功");
  648. else
  649. return Error("修改失败");
  650. }
  651. }
  652. else
  653. {
  654. return Error("修改失败");
  655. }
  656. }
  657. else
  658. {
  659. return Error("修改失败");
  660. }
  661. }
  662. /// <summary>
  663. /// 修改密码
  664. /// </summary>
  665. /// <returns></returns>
  666. [APPActionFilter]
  667. [HttpPost]
  668. public ActionResult UpdatePassword()
  669. {
  670. string usercode = RequestString.GetFormString("usercode");
  671. string old = RequestString.GetFormString("old");
  672. string new1 = RequestString.GetFormString("new1");
  673. string new2 = RequestString.GetFormString("new2");
  674. if (string.IsNullOrEmpty(old) || string.IsNullOrEmpty(new1) || string.IsNullOrEmpty(new2))
  675. {
  676. return Error("请输入新旧密码");
  677. }
  678. if (new1 != new2)
  679. {
  680. return Error("两次输入的不一致");
  681. }
  682. var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
  683. if (old == userinfo.F_Password)
  684. {
  685. userinfo.F_Password = new1;
  686. new BLL.T_Sys_Users().Update(userinfo);
  687. return Success("修改成功");
  688. }
  689. else
  690. {
  691. return Error("原密码错误");
  692. }
  693. }
  694. /// <summary>
  695. /// 获取工单列表
  696. /// </summary>
  697. /// <returns></returns>
  698. [APPActionFilter]
  699. public ActionResult GetWorkOrderList(int isdc = 0)
  700. {
  701. //string sql = " and F_IsDelete=0 ";
  702. string sql = " and (F_IsEnabled=0 or F_IsDelete=0) ";
  703. // var ouid = DbHelperSQL.GetSingle(" select F_ID from T_Sys_Users where F_OpenId ='" + strusercode + "'");
  704. // string sqlwhere = "select F_WorkOrderID FROM T_Bus_UserWorkOrder where F_UserId = '" + ouid.ToString() + "' ";
  705. // sql += " and F_WorkOrderID in (" + sqlwhere + ")";
  706. DataTable dt = new DataTable();
  707. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  708. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  709. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  710. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  711. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  712. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  713. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  714. int source = RequestString.GetInt("source", 0);
  715. int keyid = RequestString.GetInt("keyid", 0);
  716. int type = RequestString.GetInt("type", 0);
  717. int bigtype = RequestString.GetInt("bigtype", 0);
  718. int smalltype = RequestString.GetInt("smalltype", 0);
  719. int sourcearea = RequestString.GetInt("sourcearea", 0);
  720. int deptid = RequestString.GetInt("deptid", 0);
  721. int dealtype = RequestString.GetInt("dealtype", -1);
  722. int issend = RequestString.GetInt("issend", -1);
  723. int isdeal = RequestString.GetInt("isdeal", -1);
  724. string strpageindex = RequestString.GetQueryString("page");
  725. int pageindex = 1;
  726. string strpagesize = RequestString.GetQueryString("pagesize");
  727. int pagesize = 10;
  728. #region sql 语句相关处理
  729. if (strstate.Trim() != "" && strstate != "undefined")
  730. {
  731. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  732. }
  733. if (strworkid.Trim() != "" && strworkid != "undefined")
  734. {
  735. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  736. }
  737. if (strname.Trim() != "" && strname != "undefined")
  738. {
  739. sql += " and F_CusName like '%" + strname + "%' ";
  740. }
  741. if (strtel.Trim() != "" && strtel != "undefined")
  742. {
  743. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  744. }
  745. if (strkey.Trim() != "" && strkey != "undefined")
  746. {
  747. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  748. }
  749. if (source != 0)
  750. {
  751. sql += " and F_InfoSource = '" + source + "' ";
  752. }
  753. if (keyid != 0)
  754. {
  755. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  756. }
  757. if (type != 0)
  758. {
  759. sql += " and F_InfoType = '" + type + "' ";
  760. }
  761. if (bigtype != 0)
  762. {
  763. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  764. }
  765. if (smalltype != 0)
  766. {
  767. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  768. }
  769. if (sourcearea != 0)
  770. {
  771. sql += " and F_SourceArea = '" + sourcearea + "' ";
  772. }
  773. if (deptid != 0)
  774. {
  775. string sqlwhere1 = "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 ";
  776. sql += " and F_WorkOrderID in(" + sqlwhere1 + ")";
  777. }
  778. if (dealtype != -1)
  779. {
  780. sql += " and isnull(F_IsResult,0) = '" + dealtype + "' ";
  781. }
  782. if (issend != -1)
  783. {
  784. sql += " and isnull(F_IsRelease,0) = '" + issend + "' ";
  785. }
  786. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  787. {
  788. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  789. }
  790. if (strendtime.Trim() != "" && strendtime != "undefined")
  791. {
  792. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  793. }
  794. if (isdeal != -1)
  795. {
  796. if (isdeal == 1)
  797. {
  798. sql += " and F_WorkState = '9' ";
  799. }
  800. else
  801. {
  802. sql += " and F_WorkState != '9' ";
  803. }
  804. }
  805. #endregion
  806. if (strpageindex.Trim() != "")
  807. {
  808. pageindex = Convert.ToInt32(strpageindex);
  809. }
  810. if (strpagesize.Trim() != "")
  811. {
  812. pagesize = Convert.ToInt32(strpagesize);
  813. }
  814. string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  815. if (isdc > 0)
  816. {
  817. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder where 1=1 " + sql).Tables[0];
  818. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  819. if (msg == "")
  820. {
  821. return Success("导出成功");
  822. }
  823. else
  824. {
  825. return Error("导出失败");
  826. }
  827. }
  828. int recordCount = 0;
  829. dt = BLL.PagerBLL.GetListPager(
  830. "T_Bus_WorkOrder",
  831. "F_WorkOrderId",
  832. cols,
  833. sql,
  834. "ORDER BY F_CreateTime DESC",
  835. pagesize,
  836. pageindex,
  837. true,
  838. out recordCount);
  839. var obj = new
  840. {
  841. state = "success",
  842. message = "成功",
  843. rows = dt,
  844. total = recordCount
  845. };
  846. return Content(obj.ToJson());
  847. }
  848. //市民评议
  849. public ActionResult Comment(string workorderid,string Satisfaction,string content)
  850. {
  851. var model = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
  852. if (model != null)
  853. {
  854. string strStm_Src_Dsc = "";
  855. var DictionaryValue = new BLL.T_Sys_DictionaryValue().GetModel((int)model.F_InfoSource);
  856. if (DictionaryValue != null)
  857. {
  858. strStm_Src_Dsc = DictionaryValue.F_Value;
  859. }
  860. string strSql = string.Format(@"INSERT INTO PublicComment ( [WorkOrderId], [strStm_Src_Dsc], [strWrkOrder_Cst_Ssf_Cd], [strUdt_Psn_ID], [strSsf_Cst_Ass_CntDsc], [strRltv_InsID], [strInpt_Inst_Nm], [strHpCnt], [CreateTime],[str_type])
  861. values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}') ;select @@IDENTITY ", model.F_WorkOrderId, strStm_Src_Dsc, Satisfaction, "", content, "", "", "", DateTime.Now, 3);
  862. object objres = DbHelperSQL.GetSingle(strSql);
  863. return Success("评议成功");
  864. }
  865. else
  866. {
  867. return Error("工单不存在");
  868. }
  869. }
  870. /// <summary>
  871. /// 获取工单列表
  872. /// </summary>
  873. /// <returns></returns>
  874. public ActionResult GetList(int isdc = 0)
  875. {
  876. DataTable dt = new DataTable();
  877. string sql = " and F_IsDelete=0 ";
  878. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  879. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  880. string state = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  881. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  882. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  883. int ispy = RequestString.GetInt("ispy", -1);
  884. string strpageindex = RequestString.GetQueryString("page");
  885. int pageindex = 1;
  886. string strpagesize = RequestString.GetQueryString("pagesize");
  887. int pagesize = 10;
  888. #region sql 语句相关处理
  889. if (strtel.Trim() != "" && strtel != "undefined")
  890. {
  891. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  892. }
  893. if (strkey.Trim() != "" && strkey != "undefined")
  894. {
  895. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%'" +
  896. " or F_Result like '%" + strkey + "%' ) ";
  897. }
  898. if (state.Trim() != "" && state != "undefined")
  899. {
  900. if (state == "1")
  901. {
  902. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.submit + "," + (int)EnumWorkState.receive + (int)EnumWorkState.resubmit + ") ";
  903. }
  904. else if (state == "2")
  905. {
  906. sql += " and F_WorkState in (" + (int)EnumWorkState.auditreback + "," + (int)EnumWorkState.dealing + "," + (int)EnumWorkState.auditdelay + (int)EnumWorkState.reload + (int)EnumWorkState.audit + (int)EnumWorkState.rejload + ") ";
  907. }
  908. else if (state == "3")
  909. {
  910. sql += " and F_WorkState in (" + (int)EnumWorkState.visit + "," + (int)EnumWorkState.finish + "," + (int)EnumWorkState.dealed + ") ";
  911. }
  912. else if (state == "4")
  913. {
  914. sql += " and F_WorkState not in ( 6,7,9 ) ";
  915. }
  916. }
  917. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  918. {
  919. if (strendtime.Trim() != "" && strendtime != "undefined")
  920. {
  921. sql += " and F_CreateTime between '" + strstarttime +
  922. "' AND '" + strendtime + "'";
  923. }
  924. else
  925. {
  926. sql += " and F_CreateTime>='" + strstarttime + "' ";
  927. }
  928. }
  929. else
  930. {
  931. if (strendtime.Trim() != "" && strendtime != "undefined")
  932. {
  933. sql += " and F_CreateTime<='" + strendtime + "' ";
  934. }
  935. }
  936. if (ispy >-1)
  937. {
  938. if (ispy ==0)
  939. {
  940. sql += "and F_WorkOrderId not in (select WorkOrderId from PublicComment WITH(NOLOCK)) ";
  941. }
  942. else
  943. {
  944. sql += "and F_WorkOrderId in (select WorkOrderId from PublicComment WITH(NOLOCK) )";
  945. }
  946. }
  947. #endregion
  948. if (strpageindex.Trim() != "")
  949. {
  950. pageindex = Convert.ToInt32(strpageindex);
  951. }
  952. if (strpagesize.Trim() != "")
  953. {
  954. pagesize = Convert.ToInt32(strpagesize);
  955. }
  956. string cols = "*,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  957. #region 导出
  958. #endregion
  959. int recordCount = 0;
  960. dt = BLL.PagerBLL.GetListPager(
  961. "T_Bus_WorkOrder a WITH(NOLOCK)" ,
  962. "F_Id",
  963. cols,
  964. sql,
  965. "ORDER BY F_CreateTime DESC",
  966. pagesize,
  967. pageindex,
  968. true,
  969. out recordCount);
  970. #region 声音文件和交办超时
  971. foreach (DataRow dr in dt.Rows)
  972. {
  973. }
  974. #endregion
  975. var obj = new
  976. {
  977. state = "success",
  978. message = "成功",
  979. rows = dt,
  980. total = recordCount
  981. };
  982. return Content(obj.ToJson());
  983. }
  984. private BLL.T_Sys_SystemConfig configBll = new BLL.T_Sys_SystemConfig();
  985. public ActionResult GetWorkOrderNew()
  986. {
  987. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  988. if (!string.IsNullOrEmpty(strworkorderid))
  989. {
  990. var configfj = configBll.GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  991. #region 基本信息
  992. string sql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName1,dbo.GetAreaName(F_SourceArea) as AreaName,dbo.GetDictionaryName(F_InfoSource) as SourceName,dbo.GetKeyNames(F_Key) as KeyName,dbo.GetDeptName(F_MainDeptId) deptname ,dbo.GetAreaChildrenCode(F_Township) as Township , dbo.GetAreaChildrenCode(F_Village) as Village,F_DeptIdIsSms = (select F_IsSms from T_Sys_Department WITH(NOLOCK) where F_DeptId =a.F_MainDeptId) from T_Bus_WorkOrder a WITH(NOLOCK) where F_WorkOrderId ='" + strworkorderid + "'";
  993. var dt = DbHelperSQL.Query(sql).Tables[0];
  994. if (dt.Rows.Count > 0)
  995. {
  996. #region 附件
  997. if (configfj != null)
  998. {
  999. dt = BindFileData(dt, configfj.F_ParamValue);
  1000. }
  1001. string pysql = "select * from PublicComment WITH(NOLOCK) where WorkOrderId ='" + strworkorderid + "' order by CreateTime";
  1002. var pydt = DbHelperSQL.Query(pysql).Tables[0];
  1003. #endregion
  1004. var obj = new
  1005. {
  1006. data = dt,
  1007. pysql= pysql
  1008. };
  1009. return Success("获取成功", obj);
  1010. }
  1011. else
  1012. {
  1013. return Error("获取失败");
  1014. }
  1015. #endregion
  1016. }
  1017. return Error("获取失败");
  1018. }
  1019. private BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
  1020. /// <summary>
  1021. /// 获取工单列表
  1022. /// </summary>
  1023. /// <returns></returns>
  1024. [APPActionFilter]
  1025. public ActionResult GetOrderCount()
  1026. {
  1027. //string sql = " and F_IsDelete=0 ";
  1028. string sql = " select count(1) from T_Bus_WorkOrder where F_IsDelete=0 ";
  1029. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  1030. Model.T_Sys_UserAccount userModel = userBLL.GetModel(strusercode);
  1031. string sqlld = " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 ";
  1032. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  1033. {
  1034. sqlld += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1035. }
  1036. else
  1037. {
  1038. sqlld += ")";
  1039. }
  1040. string sqllddcl = sql + " and F_WorkState = '1' ";
  1041. string sqlthsh = sql + " and F_WorkState = '3' " + sqlld;
  1042. string sqlyssh = sql + " and F_WorkState = '5' " + sqlld;
  1043. string sqlcbdjb = sql + " and F_WorkState = '11' " + sqlld;
  1044. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  1045. {
  1046. sqllddcl += " and (F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo WITH(NOLOCK) where F_State = 1 and F_IsDelete = 0 "
  1047. + "and F_CreateUser = '" + userModel.F_UserCode + "') or (select top 1 F_WorkOrderId from T_Bus_AssignedInfo WITH(NOLOCK) where"
  1048. + " F_State = 1 and F_IsDelete = 0 and T_Bus_AssignedInfo.F_WorkOrderId = T_Bus_WorkOrder.F_WorkOrderId) is null)";
  1049. }
  1050. string dw = "";
  1051. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1052. {
  1053. dw += " and F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and "
  1054. + " ISNULL(F_FeedbackTime, '')='' and F_MainDeptId =" + userModel.F_DeptId + " and F_IsSure in (0,1))";
  1055. }
  1056. string dwdcs = sql + " and F_WorkState = '2' " + dw;
  1057. string dwdbl = sql + " and F_WorkState = '4' " + dw;
  1058. string dwthsh = sql + " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type = 3 ";
  1059. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1060. {
  1061. dwthsh += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1062. }
  1063. else
  1064. {
  1065. dwthsh += ")";
  1066. }
  1067. string dwyssh = sql + " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_DelayTime WITH(NOLOCK) where F_State=1 and F_IsDelete=0 ";
  1068. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1069. {
  1070. dwyssh += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1071. }
  1072. else
  1073. {
  1074. dwyssh += ")";
  1075. }
  1076. string dwspdb = sql + " and F_WorkState = '11' " + dw;
  1077. int[] sts = new int[] { (int)EnumWorkState.dealing, (int)EnumWorkState.auditdelay };
  1078. string ejdbl = sql + " and F_WorkState in (" + string.Join(",", sts.Select(p => p.ToString())) + ")";
  1079. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1080. {
  1081. ejdbl += " and F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo_Next WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and "
  1082. + " ISNULL(F_FeedbackTime, '')='' and F_MainDeptId =" + userModel.F_DeptId + " and F_IsSure in (0,1))";
  1083. }
  1084. string ejybl = sql + " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_Feedback_Next WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type in (1,2) ";
  1085. if (userModel.F_RoleCode != "GLY" && userModel.F_RoleCode != "DDZG")
  1086. {
  1087. ejybl += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1088. }
  1089. else
  1090. {
  1091. ejybl += ")";
  1092. }
  1093. var obj = new
  1094. {
  1095. sqllddcl = DbHelperSQL.GetSingle(sqllddcl).ToString(),
  1096. sqlthsh = DbHelperSQL.GetSingle(sqlthsh).ToString(),
  1097. sqlyssh = DbHelperSQL.GetSingle(sqlyssh).ToString(),
  1098. sqlcbdjb = DbHelperSQL.GetSingle(sqlcbdjb).ToString(),
  1099. dwdcs = DbHelperSQL.GetSingle(dwdcs).ToString(),
  1100. dwdbl = DbHelperSQL.GetSingle(dwdbl).ToString(),
  1101. dwthsh = DbHelperSQL.GetSingle(dwthsh).ToString(),
  1102. dwyssh = DbHelperSQL.GetSingle(dwyssh).ToString(),
  1103. dwspdb = DbHelperSQL.GetSingle(dwspdb).ToString(),
  1104. ejdbl = DbHelperSQL.GetSingle(ejdbl).ToString(),
  1105. ejybl = DbHelperSQL.GetSingle(ejybl).ToString()
  1106. };
  1107. return Success("成功", obj);
  1108. }
  1109. /// <summary>
  1110. /// 获取工单数量
  1111. /// </summary>
  1112. /// <returns></returns>
  1113. [APPActionFilter]
  1114. public ActionResult GetWorkOrderCount(string usercode)
  1115. {
  1116. string stropenid = usercode;
  1117. int type = RequestString.GetInt("type", 0);
  1118. var wxuser = new BLL.T_Sys_UserAccount().GetModelList(" F_UserCode='" + stropenid.Trim() + "' and F_DeleteFlag=0 ").FirstOrDefault();
  1119. string where = " F_WorkOrderId in (select F_WorkOrderId from T_Bus_UserWorkOrder where F_UserId='" + wxuser.F_UserId + "') ";
  1120. string sql = " select count(1) from T_Bus_UserWorkOrder where F_UserId='" + wxuser.F_UserId + "' ";
  1121. string sqlblz = " select count(1) from T_Bus_WorkOrder where " + where + " and F_WorkState!=9 and (F_IsEnabled=0 or F_IsDelete=0)";
  1122. string sqlybl = " select count(1) from T_Bus_WorkOrder where " + where + " and F_WorkState =9 and (F_IsEnabled=0 or F_IsDelete=0)";
  1123. string sqltype = " select F_ValueId,F_Value,(select COUNT(1) from T_Bus_WorkOrder where (F_IsEnabled=0 or F_IsDelete=0) ";
  1124. if (type == 1)
  1125. {
  1126. sqltype += " and F_WorkState!=9";
  1127. }
  1128. else if (type == 2)
  1129. {
  1130. sqltype += " and F_WorkState=9";
  1131. }
  1132. sqltype += " and F_InfoType=F_ValueId and " + where + ") Count from dbo.T_Sys_DictionaryValue where F_ItemId=2 and F_State=0 ";
  1133. DataTable dt = DbHelperSQL.Query(sqltype).Tables[0];
  1134. var obj = new
  1135. {
  1136. total = DbHelperSQL.GetSingle(sql).ToString(),
  1137. blzcount = DbHelperSQL.GetSingle(sqlblz).ToString(),
  1138. yblcount = DbHelperSQL.GetSingle(sqlybl).ToString(),
  1139. typedata = dt
  1140. };
  1141. return Success("成功", obj);
  1142. }
  1143. /// <summary>
  1144. /// APP上传图片
  1145. /// </summary>
  1146. /// <returns></returns>
  1147. [APPActionFilter]
  1148. public ActionResult Upload64()
  1149. {
  1150. //string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
  1151. string dataurl = RequestString.GetFormString("dataurl");
  1152. string filename = RequestString.GetFormString("filename");
  1153. if (!string.IsNullOrEmpty(dataurl))
  1154. {
  1155. string path = "/Upload/APP/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  1156. ImageUpload iu = new ImageUpload();
  1157. iu.SavePath = path;
  1158. iu.DataUrl = dataurl;
  1159. if (!string.IsNullOrEmpty(filename))
  1160. {
  1161. iu.SaveType = 1;
  1162. iu.InFileName = filename;
  1163. }
  1164. iu.Upload64();
  1165. int n = iu.Error;
  1166. if (n == 0)
  1167. {
  1168. path = path + iu.OutFileName;
  1169. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  1170. model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  1171. model_T_Sys_Accessories.F_FileName = iu.OutFileName;//附件名称
  1172. model_T_Sys_Accessories.F_FileType = ".jpg";//附件类型
  1173. model_T_Sys_Accessories.F_FileUrl = path;//附件地址
  1174. model_T_Sys_Accessories.F_Size = iu.FileSize;
  1175. //model_T_Sys_Accessories.F_UserCode = userModel.F_UserCode;//上传人
  1176. int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  1177. model_T_Sys_Accessories.F_FileId = id;
  1178. return Success("成功", model_T_Sys_Accessories);
  1179. }
  1180. else
  1181. {
  1182. string msg = string.Empty;
  1183. switch (n)
  1184. {
  1185. case 1: msg = "请选择要上传的文件"; break;
  1186. case 2: msg = "上传的文件类型不支持"; break;
  1187. case 3: msg = "上传的文件过大"; break;
  1188. case 4: msg = "未知错误"; break;
  1189. }
  1190. return Error(msg);
  1191. }
  1192. }
  1193. else
  1194. {
  1195. return Error("请选择要上传的文件");
  1196. }
  1197. }
  1198. /// <summary>
  1199. /// 市民催单
  1200. /// </summary>
  1201. /// <returns></returns>
  1202. [APPActionFilter]
  1203. public ActionResult AdditionalWorkOrder()
  1204. {
  1205. string usercode = RequestString.GetFormString("usercode");
  1206. var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
  1207. string workorderid = RequestString.GetFormString("workorderid");
  1208. string title = RequestString.GetFormString("title");
  1209. string content = RequestString.GetFormString("content");
  1210. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
  1211. if (modelT_Bus_WorkOrder != null)
  1212. {
  1213. using (TransactionScope trans = new TransactionScope())
  1214. {
  1215. #region 插入附加记录
  1216. //批示记录
  1217. Model.T_Bus_Additional model_T_Bus_Additional = new Model.T_Bus_Additional();
  1218. model_T_Bus_Additional.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单流水号
  1219. model_T_Bus_Additional.F_Title = title;
  1220. model_T_Bus_Additional.F_Content = content;
  1221. model_T_Bus_Additional.F_CreateTime = DateTime.Now;
  1222. model_T_Bus_Additional.F_IsDelete = 0;
  1223. model_T_Bus_Additional.F_State = 1;
  1224. new BLL.T_Bus_Additional().Add(model_T_Bus_Additional);
  1225. #endregion
  1226. #region 插入操作记录
  1227. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  1228. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  1229. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  1230. oper.F_Message = "市民(" + userinfo.F_OpenId + ")催单,内容:" + content;
  1231. //oper.F_CreateUser = userModel.F_UserCode;
  1232. oper.F_CreateTime = DateTime.Now;
  1233. oper.F_IsDelete = 0;
  1234. new BLL.T_Bus_Operation().Add(oper);
  1235. #endregion
  1236. trans.Complete();
  1237. }
  1238. return Success("操作成功");
  1239. }
  1240. else
  1241. {
  1242. return Error("操作失败");
  1243. }
  1244. }
  1245. /// <summary>
  1246. /// 获取工单信息
  1247. /// </summary>
  1248. /// <returns></returns>
  1249. [APPActionFilter]
  1250. public ActionResult GetWorkOrder()
  1251. {
  1252. string usercode = RequestString.GetFormString("usercode");
  1253. var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
  1254. string workorderid = RequestString.GetFormString("workorderid");
  1255. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  1256. //int type = RequestString.GetInt("type", 0);//0基本信息1监察意见2领导批示3办理情况4回访信息5督办信息6办理过程
  1257. if (!string.IsNullOrEmpty(strworkorderid))
  1258. {
  1259. string sql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName1,"
  1260. + "dbo.GetAreaName(F_SourceArea) as AreaName,dbo.GetDictionaryName(F_InfoSource) as SourceName "
  1261. + " from T_Bus_WorkOrder where F_WorkOrderId ='" + strworkorderid + "'";
  1262. var dt = DbHelperSQL.Query(sql).Tables[0];
  1263. if (dt.Rows.Count > 0)
  1264. {
  1265. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  1266. string jcsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_DeptId) as DeptName "
  1267. + "from T_Bus_RemindRecord where F_Type=2 and F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1268. string dbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_DeptId) as DeptName "
  1269. + "from T_Bus_RemindRecord where F_Type=1 and F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1270. string pssql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1271. + "from T_Bus_SubmitSuper where F_State=1 and F_IsDelete=0 and F_Type=1 and F_WorkOrderId ='" + strworkorderid + "'";
  1272. string zssql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1273. + "from T_Bus_SubmitSuper where F_State=1 and F_IsDelete=0 and F_Type=2 and F_WorkOrderId ='" + strworkorderid + "'";
  1274. string htsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1275. + "from T_Bus_SubmitSuper where F_State=1 and F_IsDelete=0 and F_Type=3 and F_WorkOrderId ='" + strworkorderid + "'";
  1276. string jbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_MainDeptId) as DeptName,dbo.GetDeptNames(F_OtherDeptIds) as OtherDeptName "
  1277. + "from T_Bus_AssignedInfo where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1278. string thsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_CreateDeptId) as DeptName "
  1279. + "from T_Bus_Feedback where F_State=1 and F_Type=3 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1280. string yssql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1281. + "from T_Bus_DelayTime where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1282. string blsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_CreateDeptId) as DeptName "
  1283. + "from T_Bus_Feedback where F_State=1 and F_Type!=3 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1284. string hfsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1285. + "from T_Bus_VisitResult where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1286. string gcsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1287. + "from T_Bus_Operation where F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1288. string cbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1289. + "from T_Bus_Additional where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1290. #region 附件
  1291. if (configfj != null)
  1292. {
  1293. dt = BindFileData(dt, configfj.F_ParamValue);
  1294. }
  1295. #endregion
  1296. #region 监察信息
  1297. var jcdt = DbHelperSQL.Query(jcsql).Tables[0];
  1298. if (configfj != null)
  1299. {
  1300. jcdt = BindFileData(jcdt, configfj.F_ParamValue);
  1301. }
  1302. #endregion
  1303. #region 批示信息
  1304. var psdt = DbHelperSQL.Query(pssql).Tables[0];
  1305. if (configfj != null)
  1306. {
  1307. psdt = BindFileData(psdt, configfj.F_ParamValue);
  1308. }
  1309. #endregion
  1310. #region 指示信息
  1311. var zsdt = DbHelperSQL.Query(zssql).Tables[0];
  1312. if (configfj != null)
  1313. {
  1314. zsdt = BindFileData(zsdt, configfj.F_ParamValue);
  1315. }
  1316. #endregion
  1317. #region 回退信息
  1318. var htdt = DbHelperSQL.Query(htsql).Tables[0];
  1319. #endregion
  1320. #region 督办信息
  1321. var dbdt = DbHelperSQL.Query(dbsql).Tables[0];
  1322. if (configfj != null)
  1323. {
  1324. dbdt = BindFileData(dbdt, configfj.F_ParamValue);
  1325. }
  1326. #endregion
  1327. #region 交办信息
  1328. var jbdt = DbHelperSQL.Query(jbsql).Tables[0];
  1329. if (configfj != null)
  1330. {
  1331. jbdt = BindFileData(jbdt, configfj.F_ParamValue);
  1332. }
  1333. #endregion
  1334. #region 退回信息
  1335. var thdt = DbHelperSQL.Query(thsql).Tables[0];
  1336. #endregion
  1337. #region 延时信息
  1338. var ysdt = DbHelperSQL.Query(yssql).Tables[0];
  1339. #endregion
  1340. #region 办理情况
  1341. var bldt = DbHelperSQL.Query(blsql).Tables[0];
  1342. if (configfj != null)
  1343. {
  1344. bldt = BindFileData(bldt, configfj.F_ParamValue);
  1345. }
  1346. #endregion
  1347. #region 回访信息
  1348. var hfdt = DbHelperSQL.Query(hfsql).Tables[0];
  1349. #endregion
  1350. #region 市民催单
  1351. var cbdt = DbHelperSQL.Query(cbsql).Tables[0];
  1352. #endregion
  1353. #region 办理过程
  1354. var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
  1355. gcdt.Columns.Add("File", typeof(object));
  1356. if (configfj != null)
  1357. {
  1358. foreach (DataRow bldr in gcdt.Rows)
  1359. {
  1360. if (bldr["F_File"] != null && bldr["F_File"].ToString() != "" && configfj != null)
  1361. {
  1362. bldr["File"] = GetFileData(bldr["F_File"].ToString(), configfj.F_ParamValue);
  1363. }
  1364. }
  1365. }
  1366. #endregion
  1367. var obj = new
  1368. {
  1369. data = dt,
  1370. jcdata = jcdt,
  1371. psdata = psdt,
  1372. zsdata = zsdt,
  1373. htdata = htdt,
  1374. dbdata = dbdt,
  1375. jbdata = jbdt,
  1376. thdata = thdt,
  1377. ysdata = ysdt,
  1378. bldata = bldt,
  1379. hfdata = hfdt,
  1380. cbdata = cbdt,
  1381. gcdata = gcdt
  1382. };
  1383. return Success("获取成功", obj);
  1384. }
  1385. else
  1386. {
  1387. return Error("获取失败");
  1388. }
  1389. }
  1390. else
  1391. {
  1392. return Error("参数传输失败");
  1393. }
  1394. }
  1395. /// <summary>
  1396. /// 获取附件数据
  1397. /// </summary>
  1398. /// <param name="ids">附件id,多个用英文逗号,隔开</param>
  1399. /// <param name="prefix">前缀</param>
  1400. /// <returns></returns>
  1401. public DataTable GetFileData(string ids, string prefix)
  1402. {
  1403. DataTable dt = DbHelperSQL.Query("select * from T_Sys_Accessories where F_FileId in (" + ids + ")").Tables[0];
  1404. foreach (DataRow dr in dt.Rows)
  1405. {
  1406. dr["F_FileUrl"] = prefix + dr["F_FileUrl"].ToString();
  1407. }
  1408. return dt;
  1409. }
  1410. /// <summary>
  1411. /// 绑定附件信息
  1412. /// </summary>
  1413. /// <param name="dt"></param>
  1414. /// <param name="prefix"></param>
  1415. /// <returns></returns>
  1416. public DataTable BindFileData(DataTable dt, string prefix)
  1417. {
  1418. dt.Columns.Add("File", typeof(object));
  1419. foreach (DataRow dr in dt.Rows)
  1420. {
  1421. if (dr["F_File"] != null && dr["F_File"].ToString() != "")
  1422. {
  1423. dr["File"] = GetFileData(dr["F_File"].ToString(), prefix);
  1424. }
  1425. }
  1426. return dt;
  1427. }
  1428. /// <summary>
  1429. /// 修改工单信息
  1430. /// </summary>
  1431. /// <returns></returns>
  1432. [APPActionFilter]
  1433. public ActionResult EditWorkOrder()
  1434. {
  1435. string usercode = RequestString.GetFormString("usercode");
  1436. var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
  1437. string workorderid = RequestString.GetFormString("workorderid");
  1438. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
  1439. Model.T_Bus_UserWorkOrder modelT_Bus_UserWorkOrder = new BLL.T_Bus_UserWorkOrder().GetModelList(" F_WorkOrderId='" + workorderid + "' ").FirstOrDefault();
  1440. if (modelT_Bus_WorkOrder != null && modelT_Bus_UserWorkOrder != null && modelT_Bus_UserWorkOrder.F_UserId == userinfo.F_Id)
  1441. {
  1442. string cusname = RequestString.GetFormString("cusname");
  1443. string cussex = RequestString.GetFormString("cussex");
  1444. string cusphone = RequestString.GetFormString("cusphone");
  1445. string cusaddress = RequestString.GetFormString("cusaddress");
  1446. string email = RequestString.GetFormString("email");
  1447. string zipcode = RequestString.GetFormString("zipcode");
  1448. string conname = RequestString.GetFormString("conname");
  1449. string conphone = RequestString.GetFormString("conphone");
  1450. string title = RequestString.GetFormString("title");
  1451. string content = RequestString.GetFormString("content");
  1452. string files = RequestString.GetFormString("files");
  1453. int sourcearea = RequestString.GetInt("sourcearea", 0);
  1454. string sourceaddress = RequestString.GetFormString("sourceaddress");
  1455. string keys = RequestString.GetFormString("keys");
  1456. int type = RequestString.GetInt("type", 0);
  1457. int bigtype = RequestString.GetInt("bigtype", 0);
  1458. int smalltype = RequestString.GetInt("smalltype", 0);
  1459. int isprotect = RequestString.GetInt("isprotect", 0);
  1460. int level = RequestString.GetInt("level", 0);
  1461. int issubmit = RequestString.GetInt("issubmit", 0);
  1462. using (TransactionScope trans = new TransactionScope())
  1463. {
  1464. #region 保存工单信息
  1465. modelT_Bus_WorkOrder.F_InfoType = type;//信息类别
  1466. modelT_Bus_WorkOrder.F_InfoConBigType = bigtype;//内容大类
  1467. modelT_Bus_WorkOrder.F_InfoConSmallType = smalltype;//内容小类
  1468. modelT_Bus_WorkOrder.F_SourceArea = sourcearea;//反映地域
  1469. modelT_Bus_WorkOrder.F_SourceAddress = sourceaddress;//事发地址
  1470. modelT_Bus_WorkOrder.F_CusName = cusname;//投诉人姓名
  1471. modelT_Bus_WorkOrder.F_CusSex = cussex;//性别
  1472. modelT_Bus_WorkOrder.F_CusPhone = cusphone;//来电号码
  1473. modelT_Bus_WorkOrder.F_CusAddress = cusaddress;//地址
  1474. modelT_Bus_WorkOrder.F_ZipCode = zipcode;//邮编
  1475. modelT_Bus_WorkOrder.F_ConName = conname;//联系人姓名
  1476. modelT_Bus_WorkOrder.F_ConPhone = conphone;//联系人电话
  1477. modelT_Bus_WorkOrder.F_Email = email;//E-mail
  1478. modelT_Bus_WorkOrder.F_ComTitle = title;//标题
  1479. modelT_Bus_WorkOrder.F_ComContent = content;//情况摘要(投诉内容)
  1480. modelT_Bus_WorkOrder.F_File = files;//附件
  1481. modelT_Bus_WorkOrder.F_IsProtect = isprotect;//保密方式0否1是
  1482. modelT_Bus_WorkOrder.F_Key = keys;
  1483. modelT_Bus_WorkOrder.F_Level = level;
  1484. new BLL.T_Bus_WorkOrder().Update(modelT_Bus_WorkOrder);
  1485. #endregion
  1486. #region 插入操作记录
  1487. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  1488. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  1489. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  1490. oper.F_CallRecordId = modelT_Bus_WorkOrder.F_CallRecordId;
  1491. oper.F_File = modelT_Bus_WorkOrder.F_File;
  1492. oper.F_Message = "市民(" + userinfo.F_OpenId + ") 修改了工单";
  1493. //oper.F_CreateUser = userModel.F_UserCode;
  1494. oper.F_CreateTime = DateTime.Now;
  1495. oper.F_IsDelete = 0;
  1496. new BLL.T_Bus_Operation().Add(oper);
  1497. #endregion
  1498. trans.Complete();
  1499. }
  1500. return Success("操作成功");
  1501. }
  1502. else
  1503. {
  1504. return Error("操作失败");
  1505. }
  1506. }
  1507. /// <summary>
  1508. /// 获取用户信息
  1509. /// </summary>
  1510. /// <returns></returns>
  1511. [APPActionFilter]
  1512. public ActionResult GetUserInfo()
  1513. {
  1514. string usercode = RequestString.GetQueryString("usercode");
  1515. var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
  1516. return Success("获取成功", userinfo);
  1517. }
  1518. /// <summary>
  1519. /// 修改用户
  1520. /// </summary>
  1521. /// <param name="input"></param>
  1522. /// <returns></returns>
  1523. [HttpPost]
  1524. [APPActionFilter]
  1525. public ActionResult EditUser()
  1526. {
  1527. string usercode = RequestString.GetFormString("usercode");
  1528. var dModel = new BLL.T_Sys_Users().GetModel(usercode);
  1529. string name = RequestString.GetFormString("name");
  1530. string phone = RequestString.GetFormString("phone");
  1531. int sex = RequestString.GetInt("sex", 0);
  1532. string province = RequestString.GetFormString("province");
  1533. string city = RequestString.GetFormString("city");
  1534. string county = RequestString.GetFormString("county");
  1535. string address = RequestString.GetFormString("address");
  1536. var list = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + usercode + "' and F_Id!='" + dModel.F_Id + "' ");
  1537. if (list.Count > 0)
  1538. {
  1539. return Error("已经存在此账号");
  1540. }
  1541. else
  1542. {
  1543. dModel.F_Name = name;
  1544. dModel.F_Telphone = phone;
  1545. dModel.F_Sex = sex;
  1546. dModel.F_Province = province;
  1547. dModel.F_City = city;
  1548. dModel.F_County = county;
  1549. dModel.F_Address = address;
  1550. bool n = new BLL.T_Sys_Users().Update(dModel);
  1551. if (n)
  1552. return Success("修改成功", n);
  1553. else
  1554. return Error("修改失败");
  1555. }
  1556. }
  1557. private BLL.T_Cus_CustomerBase cusBLL = new BLL.T_Cus_CustomerBase();
  1558. /// <summary>
  1559. /// 保存客户档案
  1560. /// </summary>
  1561. /// <param name="telphone"></param>
  1562. /// <param name="name"></param>
  1563. /// <param name="phone"></param>
  1564. /// <param name="countryid"></param>
  1565. /// <param name="address"></param>
  1566. /// <returns></returns>
  1567. private void saveCus(string name, string phone, string address)
  1568. {
  1569. int res = 0;
  1570. Model.T_Cus_CustomerBase cusmodel = new Model.T_Cus_CustomerBase();
  1571. if (!string.IsNullOrWhiteSpace(phone))
  1572. {
  1573. cusmodel = cusBLL.GetModelBy(phone, name);
  1574. if (cusmodel == null)
  1575. {
  1576. cusmodel = new Model.T_Cus_CustomerBase();
  1577. cusmodel.F_Address = address;
  1578. cusmodel.F_CustomerName = name;
  1579. cusmodel.F_Mobile = phone;
  1580. cusmodel.F_DeleteFlag = 0;
  1581. res = cusBLL.Add(cusmodel);
  1582. }
  1583. }
  1584. }
  1585. string url = "http://172.16.0.10/Affairs/";
  1586. // string url = "http://localhost:63660/Affairs/";
  1587. public void case_info(string workorderid, string parameter)
  1588. {
  1589. var Affairs = int.Parse(Configs.GetValue("Affairs"));
  1590. if (Affairs > 0)
  1591. {
  1592. WebClient web = new WebClient();
  1593. web.Encoding = Encoding.UTF8;
  1594. string Dataurl = web.DownloadString(url + parameter + "?workorderid=" + workorderid);
  1595. }
  1596. }
  1597. public void process_info(int id, string parameter, string title)
  1598. {
  1599. var Affairs = int.Parse(Configs.GetValue("Affairs"));
  1600. if (Affairs > 0)
  1601. {
  1602. WebClient web = new WebClient();
  1603. web.Encoding = Encoding.UTF8;
  1604. string Dataurl = web.DownloadString(url + parameter + "?id=" + id + "&title=" + title);
  1605. }
  1606. }
  1607. public void material_info(string WorkOrderId, string file, string area, int id, string type)
  1608. {
  1609. var Affairs = int.Parse(Configs.GetValue("Affairs"));
  1610. if (Affairs > 0)
  1611. {
  1612. WebClient web = new WebClient();
  1613. web.Encoding = Encoding.UTF8;
  1614. string Dataurl = web.DownloadString(url + "case_material_info" + "?WorkOrderId=" + WorkOrderId + "&file=" + file + "&area=" + area + "&id=" + id + "&type=" + type);
  1615. }
  1616. }
  1617. }
  1618. }