MobileProblemController.cs 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559
  1. using PMS.BusinessModels.Account;
  2. using PMS.BusinessModels.ComplaintManage;
  3. using PMS.BusinessModels.MobileProblem;
  4. using PMS.BusinessModels.Problem;
  5. using PMS.BusinessModels.SMS;
  6. using PMS.EntityModels.Product;
  7. using PMS.EntityModels.WorkFlow;
  8. using PMS.Interface;
  9. using PMS.Interface.BaseCode;
  10. using PMS.Interface.Channel;
  11. using PMS.Interface.ComplaintManage;
  12. using PMS.Interface.MessageManage;
  13. using PMS.Interface.MoblieProblemRegist;
  14. using PMS.Interface.PresonManager;
  15. using PMS.Interface.Problems;
  16. using PMS.Interface.Product;
  17. using PMS.Interface.ProManager;
  18. using PMS.Interface.WorkFlow;
  19. using PMS.Plugins.Common;
  20. using PMS.Plugins.SMS;
  21. using QWPlatform.SystemLibrary;
  22. using QWPlatform.SystemLibrary.LogManager;
  23. using QWPlatform.SystemLibrary.Utils;
  24. using System;
  25. using System.Collections.Generic;
  26. using System.Data;
  27. using System.IO;
  28. using System.Linq;
  29. using System.Threading.Tasks;
  30. using System.Web;
  31. using System.Web.Mvc;
  32. namespace PMS.WebUI.Controllers
  33. {
  34. /// <summary>
  35. /// 创建人:伍莲魁
  36. /// 创建日期:2019/1/2
  37. /// 模块功能:问题登记移动端控制器
  38. /// </summary>
  39. [CheckLogin("/MobileAccount/MobileProblemLogin")]
  40. public class MobileProblemController : BaseController
  41. {
  42. IProductModule Product_obj = InterfaceFactory.CreateBusinessInstance<IProductModule>();
  43. IBaseCode BaseCode_obj = InterfaceFactory.CreateBusinessInstance<IBaseCode>();
  44. IPersonModule Iperson_obj = InterfaceFactory.CreateBusinessInstance<IPersonModule>();
  45. IMoblieProblem MoblieProblem_obj = InterfaceFactory.CreateBusinessInstance<IMoblieProblem>();
  46. IProModule Pro_obj = InterfaceFactory.CreateBusinessInstance<IProModule>();
  47. ICPWTGCModel ZpwtgcModel = InterfaceFactory.CreateBusinessInstance<ICPWTGCModel>();
  48. IWorkFlow IWorkFlowModel = InterfaceFactory.CreateBusinessInstance<IWorkFlow>();
  49. IComplaintList Complaint_List = InterfaceFactory.CreateBusinessInstance<IComplaintList>();
  50. IChannel IChannel = InterfaceFactory.CreateBusinessInstance<IChannel>();
  51. //项目问题管理
  52. IProjectProblems projectProblems = InterfaceFactory.CreateBusinessInstance<IProjectProblems>();
  53. //推送消息
  54. IMessageManage notice = InterfaceFactory.CreateBusinessInstance<IMessageManage>();
  55. // GET: MobileProblem
  56. #region 视图
  57. public ActionResult Home()
  58. {
  59. return View();
  60. }
  61. public ActionResult NewProblem()
  62. {
  63. var UserInfo = GetCurrentUser();
  64. var UserType = Convert.ToString(UserInfo.PersonProperty);
  65. ViewBag.CurrentProject = UserInfo.DefaultProjectID;
  66. ViewBag.UserType = "true";
  67. if (UserType == "3")
  68. {
  69. ViewBag.UserType = "false";
  70. }
  71. else
  72. {
  73. var proId = Pro_obj.GetProjectByUserId(UserInfo.PersonID);
  74. if (!String.IsNullOrEmpty(proId))
  75. {
  76. ViewBag.CurrentProject = proId;
  77. }
  78. }
  79. return View();
  80. }
  81. /// <summary>
  82. /// 判断用户性质进入不同的问题登记页面
  83. /// </summary>
  84. /// <param name="id"></param>
  85. /// <returns></returns>
  86. public ActionResult NewProblems(string id)
  87. {
  88. var UserInfo = GetCurrentUser();
  89. var UserType = UserInfo.PersonProperty;
  90. var url = "NewProblemForCustom/";
  91. if (UserType != 3)
  92. {
  93. url = "NewProblemForProject/";
  94. }
  95. return RedirectToAction(url + id);
  96. }
  97. public ActionResult NewProblemForProject(string id)
  98. {
  99. ViewBag.PersonProperty = GetCurrentUser().PersonProperty;
  100. ViewBag.ProjectId = GetCurrentUser().DefaultProjectID;
  101. ViewBag.OrgID = GetCurrentUser().OrgID;
  102. ViewBag.ProductCode = id;
  103. return View();
  104. }
  105. public ActionResult NewProblemForCustom(string id)
  106. {
  107. ViewBag.ProductCode = id;
  108. return View();
  109. }
  110. public ActionResult My()
  111. {
  112. ViewBag.PersonProperty = GetCurrentUser().PersonProperty;
  113. return View();
  114. }
  115. public ActionResult PersonalSetting()
  116. {
  117. return View();
  118. }
  119. public ActionResult UserDefualtSet()
  120. {
  121. ViewBag.Property = GetCurrentUser().PersonProperty;
  122. return View();
  123. }
  124. public ActionResult QueryProblem()
  125. {
  126. var UserInfo = GetCurrentUser();
  127. if (UserInfo.PersonProperty != 3)
  128. {
  129. return RedirectToAction("QueryProblemProject");
  130. }
  131. else
  132. {
  133. return RedirectToAction("QueryProblemCustom");
  134. }
  135. }
  136. /// <summary>
  137. /// 用户查询
  138. /// </summary>
  139. /// <returns></returns>
  140. public ActionResult QueryProblemCustom()
  141. {
  142. return View();
  143. }
  144. /// <summary>
  145. /// 项目人员查询
  146. /// </summary>
  147. /// <returns></returns>
  148. public ActionResult QueryProblemProject()
  149. {
  150. ViewBag.PersonPropert = GetCurrentUser().PersonProperty;
  151. return View();
  152. }
  153. public ActionResult ProblemQuickSearch()
  154. {
  155. return View();
  156. }
  157. /// <summary>
  158. /// 问题详细
  159. /// </summary>
  160. /// <returns></returns>
  161. public ActionResult ProblemDetail(string id)
  162. {
  163. var UserInfo = GetCurrentUser();
  164. ///如果是客户则跳转到客户的详细界面
  165. if (UserInfo.PersonProperty == 3)
  166. {
  167. return RedirectToAction("ProblemDetailCutom/" + id);
  168. }
  169. else
  170. {
  171. var json = MoblieProblem_obj.ProblemDetailByProject(id, UserInfo.PersonProperty, UserInfo.JobCode, UserInfo.PersonID);
  172. var Model = Strings.JsonToModel<ProblemDetailModel>(json);
  173. ViewBag.ID = id;
  174. ViewBag.PersonProperty = UserInfo.PersonProperty;
  175. return View(Model);
  176. }
  177. }
  178. /// <summary>
  179. /// 问题详细客户界面
  180. /// </summary>
  181. /// <returns></returns>
  182. public ActionResult ProblemDetailCutom(string id)
  183. {
  184. var UserInfo = GetCurrentUser();
  185. var json = MoblieProblem_obj.ProblemDetail(id, UserInfo.PersonID);
  186. var Model = Strings.JsonToModel<ProblemDetailModel>(json);
  187. ViewBag.ID = id;
  188. ViewBag.PersonProperty = UserInfo.PersonProperty;
  189. return View(Model);
  190. }
  191. public ActionResult ModifyProblem(string id)
  192. {
  193. ViewBag.PersonProperty = GetCurrentUser().PersonProperty;
  194. ViewBag.ID = id;
  195. return View();
  196. }
  197. /// <summary>
  198. /// 问题回退或终止填写界面
  199. /// </summary>
  200. /// <returns></returns>
  201. public ActionResult ProblemBack(string id, string type)
  202. {
  203. ViewBag.ID = id;
  204. ViewBag.type = type;
  205. return View();
  206. }
  207. public ActionResult ProblemDistribution(string id)
  208. {
  209. var UserInfo = GetCurrentUser();
  210. ViewBag.ID = id;
  211. ViewBag.PersonProperty = UserInfo.PersonProperty;
  212. ViewBag.CompanyID = UserInfo.CompanyID;
  213. ViewBag.DefaultProjectID = UserInfo.DefaultProjectID;
  214. return View();
  215. }
  216. public ActionResult ProblemDeal(string id)
  217. {
  218. ViewBag.ID = id;
  219. return View();
  220. }
  221. /// <summary>
  222. /// 根据ID获取登陆人详细信息
  223. /// </summary>
  224. /// <returns></returns>
  225. [HttpPost]
  226. public ActionResult GetCUserInfo()
  227. {
  228. var UserInfo = GetCurrentUser();
  229. var json = Complaint_List.GetComplaintPerson(UserInfo.PersonID);
  230. return Content(json, "application/json");
  231. }
  232. /// <summary>
  233. /// 获取我的问题统计信息
  234. /// </summary>
  235. /// <returns></returns>
  236. [HttpPost]
  237. public ActionResult GetCount()
  238. {
  239. var UserInfo = GetCurrentUser();
  240. string json;
  241. ///如果为客户
  242. if (UserInfo.PersonProperty == 3)
  243. {
  244. json = MoblieProblem_obj.GetCountForCustom(UserInfo.PersonID);
  245. }
  246. else
  247. {
  248. json = MoblieProblem_obj.GetCount(UserInfo.PersonID);
  249. }
  250. return Content(json, "application/json");
  251. }
  252. /// <summary>
  253. /// 公告列表页面
  254. /// </summary>
  255. /// <returns></returns>
  256. public ActionResult NoticeList()
  257. {
  258. return View();
  259. }
  260. /// <summary>
  261. /// 公告详细
  262. /// </summary>
  263. /// <param name="id"></param>
  264. /// <returns></returns>
  265. public ActionResult NoticesDetail(string id)
  266. {
  267. ViewBag.ID = id;
  268. return View();
  269. }
  270. #endregion
  271. #region 问题登记相关业务
  272. /// <summary>
  273. /// 获取产品编码
  274. /// </summary>
  275. /// <returns></returns>
  276. public ActionResult GetProductCode(string DeafualtProjectId)
  277. {
  278. string json;
  279. //if (!String.IsNullOrEmpty(DeafualtProjectId))
  280. //{
  281. // json = Product_obj.GetProductCodeBycustom(DeafualtProjectId);
  282. // return Content(json, "application/json");
  283. //}
  284. var userinfo = GetCurrentUser();
  285. if (userinfo.PersonProperty == 3 || userinfo.PersonProperty == 4)
  286. {
  287. json = Product_obj.GetProductCodeBycustom(userinfo.DefaultProjectID);
  288. }
  289. else
  290. {
  291. json = Product_obj.GetProductCode();
  292. }
  293. return Content(json, "application/json");
  294. }
  295. /// <summary>
  296. /// 客户获取所在项目的产品编码
  297. /// </summary>
  298. /// <returns></returns>
  299. public ActionResult GetProductCodeBycustom()
  300. {
  301. var userinfo = GetCurrentUser();
  302. var json = Product_obj.GetProductCodeBycustom(userinfo.DefaultProjectID);
  303. return Content(json, "application/json");
  304. }
  305. /// <summary>
  306. /// 获取当前登录帐户项目的产品
  307. /// </summary>
  308. /// <returns></returns>
  309. public ActionResult GetProduct(string id)
  310. {
  311. var json = Product_obj.GetProductByProjectId(id);
  312. return Content(json, "application/json");
  313. }
  314. /// <summary>
  315. /// 根据分类ID获取基础编码
  316. /// </summary>
  317. /// <param name="ClassificationID"></param>
  318. /// <returns></returns>
  319. public ActionResult GetCodeCombobox(string ClassificationID)
  320. {
  321. var json = BaseCode_obj.GetCodeComboboxs(ClassificationID);
  322. return Content(json, "application/json");
  323. }
  324. /// <summary>
  325. /// 获取当前用户渠道的项目信息
  326. /// </summary>
  327. /// <returns></returns>
  328. public ActionResult GetProductCombobox()
  329. {
  330. var UserInfo = GetCurrentUser();
  331. var json = Iperson_obj.GetProjectCobo(UserInfo.CompanyID, GetAuthDats().Project);
  332. return Content(json, "application/json");
  333. }
  334. /// <summary>
  335. /// 获取项目下的机构信息
  336. /// </summary>
  337. /// <returns></returns>
  338. public ActionResult GetInstitution(string id)
  339. {
  340. var json = Pro_obj.GetInstitutionByProjectId(id);
  341. return Content(json, "application/json");
  342. }
  343. /// <summary>
  344. /// 登记产品问题
  345. /// </summary>
  346. /// <param name="model"></param>
  347. /// <returns></returns>
  348. public ActionResult SubmitProblem(SubmitProblemFormModel model)
  349. {
  350. var UserInfo = GetCurrentUser();
  351. var status = Convert.ToString(UserInfo.PersonProperty);
  352. model.registrant = UserInfo.Name;
  353. model.registrantID = UserInfo.PersonID;
  354. model.registrantProperty = UserInfo.PersonProperty;
  355. model.CompanyID = UserInfo.CompanyID;
  356. /// 获取登记流程ID和进入流程ID
  357. var sub = GetProceessID(UserInfo, model.InstitutionID, model.ProblemNature, model.ProjectID);
  358. model.ProcessID = sub.ProcessID;
  359. model.NextProcessID = sub.NextProcessID;
  360. var r = MoblieProblem_obj.SubmitProblem(status, model);
  361. if (!String.IsNullOrEmpty(r))
  362. {
  363. if (model.DealStatus != "1")
  364. {
  365. var ProblemID = projectProblems.GetWTID(r);
  366. RegistNotify(ProblemID);
  367. var str = "您有新的问题需要处理!";
  368. var ProcessRemark = "有新的问题登记,请注意查收!";
  369. Logger.Instance.Info("登记问题推送1" + model.ProjectID);
  370. if (model.ProjectID.IsNullOrEmpty())
  371. {
  372. model.ProjectID = UserInfo.DefaultProjectID;
  373. }
  374. Logger.Instance.Info("登记问题推送2" + model.ProjectID);
  375. var dt = Iperson_obj.GetCurrentProjectInfo(model.ProjectID);
  376. if (dt.Rows.Count > 0)
  377. {
  378. ProcessRemark ="【"+ dt.Rows[0].GetValueByName<string>("名称")+"】"+ "登记了新问题,请注意查收!";
  379. }
  380. WeChartPush(str, ProblemID, ProcessRemark, model.CompanyID);
  381. dt = null;
  382. }
  383. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, r, null).ToString(), "application/json");
  384. }
  385. else
  386. {
  387. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "登记失败!请联系管理员查看日志", null).ToString(), "application/json");
  388. }
  389. }
  390. /// <summary>
  391. /// 微信推送
  392. /// </summary>
  393. /// <param name="str">标题</param>
  394. /// <param name="ProblemID">问题id</param>
  395. /// <param name="ProcessRemark">内容</param>
  396. /// <param name="ChannelID">渠道id</param>
  397. private void WeChartPush(string str, string ProblemID, string ProcessRemark, string ChannelID)
  398. {
  399. //ProcessRemark = Tools.RemoveHTML(ProcessRemark);
  400. NotificationDto no = new NotificationDto();
  401. no.style = "3";
  402. no.template_code = "OIE51OsXeECnoPxGgPTQ7acXybc7t1plgAbdlH-mMWE";
  403. no.template_value = "{\"first\":{\"value\":\"" + str + "\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + DateTime.Now + "\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"" + ProcessRemark + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"点击【查看详情】立即查阅您的问题记录\",\"color\":\"#173177\"}}";
  404. no.url = "https://zlpms.zlsoft.com:8078/MobileProblem/ProblemDetail/" + ProblemID;
  405. List<MessageDetailsDto> list = new List<MessageDetailsDto>();
  406. var dt = MoblieProblem_obj.GetChannelExtend(ChannelID);
  407. if (dt != null && dt.Rows.Count > 0)
  408. {
  409. for (int i = 0; i < dt.Rows.Count; i++)
  410. {
  411. MessageDetailsDto mdd = new MessageDetailsDto();
  412. mdd.接收人id = dt.Rows[i].GetValueByName<string>("微信id");
  413. list.Add(mdd);
  414. }
  415. no.record_items = list;
  416. notice.SendWeChartTempletMessge(no);
  417. }
  418. }
  419. /// <summary>
  420. /// 获取登记流程ID和进入流程ID
  421. /// </summary>
  422. /// <param name="model"></param>
  423. /// <returns></returns>
  424. private SubmitProblemFormModel GetProceessID(UserInfo UserInfo, string Institution, int? ProblemProperty, string ProjectID)
  425. {
  426. SubmitProblemFormModel model = new SubmitProblemFormModel();
  427. WorkFlowModel workmodel = new WorkFlowModel();
  428. ///如果是用户或者是机构管理员
  429. if (UserInfo.PersonProperty == 3 || UserInfo.PersonProperty == 4)
  430. {
  431. workmodel = MoblieProblem_obj.GetNewProblemWorkId(UserInfo.OrgID, UserInfo.DefaultProjectID);
  432. }
  433. ///如果是中联人员或者卫计委
  434. else
  435. {
  436. workmodel = MoblieProblem_obj.GetNewProblemWorkId(Institution, ProjectID);
  437. }
  438. ///登记流程ID
  439. model.ProcessID = workmodel.ID;
  440. ///目录ID
  441. model.Catalog = workmodel.CategoryID ?? 1;
  442. ///获取进入流程ID
  443. model.NextProcessID = IWorkFlowModel.GetNewProblemWorkFlowID(model.Catalog, UserInfo.PersonProperty, (ProblemProperty ?? 1));
  444. return model;
  445. }
  446. /// <summary>
  447. /// 上传图片到FTP
  448. /// </summary>
  449. /// <param name="ProblemID"></param>
  450. /// <returns></returns>
  451. public ActionResult ImageUploadFTP(string ProblemID)
  452. {
  453. var result = "0";
  454. var files = this.Request.Files;
  455. if (this.Request.Files.Count > 0)
  456. {
  457. using (BinaryReader br = new BinaryReader(files[0].InputStream))
  458. {
  459. byte[] byteData = br.ReadBytes((int)files[0].InputStream.Length);
  460. var uploadFile = files[0];
  461. var fileName = uploadFile.FileName;
  462. var fileLen = uploadFile.ContentLength;
  463. string _tp = System.IO.Path.GetExtension(fileName);
  464. //判断附件类型
  465. string fileType = "2";
  466. if (_tp == ".jpg" || _tp == ".png" || _tp == ".jpeg" || _tp == ".bmp")
  467. {
  468. fileType = "1";
  469. }
  470. var UplodResult = UploadFile(byteData, fileName, _tp);
  471. if (UplodResult.code == 100)
  472. {
  473. ///数据库存储ID
  474. var Complete = MoblieProblem_obj.ImageUpload(ProblemID, UplodResult.data, GetCurrentUser().Name, fileType);
  475. if (Complete)
  476. {
  477. result = "1";
  478. }
  479. }
  480. }
  481. }
  482. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, result, null).ToString(), "application/json");
  483. }
  484. /// <summary>
  485. /// 获取项目机构树(权限)
  486. /// </summary>
  487. /// <returns></returns>
  488. public ActionResult GetProjectTree()
  489. {
  490. var json = Iperson_obj.GetProjectTree(GetAuthDats().Project);
  491. return Content(json, "application/json");
  492. }
  493. /// <summary>
  494. /// 通过产品Code获取项目机构树(权限)
  495. /// </summary>
  496. /// <param name="Code"></param>
  497. /// <returns></returns>
  498. public ActionResult GetProjectTreeByCode(string id)
  499. {
  500. var json = Iperson_obj.GetProjectTreeByCode(GetAuthDats().Project, id);
  501. return Content(json, "application/json");
  502. }
  503. /// <summary>
  504. /// 通过分类编码获取基础编码的Combobox(代码,显示名)
  505. /// </summary>
  506. /// <returns></returns>
  507. public ActionResult GetComboboxByCode(string id)
  508. {
  509. var json = BaseCode_obj.GetComboboxByCode(id);
  510. return Content(json, "application/json");
  511. }
  512. #endregion
  513. #region 问题查询业务
  514. /// <summary>
  515. /// 客户查询问题
  516. /// </summary>
  517. /// <param name="Model"></param>
  518. /// <returns></returns>
  519. public ActionResult QueryMyProblemByCustom(QueryMyProblemModel Model)
  520. {
  521. var UserInfo = GetCurrentUser();
  522. Model.CurrentUserId = UserInfo.PersonID;
  523. var dt = MoblieProblem_obj.QueryMyProblem(Model);
  524. return Content(dt.ToJson(), "application/json");
  525. }
  526. /// <summary>
  527. /// 获取项目数据权限combobox
  528. /// </summary>
  529. /// <returns></returns>
  530. public ActionResult GetAllProject()
  531. {
  532. var json = Iperson_obj.GetAllProject(GetAuthDats().Project);
  533. return Content(json, "application/json");
  534. }
  535. /// <summary>
  536. /// 获取机构索引
  537. /// </summary>
  538. /// <param name=""></param>
  539. /// <returns></returns>
  540. public ActionResult GetInstitutionIndex(string id)
  541. {
  542. var json = Pro_obj.GetInstitutionIndex(id);
  543. return Content(json, "application/json");
  544. }
  545. /// <summary>
  546. /// 根据权限和产品编码获取项目列表索引
  547. /// </summary>
  548. /// <param name="id"></param>
  549. /// <returns></returns>
  550. public ActionResult GetProjectIndexByCode(string id)
  551. {
  552. var json = Pro_obj.GetProjectIndexByCode(GetAuthDats().Project, id);
  553. return Content(json, "application/json");
  554. }
  555. public ActionResult SelectProblemItem()
  556. {
  557. ViewBag.PersonProperty = GetCurrentUser().PersonProperty;
  558. ViewBag.ProjectId = GetCurrentUser().DefaultProjectID;
  559. ViewBag.OrgID = GetCurrentUser().OrgID;
  560. return View();
  561. }
  562. /// <summary>
  563. /// 根据渠道获取项目索引
  564. /// </summary>
  565. /// <returns></returns>
  566. public ActionResult GetChannelProjectIndexByCode()
  567. {
  568. var json = Pro_obj.GetChannelProjectIndexByCode(GetCurrentUser().CompanyID);
  569. return Content(json, "application/json");
  570. }
  571. /// <summary>
  572. /// 项目人员问题查询
  573. /// </summary>
  574. /// <returns></returns>
  575. public ActionResult QueryProblemByProject(QueryProblemByProjectModel model)
  576. {
  577. var UserInfo = GetCurrentUser();
  578. model.CurrentUserId = UserInfo.PersonID;
  579. //如果选择所有项目,则取所有权限项目
  580. if (model.Project == "all")
  581. {
  582. model.Project = GetAuthDats().Project;
  583. }
  584. var dt = MoblieProblem_obj.QueryProblemByProject(model);
  585. if (dt != null && dt.Rows.Count > 0)
  586. {
  587. //获取当前登陆人应在的处理环节
  588. var CurrentLink = MoblieProblem_obj.GetUserLinkId(UserInfo.PersonProperty, UserInfo.JobCode);
  589. foreach (DataRow dr in dt.Rows)
  590. {
  591. //判断当前处理人是否为自己 以及 按钮权限
  592. if (UserInfo.PersonID != dr.GetValueByName<string>("受理人id"))
  593. {
  594. dr["是否为当前处理人"] = '0';
  595. }
  596. //判断是否解决或是否终止
  597. if (dr.GetValueByName<int>("是否解决") == 1 || dr.GetValueByName<int>("是否终止") == 1)
  598. {
  599. dr["按钮权限"] = '0';
  600. }
  601. ///判断是否越级
  602. if (CurrentLink < dr.GetValueByName<int>("环节id"))
  603. {
  604. dr["按钮权限"] = '0';
  605. }
  606. }
  607. }
  608. return Content(dt.ToJson(), "application/json");
  609. }
  610. /// <summary>
  611. /// 获取医院管理员所属项目和机构
  612. /// </summary>
  613. /// <returns></returns>
  614. public ActionResult GetPerson()
  615. {
  616. var json = MoblieProblem_obj.GetPerson(GetCurrentUser().PersonID);
  617. return Content(json, "application/json");
  618. }
  619. #endregion
  620. #region 问题详细相关业务
  621. /// <summary>
  622. /// 获取产品问题过程处理流程
  623. /// </summary>
  624. /// <returns></returns>
  625. public ActionResult GetClc(string id)
  626. {
  627. return Content(ZpwtgcModel.GetClc(id), "application/json");
  628. }
  629. /// <summary>
  630. /// 获取产品问题过程沟通需要的信息
  631. /// </summary>
  632. /// <param name="ID"></param>
  633. /// <returns></returns>
  634. public ActionResult GetCommunicates(string id)
  635. {
  636. return Content(ZpwtgcModel.GetCommunicates(id), "application/json");
  637. }
  638. /// <summary>
  639. /// 保存问题沟通
  640. /// </summary>
  641. /// <param name="model"></param>
  642. /// <returns></returns>
  643. public ActionResult SubmitContent(CPWTGCModel model)
  644. {
  645. model.JLSJ = DateTime.Now;
  646. var UserInfo = GetCurrentUser();
  647. model.JLRID = UserInfo.PersonID;
  648. string result = ZpwtgcModel.SubmitContent(model);
  649. string[] results = result.Split('|');
  650. if (results[0] == "1")
  651. {
  652. return this.ResponseJson(System.Net.HttpStatusCode.OK, "保存成功");
  653. }
  654. return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "保存失败");
  655. }
  656. /// <summary>
  657. /// 获取问题的图片
  658. /// </summary>
  659. /// <param name="id"></param>
  660. /// <returns></returns>
  661. public ActionResult GetFileFormFTP(string id)
  662. {
  663. var dt = MoblieProblem_obj.GetFileFormFTP(id);
  664. return Content(dt.ToJson(), "application/json");
  665. }
  666. public ActionResult QuerckSearch(QueryMyProblemModel model)
  667. {
  668. model.CurrentUserId = GetCurrentUser().PersonID;
  669. var json = MoblieProblem_obj.QuerckSearch(model);
  670. return Content(json, "application/json");
  671. }
  672. #endregion
  673. #region 问题操作相关业务
  674. /// <summary>
  675. /// 受理问题
  676. /// </summary>
  677. /// <param name="id"></param>
  678. /// <returns></returns>
  679. public ActionResult AcceptProblem(string id)
  680. {
  681. ///判断用户权限
  682. var UserInfo = GetCurrentUser();
  683. var PersonProperty = UserInfo.PersonProperty;
  684. var jude = CrossJud(id, PersonProperty, UserInfo.JobCode);
  685. if (!jude)
  686. {
  687. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "您的权限不足,不能受理该问题", null).ToString(), "application/json");
  688. }
  689. //获取进入流程ID
  690. var WorkId = IWorkFlowModel.GetDealWorkId(id, UserInfo.PersonProperty, UserInfo.JobCode);
  691. //受理问题
  692. var DealModel = new ProblemDealModel();
  693. DealModel.ProblemId = id;
  694. DealModel.NextWorkId = WorkId;
  695. DealModel.DealPeronName = UserInfo.Name;
  696. DealModel.DealPeronId = UserInfo.PersonID;
  697. var re = IWorkFlowModel.ProblemAccept(DealModel);
  698. if (re)
  699. {
  700. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "受理成功!", null).ToString(), "application/json");
  701. }
  702. else
  703. {
  704. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "受理失败!", null).ToString(), "application/json");
  705. }
  706. }
  707. /// <summary>
  708. /// 越级判断
  709. /// </summary>
  710. /// <param name="ProblemId"></param>
  711. /// <param name="PersonProperty"></param>
  712. /// <returns></returns>
  713. private bool CrossJud(string ProblemId, int PersonProperty, string JobCode)
  714. {
  715. return MoblieProblem_obj.CrossJud(ProblemId, PersonProperty, JobCode);
  716. }
  717. /// <summary>
  718. /// 判断是否为自己处理的问题
  719. /// </summary>
  720. /// <param name="id"></param>
  721. /// <returns></returns>
  722. public ActionResult IsMyProblem(string id)
  723. {
  724. var json = MoblieProblem_obj.IsMyProblem(id, GetCurrentUser().PersonID);
  725. return Content(json, "application/json");
  726. }
  727. /// <summary>
  728. /// 问题回退,终止
  729. /// </summary>
  730. /// <param name="id"></param>
  731. /// <param name="type"></param>
  732. /// <param name="Deatil"></param>
  733. /// <returns></returns>
  734. public ActionResult ProblemBackSubmit(string id, string type, string Deatil)
  735. {
  736. var UserInfo = GetCurrentUser();
  737. var DealModel = new ProblemDealModel();
  738. DealModel.ProblemId = id;
  739. DealModel.DealPeronName = UserInfo.Name;
  740. DealModel.DealPeronId = UserInfo.PersonID;
  741. DealModel.Describe = Deatil;
  742. bool re = false;
  743. string ProcessId = string.Empty;
  744. ///回退问题
  745. if (type == "1")
  746. {
  747. DealModel.NextWorkId = IWorkFlowModel.GetBackProblemWorkFlowID(id);
  748. ///如果回退的下个流程不存在
  749. if (DealModel.NextWorkId < 1)
  750. {
  751. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "问题已在最初始状态,无法回退!", null).ToString(), "application/json");
  752. }
  753. re = IWorkFlowModel.ProblemRollBack(DealModel, out ProcessId);
  754. }
  755. ///终止问题
  756. else
  757. {
  758. re = IWorkFlowModel.ProblemBreak(DealModel, out ProcessId);
  759. }
  760. //返回
  761. if (re)
  762. {
  763. if (type == "1")
  764. {
  765. DealNotify(DealModel.ProblemId, 1 );
  766. }
  767. var ProblemProcessModel = new ProblemProcessModel()
  768. {
  769. IsBack = (type=="1"),
  770. IsStop= (type != "1"),
  771. ProblemID = DealModel.ProblemId
  772. };
  773. SitePush(ProblemProcessModel);
  774. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, ProcessId, null).ToString(), "application/json");
  775. }
  776. else
  777. {
  778. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "操作失败!", null).ToString(), "application/json");
  779. }
  780. }
  781. /// <summary>
  782. /// 获取渠道Combobox
  783. /// </summary>
  784. /// <returns></returns>
  785. public ActionResult GetChannel()
  786. {
  787. var json = IChannel.GetChannelCombo();
  788. return Content(json, "application/json");
  789. }
  790. /// <summary>
  791. /// 获取项目Combobox
  792. /// </summary>
  793. /// <param name="id"></param>
  794. /// <returns></returns>
  795. public ActionResult GetProject(string id)
  796. {
  797. var json = IChannel.GetProjectCombobox(id);
  798. return Content(json, "application/json");
  799. }
  800. /// <summary>
  801. /// 获取分配人员
  802. /// </summary>
  803. /// <returns></returns>
  804. public ActionResult GetDistribuPerson(string search, string problemId)
  805. {
  806. var UserInfo = GetCurrentUser();
  807. var json = MoblieProblem_obj.GetPerson(search, UserInfo.PersonProperty, problemId);
  808. return Content(json, "application/json");
  809. }
  810. /// <summary>
  811. /// 问题分配
  812. /// </summary>
  813. /// <param name="id"></param>
  814. /// <param name="PersonID"></param>
  815. /// <param name="PersonName"></param>
  816. /// <param name="Deatil"></param>
  817. /// <returns></returns>
  818. public ActionResult ProblemDistributeSubmit(string id, string PersonID, string PersonName, string Deatil)
  819. {
  820. var UserInfo = GetCurrentUser();
  821. ///获取分配人的人员性质和职务
  822. var User = MoblieProblem_obj.GetPersonProperty(PersonID);
  823. ///判断分配人是否有处理环节
  824. var IsDealProcess = MoblieProblem_obj.IsDealProcess(id, User.PersonProperty);
  825. if (!IsDealProcess)
  826. {
  827. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "分配失败,分配人未配置环节,请联系管理员!", null).ToString(), "application/json");
  828. }
  829. //获取进入流程ID
  830. var WorkId = IWorkFlowModel.GetDealWorkId(id, User.PersonProperty, User.JobCode);
  831. //分配人员
  832. var DealModel = new ProblemDealModel();
  833. DealModel.ProblemId = id;
  834. DealModel.Describe = Deatil;
  835. DealModel.NextWorkId = WorkId;
  836. DealModel.DealPeronId = UserInfo.PersonID;
  837. DealModel.AssignPersonName = PersonName;
  838. DealModel.AssignPersonId = PersonID;
  839. string ProcessId = string.Empty;
  840. var re = IWorkFlowModel.ProblemAssgin(DealModel, out ProcessId);
  841. if (re)
  842. {
  843. var ProblemProcessModel = new ProblemProcessModel()
  844. {
  845. IsAssign=true,
  846. AssignID= DealModel.AssignPersonId,
  847. ProblemID= id
  848. };
  849. SitePush(ProblemProcessModel);
  850. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, ProcessId, null).ToString(), "application/json");
  851. }
  852. else
  853. {
  854. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "分配失败!", null).ToString(), "application/json");
  855. }
  856. }
  857. /// <summary>
  858. /// 获取存在产品问题的产品所有版本
  859. /// </summary>
  860. /// <param name="id"></param>
  861. /// <returns></returns>
  862. public ActionResult GetProblemVison(string id)
  863. {
  864. var json = MoblieProblem_obj.GetProblemVison(id);
  865. return Content(json, "application/json");
  866. }
  867. public ActionResult ProblemDealSubmit(ProblemDealForm Model)
  868. {
  869. var UserInfo = GetCurrentUser();
  870. var DealModel = new ProblemDealModel();
  871. DealModel.ProblemId = Model.ProblemID;
  872. DealModel.Describe = Model.DealDescribe;
  873. DealModel.DealPeronId = UserInfo.PersonID;
  874. DealModel.DealPeronName = UserInfo.Name;
  875. //获取进入流程ID
  876. DealModel.NextWorkId = IWorkFlowModel.GetDealWorkId(Model.ProblemID, UserInfo.PersonProperty, UserInfo.JobCode);
  877. bool re;
  878. string ProcessId = string.Empty;
  879. ///如果处理完成
  880. if (Model.Iscomplete)
  881. {
  882. DealModel.Solution = Model.DealDescribe;
  883. DealModel.Version = Model.Vision;
  884. re = IWorkFlowModel.ProblemSolution(DealModel, out ProcessId, UserInfo);
  885. }
  886. //如果未完成
  887. else
  888. {
  889. re = IWorkFlowModel.ProblemDeal(DealModel, out ProcessId);
  890. }
  891. //判断执行状态
  892. if (re)
  893. {
  894. if (Model.Iscomplete)
  895. {
  896. var ProblemProcessModel = new ProblemProcessModel()
  897. {
  898. IsSolve=true,
  899. ProblemID= DealModel.ProblemId
  900. };
  901. SitePush(ProblemProcessModel);
  902. }
  903. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, ProcessId, null).ToString(), "application/json");
  904. }
  905. else
  906. {
  907. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "处理失败!", null).ToString(), "application/json");
  908. }
  909. }
  910. /// <summary>
  911. /// 问题向上提交
  912. /// </summary>
  913. /// <param name="id"></param>
  914. /// <returns></returns>
  915. public ActionResult ProblemPutSubmit(string id)
  916. {
  917. var UserInfo = GetCurrentUser();
  918. var DealModel = new ProblemDealModel();
  919. DealModel.ProblemId = id;
  920. DealModel.DealPeronId = UserInfo.PersonID;
  921. //获取提交问题进入流程ID
  922. DealModel.NextWorkId = IWorkFlowModel.GetSubmitProblemWorkFlowID(UserInfo.PersonProperty, id);
  923. var re = IWorkFlowModel.ProblemSubmit(DealModel);
  924. //判断执行状态
  925. if (re)
  926. {
  927. DealNotify(DealModel.ProblemId, 2);
  928. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "提交成功!", null).ToString(), "application/json");
  929. }
  930. else
  931. {
  932. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "提交失败!", null).ToString(), "application/json");
  933. }
  934. }
  935. /// <summary>
  936. /// 上传附件到FTP并保存到问题附件
  937. /// </summary>
  938. /// <param name="file"></param>
  939. /// <param name="Model"></param>
  940. /// <returns></returns>
  941. public ActionResult FlieUploadAndSave(string ProcessId)
  942. {
  943. var files = this.Request.Files;
  944. var rs = false;
  945. var Model = new ProcessFileModel();
  946. Model.Name = GetCurrentUser().Name;
  947. Model.ProcessId = ProcessId;
  948. if (files.Count > 0)
  949. {
  950. for (int i = 0; i < files.Count; i++)
  951. {
  952. using (BinaryReader br = new BinaryReader(files[i].InputStream))
  953. {
  954. byte[] byteData = br.ReadBytes((int)files[i].InputStream.Length);
  955. var uploadFile = files[i];
  956. var fileName = uploadFile.FileName;
  957. string _tp = System.IO.Path.GetExtension(fileName);
  958. //判断附件类型
  959. string fileType = "2";
  960. if (_tp == ".jpg" || _tp == ".png" || _tp == ".jpeg" || _tp == ".bmp")
  961. {
  962. fileType = "1";
  963. }
  964. Model.Type = fileType;
  965. //上传
  966. var UplodResult = UploadFile(byteData, fileName, _tp);
  967. ///是否上传成功
  968. if (UplodResult.code == 100)
  969. {
  970. ///保存到问题附件表
  971. Model.FileId = UplodResult.data;
  972. rs = IWorkFlowModel.SaveProcessFile(Model);
  973. }
  974. }
  975. }
  976. }
  977. if (rs)
  978. {
  979. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "成功", null).ToString(), "application/json");
  980. }
  981. else
  982. {
  983. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "失败", null).ToString(), "application/json");
  984. }
  985. }
  986. /// <summary>
  987. /// 上传附件到FTP并保存到问题附件(base64)
  988. /// </summary>
  989. /// <param name="ProcessId"></param>
  990. /// <returns></returns>
  991. public ActionResult Base64UploadAndSave(string ProcessId, string dataURL, string name)
  992. {
  993. var rs = false;
  994. var Model = new ProcessFileModel();
  995. Model.Name = GetCurrentUser().Name;
  996. Model.ProcessId = ProcessId;
  997. Model.Type = "1";
  998. name += ".jpeg";
  999. if (!string.IsNullOrEmpty(dataURL))
  1000. {
  1001. String base64 = dataURL.Substring(dataURL.IndexOf(",") + 1);
  1002. byte[] byteData = Convert.FromBase64String(base64);
  1003. //上传
  1004. var UplodResult = UploadFile(byteData, name, ".jpeg");
  1005. ///是否上传成功
  1006. if (UplodResult.code == 100)
  1007. {
  1008. ///保存到问题附件表
  1009. Model.FileId = UplodResult.data;
  1010. rs = IWorkFlowModel.SaveProcessFile(Model);
  1011. }
  1012. }
  1013. if (rs)
  1014. {
  1015. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "成功", null).ToString(), "application/json");
  1016. }
  1017. else
  1018. {
  1019. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "失败", null).ToString(), "application/json");
  1020. }
  1021. }
  1022. //查看附件图像(id:附件id,type:缩略图o原图,s缩略图,m大图)
  1023. public ActionResult ViewProblemImage(string id, string type)
  1024. {
  1025. try
  1026. {
  1027. if (string.IsNullOrEmpty(type))
  1028. {//文件流传输
  1029. var obj = DownloadFileBase64(id, string.Empty);
  1030. if (obj != null)
  1031. {
  1032. //将base64转bytes
  1033. var data = Convert.FromBase64String(obj.base64);
  1034. return File(data, "application/octet-stream", obj.fileName);
  1035. }
  1036. else
  1037. {
  1038. Logger.Instance.Warn("未获取到文件对象:" + id);
  1039. return View();
  1040. }
  1041. }
  1042. else
  1043. {//图像传输
  1044. var data = base.DownloadFileBytes(id, type);
  1045. return File(data, "image/jpeg");
  1046. }
  1047. }
  1048. catch (Exception ex)
  1049. {
  1050. Logger.Instance.Warn("问题件服务器出现了异常:" + ex.Message);
  1051. return View();
  1052. }
  1053. }
  1054. /// <summary>
  1055. /// 获取图片Base64
  1056. /// </summary>
  1057. /// <param name="id"></param>
  1058. /// <returns></returns>
  1059. public ActionResult GetBase64(string id)
  1060. {
  1061. var obj = DownloadFileBase64(id, string.Empty);
  1062. FTPFileModel model = new FTPFileModel
  1063. {
  1064. base64 = obj.base64,
  1065. fileName = obj.fileName,
  1066. format = obj.format
  1067. };
  1068. return Content(model.base64ToImage, "application/json");
  1069. }
  1070. /// <summary>
  1071. /// 获取问题信息
  1072. /// </summary>
  1073. /// <param name="id"></param>
  1074. /// <returns></returns>
  1075. public ActionResult GetProblemInfomation(string id)
  1076. {
  1077. var json = MoblieProblem_obj.GetProblemInfomation(id);
  1078. return Content(json, "application/json");
  1079. }
  1080. /// <summary>
  1081. /// 修改问题
  1082. /// </summary>
  1083. /// <param name="model"></param>
  1084. /// <returns></returns>
  1085. public ActionResult ModifySubmit(SubmitProblemFormModel model)
  1086. {
  1087. var UserInfo = GetCurrentUser();
  1088. model.registrantID = UserInfo.PersonID;
  1089. string r;
  1090. //判断是否为自己登记的问题(管理员可以修改他人的问题)
  1091. var s = MoblieProblem_obj.IsModifyMyProblem(UserInfo.PersonID, model.ProblemId);
  1092. if (!s && UserInfo.PersonProperty==3)
  1093. {
  1094. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "不能修改他人登记的问题!", null).ToString(), "application/json");
  1095. }
  1096. if (UserInfo.PersonProperty == 3)
  1097. {
  1098. r = MoblieProblem_obj.ModifySubmitForCustom(model);
  1099. }
  1100. else
  1101. {
  1102. r = MoblieProblem_obj.ModifySubmit(model);
  1103. }
  1104. if (!String.IsNullOrEmpty(r))
  1105. {
  1106. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, r, null).ToString(), "application/json");
  1107. }
  1108. else
  1109. {
  1110. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "修改失败!请联系管理员查看日志", null).ToString(), "application/json");
  1111. }
  1112. }
  1113. /// <summary>
  1114. /// 获取问题登记的附件
  1115. /// </summary>
  1116. public ActionResult GetProblemFlie(string id)
  1117. {
  1118. var json = MoblieProblem_obj.GetProblemFlie(id);
  1119. return Content(json, "application/json");
  1120. }
  1121. #endregion
  1122. #region 获取验证码
  1123. public ActionResult GetSMSCodeCurrent()
  1124. {
  1125. bool r = false;
  1126. ///发送短信
  1127. var tele = GetCurrentUser().Account;
  1128. //var smsSend = SysCom.Instance.ZlsoftAppSms(tele);
  1129. var dt = account_obj.GetTelAccountInfo(tele);
  1130. if (dt != null && dt.Rows.Count > 0)
  1131. {
  1132. }
  1133. else
  1134. {
  1135. Logger.Instance.Info("手机号未注册,就在进行发验证码"+tele);
  1136. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "当前手机号未生成账号,请点击右上角先进行注册", null).ToString(), "application/json");
  1137. }
  1138. var code = "";
  1139. var smsSend = SendSMS.SendKuaiZiSMS(tele,ref code);
  1140. if (!string.IsNullOrEmpty(code))
  1141. {
  1142. r = MoblieProblem_obj.GetSMSCode(tele, code);
  1143. }
  1144. if (r)
  1145. {
  1146. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "发送成功,10分钟内有效!", null).ToString(), "application/json");
  1147. }
  1148. else
  1149. {
  1150. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "短信发送失败,请联系管理员", null).ToString(), "application/json");
  1151. }
  1152. }
  1153. /// <summary>
  1154. /// 修改密码
  1155. /// </summary>
  1156. /// <param name="telephone"></param>
  1157. /// <param name="Code"></param>
  1158. /// <param name="password"></param>
  1159. /// <returns></returns>
  1160. public ActionResult PasswordModifySubmit(string Code, string password)
  1161. {
  1162. var r = MoblieProblem_obj.PasswordModifySubmit(GetCurrentUser().Account, Code, password);
  1163. if (r == "1")
  1164. {
  1165. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "修改成功", null).ToString(), "application/json");
  1166. }
  1167. else
  1168. {
  1169. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, r, null).ToString(), "application/json");
  1170. }
  1171. }
  1172. #endregion
  1173. #region 向客户端发送更新操作
  1174. /// <summary>
  1175. /// 向客户端发送更新操作
  1176. /// </summary>
  1177. /// <param name="Processid">问题流程ID</param>
  1178. private void RefreshProblem(string id)
  1179. {
  1180. var HJID = MoblieProblem_obj.GetProblemByProcssId(id);
  1181. if (HJID <= 3)
  1182. {//更新项目问题管理列表
  1183. App_Start.ClientManager.RefreshProblem("1");
  1184. }
  1185. else if (HJID == 4)
  1186. {//更新技术支持
  1187. App_Start.ClientManager.RefreshProblem("2");
  1188. }
  1189. else
  1190. {//研发
  1191. App_Start.ClientManager.RefreshProblem("3");
  1192. }
  1193. }
  1194. /// <summary>
  1195. /// 向客户端发送更新操作
  1196. /// </summary>
  1197. /// <param name="id">工作流ID</param>
  1198. private void RefreshProblemByWorkId(int id)
  1199. {
  1200. try
  1201. {
  1202. var HJID = MoblieProblem_obj.GetProblemByWorkId(id);
  1203. if (HJID <= 3)
  1204. {//更新项目问题管理列表
  1205. App_Start.ClientManager.RefreshProblem("1");
  1206. }
  1207. else if (HJID == 4)
  1208. {//更新技术支持
  1209. App_Start.ClientManager.RefreshProblem("2");
  1210. }
  1211. else
  1212. {//研发
  1213. App_Start.ClientManager.RefreshProblem("3");
  1214. }
  1215. }
  1216. catch(Exception ex)
  1217. {
  1218. Logger.Instance.Error("更新客户端出错", ex);
  1219. }
  1220. }
  1221. //站点推送
  1222. private void SitePush(ProblemProcessModel model)
  1223. {
  1224. var userInfo = GetCurrentUser();
  1225. try
  1226. {
  1227. if (model.IsAssign)
  1228. {//处理成功与指派人员时需要向该被指派人员推送消息
  1229. var NotefiyConfigInfo = projectProblems.GetNotifyConfigInfoByUserId(model.AssignID);
  1230. if (NotefiyConfigInfo != null && NotefiyConfigInfo.Assign.SendSite)
  1231. this.SendDealMessage(model.ProblemID,model.AssignID, "有新的问题指派给您,请注意查收!",1);
  1232. }
  1233. else if (model.IsSolve)
  1234. {
  1235. var WTJLModel = projectProblems.GetWTJLModel(model.ProblemID);
  1236. var NotefiyConfigInfo = projectProblems.GetNotifyConfigInfoByUserId(WTJLModel.DJRID);
  1237. if (NotefiyConfigInfo != null && NotefiyConfigInfo.SolveTime.SendSite)
  1238. {
  1239. var str = "您的编号为【" + WTJLModel.BH.ToString() + "】的问题已被解决,处理人:" + WTJLModel.SLR;
  1240. this.SendDealMessage(model.ProblemID,WTJLModel.DJRID, str,2);
  1241. }
  1242. }
  1243. else if (model.IsBack)
  1244. {
  1245. var WTJLModel = projectProblems.GetWTJLModel(model.ProblemID);
  1246. var NotefiyConfigInfo = projectProblems.GetNotifyConfigInfoByUserId(WTJLModel.DJRID);
  1247. if (NotefiyConfigInfo != null && NotefiyConfigInfo.BackTime.SendSite)
  1248. {
  1249. var str = "您的编号为【" + WTJLModel.BH.ToString() + "】的问题已被回退,处理人:" + userInfo.Name;
  1250. this.SendDealMessage(model.ProblemID,WTJLModel.DJRID, str,3);
  1251. }
  1252. }
  1253. else if (model.IsStop)
  1254. {
  1255. var WTJLModel = projectProblems.GetWTJLModel(model.ProblemID);
  1256. var NotefiyConfigInfo = projectProblems.GetNotifyConfigInfoByUserId(WTJLModel.DJRID);
  1257. if (NotefiyConfigInfo != null && NotefiyConfigInfo.StopTime.SendSite)
  1258. {
  1259. var str = "您的编号为【" + WTJLModel.BH.ToString() + "】的问题已被终止,处理人:" + userInfo.Name;
  1260. this.SendDealMessage(model.ProblemID,WTJLModel.DJRID, str,4);
  1261. }
  1262. }
  1263. else if (model.IsCommit && !string.IsNullOrEmpty(model.SubID))
  1264. {
  1265. var NotefiyConfigInfo = projectProblems.GetNotifyConfigInfoByUserId(model.SubID);
  1266. if (NotefiyConfigInfo != null && NotefiyConfigInfo.Assign.SendSite)
  1267. this.SendDealMessage(model.ProblemID,model.SubID, "有新的问题提交给您,请注意查收!",5);
  1268. }
  1269. }
  1270. catch (Exception ex)
  1271. {
  1272. Logger.Instance.Error("站点推送失败,原因:" + ex);
  1273. }
  1274. }
  1275. //登记问题获取推送人
  1276. private List<string> GetPushPerson(string ProblemId)
  1277. {
  1278. ///通过问题流程Id获取问题Id
  1279. var PersonId = GetCurrentUser().PersonID;
  1280. var list = projectProblems.GetPushPerson(ProblemId);
  1281. //去除自己
  1282. list.Remove(PersonId);
  1283. return list;
  1284. }
  1285. /// <summary>
  1286. /// 登记推送
  1287. /// </summary>
  1288. /// <param name="id"></param>
  1289. private void RegistNotify(string id)
  1290. {
  1291. var PushPerson = GetPushPerson(id);
  1292. var PushPersonTask = Task.Factory.StartNew(() => Parallel.ForEach<string>(PushPerson, item => this.RefreshProblemAndSendMessage(item, "有新的问题登记,请注意查收!",id)));
  1293. Task.WaitAll(PushPersonTask);
  1294. return;
  1295. }
  1296. /// <summary>
  1297. /// 回退和向上提交的问题推送
  1298. /// </summary>
  1299. /// <param name="id"></param>
  1300. private void DealNotify(string id, int type)
  1301. {
  1302. string Message;
  1303. if (type == 1)
  1304. {
  1305. //回退
  1306. Message = "有新的问题回退,请注意查收!";
  1307. }
  1308. else
  1309. {//提交
  1310. Message = "有新的问题向上提交,请注意查收!";
  1311. }
  1312. var PushPerson = GetPushPerson(id);
  1313. var PushPersonTask = Task.Factory.StartNew(() => Parallel.ForEach<string>(PushPerson, item => this.RefreshProblemAndSendMessage(item, Message, id)));
  1314. Task.WaitAll(PushPersonTask);
  1315. return;
  1316. }
  1317. #endregion
  1318. #region 版本问题查询
  1319. public ActionResult VersionProblem()
  1320. {
  1321. return View();
  1322. }
  1323. public ActionResult VersionProblemDeatil(string id,string vpid)
  1324. {
  1325. var UserInfo = GetCurrentUser();
  1326. var json = MoblieProblem_obj.ProblemDetail(id, UserInfo.PersonID);
  1327. var Model = Strings.JsonToModel<ProblemDetailModel>(json);
  1328. ViewBag.ID = id;
  1329. ViewBag.vpid = vpid;
  1330. ViewBag.PersonProperty = UserInfo.PersonProperty;
  1331. return View(Model);
  1332. }
  1333. /// <summary>
  1334. /// 获取版本问题说明及其补丁
  1335. /// </summary>
  1336. /// <param name="id"></param>
  1337. /// <returns></returns>
  1338. public ActionResult getVersionPoblemExplain(string id)
  1339. {
  1340. var json = MoblieProblem_obj.getVersionPoblemExplain(id);
  1341. return Content(json, "application/json");
  1342. }
  1343. /// <summary>
  1344. /// 下载版本附件
  1345. /// </summary>
  1346. /// <param name="id"></param>
  1347. /// <param name="type"></param>
  1348. /// <returns></returns>
  1349. public ActionResult DownLoadVersionFile(string id, string type,string flieVersionId)
  1350. {
  1351. if (string.IsNullOrEmpty(type))
  1352. {//文件流传输
  1353. var obj = DownloadFileBase64(id, string.Empty);
  1354. if (obj != null)
  1355. {
  1356. //将base64转bytes
  1357. var data = Convert.FromBase64String(obj.base64);
  1358. MoblieProblem_obj.SaveLogger(id, flieVersionId, GetCurrentUser().PersonID);
  1359. return File(data, "application/octet-stream", obj.fileName);
  1360. }
  1361. else
  1362. {
  1363. Logger.Instance.Warn("未获取到文件对象:" + id);
  1364. return View();
  1365. }
  1366. }
  1367. else
  1368. {//图像传输
  1369. var data = base.DownloadFileBytes(id, type);
  1370. return File(data, "image/jpeg");
  1371. }
  1372. }
  1373. #endregion
  1374. #region 我的评价
  1375. /// <summary>
  1376. /// 我的评价-首页
  1377. /// </summary>
  1378. /// <returns></returns>
  1379. public ActionResult MyComments()
  1380. {
  1381. ViewBag.PersonPropert = GetCurrentUser().PersonProperty;
  1382. return View();
  1383. }
  1384. /// <summary>
  1385. ///获取待评价已评价的问题列表
  1386. /// </summary>
  1387. /// <param name="model"></param>
  1388. /// <param name="ID"></param>
  1389. /// <returns></returns>
  1390. public ActionResult GetQuestionList(MyCommModel model)
  1391. {
  1392. int total = 0;
  1393. var user = GetCurrentUser();
  1394. model.PersonId = user.PersonID;
  1395. var result = MoblieProblem_obj.GetQuestionList(model.PersonId, model.pageindex, model.pagesize,model.Tab, out total);
  1396. return Content(result, "application/json");
  1397. }
  1398. /// <summary>
  1399. /// 获取已评价后的内容
  1400. /// </summary>
  1401. /// <param name="ProblemID">问题id</param>
  1402. /// <returns></returns>
  1403. public ActionResult GetEvaluationContent(string ProblemID)
  1404. {
  1405. var user = GetCurrentUser();
  1406. var result = MoblieProblem_obj.GetEvaluationContent(user.PersonID, ProblemID);
  1407. return Content(result, "application/json");
  1408. }
  1409. /// <summary>
  1410. /// 问题评价
  1411. /// </summary>
  1412. /// <param name="id"></param>
  1413. /// <returns></returns>
  1414. public ActionResult ProblemReamrk(string id)
  1415. {
  1416. var UserInfo = GetCurrentUser();
  1417. ViewBag.ID = id;
  1418. var json = MoblieProblem_obj.ProblemDetail(id, UserInfo.PersonID);
  1419. var Model = Strings.JsonToModel<ProblemDetailModel>(json);
  1420. ViewBag.PersonProperty = UserInfo.PersonProperty;
  1421. return View(Model);
  1422. }/// <summary>
  1423. /// 提交评论
  1424. /// </summary>
  1425. /// <returns></returns>
  1426. public ActionResult ProblemReamrkSubmit(commentsModel model)
  1427. {
  1428. string CommentsId = string.Empty;
  1429. var user = GetCurrentUser();
  1430. model.CommitPerson = user.Name;
  1431. model.CommitPersonId = user.PersonID;
  1432. var r = MoblieProblem_obj.ProblemReamrkSubmit(model, out CommentsId);
  1433. var json = new
  1434. {
  1435. Code = r ? "200" : "0",
  1436. CommentsId = CommentsId
  1437. };
  1438. return Content(Strings.ObjectToJson(json), "application/json");
  1439. }
  1440. public ActionResult CommitUpload(CommitFlie model, string ID)
  1441. {
  1442. var files = this.Request.Files;
  1443. var rs = false;
  1444. model.CommitId = ID;
  1445. model.Name = GetCurrentUser().Name;
  1446. if (files.Count > 0)
  1447. {
  1448. for (int i = 0; i < files.Count; i++)
  1449. {
  1450. using (BinaryReader br = new BinaryReader(files[i].InputStream))
  1451. {
  1452. byte[] byteData = br.ReadBytes((int)files[i].InputStream.Length);
  1453. var uploadFile = files[i];
  1454. var fileName = uploadFile.FileName;
  1455. string _tp = System.IO.Path.GetExtension(fileName);
  1456. //判断附件类型
  1457. string fileType = "2";
  1458. if (_tp == ".jpg" || _tp == ".png" || _tp == ".jpeg" || _tp == ".bmp")
  1459. {
  1460. fileType = "1";
  1461. }
  1462. model.FlieType = fileType;
  1463. //上传
  1464. var UplodResult = UploadFile(byteData, fileName, _tp);
  1465. ///是否上传成功
  1466. if (UplodResult.code == 100)
  1467. {
  1468. ///保存到评价附件表
  1469. model.FlieID = UplodResult.data;
  1470. rs = MoblieProblem_obj.CommitFlieUplod(model);
  1471. }
  1472. }
  1473. }
  1474. }
  1475. if (rs)
  1476. {
  1477. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "成功", null).ToString(), "application/json");
  1478. }
  1479. else
  1480. {
  1481. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "失败", null).ToString(), "application/json");
  1482. }
  1483. }
  1484. /// <summary>
  1485. /// 判断是否能够评价
  1486. /// </summary>
  1487. /// <param name="ProblemId"></param>
  1488. /// <returns></returns>
  1489. public ActionResult IsCommit(string id)
  1490. {
  1491. var r = MoblieProblem_obj.IsCommit(id, GetCurrentUser().PersonID);
  1492. return Content(r ? "1" : "0");
  1493. }
  1494. /// <summary>
  1495. /// 获取文件图片
  1496. /// </summary>
  1497. /// <param name="id">评价id</param>
  1498. /// <returns></returns>
  1499. public ActionResult GetEvaluationFile(string id)
  1500. {
  1501. var r = MoblieProblem_obj.GetEvaluationFile(id);
  1502. return Content(r, "application/json");
  1503. }
  1504. #endregion
  1505. }
  1506. }