Нет описания

APPController.cs 106KB

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