123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- using PMS.BusinessModels.Account;
- using PMS.BusinessModels.ComplaintManage;
- using PMS.EntityModels.PersonManager;
- using PMS.Interface;
- using PMS.Interface.BaseCode;
- using PMS.Interface.ComplaintManage;
- using PMS.Interface.SysManager;
- using QWPlatform.SystemLibrary.Security;
- using QWPlatform.SystemLibrary.Web;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Newtonsoft.Json;
- using QWPlatform.SystemLibrary.Utils;
- namespace PMS.WebUI.Controllers
- {
- [CheckLogin("/MobileAccount/ComplaintLogin")]
- public class ComplaintController : BaseController
- {
- IComplaintList Complaint_List = InterfaceFactory.CreateBusinessInstance<IComplaintList>();
- IBaseCode BaseCode_obj = InterfaceFactory.CreateBusinessInstance<IBaseCode>();
- // GET: Complaint
-
- public ActionResult ComplaintUser()
- {
- return View();
- }
- public ActionResult NewComplaint()
- {
- return View();
- }
- public ActionResult QueryComplaint()
- {
- return View();
- }
- public ActionResult ComplaintDetail(string id)
- {
- ViewBag.id = id;
- return View();
- }
-
- /// <summary>
- /// 投诉登记
- /// </summary>
- /// <param name="typeCode">种类</param>
- /// <param name="events">标题</param>
- /// <param name="detail">描述</param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult ComplaintRegistration(string typeCode,string events,string detail)
- {
- var UserInfo = GetCurrentUser();
- var r = Complaint_List.ComplaintRegistration( typeCode, events, detail, UserInfo.PersonID);
- if (!String.IsNullOrEmpty(r))
- {
- return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, r, null).ToString(), "application/json");
- }
- else
- {
- return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "投诉失败!请查看日志", null).ToString(), "application/json");
- }
- }
-
- /// <summary>
- /// 上传投诉图片
- /// </summary>
- /// <param name="CompliantID">投诉ID</param>
- /// <returns></returns>
- public ActionResult ImageUpload(string CompliantID)
- {
- var result = "0";
- var tt = this.Request.Files;
- var basePath = HttpRuntime.BinDirectory.TrimEnd('\\');//
- basePath = basePath.Substring(0, basePath.Length - 4);//移除\bin
- var date = DateTime.Now.ToString("yyyyMMdd");
- var src = "/UploadFile/" + date + "/" + CompliantID + "/";
- var path = basePath + "\\UploadFile\\" + date + "\\" + CompliantID + "\\";
- if (this.Request.Files.Count > 0)
- {
- var uploadFile = this.Request.Files[0];
- if (uploadFile != null)
- {
- if (!Directory.Exists(path))
- {
- Directory.CreateDirectory(path);//创建文件夹
- }
-
- var fileName = uploadFile.FileName;
- var fileLen = uploadFile.ContentLength;
- byte[] fileContent = new byte[fileLen];
- src += fileName;
- path += fileName;
- uploadFile.InputStream.Read(fileContent, 0, fileLen);
- System.IO.File.WriteAllBytes(path, fileContent);
- var r= Complaint_List.ImageUpload(CompliantID, src);
- if (r)
- {
- result = "1";
- }
-
- }
- }
- return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, result, null).ToString(), "application/json");
- }
- /// <summary>
- /// 上传图片到FTP
- /// </summary>
- /// <param name="CompliantID"></param>
- /// <returns></returns>
- public ActionResult ImageUploadFTP(string CompliantID)
- {
- var result = "0";
- var files = this.Request.Files;
-
- if (this.Request.Files.Count > 0)
- {
- using (BinaryReader br = new BinaryReader(files[0].InputStream))
- {
- byte[] byteData = br.ReadBytes((int)files[0].InputStream.Length);
- var uploadFile = files[0];
- var fileName = uploadFile.FileName;
- var fileLen = uploadFile.ContentLength;
- string _tp = System.IO.Path.GetExtension(fileName);
- var UplodResult = UploadFile(byteData, fileName, _tp);
- if (UplodResult.code == 100)
- {
- ///数据库存储ID
- var Complete= Complaint_List.ImageUpload(CompliantID, UplodResult.data);
- if (Complete)
- {
- result = "1";
- }
- }
- }
-
- }
- return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, result, null).ToString(), "application/json");
- }
- /// <summary>
- /// 获取投诉种类Combobox
- /// </summary>
- /// <param name="ClassificationID"></param>
- /// <returns></returns>
- public ActionResult GetCodeCombobox(string ClassificationID)
- {
- var json = BaseCode_obj.GetCodeCombobox(ClassificationID);
- return Content(json, "application/json");
- }
- /// <summary>
- /// 根据ID获取投诉人详细信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetCUserInfo()
- {
- var UserInfo = GetCurrentUser();
- var json = Complaint_List.GetComplaintPerson(UserInfo.PersonID);
- return Content(json, "application/json");
- }
- /// <summary>
- /// 个人投诉记录查询
- /// </summary>
- /// <param name="model">查询条件</param>
- /// <returns></returns>
- public ActionResult QueryPersonelComplaint(QueryComplaintModel model)
- {
- var UserInfo = GetCurrentUser();
- model.UserId = UserInfo.PersonID;
- var json = Complaint_List.QueryComplaint(model);
- return Content(json, "application/json");
- }
- /// <summary>
- /// 通过ID获取投诉详情信息
- /// </summary>
- /// <param name="id">投诉ID</param>
- /// <returns></returns>
- public ActionResult GetComplaintDetail(string id)
- {
- var json = Complaint_List.GetComplaintDetail(id);
- return Content(json, "application/json");
- }
- /// <summary>
- /// 撤销投诉
- /// </summary>
- /// <param name="id">投诉ID</param>
- /// <returns></returns>
- public ActionResult DeleteComplaint(string id)
- {
- var r = Complaint_List.DeleteComplaint(id);
- if (r)
- {//删除成功
- return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "撤销成功", null).ToString(), "application/json");
- }
- else
- {//删除失败
- return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "撤销失败,投诉正在受理中!", null).ToString(), "application/json");
- }
- }
-
- }
- }
|