Sin descripción

APPController.cs 107KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394
  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.Sms;
  7. using CallCenterApi.Interface.Controllers.workorder;
  8. using CallCenterApi.Interface.Models.Common;
  9. using CallCenterApi.Model;
  10. using Newtonsoft.Json;
  11. using Newtonsoft.Json.Linq;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Data;
  15. using System.IO;
  16. using System.Linq;
  17. using System.Net;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using System.Transactions;
  21. using System.Web;
  22. using System.Web.Mvc;
  23. namespace CallCenterApi.Interface.Controllers
  24. {
  25. public class APPController : BaseController
  26. {
  27. // GET: APP
  28. /// <summary>
  29. /// 登录
  30. /// </summary>
  31. /// <returns></returns>
  32. public ActionResult Login(string usercode, string password)
  33. {
  34. DateTime ExpiredTime = DateTime.Now.AddDays(1);
  35. bool appResult = DateTime.Now < ExpiredTime;// Convert.ToDateTime(ReadFile(HttpRuntime.AppDomainAppPath + "tools\\hykj.hy"));
  36. if (appResult)
  37. {
  38. DataTable dt = new DataTable();
  39. try
  40. {
  41. Dictionary<string, string> paras = new Dictionary<string, string>();
  42. string sql = " select * from T_Sys_Users where F_OpenId=@F_OpenId and F_Password=@F_Password";
  43. paras.Add("@F_OpenId", usercode);
  44. paras.Add("@F_Password", password);
  45. dt = DbHelperSQL.Query(sql, paras).Tables[0];
  46. if (dt != null)
  47. {
  48. //写入登录日志
  49. new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  50. {
  51. F_LoginName = dt.Rows[0]["F_OpenId"].ToString(),
  52. F_LoginId = Convert.ToInt32(dt.Rows[0]["F_Id"].ToString()),
  53. F_Result = "APP市民登录成功",
  54. F_LoginIP = Common.DTRequest.GetIP(),
  55. F_Hostname = Common.DTRequest.GetIP(),
  56. F_LoginDate = DateTime.Now,
  57. F_Remark = "",
  58. F_State = 0
  59. });
  60. return Success("登录成功", new
  61. {
  62. usercode = dt.Rows[0]["F_OpenId"].ToString(),
  63. userid = dt.Rows[0]["F_Id"].ToString()
  64. });
  65. }
  66. else
  67. {
  68. //写入登录日志
  69. DataTable dt1 = new CallCenterApi.BLL.T_Sys_Users().GetList("F_OpenId='" + usercode + "'").Tables[0];
  70. if (dt1.Rows.Count > 0)
  71. {
  72. int rr = new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  73. {
  74. F_LoginName = dt1.Rows[0]["F_OpenId"].ToString(),
  75. F_LoginId = Convert.ToInt32(dt1.Rows[0]["F_Id"].ToString()),
  76. F_Result = "APP市民登录失败:帐号-" + usercode,
  77. F_LoginIP = Common.DTRequest.GetIP(),
  78. F_Hostname = Common.DTRequest.GetIP(),
  79. F_LoginDate = DateTime.Now,
  80. F_Remark = "",
  81. F_State = 0
  82. });
  83. }
  84. else
  85. {
  86. int rr = new BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  87. {
  88. F_LoginName = usercode,
  89. F_LoginId = -1,
  90. F_Result = "APP市民登录失败:帐号-" + usercode,
  91. F_LoginIP = Common.DTRequest.GetIP(),
  92. F_Hostname = Common.DTRequest.GetIP(),
  93. F_LoginDate = DateTime.Now,
  94. F_Remark = "",
  95. F_State = 0
  96. });
  97. }
  98. return Error("账号或密码错误,请重新登录");
  99. }
  100. }
  101. catch
  102. {
  103. return Error("账号或密码错误,请重新登录");
  104. }
  105. }
  106. else
  107. {
  108. return Error("授权过期,请联系系统厂家。");
  109. }
  110. }
  111. [HttpPost]
  112. public ActionResult loginNologin()
  113. {
  114. string loginNo = RequestString.GetFormString("loginNo");//登录账号
  115. string loginPassword = RequestString.GetFormString("loginPassword");//登录密码
  116. int type = RequestString.GetInt("type", 0); ;//0自然人注册1法人注册
  117. DataTable dt = new DataTable();
  118. try
  119. {
  120. Dictionary<string, string> paras = new Dictionary<string, string>();
  121. string sql = "";
  122. sql = " select * from T_Sys_Users where F_OpenId=@F_OpenId and F_Password=@F_Password";
  123. paras.Add("@F_OpenId", loginNo);
  124. paras.Add("@F_Password", loginPassword);//login.Password
  125. dt = DbHelperSQL.Query(sql, paras).Tables[0];
  126. if (dt != null)
  127. {
  128. if (dt.Rows.Count > 0)
  129. {
  130. string Smsurl = "https://zwfw.anyang.gov.cn/gsp/uc10002";
  131. string acctType = "10";
  132. if (type == 1)
  133. {
  134. acctType = "20";
  135. Smsurl = "https://zwfw.anyang.gov.cn/gsp/uc20002";
  136. }
  137. var dic = new SortedDictionary<string, string>
  138. {
  139. {"loginNo", loginNo},
  140. {"loginPassword", loginPassword},
  141. {"loginType", "AU01"},
  142. {"acctType", acctType},
  143. };
  144. //序列化参数
  145. var jsonParam = JsonConvert.SerializeObject(dic);
  146. var responseString = HttpMethods.HttpPost(Smsurl, jsonParam, "application/json;charset=UTF-8");
  147. JObject jo = (JObject)JsonConvert.DeserializeObject(responseString);
  148. Dictionary<string, string> Dic = new Dictionary<string, string>();
  149. Dic.Add("F_OpenId", dt.Rows[0]["F_OpenId"].ToString());
  150. Dic.Add("F_Name", dt.Rows[0]["F_Name"].ToString());
  151. Dic.Add("F_Telphone", dt.Rows[0]["F_Telphone"].ToString());
  152. new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  153. {
  154. F_LoginName = dt.Rows[0]["F_OpenId"].ToString(),
  155. F_LoginId = Convert.ToInt32(dt.Rows[0]["F_OpenId"].ToString()),
  156. F_Result = "登录成功",
  157. F_LoginIP = Common.DTRequest.GetIP(),
  158. F_Hostname = Common.DTRequest.GetIP(),
  159. F_LoginDate = DateTime.Now,
  160. F_Remark = "",
  161. F_State = 0
  162. });
  163. var token = FormsPrincipal<Dictionary<string, string>>.GetCookieValue(Dic["F_OpenId"], Dic);
  164. return Success("登录成功", new
  165. {
  166. token = token
  167. });
  168. }
  169. else
  170. {
  171. return Error("账号或密码错误,请重新登录");
  172. }
  173. }
  174. else
  175. {
  176. return Error("账号或密码错误,请重新登录");
  177. }
  178. }
  179. catch (Exception ex)
  180. {
  181. return Error("错误:" + ex.Message);
  182. }
  183. finally
  184. {
  185. dt.Clear();
  186. dt.Dispose();
  187. }
  188. }
  189. private BLL.T_Bus_WorkOrder workorderBLL = new BLL.T_Bus_WorkOrder();
  190. private BLL.T_Bus_Operation operBLL = new BLL.T_Bus_Operation();
  191. /// <summary>
  192. /// 登录用户
  193. /// </summary>
  194. /// <param name="input"></param>
  195. /// <returns></returns>
  196. // [HttpPost]
  197. public ActionResult APPSlogin(string loginNo, string loginPassword, string userMobile, string validateCode)
  198. {
  199. string mobileKey = "";
  200. JObject jObject = GetMobileKey(userMobile, validateCode);
  201. if (jObject["C-API-Status"].ToString() == "00")
  202. {
  203. var Body = jObject["C-Response-Body"].ToString();
  204. var txnBodyComresult = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(Body);
  205. mobileKey = txnBodyComresult["mobileKey"] == null ? "" : txnBodyComresult["mobileKey"].ToString();
  206. }
  207. else
  208. {
  209. return Error(jObject["C-Response-Desc"].ToString());
  210. }
  211. if (mobileKey == "")
  212. return Error("mobileKey获取失败");
  213. string url = appurl + "/gsp/uc11002";
  214. var txnBodyCom = new SortedDictionary<string, string>
  215. {
  216. {"userMobile", userMobile},
  217. {"loginNo",loginNo},
  218. {"acctType", "10"},
  219. {"loginType", "AU09"},
  220. {"loginPassword", loginPassword},
  221. {"mobileKey", mobileKey}
  222. };
  223. var txnCommCom = new SortedDictionary<string, string>
  224. {
  225. {"tRecInPage", "10"},
  226. {"txnIttChnlCgyCode", "D001C004"},
  227. {"tStsTraceId", "110567980"},
  228. {"tPageJump", "1"},
  229. {"txnIttChnlId", "99990001000000000000000"},
  230. };
  231. var sms = new Dictionary<string, string>
  232. {
  233. {"txnBodyCom", txnBodyCom.ToJson ()},
  234. {"txnCommCom", txnCommCom.ToJson ()}
  235. };
  236. //序列化参数
  237. var param = new
  238. {
  239. txnBodyCom = txnBodyCom,
  240. txnCommCom = txnCommCom
  241. };
  242. var jsonParam = JsonConvert.SerializeObject(param);
  243. var responseString = HttpMethods.HttpPost(url, jsonParam, "application/json");
  244. JObject jo = (JObject)JsonConvert.DeserializeObject(responseString);
  245. if (jo["C-API-Status"].ToString() == "00")
  246. { //写入登录日志
  247. Model.T_Sys_Users dModel = new Model.T_Sys_Users();
  248. var list = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + loginNo + "' ");
  249. if (list.Count > 0)
  250. {
  251. dModel = list.First();
  252. }
  253. else
  254. {
  255. dModel.F_OpenId = loginNo;
  256. dModel.F_Password = loginPassword;
  257. dModel.F_Name = loginNo;
  258. dModel.F_Telphone = userMobile;
  259. dModel.F_Type = (int)EnumUserType.app;//4;
  260. dModel.F_CreateTime = DateTime.Now;
  261. long n = new BLL.T_Sys_Users().Add(dModel);
  262. dModel.F_Id = n;
  263. }
  264. new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  265. {
  266. F_LoginName = dModel.F_OpenId .ToString(),
  267. F_LoginId = (int )dModel.F_Id,
  268. F_Result = "市民登录成功",
  269. F_LoginIP = Common.DTRequest.GetIP(),
  270. F_Hostname = Common.DTRequest.GetIP(),
  271. F_LoginDate = DateTime.Now,
  272. F_Remark = "",
  273. F_State = 0
  274. });
  275. return Success("登录成功", new
  276. {
  277. usercode = dModel.F_OpenId.ToString(),
  278. userid = dModel.F_Id.ToString ()
  279. });
  280. }
  281. else
  282. {
  283. DataTable dt1 = new CallCenterApi.BLL.T_Sys_Users().GetList("F_OpenId='" + loginNo + "'").Tables[0];
  284. if (dt1.Rows.Count > 0)
  285. {
  286. int rr = new CallCenterApi.BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  287. {
  288. F_LoginName = dt1.Rows[0]["F_OpenId"].ToString(),
  289. F_LoginId = Convert.ToInt32(dt1.Rows[0]["F_Id"].ToString()),
  290. F_Result = "市民登录失败:帐号-" + loginNo,
  291. F_LoginIP = Common.DTRequest.GetIP(),
  292. F_Hostname = Common.DTRequest.GetIP(),
  293. F_LoginDate = DateTime.Now,
  294. F_Remark = "",
  295. F_State = 0
  296. });
  297. }
  298. else
  299. {
  300. int rr = new BLL.T_Sys_LoginLogs().Add(new Model.T_Sys_LoginLogs()
  301. {
  302. F_LoginName = loginNo,
  303. F_LoginId = -1,
  304. F_Result = "市民登录失败:帐号-" + loginNo,
  305. F_LoginIP = Common.DTRequest.GetIP(),
  306. F_Hostname = Common.DTRequest.GetIP(),
  307. F_LoginDate = DateTime.Now,
  308. F_Remark = "",
  309. F_State = 0
  310. });
  311. }
  312. return Error(jObject["C-Response-Desc"].ToString());
  313. }
  314. }
  315. public ActionResult SendCode(string mobile,string workorderid)
  316. {
  317. if (string.IsNullOrEmpty(workorderid))
  318. return Error("请选择工单");
  319. var model = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
  320. if (model == null)
  321. return Error("工单不存在");
  322. if (!string.IsNullOrEmpty(model .F_CusPhone ))
  323. {
  324. if (model.F_CusPhone.Trim().Length > 11)
  325. model.F_CusPhone = model.F_CusPhone.Substring(1, 11);
  326. }
  327. if (string.IsNullOrEmpty(mobile))
  328. {
  329. return Error("请输入将要发送的号码");
  330. }
  331. if (model.F_CusPhone != mobile)
  332. return Error("手机号错误");
  333. int codes = new Random().Next(1000, 9999);
  334. // string msg = codes.ToString ();
  335. // bool n = SMSController.AddSmS(0, msg, "你的验证码是"+ codes+".十分钟有效.", mobile, "168411", "");
  336. string mag = "[\"" + codes.ToString() + "\"]";
  337. string v = SmsNewController.AddSmS(0, "你的验证码是" + codes + ".十分钟有效.", mobile, "681240638956277760", mag,
  338. "");
  339. if (v == "")
  340. {
  341. return Success("发送成功");
  342. }
  343. else
  344. return Error("发送失败");
  345. }
  346. public ActionResult Verification (string phone ,string code)
  347. {
  348. if (string.IsNullOrEmpty(phone))
  349. return Error("请输入手机号码");
  350. string msgcount = "你的验证码是" + code + ".十分钟有效.";
  351. if (string.IsNullOrEmpty(code))
  352. return Error("请输入验证码");
  353. var sms = new BLL.T_SMS_RecvSMS().GetModelList("Content='" + msgcount + "' and CallerNum='" + phone + "'order by RecvTime desc");
  354. if (sms != null && sms.Count > 0)
  355. {
  356. var modelSms = sms.First();
  357. if ((DateTime.Now - modelSms.RecvTime).Minutes > 10)
  358. {
  359. return Error("验证码已失效");
  360. }
  361. else
  362. return Success("验证成功");
  363. }
  364. else
  365. return Error("请输入正确验证码");
  366. }
  367. /// <summary>
  368. /// 添加工单信息
  369. /// </summary>
  370. /// <returns></returns>
  371. //[Authority]
  372. public ActionResult AddWorkOrder()
  373. {
  374. string loginNo = RequestString.GetFormString("loginNo");
  375. int source = RequestString.GetInt("source", 0);//来源
  376. string cusname = RequestString.GetFormString("cusname");//姓名
  377. string cussex = RequestString.GetFormString("cussex");//性别
  378. string cusphone = RequestString.GetFormString("cusphone");//手机号
  379. string cusaddress = RequestString.GetFormString("cusaddress");//地址
  380. string conname = RequestString.GetFormString("conname");//联系人姓名
  381. string conphone = RequestString.GetFormString("conphone");//联系人性别
  382. string title = RequestString.GetFormString("title");//标题
  383. string content = RequestString.GetFormString("content");//内容
  384. string files = RequestString.GetFormString("files");//附件
  385. int sourcearea = RequestString.GetInt("sourcearea", 0);//事发区域
  386. string sourceaddress = RequestString.GetFormString("sourceaddress");//事发地址
  387. string code = RequestString.GetFormString("code");//验证🐎
  388. string keys = RequestString.GetFormString("keys");//反应类别
  389. string splituser = RequestString.GetFormString("splituser");//不需要
  390. int type = RequestString.GetInt("type", 0);//信息类别
  391. int isprotect = RequestString.GetInt("isprotect", 0);//保密方式0否1是
  392. int level = RequestString.GetInt("level", 0);//紧急程度
  393. int business = RequestString.GetInt("business", 0); ;//
  394. int township = RequestString.GetInt("township", 0);//乡镇
  395. int village = RequestString.GetInt("village", 0);//村
  396. if (string.IsNullOrEmpty(cusphone))
  397. return Error("请输入手机号码");
  398. string msgcount = "您的验证码是" + code + ",10分钟内有效。";
  399. if (string.IsNullOrEmpty(code))
  400. return Error("请输入验证码");
  401. var sms = new BLL.T_SMS_RecvSMS().GetModelList("Content='" + msgcount + "' and CallerNum='" + cusphone + "'order by RecvTime desc");
  402. if (sms != null && sms.Count > 0)
  403. {
  404. var modelSms = sms.First();
  405. if ((DateTime.Now - modelSms.RecvTime).Minutes > 10)
  406. {
  407. return Error("验证码已失效");
  408. }
  409. }
  410. else
  411. return Error("请输入正确验证码");
  412. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new Model.T_Bus_WorkOrder();
  413. using (TransactionScope trans = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 10, 0)))
  414. {
  415. #region 保存工单信息
  416. string creattime = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
  417. string endtime = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";
  418. modelT_Bus_WorkOrder.F_WorkOrderId = workorderBLL.GetNewWorkOrderID(source, sourcearea, creattime, endtime);
  419. modelT_Bus_WorkOrder.F_InfoSource = source;//信息来源
  420. modelT_Bus_WorkOrder.F_InfoType = type;//信息类别
  421. modelT_Bus_WorkOrder.F_SourceArea = sourcearea;//反映地域
  422. modelT_Bus_WorkOrder.F_SourceAddress = sourceaddress;//事发地址
  423. modelT_Bus_WorkOrder.F_CusName = cusname;//投诉人姓名
  424. modelT_Bus_WorkOrder.F_CusSex = cussex;//性别
  425. modelT_Bus_WorkOrder.F_CusPhone = cusphone;//来电号码
  426. modelT_Bus_WorkOrder.F_CusAddress = cusaddress;//地址
  427. modelT_Bus_WorkOrder.F_ConName = conname;//联系人姓名
  428. modelT_Bus_WorkOrder.F_ConPhone = conphone;//联系人电话
  429. modelT_Bus_WorkOrder.F_ComTitle = title;//标题
  430. modelT_Bus_WorkOrder.F_ComContent = content;//情况摘要(投诉内容)
  431. modelT_Bus_WorkOrder.F_File = files;//附件
  432. modelT_Bus_WorkOrder.F_IsProtect = isprotect;//保密方式0否1是
  433. modelT_Bus_WorkOrder.F_Key = keys;
  434. modelT_Bus_WorkOrder.F_SplitUser = splituser;
  435. modelT_Bus_WorkOrder.F_Level = level;
  436. modelT_Bus_WorkOrder.F_Township = township;
  437. modelT_Bus_WorkOrder.F_Village = village;
  438. Task.Run(() =>
  439. {
  440. saveCus(cusname, cusphone, cusaddress);
  441. });
  442. modelT_Bus_WorkOrder.F_Latitude = 0;//纬度
  443. modelT_Bus_WorkOrder.F_Longitude = 0;//经度
  444. modelT_Bus_WorkOrder.F_IsResult = 0;
  445. modelT_Bus_WorkOrder.F_CreateUser = loginNo;//登记人工号
  446. modelT_Bus_WorkOrder.F_CreateTime = DateTime.Now;//登记时间
  447. modelT_Bus_WorkOrder.F_WorkState = (int)EnumWorkState.neworder;// 0;//工单状态0登记中
  448. modelT_Bus_WorkOrder.F_IsClosed = 0;//工单是否关闭
  449. modelT_Bus_WorkOrder.F_IsOverdue = 0;//是否逾期(0:否,1:是)
  450. modelT_Bus_WorkOrder.F_IsDelete = 0;//是否删除(0:否,1:是)
  451. modelT_Bus_WorkOrder.F_ToBereply = 0;
  452. //如果选择即刻答复:是,即为直办,工单结束
  453. #region
  454. #endregion
  455. modelT_Bus_WorkOrder.F_Id = workorderBLL.Add(modelT_Bus_WorkOrder);
  456. #endregion
  457. trans.Complete();
  458. }
  459. if (modelT_Bus_WorkOrder.F_Id <= 0)
  460. return Error("添加失败");
  461. else
  462. {
  463. string userinfo = User.depname + "(" + User.F_UserCode + ")";
  464. string message = "";
  465. message = userinfo + " 登记了工单,工单编号:" + modelT_Bus_WorkOrder.F_WorkOrderId;
  466. Task.Run(() =>
  467. {
  468. #region 插入操作记录
  469. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  470. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  471. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  472. oper.F_CallRecordId = modelT_Bus_WorkOrder.F_CallRecordId;
  473. oper.F_File = modelT_Bus_WorkOrder.F_File;
  474. oper.F_Message = message;
  475. oper.F_CreateUser = loginNo;
  476. oper.F_CreateTime = DateTime.Now;
  477. oper.F_IsDelete = 0;
  478. operBLL.Add(oper);
  479. string count = "您反映的事项已受理并转交相关部门处理,感谢您拨打市长热线!";
  480. // string msg = "";
  481. // bool n = SMSController.AddSmS(0, msg, count, modelT_Bus_WorkOrder.F_CusPhone, "197387", "", modelT_Bus_WorkOrder.F_WorkOrderId);
  482. string phone = modelT_Bus_WorkOrder.F_CusPhone;
  483. if (phone.Length > 11)
  484. phone = phone.Substring(1, 11);
  485. string n = SmsNewController.AddSmS(0, count, phone, "681240256766803968", "", modelT_Bus_WorkOrder.F_WorkOrderId);
  486. #endregion
  487. }).ContinueWith(p => {
  488. System.Diagnostics.Debug.WriteLine(DateTime.Now);
  489. });
  490. Task.Run(() =>
  491. {
  492. #region 插入推送消息
  493. //推送消息表
  494. if (modelT_Bus_WorkOrder.F_WorkState != (int)EnumWorkState.neworder && modelT_Bus_WorkOrder.F_WorkState != (int)EnumWorkState.audit)
  495. {
  496. var role = new BLL.T_Sys_RoleInfo().GetModelList(" (F_RoleCode='ZXLD' or F_RoleCode='ZXLDGLYGLY' or F_RoleCode='MTDD') ").Select(p => p.F_RoleId);
  497. var users = userBLL.GetModelList(" F_RoleId in (" + string.Join(",", role) + ") ");
  498. }
  499. #endregion
  500. }).ContinueWith(p => {
  501. System.Diagnostics.Debug.WriteLine(DateTime.Now);
  502. });
  503. Task.Run(() =>
  504. {
  505. case_info(modelT_Bus_WorkOrder.F_WorkOrderId, "case_info");
  506. if (!string .IsNullOrEmpty (files))
  507. {
  508. material_info(modelT_Bus_WorkOrder.F_WorkOrderId, files, modelT_Bus_WorkOrder.F_Id, "10");
  509. }
  510. }).ContinueWith(p => {
  511. System.Diagnostics.Debug.WriteLine(DateTime.Now);
  512. });
  513. }
  514. return Success("操作成功");
  515. }
  516. /// <summary>
  517. /// 注册用户
  518. /// </summary>
  519. /// <param name="input"></param>
  520. /// <returns></returns>
  521. // [HttpPost]
  522. public ActionResult AddUser(string loginNo,string loginPassword,string userMobile,string validateCode)
  523. {
  524. Model.T_Sys_Users dModel = new Model.T_Sys_Users();
  525. var list = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + loginNo + "' ");
  526. if (list.Count > 0)
  527. {
  528. return Error("已经存在此账号");
  529. }
  530. else
  531. {
  532. string isFirstLogin = "";
  533. string mobileKey = "";
  534. JObject jObject = GetMobileKey(userMobile, validateCode);
  535. if (jObject["C-API-Status"].ToString() == "00")
  536. {
  537. var Body = jObject["C-Response-Body"].ToString ();
  538. var txnBodyComresult = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(Body);
  539. mobileKey = txnBodyComresult["mobileKey"] == null ? "" : txnBodyComresult["mobileKey"].ToString();
  540. isFirstLogin = txnBodyComresult["isFirstLogin"] == null ? "" : txnBodyComresult["isFirstLogin"].ToString();
  541. }
  542. else
  543. {
  544. return Error(jObject["C-Response-Desc"].ToString());
  545. }
  546. if (mobileKey=="")
  547. return Error("mobileKey获取失败");
  548. if (isFirstLogin == ""|| isFirstLogin=="0")
  549. return Error("该手机号码已注册");
  550. string url = appurl + "/gsp/uc10041";
  551. var txnBodyCom = new SortedDictionary<string, string>
  552. {
  553. {"userMobile", userMobile},//用户手机号
  554. {"loginNo",loginNo},//33 自然人注册&登录
  555. {"loginPassword", loginPassword},
  556. {"mobileKey", mobileKey}
  557. };
  558. var txnCommCom = new SortedDictionary<string, string>
  559. {
  560. {"tRecInPage", "10"},
  561. {"txnIttChnlCgyCode", "D001C004"},
  562. {"tStsTraceId", "110567980"},
  563. {"tPageJump", "1"},
  564. {"txnIttChnlId", "99990001000000000000000"},
  565. };
  566. var sms = new Dictionary<string, string>
  567. {
  568. {"txnBodyCom", txnBodyCom.ToJson ()},
  569. {"txnCommCom", txnCommCom.ToJson ()}
  570. };
  571. //序列化参数
  572. var param = new
  573. {
  574. txnBodyCom = txnBodyCom,
  575. txnCommCom = txnCommCom
  576. };
  577. var jsonParam = JsonConvert.SerializeObject(param);
  578. var responseString = HttpMethods.HttpPost(url , jsonParam, "application/json");
  579. JObject jo = (JObject)JsonConvert.DeserializeObject(responseString);
  580. if (jo["C-API-Status"].ToString() == "00")
  581. {
  582. dModel.F_OpenId = loginNo;
  583. dModel.F_Password = loginPassword;
  584. dModel.F_Name = loginNo;
  585. dModel.F_Telphone = userMobile;
  586. dModel.F_Type = (int)EnumUserType.app;//4;
  587. dModel.F_CreateTime = DateTime.Now;
  588. long n = new BLL.T_Sys_Users().Add(dModel);
  589. if (n > 0)
  590. return Success("添加成功");
  591. else
  592. return Error("添加失败");
  593. }
  594. else
  595. {
  596. return Error(jObject["C-Response-Desc"].ToString());
  597. }
  598. }
  599. }
  600. private string appurl = Configs.GetValue("AppUrl");
  601. public JObject GetMobileKey(string userMobile,string validateCode)
  602. {
  603. string Smsurl = appurl + "/gsp/uc00006";
  604. var txnBodyCom = new SortedDictionary<string, string>
  605. {
  606. {"userMobile", userMobile},//用户手机号
  607. {"validateCodeType", "33"},//33 自然人注册&登录
  608. {"validateCode", validateCode}
  609. };
  610. var txnCommCom = new SortedDictionary<string, string>
  611. {
  612. {"tRecInPage", "10"},
  613. {"txnIttChnlCgyCode", "D001C004"},
  614. {"tStsTraceId", "110567980"},
  615. {"tPageJump", "1"},
  616. {"txnIttChnlId", "99990001000000000000000"},
  617. };
  618. var sms = new Dictionary<string, string>
  619. {
  620. {"txnBodyCom", txnBodyCom.ToJson ()},
  621. {"txnCommCom", txnCommCom.ToJson ()}
  622. };
  623. //序列化参数
  624. var param = new
  625. {
  626. txnBodyCom = txnBodyCom,
  627. txnCommCom = txnCommCom
  628. };
  629. var jsonParam = JsonConvert.SerializeObject(param);
  630. var responseString = HttpMethods.HttpPost(Smsurl, jsonParam, "application/json");
  631. JObject jo = (JObject)JsonConvert.DeserializeObject(responseString);
  632. return jo;
  633. }
  634. /// <summary>
  635. /// 发送短信
  636. /// </summary>
  637. /// <param name="input"></param>
  638. /// <returns></returns>
  639. public ActionResult SendSms(string userMobile,string vcodeId,string vcode)
  640. {
  641. string Smsurl = appurl+ "/gsp/uc00001";
  642. var txnBodyCom = new SortedDictionary<string, string >
  643. {
  644. {"userMobile", userMobile},//用户手机号
  645. {"validateCodeType", "33"},
  646. {"vcodeId", vcodeId},
  647. {"vcode", vcode}
  648. };
  649. var txnCommCom = new SortedDictionary<string, string>
  650. {
  651. {"tRecInPage", "10"},
  652. {"txnIttChnlCgyCode", "D001C004"},
  653. {"tStsTraceId", "110567980"},
  654. {"tPageJump", "1"},
  655. {"txnIttChnlId", "99990001000000000000000"},
  656. };
  657. var sms = new Dictionary<string, string >
  658. {
  659. {"txnBodyCom", txnBodyCom.ToJson ()},
  660. {"txnCommCom", txnCommCom.ToJson ()}
  661. };
  662. //序列化参数
  663. var param = new {
  664. txnBodyCom= txnBodyCom,
  665. txnCommCom= txnCommCom
  666. } ;
  667. var jsonParam = JsonConvert.SerializeObject(param);
  668. var responseString = HttpMethods.HttpPost(Smsurl, jsonParam, "application/json");
  669. JObject jo = (JObject)JsonConvert.DeserializeObject(responseString);
  670. if (jo["C-API-Status"].ToString() == "00")
  671. return Success("发送成功", jo["C-Response-Desc"].ToString ());
  672. else
  673. return Error(jo["C-Response-Desc"].ToString());
  674. }
  675. /// <summary>
  676. /// 编辑用户
  677. /// </summary>
  678. /// <param name="input"></param>
  679. /// <returns></returns>
  680. [APPActionFilter]
  681. [HttpPost]
  682. public ActionResult UpdateUser()
  683. {
  684. int id = RequestString.GetInt("id", 0);
  685. string usercode = RequestString.GetFormString("usercode");
  686. string password = RequestString.GetFormString("password");
  687. string name = RequestString.GetFormString("name");
  688. string phone = RequestString.GetFormString("phone");
  689. int sex = RequestString.GetInt("sex", 0);
  690. string province = RequestString.GetFormString("province");
  691. string city = RequestString.GetFormString("city");
  692. string county = RequestString.GetFormString("county");
  693. string address = RequestString.GetFormString("address");
  694. Model.T_Sys_Users dModel = new Model.T_Sys_Users();
  695. if (id == 0)
  696. {
  697. dModel = new BLL.T_Sys_Users().GetModel(id);
  698. if (dModel != null)
  699. {
  700. var list = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + usercode + "' and F_Id!='" + id + "' ");
  701. if (list.Count > 0)
  702. {
  703. return Error("已经存在此账号");
  704. }
  705. else
  706. {
  707. dModel.F_OpenId = usercode;
  708. dModel.F_Name = name;
  709. dModel.F_Telphone = phone;
  710. dModel.F_Sex = sex;
  711. dModel.F_Province = province;
  712. dModel.F_City = city;
  713. dModel.F_County = county;
  714. dModel.F_Address = address;
  715. if (new BLL.T_Sys_Users().Update(dModel))
  716. return Success("修改成功");
  717. else
  718. return Error("修改失败");
  719. }
  720. }
  721. else
  722. {
  723. return Error("修改失败");
  724. }
  725. }
  726. else
  727. {
  728. return Error("修改失败");
  729. }
  730. }
  731. /// <summary>
  732. /// 修改密码
  733. /// </summary>
  734. /// <returns></returns>
  735. [APPActionFilter]
  736. [HttpPost]
  737. public ActionResult UpdatePassword()
  738. {
  739. string usercode = RequestString.GetFormString("usercode");
  740. string old = RequestString.GetFormString("old");
  741. string new1 = RequestString.GetFormString("new1");
  742. string new2 = RequestString.GetFormString("new2");
  743. if (string.IsNullOrEmpty(old) || string.IsNullOrEmpty(new1) || string.IsNullOrEmpty(new2))
  744. {
  745. return Error("请输入新旧密码");
  746. }
  747. if (new1 != new2)
  748. {
  749. return Error("两次输入的不一致");
  750. }
  751. var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
  752. if (old == userinfo.F_Password)
  753. {
  754. userinfo.F_Password = new1;
  755. new BLL.T_Sys_Users().Update(userinfo);
  756. return Success("修改成功");
  757. }
  758. else
  759. {
  760. return Error("原密码错误");
  761. }
  762. }
  763. /// <summary>
  764. /// 获取工单列表
  765. /// </summary>
  766. /// <returns></returns>
  767. [APPActionFilter]
  768. public ActionResult GetWorkOrderList(int isdc = 0)
  769. {
  770. //string sql = " and F_IsDelete=0 ";
  771. string sql = " and (F_IsEnabled=0 or F_IsDelete=0) ";
  772. // var ouid = DbHelperSQL.GetSingle(" select F_ID from T_Sys_Users where F_OpenId ='" + strusercode + "'");
  773. // string sqlwhere = "select F_WorkOrderID FROM T_Bus_UserWorkOrder where F_UserId = '" + ouid.ToString() + "' ";
  774. // sql += " and F_WorkOrderID in (" + sqlwhere + ")";
  775. DataTable dt = new DataTable();
  776. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  777. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  778. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  779. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  780. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  781. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  782. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  783. int source = RequestString.GetInt("source", 0);
  784. int keyid = RequestString.GetInt("keyid", 0);
  785. int type = RequestString.GetInt("type", 0);
  786. int bigtype = RequestString.GetInt("bigtype", 0);
  787. int smalltype = RequestString.GetInt("smalltype", 0);
  788. int sourcearea = RequestString.GetInt("sourcearea", 0);
  789. int deptid = RequestString.GetInt("deptid", 0);
  790. int dealtype = RequestString.GetInt("dealtype", -1);
  791. int issend = RequestString.GetInt("issend", -1);
  792. int isdeal = RequestString.GetInt("isdeal", -1);
  793. string strpageindex = RequestString.GetQueryString("page");
  794. int pageindex = 1;
  795. string strpagesize = RequestString.GetQueryString("pagesize");
  796. int pagesize = 10;
  797. #region sql 语句相关处理
  798. if (strstate.Trim() != "" && strstate != "undefined")
  799. {
  800. sql += " and F_WorkState = '" + strstate.Trim() + "' ";
  801. }
  802. if (strworkid.Trim() != "" && strworkid != "undefined")
  803. {
  804. sql += " and F_WorkOrderId like '%" + strworkid + "%' ";
  805. }
  806. if (strname.Trim() != "" && strname != "undefined")
  807. {
  808. sql += " and F_CusName like '%" + strname + "%' ";
  809. }
  810. if (strtel.Trim() != "" && strtel != "undefined")
  811. {
  812. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  813. }
  814. if (strkey.Trim() != "" && strkey != "undefined")
  815. {
  816. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%') ";
  817. }
  818. if (source != 0)
  819. {
  820. sql += " and F_InfoSource = '" + source + "' ";
  821. }
  822. if (keyid != 0)
  823. {
  824. sql += " and ','+F_Key+',' like '%," + keyid + ",%' ";
  825. }
  826. if (type != 0)
  827. {
  828. sql += " and F_InfoType = '" + type + "' ";
  829. }
  830. if (bigtype != 0)
  831. {
  832. sql += " and F_InfoConBigType = '" + bigtype + "' ";
  833. }
  834. if (smalltype != 0)
  835. {
  836. sql += " and F_InfoConSmallType = '" + smalltype + "' ";
  837. }
  838. if (sourcearea != 0)
  839. {
  840. sql += " and F_SourceArea = '" + sourcearea + "' ";
  841. }
  842. if (deptid != 0)
  843. {
  844. 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 ";
  845. sql += " and F_WorkOrderID in(" + sqlwhere1 + ")";
  846. }
  847. if (dealtype != -1)
  848. {
  849. sql += " and isnull(F_IsResult,0) = '" + dealtype + "' ";
  850. }
  851. if (issend != -1)
  852. {
  853. sql += " and isnull(F_IsRelease,0) = '" + issend + "' ";
  854. }
  855. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  856. {
  857. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  858. }
  859. if (strendtime.Trim() != "" && strendtime != "undefined")
  860. {
  861. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  862. }
  863. if (isdeal != -1)
  864. {
  865. if (isdeal == 1)
  866. {
  867. sql += " and F_WorkState = '9' ";
  868. }
  869. else
  870. {
  871. sql += " and F_WorkState != '9' ";
  872. }
  873. }
  874. #endregion
  875. if (strpageindex.Trim() != "")
  876. {
  877. pageindex = Convert.ToInt32(strpageindex);
  878. }
  879. if (strpagesize.Trim() != "")
  880. {
  881. pagesize = Convert.ToInt32(strpagesize);
  882. }
  883. string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  884. if (isdc > 0)
  885. {
  886. var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Bus_WorkOrder where 1=1 " + sql).Tables[0];
  887. var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
  888. if (msg == "")
  889. {
  890. return Success("导出成功");
  891. }
  892. else
  893. {
  894. return Error("导出失败");
  895. }
  896. }
  897. int recordCount = 0;
  898. dt = BLL.PagerBLL.GetListPager(
  899. "T_Bus_WorkOrder",
  900. "F_WorkOrderId",
  901. cols,
  902. sql,
  903. "ORDER BY F_CreateTime DESC",
  904. pagesize,
  905. pageindex,
  906. true,
  907. out recordCount);
  908. var obj = new
  909. {
  910. state = "success",
  911. message = "成功",
  912. rows = dt,
  913. total = recordCount
  914. };
  915. return Content(obj.ToJson());
  916. }
  917. //市民评议
  918. public ActionResult Comment(string workorderid,string Satisfaction,string content)
  919. {
  920. var model = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
  921. if (model != null)
  922. {
  923. string strStm_Src_Dsc = "";
  924. var DictionaryValue = new BLL.T_Sys_DictionaryValue().GetModel((int)model.F_InfoSource);
  925. if (DictionaryValue != null)
  926. {
  927. strStm_Src_Dsc = DictionaryValue.F_Value;
  928. }
  929. 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])
  930. values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}') ;select @@IDENTITY ", model.F_WorkOrderId, strStm_Src_Dsc, Satisfaction, "", content, "", "", "", DateTime.Now, 3);
  931. object objres = DbHelperSQL.GetSingle(strSql);
  932. if (Satisfaction == "非常满意" || Satisfaction == "满意" || Satisfaction == "基本满意")
  933. {
  934. if (model != null)
  935. {
  936. Dictionary<string, object> keyValuePairs = new Dictionary<string, object>();
  937. keyValuePairs.Add("F_WorkState", 9);
  938. keyValuePairs.Add("F_IsSatisfie", 1);
  939. keyValuePairs.Add("F_IsClosed", 1);
  940. keyValuePairs.Add("F_CloseUser", "");
  941. keyValuePairs.Add("F_CloseTime", DateTime.Now);
  942. keyValuePairs.Add("F_FinalOpinion", "市民评议满意自动结案");
  943. keyValuePairs.Add("F_IsStandard", 1);
  944. keyValuePairs.Add("F_StandardIDS", "");
  945. keyValuePairs.Add("F_ToBereply", 0);
  946. new BLL.T_Bus_WorkOrder().UpdateWorkOrder(model.F_Id, keyValuePairs);
  947. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  948. oper.F_WorkOrderId = model.F_WorkOrderId;
  949. // oper.F_AssignedId = modelT_Bus_AssignedInfo.F_Id;
  950. oper.F_State = model.F_WorkState;
  951. oper.F_Message = "市民网站评议满意,自动结案";
  952. oper.F_CreateUser = "jianhang";
  953. oper.F_CreateTime = DateTime.Now;
  954. oper.F_IsDelete = 0;
  955. operBLL.Add(oper);
  956. }
  957. }
  958. return Success("评议成功");
  959. }
  960. else
  961. {
  962. return Error("工单不存在");
  963. }
  964. }
  965. /// <summary>
  966. /// 获取工单列表
  967. /// </summary>
  968. /// <returns></returns>
  969. public ActionResult GetList(int isdc = 0)
  970. {
  971. DataTable dt = new DataTable();
  972. string sql = " and F_IsDelete=0 ";
  973. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  974. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  975. string state = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  976. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  977. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  978. int ispy = RequestString.GetInt("ispy", -1);
  979. string strpageindex = RequestString.GetQueryString("page");
  980. int pageindex = 1;
  981. string strpagesize = RequestString.GetQueryString("pagesize");
  982. int pagesize = 10;
  983. #region sql 语句相关处理
  984. if (strtel.Trim() != "" && strtel != "undefined")
  985. {
  986. sql += " and (F_CusPhone like '%" + strtel + "%' or F_ConPhone like '%" + strtel + "%') ";
  987. }
  988. if (strkey.Trim() != "" && strkey != "undefined")
  989. {
  990. sql += " and (F_ComTitle like '%" + strkey + "%' or F_ComContent like '%" + strkey + "%'" +
  991. " or F_Result like '%" + strkey + "%' ) ";
  992. }
  993. if (state.Trim() != "" && state != "undefined")
  994. {
  995. if (state == "1")
  996. {
  997. sql += " and F_WorkState in (" + (int)EnumWorkState.neworder + "," + (int)EnumWorkState.submit + "," + (int)EnumWorkState.receive + (int)EnumWorkState.resubmit + ") ";
  998. }
  999. else if (state == "2")
  1000. {
  1001. sql += " and F_WorkState in (" + (int)EnumWorkState.auditreback + "," + (int)EnumWorkState.dealing + "," + (int)EnumWorkState.auditdelay + (int)EnumWorkState.reload + (int)EnumWorkState.audit + (int)EnumWorkState.rejload + ") ";
  1002. }
  1003. else if (state == "3")
  1004. {
  1005. sql += " and F_WorkState in (" + (int)EnumWorkState.visit + "," + (int)EnumWorkState.finish + "," + (int)EnumWorkState.dealed + ") ";
  1006. }
  1007. else if (state == "4")
  1008. {
  1009. sql += " and F_WorkState not in ( 6,7,9 ) ";
  1010. }
  1011. }
  1012. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  1013. {
  1014. if (strendtime.Trim() != "" && strendtime != "undefined")
  1015. {
  1016. sql += " and F_CreateTime between '" + strstarttime +
  1017. "' AND '" + strendtime + "'";
  1018. }
  1019. else
  1020. {
  1021. sql += " and F_CreateTime>='" + strstarttime + "' ";
  1022. }
  1023. }
  1024. else
  1025. {
  1026. if (strendtime.Trim() != "" && strendtime != "undefined")
  1027. {
  1028. sql += " and F_CreateTime<='" + strendtime + "' ";
  1029. }
  1030. }
  1031. if (ispy >-1)
  1032. {
  1033. if (ispy ==0)
  1034. {
  1035. sql += "and F_WorkOrderId not in (select WorkOrderId from PublicComment WITH(NOLOCK)) ";
  1036. }
  1037. else
  1038. {
  1039. sql += "and F_WorkOrderId in (select WorkOrderId from PublicComment WITH(NOLOCK) )";
  1040. }
  1041. }
  1042. #endregion
  1043. if (strpageindex.Trim() != "")
  1044. {
  1045. pageindex = Convert.ToInt32(strpageindex);
  1046. }
  1047. if (strpagesize.Trim() != "")
  1048. {
  1049. pagesize = Convert.ToInt32(strpagesize);
  1050. }
  1051. string cols = "*,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName";
  1052. #region 导出
  1053. #endregion
  1054. int recordCount = 0;
  1055. dt = BLL.PagerBLL.GetListPager(
  1056. "T_Bus_WorkOrder a WITH(NOLOCK)" ,
  1057. "F_Id",
  1058. cols,
  1059. sql,
  1060. "ORDER BY F_CreateTime DESC",
  1061. pagesize,
  1062. pageindex,
  1063. true,
  1064. out recordCount);
  1065. #region 声音文件和交办超时
  1066. foreach (DataRow dr in dt.Rows)
  1067. {
  1068. }
  1069. #endregion
  1070. var obj = new
  1071. {
  1072. state = "success",
  1073. message = "成功",
  1074. rows = dt,
  1075. total = recordCount
  1076. };
  1077. return Content(obj.ToJson());
  1078. }
  1079. private BLL.T_Sys_SystemConfig configBll = new BLL.T_Sys_SystemConfig();
  1080. public ActionResult GetWorkOrderNew()
  1081. {
  1082. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  1083. if (!string.IsNullOrEmpty(strworkorderid))
  1084. {
  1085. var configfj = configBll.GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  1086. #region 基本信息
  1087. 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 + "'";
  1088. var dt = DbHelperSQL.Query(sql).Tables[0];
  1089. if (dt.Rows.Count > 0)
  1090. {
  1091. #region 附件
  1092. if (configfj != null)
  1093. {
  1094. dt = BindFileData(dt, configfj.F_ParamValue);
  1095. }
  1096. string pysql = "select * from PublicComment WITH(NOLOCK) where WorkOrderId ='" + strworkorderid + "' order by CreateTime";
  1097. var pydt = DbHelperSQL.Query(pysql).Tables[0];
  1098. #endregion
  1099. var obj = new
  1100. {
  1101. data = dt,
  1102. pydt
  1103. };
  1104. return Success("获取成功", obj);
  1105. }
  1106. else
  1107. {
  1108. return Error("获取失败");
  1109. }
  1110. #endregion
  1111. }
  1112. return Error("获取失败");
  1113. }
  1114. private BLL.T_Bus_RemindRecord remindBLL = new BLL.T_Bus_RemindRecord();
  1115. /// <summary>
  1116. /// 获取工单信息
  1117. /// </summary>
  1118. /// <returns></returns>
  1119. //[Authority]
  1120. public ActionResult GetWorkOrderAPP()
  1121. {
  1122. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  1123. int type = RequestString.GetInt("type", 0);//0基本信息1监察意见2领导批示3办理情况4回访信息5督办信息6办理过程
  1124. if (!string.IsNullOrEmpty(strworkorderid))
  1125. {
  1126. var configly = configBll.GetModelList(" F_ParamCode='PlayLeaveVoice' ").FirstOrDefault();
  1127. var config = configBll.GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
  1128. var configfj = configBll.GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  1129. switch (type)
  1130. {
  1131. case 0:
  1132. #region 基本信息
  1133. 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 + "'";
  1134. var dt = DbHelperSQL.Query(sql).Tables[0];
  1135. if (dt.Rows.Count > 0)
  1136. {
  1137. if (User.F_RoleCode == "WLDW" && dt.Rows[0]["F_MainDeptId"].ToString() != User.F_DeptId.ToString())
  1138. {
  1139. dt.Rows[0]["F_Result"] = "";
  1140. }
  1141. if (dt.Rows[0]["F_IsProtect"] != null && (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW"))
  1142. {
  1143. string isp = dt.Rows[0]["F_IsProtect"].ToString();
  1144. if (isp == "1")
  1145. {
  1146. dt.Rows[0]["F_CusPhone"] = "";
  1147. dt.Rows[0]["F_ConPhone"] = "";
  1148. }
  1149. }
  1150. #region 声音文件
  1151. dt.Columns.Add("FilePath", typeof(string));
  1152. if (dt.Rows[0]["F_LeaveRecordId"] != null)
  1153. {
  1154. dt.Rows[0]["FilePath"] = GetLeavePath(dt.Rows[0]["F_LeaveRecordId"].ToString(), configly.F_ParamValue);
  1155. }
  1156. else if (dt.Rows[0]["F_CallRecordId"] != null)
  1157. {
  1158. dt.Rows[0]["FilePath"] = GetCallPath(dt.Rows[0]["F_CallRecordId"].ToString(), config.F_ParamValue);
  1159. }
  1160. #endregion
  1161. #region 附件
  1162. if (configfj != null)
  1163. {
  1164. dt = BindFileData(dt, configfj.F_ParamValue);
  1165. }
  1166. #endregion
  1167. #region 操作按钮
  1168. var btns = new List<ButtonGroup.button>();
  1169. string jbsql1 = "select top 1 * from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1170. var jbdt1 = DbHelperSQL.Query(jbsql1).Tables[0];
  1171. if (jbdt1.Rows.Count > 0)
  1172. {
  1173. var jbzx = jbdt1.Rows[0];
  1174. string ispd = jbzx["F_IsNext"].ToString();
  1175. string iszbdw = "0";
  1176. string fmd = jbzx["F_MainDeptId"].ToString();
  1177. string fod = jbzx["F_OtherDeptIds"] == null ? "" : jbzx["F_OtherDeptIds"].ToString();
  1178. if (fmd == User.F_DeptId.ToString())
  1179. { iszbdw = "1"; }
  1180. else if (fod != "" && fod.Split(',').Contains(User.F_DeptId.ToString()))
  1181. {
  1182. iszbdw = "2";
  1183. }
  1184. if (!(User.F_RoleCode == "WLDW" && iszbdw == "0"))
  1185. {
  1186. btns = ButtonGroup.GetButtons(dt.Rows[0]["F_WorkState"].ToString(), User.F_RoleCode.ToUpper(), dt.Rows[0]["F_IsResult"].ToString(), iszbdw, ispd);
  1187. }
  1188. }
  1189. else
  1190. {
  1191. btns = ButtonGroup.GetButtons(dt.Rows[0]["F_WorkState"].ToString(), User.F_RoleCode.ToUpper(), dt.Rows[0]["F_IsResult"].ToString(), "0");
  1192. }
  1193. #region 判断是否存在待督办
  1194. var recount = remindBLL.GetModelList("F_State=0 and F_IsDelete=0 and F_Type=1 and F_WorkOrderId ='" + strworkorderid + "'").ToList().Count();
  1195. var butt = btns.Find(c => c.key == ButtonGroup.turnsee().key);
  1196. if (recount > 0)
  1197. {
  1198. if (butt != null)
  1199. btns.Remove(butt);
  1200. if (User.F_RoleCode == "DBZY" || User.F_RoleCode == "GLY" || User.F_RoleCode == "SPZ"
  1201. || User.F_RoleCode == "SPZJZ" || User.F_RoleCode == "DDZG")
  1202. {
  1203. btns.Add(ButtonGroup.oversee());
  1204. btns.Add(ButtonGroup.turnnosee());
  1205. }
  1206. }
  1207. if (btns == null)
  1208. {
  1209. btns.Add(ButtonGroup.query());
  1210. }
  1211. else
  1212. {
  1213. if (btns.Count == 0)
  1214. btns.Add(ButtonGroup.query());
  1215. }
  1216. #endregion
  1217. #endregion
  1218. #region 其他权限
  1219. int issend = 0;
  1220. int isnotice = 0;
  1221. if (dt.Rows[0]["F_IsNotice"] != null && (User.F_RoleCode == "ZXLD" || User.F_RoleCode == "ZXLDGLYGLY" || User.F_RoleCode == "ZXLDGLY" || User.F_RoleCode == "GLY" || User.F_RoleCode == "DDZG"))
  1222. {
  1223. if (dt.Rows[0]["F_IsNotice"].ToString() != "1")
  1224. {
  1225. isnotice = 1;
  1226. }
  1227. }
  1228. int isedit = 0;
  1229. #endregion
  1230. var obj = new
  1231. {
  1232. data = dt,
  1233. issend,
  1234. isedit,
  1235. isnotice,
  1236. btndata = btns
  1237. };
  1238. return Success("获取成功", obj);
  1239. }
  1240. else
  1241. {
  1242. return Error("获取失败");
  1243. }
  1244. #endregion
  1245. case 1:
  1246. #region 交办信息
  1247. string jbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_MainDeptId) as DeptName,dbo.GetDeptNames(F_OtherDeptIds) as OtherDeptName,dbo.GetDictionaryNames(F_StandardIDS) as StandardNames from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1248. string ejjbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_MainDeptId) as DeptName,dbo.GetDeptNames(F_OtherDeptIds) as OtherDeptName from T_Bus_AssignedInfo_Next WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1249. string thsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_CreateDeptId) as DeptName from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_Type=3 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1250. var jbdt = DbHelperSQL.Query(jbsql).Tables[0];
  1251. if (configfj != null)
  1252. {
  1253. jbdt = BindFileData(jbdt, configfj.F_ParamValue);
  1254. }
  1255. var ejjbdt = DbHelperSQL.Query(ejjbsql).Tables[0];
  1256. if (configfj != null)
  1257. {
  1258. ejjbdt = BindFileData(ejjbdt, configfj.F_ParamValue);
  1259. }
  1260. var thdt = DbHelperSQL.Query(thsql).Tables[0];
  1261. if (!string.IsNullOrEmpty(configfj.F_ParamValue))
  1262. {
  1263. BindFileData(thdt, configfj.F_ParamValue);
  1264. }
  1265. var obj1 = new
  1266. {
  1267. jbdata = jbdt,
  1268. ejjbdata = ejjbdt,
  1269. thdata = thdt
  1270. };
  1271. return Success("获取成功", obj1);
  1272. #endregion
  1273. case 2:
  1274. #region 指示信息
  1275. string zssql = "select *,dbo.GetUserName(F_CreateUser) as UserName from T_Bus_SubmitSuper WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type=2 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1276. var zsdt = DbHelperSQL.Query(zssql).Tables[0];
  1277. if (configfj != null)
  1278. {
  1279. zsdt = BindFileData(zsdt, configfj.F_ParamValue);
  1280. }
  1281. return Success("获取成功", zsdt);
  1282. #endregion
  1283. case 3:
  1284. #region 回退信息
  1285. string htsql = "select *,dbo.GetUserName(F_CreateUser) as UserName from T_Bus_SubmitSuper WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type=3 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1286. var htdt = DbHelperSQL.Query(htsql).Tables[0];
  1287. return Success("获取成功", htdt);
  1288. #endregion
  1289. case 4:
  1290. #region 办理情况
  1291. string blsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_CreateDeptId) as DeptName from T_Bus_Feedback WITH(NOLOCK) where F_State=1 and F_Type!=3 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1292. string ejblsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_CreateDeptId) as DeptName from T_Bus_Feedback_Next WITH(NOLOCK) where F_State=1 and F_Type!=3 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1293. var bldt = DbHelperSQL.Query(blsql).Tables[0];
  1294. if (bldt != null && bldt.Rows.Count > 0)
  1295. {
  1296. if (User.F_RoleCode == "WLDW" && bldt.Rows[0]["F_CreateDeptId"].ToString() != User.F_DeptId.ToString())
  1297. {
  1298. bldt.Rows[0]["F_Result"] = "";
  1299. }
  1300. }
  1301. if (configfj != null)
  1302. {
  1303. bldt = BindFileDatas(bldt, configfj.F_ParamValue);
  1304. }
  1305. var ejbldt = DbHelperSQL.Query(ejblsql).Tables[0];
  1306. if (configfj != null)
  1307. {
  1308. ejbldt = BindFileData(ejbldt, configfj.F_ParamValue);
  1309. }
  1310. var obj5 = new
  1311. {
  1312. bldata = bldt,
  1313. ejbldata = ejbldt
  1314. };
  1315. return Success("获取成功", obj5);
  1316. #endregion
  1317. case 5:
  1318. #region 延时信息
  1319. string yssql = "select *,dbo.GetUserName(F_CreateUser) as UserName from T_Bus_DelayTime WITH(NOLOCK) where F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1320. var ysdt = DbHelperSQL.Query(yssql).Tables[0];
  1321. if (configfj != null)
  1322. {
  1323. ysdt = BindFileData(ysdt, configfj.F_ParamValue);
  1324. }
  1325. return Success("获取成功", ysdt);
  1326. #endregion
  1327. case 6:
  1328. #region 回访信息
  1329. string hfsql = "select *,dbo.GetUserName(F_CreateUser) as UserName from T_Bus_VisitResult WITH(NOLOCK) where F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime ";
  1330. var hfdt = DbHelperSQL.Query(hfsql).Tables[0];
  1331. hfdt.Columns.Add("FilePath", typeof(string));
  1332. foreach (DataRow bldr in hfdt.Rows)
  1333. {
  1334. if (bldr["F_CallRecordId"] != null && config != null)
  1335. {
  1336. bldr["FilePath"] = GetCallPath(bldr["F_CallRecordId"].ToString(), config.F_ParamValue);
  1337. }
  1338. }
  1339. return Success("获取成功", hfdt);
  1340. #endregion
  1341. case 7:
  1342. #region 督办信息
  1343. string dbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_DeptId) as DeptName from T_Bus_RemindRecord WITH(NOLOCK) where F_Type=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1344. var dbdt = DbHelperSQL.Query(dbsql).Tables[0];
  1345. if (configfj != null)
  1346. {
  1347. dbdt = BindFileData(dbdt, configfj.F_ParamValue);
  1348. }
  1349. return Success("获取成功", dbdt);
  1350. #endregion
  1351. case 8:
  1352. #region 市民催单
  1353. string cbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName from T_Bus_Additional WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1354. var cbdt = DbHelperSQL.Query(cbsql).Tables[0];
  1355. cbdt.Columns.Add("FilePath", typeof(string));
  1356. foreach (DataRow bldr in cbdt.Rows)
  1357. {
  1358. if (bldr["F_CallRecordId"] != null && config != null)
  1359. {
  1360. bldr["FilePath"] = GetCallPath(bldr["F_CallRecordId"].ToString(), config.F_ParamValue);
  1361. }
  1362. }
  1363. return Success("获取成功", cbdt);
  1364. #endregion
  1365. case 9:
  1366. #region 办理过程
  1367. string gcsql = "select o.*,u.F_UserName from T_Bus_Operation o WITH(NOLOCK) left join T_Sys_UserAccount u WITH(NOLOCK) on o.F_CreateUser=u.F_UserCode where o.F_IsDelete=0 and o.F_WorkOrderId ='" + strworkorderid + "' order by o.F_CreateTime ";
  1368. var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
  1369. gcdt.Columns.Add("File", typeof(object));
  1370. gcdt.Columns.Add("FilePath", typeof(string));
  1371. if (configfj != null || configly != null || config != null)
  1372. {
  1373. foreach (DataRow bldr in gcdt.Rows)
  1374. {
  1375. if (bldr["F_File"] != null && bldr["F_File"].ToString() != "" && configfj != null)
  1376. {
  1377. bldr["File"] = GetFileData(bldr["F_File"].ToString(), configfj.F_ParamValue);
  1378. }
  1379. if (bldr["F_LeaveRecordId"] != null && configly != null)
  1380. {
  1381. bldr["FilePath"] = GetLeavePath(bldr["F_LeaveRecordId"].ToString(), configly.F_ParamValue);
  1382. }
  1383. else if (bldr["F_CallRecordId"] != null && config != null)
  1384. {
  1385. bldr["FilePath"] = GetCallPath(bldr["F_CallRecordId"].ToString(), config.F_ParamValue);
  1386. }
  1387. }
  1388. }
  1389. return Success("获取成功", gcdt);
  1390. #endregion
  1391. case 10:
  1392. #region 市民评议
  1393. string pysql = "select * from PublicComment WITH(NOLOCK) where WorkOrderId ='" + strworkorderid + "' order by CreateTime";
  1394. var pydt = DbHelperSQL.Query(pysql).Tables[0];
  1395. return Success("获取成功", pydt);
  1396. #endregion
  1397. case 11:
  1398. #region 监察信息
  1399. string jcsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_DeptId) as DeptName from T_Bus_RemindRecord WITH(NOLOCK) where F_Type=2 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1400. var jcdt = DbHelperSQL.Query(jcsql).Tables[0];
  1401. if (configfj != null)
  1402. {
  1403. jcdt = BindFileData(jcdt, configfj.F_ParamValue);
  1404. }
  1405. return Success("获取成功", jcdt);
  1406. #endregion
  1407. case 12:
  1408. #region 批示信息
  1409. string pssql = "select *,dbo.GetUserName(F_CreateUser) as UserName from T_Bus_SubmitSuper WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and F_Type=1 and F_WorkOrderId ='" + strworkorderid + "' order by F_CreateTime";
  1410. var psdt = DbHelperSQL.Query(pssql).Tables[0];
  1411. if (configfj != null)
  1412. {
  1413. psdt = BindFileData(psdt, configfj.F_ParamValue);
  1414. }
  1415. return Success("获取成功", psdt);
  1416. #endregion
  1417. case 13:
  1418. #region 审核信息
  1419. string shsql = "select *,[dbo].[GetDeptNames](a.F_MainDeptId) as DeptNames from T_Bus_ToExamine a WITH(NOLOCK) where F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "' order by F_ID desc";
  1420. var shdt = DbHelperSQL.Query(shsql).Tables[0];
  1421. return Success("获取成功", shdt);
  1422. #endregion
  1423. }
  1424. return Error("获取失败");
  1425. }
  1426. else
  1427. {
  1428. return Error("参数传输失败");
  1429. }
  1430. }
  1431. /// <summary>
  1432. /// 获取留言路径
  1433. /// </summary>
  1434. /// <param name="lid">留言id</param>
  1435. /// <param name="prefix">前缀</param>
  1436. /// <returns></returns>
  1437. public string GetLeavePath(string lid, string prefix)
  1438. {
  1439. string path = string.Empty;
  1440. try
  1441. {
  1442. var liuyan = new BLL.T_Call_LeaveRecord().GetModel(int.Parse(lid));
  1443. if (liuyan != null)
  1444. {
  1445. if (!string.IsNullOrEmpty(liuyan.F_RecFileUrl))
  1446. {
  1447. path = prefix + liuyan.F_RecFileUrl;
  1448. }
  1449. }
  1450. }
  1451. catch
  1452. {
  1453. }
  1454. return path;
  1455. }
  1456. /// <summary>
  1457. /// 获取通话录音路径
  1458. /// </summary>
  1459. /// <param name="cid">通话id</param>
  1460. /// <param name="prefix">前缀</param>
  1461. /// <returns></returns>
  1462. public string GetCallPath(string cid, string prefix)
  1463. {
  1464. string path = string.Empty;
  1465. try
  1466. {
  1467. var luyin = new BLL.T_Call_CallRecords().GetModel(int.Parse(cid));
  1468. if (luyin != null)
  1469. {
  1470. if (!string.IsNullOrEmpty(luyin.FilePath))
  1471. {
  1472. var ym = prefix;
  1473. ym = ym.Substring(0, ym.Length - 1);
  1474. string lujing = luyin.FilePath.Substring(luyin.FilePath.IndexOf(':') + 1).Replace('\\', '/');
  1475. path = ym + lujing;
  1476. }
  1477. }
  1478. }
  1479. catch
  1480. {
  1481. }
  1482. return path;
  1483. }
  1484. /// <summary>
  1485. /// 绑定追问回复附件信息
  1486. /// </summary>
  1487. /// <param name="dt"></param>
  1488. /// <param name="prefix"></param>
  1489. /// <returns></returns>
  1490. public DataTable BindFileDatas(DataTable dt, string prefix)
  1491. {
  1492. dt.Columns.Add("File", typeof(object));
  1493. foreach (DataRow dr in dt.Rows)
  1494. {
  1495. if (dr["F_File"] != null && dr["F_File"].ToString() != "")
  1496. {
  1497. dr["File"] = GetFileData(dr["F_File"].ToString(), prefix);
  1498. }
  1499. }
  1500. dt.Columns.Add("Files", typeof(object));
  1501. foreach (DataRow dr in dt.Rows)
  1502. {
  1503. if (dr["F_Files"] != null && dr["F_Files"].ToString() != "")
  1504. {
  1505. dr["Files"] = GetFileData(dr["F_Files"].ToString(), prefix);
  1506. }
  1507. }
  1508. return dt;
  1509. }
  1510. public string Upload(string pathUrl, string newFileName, string path)
  1511. {
  1512. //文件下载地址
  1513. try
  1514. {
  1515. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(pathUrl);
  1516. HttpWebResponse response = request.GetResponse() as HttpWebResponse;
  1517. Stream responseStream = response.GetResponseStream();
  1518. string Currentpath = "F:/WEB/anyang12345Api" + path;
  1519. // 如果不存在就创建file文件夹
  1520. if (!Directory.Exists(Currentpath))
  1521. {
  1522. if (Currentpath != null) Directory.CreateDirectory(Currentpath);
  1523. }
  1524. Stream stream = new FileStream(Currentpath + newFileName, FileMode.Create);
  1525. byte[] bArr = new byte[1024];
  1526. int size = responseStream.Read(bArr, 0, bArr.Length);
  1527. while (size > 0)
  1528. {
  1529. stream.Write(bArr, 0, size);
  1530. size = responseStream.Read(bArr, 0, bArr.Length);
  1531. }
  1532. stream.Close();
  1533. responseStream.Close();
  1534. return "1";
  1535. }
  1536. catch (Exception e)
  1537. {
  1538. return e.Message;
  1539. }
  1540. }
  1541. private BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
  1542. /// <summary>
  1543. /// 获取工单列表
  1544. /// </summary>
  1545. /// <returns></returns>
  1546. [APPActionFilter]
  1547. public ActionResult GetOrderCount()
  1548. {
  1549. //string sql = " and F_IsDelete=0 ";
  1550. string sql = " select count(1) from T_Bus_WorkOrder where F_IsDelete=0 ";
  1551. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  1552. Model.T_Sys_UserAccount userModel = userBLL.GetModel(strusercode);
  1553. string sqlld = " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 ";
  1554. if (userModel.F_RoleCode != "GLY"
  1555. && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  1556. {
  1557. sqlld += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1558. }
  1559. else
  1560. {
  1561. sqlld += ")";
  1562. }
  1563. string sqllddcl = sql + " and F_WorkState = '1' ";
  1564. string sqlthsh = sql + " and F_WorkState = '3' " + sqlld;
  1565. string sqlyssh = sql + " and F_WorkState = '5' " + sqlld;
  1566. string sqlcbdjb = sql + " and F_WorkState = '11' " + sqlld;
  1567. if (userModel.F_RoleCode != "GLY"
  1568. && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ" && userModel.F_RoleCode != "ZXLDGLY" && userModel.F_RoleCode != "ZXLDGLYGLY" && userModel.F_RoleCode != "DDZG")
  1569. {
  1570. sqllddcl += " and (F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo WITH(NOLOCK) where F_State = 1 and F_IsDelete = 0 "
  1571. + "and F_CreateUser = '" + userModel.F_UserCode + "') or (select top 1 F_WorkOrderId from T_Bus_AssignedInfo WITH(NOLOCK) where"
  1572. + " F_State = 1 and F_IsDelete = 0 and T_Bus_AssignedInfo.F_WorkOrderId = T_Bus_WorkOrder.F_WorkOrderId) is null)";
  1573. }
  1574. string dw = "";
  1575. if (userModel.F_RoleCode != "GLY"
  1576. && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ" && userModel.F_RoleCode != "DDZG")
  1577. {
  1578. dw += " and F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and "
  1579. + " ISNULL(F_FeedbackTime, '')='' and F_MainDeptId =" + userModel.F_DeptId + " and F_IsSure in (0,1))";
  1580. }
  1581. string dwdcs = sql + " and F_WorkState = '2' " + dw;
  1582. string dwdbl = sql + " and F_WorkState = '4' " + dw;
  1583. 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 ";
  1584. if (userModel.F_RoleCode != "GLY"
  1585. && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ" && userModel.F_RoleCode != "DDZG")
  1586. {
  1587. dwthsh += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1588. }
  1589. else
  1590. {
  1591. dwthsh += ")";
  1592. }
  1593. string dwyssh = sql + " and F_WorkOrderID in(select F_WorkOrderID from T_Bus_DelayTime WITH(NOLOCK) where F_IsDelete=0 ";
  1594. if (userModel.F_RoleCode != "GLY"
  1595. && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ" && userModel.F_RoleCode != "DDZG")
  1596. {
  1597. dwyssh += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1598. }
  1599. else
  1600. {
  1601. dwyssh += ")";
  1602. }
  1603. string dwspdb = sql + " and F_WorkState = '11' " + dw;
  1604. int[] sts = new int[] { (int)EnumWorkState.dealing, (int)EnumWorkState.auditdelay };
  1605. string ejdbl = sql + " and F_WorkState in (" + string.Join(",", sts.Select(p => p.ToString())) + ")";
  1606. if (userModel.F_RoleCode != "GLY"
  1607. && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ" && userModel.F_RoleCode != "DDZG")
  1608. {
  1609. ejdbl += " and F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedInfo_Next WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and "
  1610. + " ISNULL(F_FeedbackTime, '')='' and F_MainDeptId =" + userModel.F_DeptId + " and F_IsSure in (0,1))";
  1611. }
  1612. 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) ";
  1613. if (userModel.F_RoleCode != "GLY"
  1614. && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ" && userModel.F_RoleCode != "DDZG")
  1615. {
  1616. ejybl += " and F_CreateUser='" + userModel.F_UserCode + "')";
  1617. }
  1618. else
  1619. {
  1620. ejybl += ")";
  1621. }
  1622. var obj = new
  1623. {
  1624. sqllddcl = DbHelperSQL.GetSingle(sqllddcl).ToString(),
  1625. sqlthsh = DbHelperSQL.GetSingle(sqlthsh).ToString(),
  1626. sqlyssh = DbHelperSQL.GetSingle(sqlyssh).ToString(),
  1627. sqlcbdjb = DbHelperSQL.GetSingle(sqlcbdjb).ToString(),
  1628. dwdcs = DbHelperSQL.GetSingle(dwdcs).ToString(),
  1629. dwdbl = DbHelperSQL.GetSingle(dwdbl).ToString(),
  1630. dwthsh = DbHelperSQL.GetSingle(dwthsh).ToString(),
  1631. dwyssh = DbHelperSQL.GetSingle(dwyssh).ToString(),
  1632. dwspdb = DbHelperSQL.GetSingle(dwspdb).ToString(),
  1633. ejdbl = DbHelperSQL.GetSingle(ejdbl).ToString(),
  1634. ejybl = DbHelperSQL.GetSingle(ejybl).ToString()
  1635. };
  1636. return Success("成功", obj);
  1637. }
  1638. /// <summary>
  1639. /// 获取工单数量
  1640. /// </summary>
  1641. /// <returns></returns>
  1642. [APPActionFilter]
  1643. public ActionResult GetWorkOrderCount(string usercode)
  1644. {
  1645. string stropenid = usercode;
  1646. int type = RequestString.GetInt("type", 0);
  1647. var wxuser = new BLL.T_Sys_UserAccount().GetModelList(" F_UserCode='" + stropenid.Trim() + "' and F_DeleteFlag=0 ").FirstOrDefault();
  1648. string where = " F_WorkOrderId in (select F_WorkOrderId from T_Bus_UserWorkOrder where F_UserId='" + wxuser.F_UserId + "') ";
  1649. string sql = " select count(1) from T_Bus_UserWorkOrder where F_UserId='" + wxuser.F_UserId + "' ";
  1650. string sqlblz = " select count(1) from T_Bus_WorkOrder where " + where + " and F_WorkState!=9 and (F_IsEnabled=0 or F_IsDelete=0)";
  1651. string sqlybl = " select count(1) from T_Bus_WorkOrder where " + where + " and F_WorkState =9 and (F_IsEnabled=0 or F_IsDelete=0)";
  1652. string sqltype = " select F_ValueId,F_Value,(select COUNT(1) from T_Bus_WorkOrder where (F_IsEnabled=0 or F_IsDelete=0) ";
  1653. if (type == 1)
  1654. {
  1655. sqltype += " and F_WorkState!=9";
  1656. }
  1657. else if (type == 2)
  1658. {
  1659. sqltype += " and F_WorkState=9";
  1660. }
  1661. sqltype += " and F_InfoType=F_ValueId and " + where + ") Count from dbo.T_Sys_DictionaryValue where F_ItemId=2 and F_State=0 ";
  1662. DataTable dt = DbHelperSQL.Query(sqltype).Tables[0];
  1663. var obj = new
  1664. {
  1665. total = DbHelperSQL.GetSingle(sql).ToString(),
  1666. blzcount = DbHelperSQL.GetSingle(sqlblz).ToString(),
  1667. yblcount = DbHelperSQL.GetSingle(sqlybl).ToString(),
  1668. typedata = dt
  1669. };
  1670. return Success("成功", obj);
  1671. }
  1672. /// <summary>
  1673. /// APP上传图片
  1674. /// </summary>
  1675. /// <returns></returns>
  1676. [APPActionFilter]
  1677. public ActionResult Upload64()
  1678. {
  1679. //string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("dataurl"));
  1680. string dataurl = RequestString.GetFormString("dataurl");
  1681. string filename = RequestString.GetFormString("filename");
  1682. if (!string.IsNullOrEmpty(dataurl))
  1683. {
  1684. string path = "/Upload/APP/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  1685. ImageUpload iu = new ImageUpload();
  1686. iu.SavePath = path;
  1687. iu.DataUrl = dataurl;
  1688. if (!string.IsNullOrEmpty(filename))
  1689. {
  1690. iu.SaveType = 1;
  1691. iu.InFileName = filename;
  1692. }
  1693. iu.Upload64();
  1694. int n = iu.Error;
  1695. if (n == 0)
  1696. {
  1697. path = path + iu.OutFileName;
  1698. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  1699. model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  1700. model_T_Sys_Accessories.F_FileName = iu.OutFileName;//附件名称
  1701. model_T_Sys_Accessories.F_FileType = ".jpg";//附件类型
  1702. model_T_Sys_Accessories.F_FileUrl = path;//附件地址
  1703. model_T_Sys_Accessories.F_Size = iu.FileSize;
  1704. //model_T_Sys_Accessories.F_UserCode = userModel.F_UserCode;//上传人
  1705. int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  1706. model_T_Sys_Accessories.F_FileId = id;
  1707. return Success("成功", model_T_Sys_Accessories);
  1708. }
  1709. else
  1710. {
  1711. string msg = string.Empty;
  1712. switch (n)
  1713. {
  1714. case 1: msg = "请选择要上传的文件"; break;
  1715. case 2: msg = "上传的文件类型不支持"; break;
  1716. case 3: msg = "上传的文件过大"; break;
  1717. case 4: msg = "未知错误"; break;
  1718. }
  1719. return Error(msg);
  1720. }
  1721. }
  1722. else
  1723. {
  1724. return Error("请选择要上传的文件");
  1725. }
  1726. }
  1727. /// <summary>
  1728. /// 市民催单
  1729. /// </summary>
  1730. /// <returns></returns>
  1731. [APPActionFilter]
  1732. public ActionResult AdditionalWorkOrder()
  1733. {
  1734. string usercode = RequestString.GetFormString("usercode");
  1735. var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
  1736. string workorderid = RequestString.GetFormString("workorderid");
  1737. string title = RequestString.GetFormString("title");
  1738. string content = RequestString.GetFormString("content");
  1739. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
  1740. if (modelT_Bus_WorkOrder != null)
  1741. {
  1742. using (TransactionScope trans = new TransactionScope())
  1743. {
  1744. #region 插入附加记录
  1745. //批示记录
  1746. Model.T_Bus_Additional model_T_Bus_Additional = new Model.T_Bus_Additional();
  1747. model_T_Bus_Additional.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;//工单流水号
  1748. model_T_Bus_Additional.F_Title = title;
  1749. model_T_Bus_Additional.F_Content = content;
  1750. model_T_Bus_Additional.F_CreateTime = DateTime.Now;
  1751. model_T_Bus_Additional.F_IsDelete = 0;
  1752. model_T_Bus_Additional.F_State = 1;
  1753. new BLL.T_Bus_Additional().Add(model_T_Bus_Additional);
  1754. #endregion
  1755. #region 插入操作记录
  1756. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  1757. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  1758. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  1759. oper.F_Message = "市民(" + userinfo.F_OpenId + ")催单,内容:" + content;
  1760. //oper.F_CreateUser = userModel.F_UserCode;
  1761. oper.F_CreateTime = DateTime.Now;
  1762. oper.F_IsDelete = 0;
  1763. new BLL.T_Bus_Operation().Add(oper);
  1764. #endregion
  1765. trans.Complete();
  1766. }
  1767. return Success("操作成功");
  1768. }
  1769. else
  1770. {
  1771. return Error("操作失败");
  1772. }
  1773. }
  1774. /// <summary>
  1775. /// 获取工单信息
  1776. /// </summary>
  1777. /// <returns></returns>
  1778. [APPActionFilter]
  1779. public ActionResult GetWorkOrder()
  1780. {
  1781. string usercode = RequestString.GetFormString("usercode");
  1782. var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
  1783. string workorderid = RequestString.GetFormString("workorderid");
  1784. string strworkorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("workorderid"));
  1785. //int type = RequestString.GetInt("type", 0);//0基本信息1监察意见2领导批示3办理情况4回访信息5督办信息6办理过程
  1786. if (!string.IsNullOrEmpty(strworkorderid))
  1787. {
  1788. string sql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName1,"
  1789. + "dbo.GetAreaName(F_SourceArea) as AreaName,dbo.GetDictionaryName(F_InfoSource) as SourceName "
  1790. + " from T_Bus_WorkOrder where F_WorkOrderId ='" + strworkorderid + "'";
  1791. var dt = DbHelperSQL.Query(sql).Tables[0];
  1792. if (dt.Rows.Count > 0)
  1793. {
  1794. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  1795. string jcsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_DeptId) as DeptName "
  1796. + "from T_Bus_RemindRecord where F_Type=2 and F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1797. string dbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_DeptId) as DeptName "
  1798. + "from T_Bus_RemindRecord where F_Type=1 and F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1799. string pssql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1800. + "from T_Bus_SubmitSuper where F_State=1 and F_IsDelete=0 and F_Type=1 and F_WorkOrderId ='" + strworkorderid + "'";
  1801. string zssql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1802. + "from T_Bus_SubmitSuper where F_State=1 and F_IsDelete=0 and F_Type=2 and F_WorkOrderId ='" + strworkorderid + "'";
  1803. string htsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1804. + "from T_Bus_SubmitSuper where F_State=1 and F_IsDelete=0 and F_Type=3 and F_WorkOrderId ='" + strworkorderid + "'";
  1805. string jbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_MainDeptId) as DeptName,dbo.GetDeptNames(F_OtherDeptIds) as OtherDeptName "
  1806. + "from T_Bus_AssignedInfo where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1807. string thsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_CreateDeptId) as DeptName "
  1808. + "from T_Bus_Feedback where F_State=1 and F_Type=3 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1809. string yssql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1810. + "from T_Bus_DelayTime where F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1811. string blsql = "select *,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDeptName(F_CreateDeptId) as DeptName "
  1812. + "from T_Bus_Feedback where F_State=1 and F_Type!=3 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1813. string hfsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1814. + "from T_Bus_VisitResult where F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1815. string gcsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1816. + "from T_Bus_Operation where F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1817. string cbsql = "select *,dbo.GetUserName(F_CreateUser) as UserName "
  1818. + "from T_Bus_Additional where F_State=1 and F_IsDelete=0 and F_WorkOrderId ='" + strworkorderid + "'";
  1819. #region 附件
  1820. if (configfj != null)
  1821. {
  1822. dt = BindFileData(dt, configfj.F_ParamValue);
  1823. }
  1824. #endregion
  1825. #region 监察信息
  1826. var jcdt = DbHelperSQL.Query(jcsql).Tables[0];
  1827. if (configfj != null)
  1828. {
  1829. jcdt = BindFileData(jcdt, configfj.F_ParamValue);
  1830. }
  1831. #endregion
  1832. #region 批示信息
  1833. var psdt = DbHelperSQL.Query(pssql).Tables[0];
  1834. if (configfj != null)
  1835. {
  1836. psdt = BindFileData(psdt, configfj.F_ParamValue);
  1837. }
  1838. #endregion
  1839. #region 指示信息
  1840. var zsdt = DbHelperSQL.Query(zssql).Tables[0];
  1841. if (configfj != null)
  1842. {
  1843. zsdt = BindFileData(zsdt, configfj.F_ParamValue);
  1844. }
  1845. #endregion
  1846. #region 回退信息
  1847. var htdt = DbHelperSQL.Query(htsql).Tables[0];
  1848. #endregion
  1849. #region 督办信息
  1850. var dbdt = DbHelperSQL.Query(dbsql).Tables[0];
  1851. if (configfj != null)
  1852. {
  1853. dbdt = BindFileData(dbdt, configfj.F_ParamValue);
  1854. }
  1855. #endregion
  1856. #region 交办信息
  1857. var jbdt = DbHelperSQL.Query(jbsql).Tables[0];
  1858. if (configfj != null)
  1859. {
  1860. jbdt = BindFileData(jbdt, configfj.F_ParamValue);
  1861. }
  1862. #endregion
  1863. #region 退回信息
  1864. var thdt = DbHelperSQL.Query(thsql).Tables[0];
  1865. #endregion
  1866. #region 延时信息
  1867. var ysdt = DbHelperSQL.Query(yssql).Tables[0];
  1868. #endregion
  1869. #region 办理情况
  1870. var bldt = DbHelperSQL.Query(blsql).Tables[0];
  1871. if (configfj != null)
  1872. {
  1873. bldt = BindFileData(bldt, configfj.F_ParamValue);
  1874. }
  1875. #endregion
  1876. #region 回访信息
  1877. var hfdt = DbHelperSQL.Query(hfsql).Tables[0];
  1878. #endregion
  1879. #region 市民催单
  1880. var cbdt = DbHelperSQL.Query(cbsql).Tables[0];
  1881. #endregion
  1882. #region 办理过程
  1883. var gcdt = DbHelperSQL.Query(gcsql).Tables[0];
  1884. gcdt.Columns.Add("File", typeof(object));
  1885. if (configfj != null)
  1886. {
  1887. foreach (DataRow bldr in gcdt.Rows)
  1888. {
  1889. if (bldr["F_File"] != null && bldr["F_File"].ToString() != "" && configfj != null)
  1890. {
  1891. bldr["File"] = GetFileData(bldr["F_File"].ToString(), configfj.F_ParamValue);
  1892. }
  1893. }
  1894. }
  1895. #endregion
  1896. var obj = new
  1897. {
  1898. data = dt,
  1899. jcdata = jcdt,
  1900. psdata = psdt,
  1901. zsdata = zsdt,
  1902. htdata = htdt,
  1903. dbdata = dbdt,
  1904. jbdata = jbdt,
  1905. thdata = thdt,
  1906. ysdata = ysdt,
  1907. bldata = bldt,
  1908. hfdata = hfdt,
  1909. cbdata = cbdt,
  1910. gcdata = gcdt
  1911. };
  1912. return Success("获取成功", obj);
  1913. }
  1914. else
  1915. {
  1916. return Error("获取失败");
  1917. }
  1918. }
  1919. else
  1920. {
  1921. return Error("参数传输失败");
  1922. }
  1923. }
  1924. /// <summary>
  1925. /// 获取附件数据
  1926. /// </summary>
  1927. /// <param name="ids">附件id,多个用英文逗号,隔开</param>
  1928. /// <param name="prefix">前缀</param>
  1929. /// <returns></returns>
  1930. public DataTable GetFileData(string ids, string prefix)
  1931. {
  1932. DataTable dt = DbHelperSQL.Query("select * from T_Sys_Accessories where F_FileId in (" + ids + ")").Tables[0];
  1933. foreach (DataRow dr in dt.Rows)
  1934. {
  1935. dr["F_FileUrl"] = prefix + dr["F_FileUrl"].ToString();
  1936. }
  1937. return dt;
  1938. }
  1939. /// <summary>
  1940. /// 绑定附件信息
  1941. /// </summary>
  1942. /// <param name="dt"></param>
  1943. /// <param name="prefix"></param>
  1944. /// <returns></returns>
  1945. public DataTable BindFileData(DataTable dt, string prefix)
  1946. {
  1947. dt.Columns.Add("File", typeof(object));
  1948. foreach (DataRow dr in dt.Rows)
  1949. {
  1950. if (dr["F_File"] != null && dr["F_File"].ToString() != "")
  1951. {
  1952. dr["File"] = GetFileData(dr["F_File"].ToString(), prefix);
  1953. }
  1954. }
  1955. return dt;
  1956. }
  1957. /// <summary>
  1958. /// 修改工单信息
  1959. /// </summary>
  1960. /// <returns></returns>
  1961. [APPActionFilter]
  1962. public ActionResult EditWorkOrder()
  1963. {
  1964. string usercode = RequestString.GetFormString("usercode");
  1965. var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
  1966. string workorderid = RequestString.GetFormString("workorderid");
  1967. Model.T_Bus_WorkOrder modelT_Bus_WorkOrder = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
  1968. Model.T_Bus_UserWorkOrder modelT_Bus_UserWorkOrder = new BLL.T_Bus_UserWorkOrder().GetModelList(" F_WorkOrderId='" + workorderid + "' ").FirstOrDefault();
  1969. if (modelT_Bus_WorkOrder != null && modelT_Bus_UserWorkOrder != null && modelT_Bus_UserWorkOrder.F_UserId == userinfo.F_Id)
  1970. {
  1971. string cusname = RequestString.GetFormString("cusname");
  1972. string cussex = RequestString.GetFormString("cussex");
  1973. string cusphone = RequestString.GetFormString("cusphone");
  1974. string cusaddress = RequestString.GetFormString("cusaddress");
  1975. string email = RequestString.GetFormString("email");
  1976. string zipcode = RequestString.GetFormString("zipcode");
  1977. string conname = RequestString.GetFormString("conname");
  1978. string conphone = RequestString.GetFormString("conphone");
  1979. string title = RequestString.GetFormString("title");
  1980. string content = RequestString.GetFormString("content");
  1981. string files = RequestString.GetFormString("files");
  1982. int sourcearea = RequestString.GetInt("sourcearea", 0);
  1983. string sourceaddress = RequestString.GetFormString("sourceaddress");
  1984. string keys = RequestString.GetFormString("keys");
  1985. int type = RequestString.GetInt("type", 0);
  1986. int bigtype = RequestString.GetInt("bigtype", 0);
  1987. int smalltype = RequestString.GetInt("smalltype", 0);
  1988. int isprotect = RequestString.GetInt("isprotect", 0);
  1989. int level = RequestString.GetInt("level", 0);
  1990. int issubmit = RequestString.GetInt("issubmit", 0);
  1991. using (TransactionScope trans = new TransactionScope())
  1992. {
  1993. #region 保存工单信息
  1994. modelT_Bus_WorkOrder.F_InfoType = type;//信息类别
  1995. modelT_Bus_WorkOrder.F_InfoConBigType = bigtype;//内容大类
  1996. modelT_Bus_WorkOrder.F_InfoConSmallType = smalltype;//内容小类
  1997. modelT_Bus_WorkOrder.F_SourceArea = sourcearea;//反映地域
  1998. modelT_Bus_WorkOrder.F_SourceAddress = sourceaddress;//事发地址
  1999. modelT_Bus_WorkOrder.F_CusName = cusname;//投诉人姓名
  2000. modelT_Bus_WorkOrder.F_CusSex = cussex;//性别
  2001. modelT_Bus_WorkOrder.F_CusPhone = cusphone;//来电号码
  2002. modelT_Bus_WorkOrder.F_CusAddress = cusaddress;//地址
  2003. modelT_Bus_WorkOrder.F_ZipCode = zipcode;//邮编
  2004. modelT_Bus_WorkOrder.F_ConName = conname;//联系人姓名
  2005. modelT_Bus_WorkOrder.F_ConPhone = conphone;//联系人电话
  2006. modelT_Bus_WorkOrder.F_Email = email;//E-mail
  2007. modelT_Bus_WorkOrder.F_ComTitle = title;//标题
  2008. modelT_Bus_WorkOrder.F_ComContent = content;//情况摘要(投诉内容)
  2009. modelT_Bus_WorkOrder.F_File = files;//附件
  2010. modelT_Bus_WorkOrder.F_IsProtect = isprotect;//保密方式0否1是
  2011. modelT_Bus_WorkOrder.F_Key = keys;
  2012. modelT_Bus_WorkOrder.F_Level = level;
  2013. new BLL.T_Bus_WorkOrder().Update(modelT_Bus_WorkOrder);
  2014. #endregion
  2015. #region 插入操作记录
  2016. Model.T_Bus_Operation oper = new Model.T_Bus_Operation();
  2017. oper.F_WorkOrderId = modelT_Bus_WorkOrder.F_WorkOrderId;
  2018. oper.F_State = modelT_Bus_WorkOrder.F_WorkState;
  2019. oper.F_CallRecordId = modelT_Bus_WorkOrder.F_CallRecordId;
  2020. oper.F_File = modelT_Bus_WorkOrder.F_File;
  2021. oper.F_Message = "市民(" + userinfo.F_OpenId + ") 修改了工单";
  2022. //oper.F_CreateUser = userModel.F_UserCode;
  2023. oper.F_CreateTime = DateTime.Now;
  2024. oper.F_IsDelete = 0;
  2025. new BLL.T_Bus_Operation().Add(oper);
  2026. #endregion
  2027. trans.Complete();
  2028. }
  2029. return Success("操作成功");
  2030. }
  2031. else
  2032. {
  2033. return Error("操作失败");
  2034. }
  2035. }
  2036. /// <summary>
  2037. /// 获取用户信息
  2038. /// </summary>
  2039. /// <returns></returns>
  2040. [APPActionFilter]
  2041. public ActionResult GetUserInfo()
  2042. {
  2043. string usercode = RequestString.GetQueryString("usercode");
  2044. var userinfo = new BLL.T_Sys_Users().GetModel(usercode);
  2045. return Success("获取成功", userinfo);
  2046. }
  2047. /// <summary>
  2048. /// 修改用户
  2049. /// </summary>
  2050. /// <param name="input"></param>
  2051. /// <returns></returns>
  2052. [HttpPost]
  2053. [APPActionFilter]
  2054. public ActionResult EditUser()
  2055. {
  2056. string usercode = RequestString.GetFormString("usercode");
  2057. var dModel = new BLL.T_Sys_Users().GetModel(usercode);
  2058. string name = RequestString.GetFormString("name");
  2059. string phone = RequestString.GetFormString("phone");
  2060. int sex = RequestString.GetInt("sex", 0);
  2061. string province = RequestString.GetFormString("province");
  2062. string city = RequestString.GetFormString("city");
  2063. string county = RequestString.GetFormString("county");
  2064. string address = RequestString.GetFormString("address");
  2065. var list = new BLL.T_Sys_Users().GetModelList(" F_OpenId='" + usercode + "' and F_Id!='" + dModel.F_Id + "' ");
  2066. if (list.Count > 0)
  2067. {
  2068. return Error("已经存在此账号");
  2069. }
  2070. else
  2071. {
  2072. dModel.F_Name = name;
  2073. dModel.F_Telphone = phone;
  2074. dModel.F_Sex = sex;
  2075. dModel.F_Province = province;
  2076. dModel.F_City = city;
  2077. dModel.F_County = county;
  2078. dModel.F_Address = address;
  2079. bool n = new BLL.T_Sys_Users().Update(dModel);
  2080. if (n)
  2081. return Success("修改成功", n);
  2082. else
  2083. return Error("修改失败");
  2084. }
  2085. }
  2086. private BLL.T_Cus_CustomerBase cusBLL = new BLL.T_Cus_CustomerBase();
  2087. /// <summary>
  2088. /// 保存客户档案
  2089. /// </summary>
  2090. /// <param name="telphone"></param>
  2091. /// <param name="name"></param>
  2092. /// <param name="phone"></param>
  2093. /// <param name="countryid"></param>
  2094. /// <param name="address"></param>
  2095. /// <returns></returns>
  2096. private void saveCus(string name, string phone, string address)
  2097. {
  2098. int res = 0;
  2099. Model.T_Cus_CustomerBase cusmodel = new Model.T_Cus_CustomerBase();
  2100. if (!string.IsNullOrWhiteSpace(phone))
  2101. {
  2102. cusmodel = cusBLL.GetModelBy(phone, name);
  2103. if (cusmodel == null)
  2104. {
  2105. cusmodel = new Model.T_Cus_CustomerBase();
  2106. cusmodel.F_Address = address;
  2107. cusmodel.F_CustomerName = name;
  2108. cusmodel.F_Mobile = phone;
  2109. cusmodel.F_DeleteFlag = 0;
  2110. res = cusBLL.Add(cusmodel);
  2111. }
  2112. }
  2113. }
  2114. string url = "http://172.16.0.10/Affairs/";
  2115. // string url = "http://localhost:63660/Affairs/";
  2116. int Affairs = int.Parse(Configs.GetValue("Affairs"));
  2117. public void case_info(string workorderid, string parameter)
  2118. {
  2119. if (Affairs > 0)
  2120. {
  2121. WebClient web = new WebClient();
  2122. web.Encoding = Encoding.UTF8;
  2123. string Dataurl = web.DownloadString(url + parameter + "?workorderid=" + workorderid);
  2124. }
  2125. }
  2126. public void process_info(int id, string parameter, string title)
  2127. {
  2128. if (Affairs > 0)
  2129. {
  2130. WebClient web = new WebClient();
  2131. web.Encoding = Encoding.UTF8;
  2132. string Dataurl = web.DownloadString(url + parameter + "?id=" + id + "&title=" + title);
  2133. }
  2134. }
  2135. public void material_info(string WorkOrderId, string file, int id, string type)
  2136. {
  2137. if (Affairs > 0)
  2138. {
  2139. WebClient web = new WebClient();
  2140. web.Encoding = Encoding.UTF8;
  2141. string Dataurl = web.DownloadString(url + "case_material_info" + "?WorkOrderId=" + WorkOrderId + "&file=" + file + "&id=" + id + "&type=" + type);
  2142. }
  2143. }
  2144. }
  2145. }