ComplaintController.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. using PMS.BusinessModels.Account;
  2. using PMS.BusinessModels.ComplaintManage;
  3. using PMS.EntityModels.PersonManager;
  4. using PMS.Interface;
  5. using PMS.Interface.BaseCode;
  6. using PMS.Interface.ComplaintManage;
  7. using PMS.Interface.SysManager;
  8. using QWPlatform.SystemLibrary.Security;
  9. using QWPlatform.SystemLibrary.Web;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Web;
  16. using System.Web.Mvc;
  17. using Newtonsoft.Json;
  18. using QWPlatform.SystemLibrary.Utils;
  19. namespace PMS.WebUI.Controllers
  20. {
  21. [CheckLogin("/MobileAccount/ComplaintLogin")]
  22. public class ComplaintController : BaseController
  23. {
  24. IComplaintList Complaint_List = InterfaceFactory.CreateBusinessInstance<IComplaintList>();
  25. IBaseCode BaseCode_obj = InterfaceFactory.CreateBusinessInstance<IBaseCode>();
  26. // GET: Complaint
  27. public ActionResult ComplaintUser()
  28. {
  29. return View();
  30. }
  31. public ActionResult NewComplaint()
  32. {
  33. return View();
  34. }
  35. public ActionResult QueryComplaint()
  36. {
  37. return View();
  38. }
  39. public ActionResult ComplaintDetail(string id)
  40. {
  41. ViewBag.id = id;
  42. return View();
  43. }
  44. /// <summary>
  45. /// 投诉登记
  46. /// </summary>
  47. /// <param name="typeCode">种类</param>
  48. /// <param name="events">标题</param>
  49. /// <param name="detail">描述</param>
  50. /// <returns></returns>
  51. [HttpPost]
  52. public ActionResult ComplaintRegistration(string typeCode,string events,string detail)
  53. {
  54. var UserInfo = GetCurrentUser();
  55. var r = Complaint_List.ComplaintRegistration( typeCode, events, detail, UserInfo.PersonID);
  56. if (!String.IsNullOrEmpty(r))
  57. {
  58. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, r, null).ToString(), "application/json");
  59. }
  60. else
  61. {
  62. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "投诉失败!请查看日志", null).ToString(), "application/json");
  63. }
  64. }
  65. /// <summary>
  66. /// 上传投诉图片
  67. /// </summary>
  68. /// <param name="CompliantID">投诉ID</param>
  69. /// <returns></returns>
  70. public ActionResult ImageUpload(string CompliantID)
  71. {
  72. var result = "0";
  73. var tt = this.Request.Files;
  74. var basePath = HttpRuntime.BinDirectory.TrimEnd('\\');//
  75. basePath = basePath.Substring(0, basePath.Length - 4);//移除\bin
  76. var date = DateTime.Now.ToString("yyyyMMdd");
  77. var src = "/UploadFile/" + date + "/" + CompliantID + "/";
  78. var path = basePath + "\\UploadFile\\" + date + "\\" + CompliantID + "\\";
  79. if (this.Request.Files.Count > 0)
  80. {
  81. var uploadFile = this.Request.Files[0];
  82. if (uploadFile != null)
  83. {
  84. if (!Directory.Exists(path))
  85. {
  86. Directory.CreateDirectory(path);//创建文件夹
  87. }
  88. var fileName = uploadFile.FileName;
  89. var fileLen = uploadFile.ContentLength;
  90. byte[] fileContent = new byte[fileLen];
  91. src += fileName;
  92. path += fileName;
  93. uploadFile.InputStream.Read(fileContent, 0, fileLen);
  94. System.IO.File.WriteAllBytes(path, fileContent);
  95. var r= Complaint_List.ImageUpload(CompliantID, src);
  96. if (r)
  97. {
  98. result = "1";
  99. }
  100. }
  101. }
  102. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, result, null).ToString(), "application/json");
  103. }
  104. /// <summary>
  105. /// 上传图片到FTP
  106. /// </summary>
  107. /// <param name="CompliantID"></param>
  108. /// <returns></returns>
  109. public ActionResult ImageUploadFTP(string CompliantID)
  110. {
  111. var result = "0";
  112. var files = this.Request.Files;
  113. if (this.Request.Files.Count > 0)
  114. {
  115. using (BinaryReader br = new BinaryReader(files[0].InputStream))
  116. {
  117. byte[] byteData = br.ReadBytes((int)files[0].InputStream.Length);
  118. var uploadFile = files[0];
  119. var fileName = uploadFile.FileName;
  120. var fileLen = uploadFile.ContentLength;
  121. string _tp = System.IO.Path.GetExtension(fileName);
  122. var UplodResult = UploadFile(byteData, fileName, _tp);
  123. if (UplodResult.code == 100)
  124. {
  125. ///数据库存储ID
  126. var Complete= Complaint_List.ImageUpload(CompliantID, UplodResult.data);
  127. if (Complete)
  128. {
  129. result = "1";
  130. }
  131. }
  132. }
  133. }
  134. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, result, null).ToString(), "application/json");
  135. }
  136. /// <summary>
  137. /// 获取投诉种类Combobox
  138. /// </summary>
  139. /// <param name="ClassificationID"></param>
  140. /// <returns></returns>
  141. public ActionResult GetCodeCombobox(string ClassificationID)
  142. {
  143. var json = BaseCode_obj.GetCodeCombobox(ClassificationID);
  144. return Content(json, "application/json");
  145. }
  146. /// <summary>
  147. /// 根据ID获取投诉人详细信息
  148. /// </summary>
  149. /// <returns></returns>
  150. [HttpPost]
  151. public ActionResult GetCUserInfo()
  152. {
  153. var UserInfo = GetCurrentUser();
  154. var json = Complaint_List.GetComplaintPerson(UserInfo.PersonID);
  155. return Content(json, "application/json");
  156. }
  157. /// <summary>
  158. /// 个人投诉记录查询
  159. /// </summary>
  160. /// <param name="model">查询条件</param>
  161. /// <returns></returns>
  162. public ActionResult QueryPersonelComplaint(QueryComplaintModel model)
  163. {
  164. var UserInfo = GetCurrentUser();
  165. model.UserId = UserInfo.PersonID;
  166. var json = Complaint_List.QueryComplaint(model);
  167. return Content(json, "application/json");
  168. }
  169. /// <summary>
  170. /// 通过ID获取投诉详情信息
  171. /// </summary>
  172. /// <param name="id">投诉ID</param>
  173. /// <returns></returns>
  174. public ActionResult GetComplaintDetail(string id)
  175. {
  176. var json = Complaint_List.GetComplaintDetail(id);
  177. return Content(json, "application/json");
  178. }
  179. /// <summary>
  180. /// 撤销投诉
  181. /// </summary>
  182. /// <param name="id">投诉ID</param>
  183. /// <returns></returns>
  184. public ActionResult DeleteComplaint(string id)
  185. {
  186. var r = Complaint_List.DeleteComplaint(id);
  187. if (r)
  188. {//删除成功
  189. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "撤销成功", null).ToString(), "application/json");
  190. }
  191. else
  192. {//删除失败
  193. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "撤销失败,投诉正在受理中!", null).ToString(), "application/json");
  194. }
  195. }
  196. }
  197. }