using PMS.BusinessModels.Account;
using PMS.BusinessModels.ComplaintManage;
using PMS.BusinessModels.MobileProblem;
using PMS.BusinessModels.Problem;
using PMS.BusinessModels.SMS;
using PMS.EntityModels.Product;
using PMS.EntityModels.WorkFlow;
using PMS.Interface;
using PMS.Interface.BaseCode;
using PMS.Interface.Channel;
using PMS.Interface.ComplaintManage;
using PMS.Interface.MessageManage;
using PMS.Interface.MoblieProblemRegist;
using PMS.Interface.PresonManager;
using PMS.Interface.Problems;
using PMS.Interface.Product;
using PMS.Interface.ProManager;
using PMS.Interface.WorkFlow;
using PMS.Plugins.Common;
using PMS.Plugins.SMS;
using QWPlatform.SystemLibrary;
using QWPlatform.SystemLibrary.LogManager;
using QWPlatform.SystemLibrary.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
namespace PMS.WebUI.Controllers
{
///
/// 创建人:伍莲魁
/// 创建日期:2019/1/2
/// 模块功能:问题登记移动端控制器
///
[CheckLogin("/MobileAccount/MobileProblemLogin")]
public class MobileProblemController : BaseController
{
IProductModule Product_obj = InterfaceFactory.CreateBusinessInstance();
IBaseCode BaseCode_obj = InterfaceFactory.CreateBusinessInstance();
IPersonModule Iperson_obj = InterfaceFactory.CreateBusinessInstance();
IMoblieProblem MoblieProblem_obj = InterfaceFactory.CreateBusinessInstance();
IProModule Pro_obj = InterfaceFactory.CreateBusinessInstance();
ICPWTGCModel ZpwtgcModel = InterfaceFactory.CreateBusinessInstance();
IWorkFlow IWorkFlowModel = InterfaceFactory.CreateBusinessInstance();
IComplaintList Complaint_List = InterfaceFactory.CreateBusinessInstance();
IChannel IChannel = InterfaceFactory.CreateBusinessInstance();
//项目问题管理
IProjectProblems projectProblems = InterfaceFactory.CreateBusinessInstance();
//推送消息
IMessageManage notice = InterfaceFactory.CreateBusinessInstance();
// GET: MobileProblem
#region 视图
public ActionResult Home()
{
return View();
}
public ActionResult NewProblem()
{
var UserInfo = GetCurrentUser();
var UserType = Convert.ToString(UserInfo.PersonProperty);
ViewBag.CurrentProject = UserInfo.DefaultProjectID;
ViewBag.UserType = "true";
if (UserType == "3")
{
ViewBag.UserType = "false";
}
else
{
var proId = Pro_obj.GetProjectByUserId(UserInfo.PersonID);
if (!String.IsNullOrEmpty(proId))
{
ViewBag.CurrentProject = proId;
}
}
return View();
}
///
/// 判断用户性质进入不同的问题登记页面
///
///
///
public ActionResult NewProblems(string id)
{
var UserInfo = GetCurrentUser();
var UserType = UserInfo.PersonProperty;
var url = "NewProblemForCustom/";
if (UserType != 3)
{
url = "NewProblemForProject/";
}
return RedirectToAction(url + id);
}
public ActionResult NewProblemForProject(string id)
{
ViewBag.PersonProperty = GetCurrentUser().PersonProperty;
ViewBag.ProjectId = GetCurrentUser().DefaultProjectID;
ViewBag.OrgID = GetCurrentUser().OrgID;
ViewBag.ProductCode = id;
return View();
}
public ActionResult NewProblemForCustom(string id)
{
ViewBag.ProductCode = id;
return View();
}
public ActionResult My()
{
ViewBag.PersonProperty = GetCurrentUser().PersonProperty;
return View();
}
public ActionResult PersonalSetting()
{
return View();
}
public ActionResult UserDefualtSet()
{
ViewBag.Property = GetCurrentUser().PersonProperty;
return View();
}
public ActionResult QueryProblem()
{
var UserInfo = GetCurrentUser();
if (UserInfo.PersonProperty != 3)
{
return RedirectToAction("QueryProblemProject");
}
else
{
return RedirectToAction("QueryProblemCustom");
}
}
///
/// 用户查询
///
///
public ActionResult QueryProblemCustom()
{
return View();
}
///
/// 项目人员查询
///
///
public ActionResult QueryProblemProject()
{
ViewBag.PersonPropert = GetCurrentUser().PersonProperty;
return View();
}
public ActionResult ProblemQuickSearch()
{
return View();
}
///
/// 问题详细
///
///
public ActionResult ProblemDetail(string id)
{
var UserInfo = GetCurrentUser();
///如果是客户则跳转到客户的详细界面
if (UserInfo.PersonProperty == 3)
{
return RedirectToAction("ProblemDetailCutom/" + id);
}
else
{
var json = MoblieProblem_obj.ProblemDetailByProject(id, UserInfo.PersonProperty, UserInfo.JobCode, UserInfo.PersonID);
var Model = Strings.JsonToModel(json);
ViewBag.ID = id;
ViewBag.PersonProperty = UserInfo.PersonProperty;
return View(Model);
}
}
///
/// 问题详细客户界面
///
///
public ActionResult ProblemDetailCutom(string id)
{
var UserInfo = GetCurrentUser();
var json = MoblieProblem_obj.ProblemDetail(id, UserInfo.PersonID);
var Model = Strings.JsonToModel(json);
ViewBag.ID = id;
ViewBag.PersonProperty = UserInfo.PersonProperty;
return View(Model);
}
public ActionResult ModifyProblem(string id)
{
ViewBag.PersonProperty = GetCurrentUser().PersonProperty;
ViewBag.ID = id;
return View();
}
///
/// 问题回退或终止填写界面
///
///
public ActionResult ProblemBack(string id, string type)
{
ViewBag.ID = id;
ViewBag.type = type;
return View();
}
public ActionResult ProblemDistribution(string id)
{
var UserInfo = GetCurrentUser();
ViewBag.ID = id;
ViewBag.PersonProperty = UserInfo.PersonProperty;
ViewBag.CompanyID = UserInfo.CompanyID;
ViewBag.DefaultProjectID = UserInfo.DefaultProjectID;
return View();
}
public ActionResult ProblemDeal(string id)
{
ViewBag.ID = id;
return View();
}
///
/// 根据ID获取登陆人详细信息
///
///
[HttpPost]
public ActionResult GetCUserInfo()
{
var UserInfo = GetCurrentUser();
var json = Complaint_List.GetComplaintPerson(UserInfo.PersonID);
return Content(json, "application/json");
}
///
/// 获取我的问题统计信息
///
///
[HttpPost]
public ActionResult GetCount()
{
var UserInfo = GetCurrentUser();
string json;
///如果为客户
if (UserInfo.PersonProperty == 3)
{
json = MoblieProblem_obj.GetCountForCustom(UserInfo.PersonID);
}
else
{
json = MoblieProblem_obj.GetCount(UserInfo.PersonID);
}
return Content(json, "application/json");
}
///
/// 公告列表页面
///
///
public ActionResult NoticeList()
{
return View();
}
///
/// 公告详细
///
///
///
public ActionResult NoticesDetail(string id)
{
ViewBag.ID = id;
return View();
}
#endregion
#region 问题登记相关业务
///
/// 获取产品编码
///
///
public ActionResult GetProductCode(string DeafualtProjectId)
{
string json;
//if (!String.IsNullOrEmpty(DeafualtProjectId))
//{
// json = Product_obj.GetProductCodeBycustom(DeafualtProjectId);
// return Content(json, "application/json");
//}
var userinfo = GetCurrentUser();
if (userinfo.PersonProperty == 3 || userinfo.PersonProperty == 4)
{
json = Product_obj.GetProductCodeBycustom(userinfo.DefaultProjectID);
}
else
{
json = Product_obj.GetProductCode();
}
return Content(json, "application/json");
}
///
/// 客户获取所在项目的产品编码
///
///
public ActionResult GetProductCodeBycustom()
{
var userinfo = GetCurrentUser();
var json = Product_obj.GetProductCodeBycustom(userinfo.DefaultProjectID);
return Content(json, "application/json");
}
///
/// 获取当前登录帐户项目的产品
///
///
public ActionResult GetProduct(string id)
{
var json = Product_obj.GetProductByProjectId(id);
return Content(json, "application/json");
}
///
/// 根据分类ID获取基础编码
///
///
///
public ActionResult GetCodeCombobox(string ClassificationID)
{
var json = BaseCode_obj.GetCodeComboboxs(ClassificationID);
return Content(json, "application/json");
}
///
/// 获取当前用户渠道的项目信息
///
///
public ActionResult GetProductCombobox()
{
var UserInfo = GetCurrentUser();
var json = Iperson_obj.GetProjectCobo(UserInfo.CompanyID, GetAuthDats().Project);
return Content(json, "application/json");
}
///
/// 获取项目下的机构信息
///
///
public ActionResult GetInstitution(string id)
{
var json = Pro_obj.GetInstitutionByProjectId(id);
return Content(json, "application/json");
}
///
/// 登记产品问题
///
///
///
public ActionResult SubmitProblem(SubmitProblemFormModel model)
{
var UserInfo = GetCurrentUser();
var status = Convert.ToString(UserInfo.PersonProperty);
model.registrant = UserInfo.Name;
model.registrantID = UserInfo.PersonID;
model.registrantProperty = UserInfo.PersonProperty;
model.CompanyID = UserInfo.CompanyID;
/// 获取登记流程ID和进入流程ID
var sub = GetProceessID(UserInfo, model.InstitutionID, model.ProblemNature, model.ProjectID);
model.ProcessID = sub.ProcessID;
model.NextProcessID = sub.NextProcessID;
var r = MoblieProblem_obj.SubmitProblem(status, model);
if (!String.IsNullOrEmpty(r))
{
if (model.DealStatus != "1")
{
var ProblemID = projectProblems.GetWTID(r);
RegistNotify(ProblemID);
var str = "您有新的问题需要处理!";
var ProcessRemark = "有新的问题登记,请注意查收!";
Logger.Instance.Info("登记问题推送1" + model.ProjectID);
if (model.ProjectID.IsNullOrEmpty())
{
model.ProjectID = UserInfo.DefaultProjectID;
}
Logger.Instance.Info("登记问题推送2" + model.ProjectID);
var dt = Iperson_obj.GetCurrentProjectInfo(model.ProjectID);
if (dt.Rows.Count > 0)
{
ProcessRemark ="【"+ dt.Rows[0].GetValueByName("名称")+"】"+ "登记了新问题,请注意查收!";
}
WeChartPush(str, ProblemID, ProcessRemark, model.CompanyID);
dt = null;
}
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");
}
}
///
/// 微信推送
///
/// 标题
/// 问题id
/// 内容
/// 渠道id
private void WeChartPush(string str, string ProblemID, string ProcessRemark, string ChannelID)
{
//ProcessRemark = Tools.RemoveHTML(ProcessRemark);
NotificationDto no = new NotificationDto();
no.style = "3";
no.template_code = "OIE51OsXeECnoPxGgPTQ7acXybc7t1plgAbdlH-mMWE";
no.template_value = "{\"first\":{\"value\":\"" + str + "\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + DateTime.Now + "\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"" + ProcessRemark + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"点击【查看详情】立即查阅您的问题记录\",\"color\":\"#173177\"}}";
no.url = "https://zlpms.zlsoft.com:8078/MobileProblem/ProblemDetail/" + ProblemID;
List list = new List();
var dt = MoblieProblem_obj.GetChannelExtend(ChannelID);
if (dt != null && dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
MessageDetailsDto mdd = new MessageDetailsDto();
mdd.接收人id = dt.Rows[i].GetValueByName("微信id");
list.Add(mdd);
}
no.record_items = list;
notice.SendWeChartTempletMessge(no);
}
}
///
/// 获取登记流程ID和进入流程ID
///
///
///
private SubmitProblemFormModel GetProceessID(UserInfo UserInfo, string Institution, int? ProblemProperty, string ProjectID)
{
SubmitProblemFormModel model = new SubmitProblemFormModel();
WorkFlowModel workmodel = new WorkFlowModel();
///如果是用户或者是机构管理员
if (UserInfo.PersonProperty == 3 || UserInfo.PersonProperty == 4)
{
workmodel = MoblieProblem_obj.GetNewProblemWorkId(UserInfo.OrgID, UserInfo.DefaultProjectID);
}
///如果是中联人员或者卫计委
else
{
workmodel = MoblieProblem_obj.GetNewProblemWorkId(Institution, ProjectID);
}
///登记流程ID
model.ProcessID = workmodel.ID;
///目录ID
model.Catalog = workmodel.CategoryID ?? 1;
///获取进入流程ID
model.NextProcessID = IWorkFlowModel.GetNewProblemWorkFlowID(model.Catalog, UserInfo.PersonProperty, (ProblemProperty ?? 1));
return model;
}
///
/// 上传图片到FTP
///
///
///
public ActionResult ImageUploadFTP(string ProblemID)
{
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);
//判断附件类型
string fileType = "2";
if (_tp == ".jpg" || _tp == ".png" || _tp == ".jpeg" || _tp == ".bmp")
{
fileType = "1";
}
var UplodResult = UploadFile(byteData, fileName, _tp);
if (UplodResult.code == 100)
{
///数据库存储ID
var Complete = MoblieProblem_obj.ImageUpload(ProblemID, UplodResult.data, GetCurrentUser().Name, fileType);
if (Complete)
{
result = "1";
}
}
}
}
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, result, null).ToString(), "application/json");
}
///
/// 获取项目机构树(权限)
///
///
public ActionResult GetProjectTree()
{
var json = Iperson_obj.GetProjectTree(GetAuthDats().Project);
return Content(json, "application/json");
}
///
/// 通过产品Code获取项目机构树(权限)
///
///
///
public ActionResult GetProjectTreeByCode(string id)
{
var json = Iperson_obj.GetProjectTreeByCode(GetAuthDats().Project, id);
return Content(json, "application/json");
}
///
/// 通过分类编码获取基础编码的Combobox(代码,显示名)
///
///
public ActionResult GetComboboxByCode(string id)
{
var json = BaseCode_obj.GetComboboxByCode(id);
return Content(json, "application/json");
}
#endregion
#region 问题查询业务
///
/// 客户查询问题
///
///
///
public ActionResult QueryMyProblemByCustom(QueryMyProblemModel Model)
{
var UserInfo = GetCurrentUser();
Model.CurrentUserId = UserInfo.PersonID;
var dt = MoblieProblem_obj.QueryMyProblem(Model);
return Content(dt.ToJson(), "application/json");
}
///
/// 获取项目数据权限combobox
///
///
public ActionResult GetAllProject()
{
var json = Iperson_obj.GetAllProject(GetAuthDats().Project);
return Content(json, "application/json");
}
///
/// 获取机构索引
///
///
///
public ActionResult GetInstitutionIndex(string id)
{
var json = Pro_obj.GetInstitutionIndex(id);
return Content(json, "application/json");
}
///
/// 根据权限和产品编码获取项目列表索引
///
///
///
public ActionResult GetProjectIndexByCode(string id)
{
var json = Pro_obj.GetProjectIndexByCode(GetAuthDats().Project, id);
return Content(json, "application/json");
}
public ActionResult SelectProblemItem()
{
ViewBag.PersonProperty = GetCurrentUser().PersonProperty;
ViewBag.ProjectId = GetCurrentUser().DefaultProjectID;
ViewBag.OrgID = GetCurrentUser().OrgID;
return View();
}
///
/// 根据渠道获取项目索引
///
///
public ActionResult GetChannelProjectIndexByCode()
{
var json = Pro_obj.GetChannelProjectIndexByCode(GetCurrentUser().CompanyID);
return Content(json, "application/json");
}
///
/// 项目人员问题查询
///
///
public ActionResult QueryProblemByProject(QueryProblemByProjectModel model)
{
var UserInfo = GetCurrentUser();
model.CurrentUserId = UserInfo.PersonID;
//如果选择所有项目,则取所有权限项目
if (model.Project == "all")
{
model.Project = GetAuthDats().Project;
}
var dt = MoblieProblem_obj.QueryProblemByProject(model);
if (dt != null && dt.Rows.Count > 0)
{
//获取当前登陆人应在的处理环节
var CurrentLink = MoblieProblem_obj.GetUserLinkId(UserInfo.PersonProperty, UserInfo.JobCode);
foreach (DataRow dr in dt.Rows)
{
//判断当前处理人是否为自己 以及 按钮权限
if (UserInfo.PersonID != dr.GetValueByName("受理人id"))
{
dr["是否为当前处理人"] = '0';
}
//判断是否解决或是否终止
if (dr.GetValueByName("是否解决") == 1 || dr.GetValueByName("是否终止") == 1)
{
dr["按钮权限"] = '0';
}
///判断是否越级
if (CurrentLink < dr.GetValueByName("环节id"))
{
dr["按钮权限"] = '0';
}
}
}
return Content(dt.ToJson(), "application/json");
}
///
/// 获取医院管理员所属项目和机构
///
///
public ActionResult GetPerson()
{
var json = MoblieProblem_obj.GetPerson(GetCurrentUser().PersonID);
return Content(json, "application/json");
}
#endregion
#region 问题详细相关业务
///
/// 获取产品问题过程处理流程
///
///
public ActionResult GetClc(string id)
{
return Content(ZpwtgcModel.GetClc(id), "application/json");
}
///
/// 获取产品问题过程沟通需要的信息
///
///
///
public ActionResult GetCommunicates(string id)
{
return Content(ZpwtgcModel.GetCommunicates(id), "application/json");
}
///
/// 保存问题沟通
///
///
///
public ActionResult SubmitContent(CPWTGCModel model)
{
model.JLSJ = DateTime.Now;
var UserInfo = GetCurrentUser();
model.JLRID = UserInfo.PersonID;
string result = ZpwtgcModel.SubmitContent(model);
string[] results = result.Split('|');
if (results[0] == "1")
{
return this.ResponseJson(System.Net.HttpStatusCode.OK, "保存成功");
}
return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "保存失败");
}
///
/// 获取问题的图片
///
///
///
public ActionResult GetFileFormFTP(string id)
{
var dt = MoblieProblem_obj.GetFileFormFTP(id);
return Content(dt.ToJson(), "application/json");
}
public ActionResult QuerckSearch(QueryMyProblemModel model)
{
model.CurrentUserId = GetCurrentUser().PersonID;
var json = MoblieProblem_obj.QuerckSearch(model);
return Content(json, "application/json");
}
#endregion
#region 问题操作相关业务
///
/// 受理问题
///
///
///
public ActionResult AcceptProblem(string id)
{
///判断用户权限
var UserInfo = GetCurrentUser();
var PersonProperty = UserInfo.PersonProperty;
var jude = CrossJud(id, PersonProperty, UserInfo.JobCode);
if (!jude)
{
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "您的权限不足,不能受理该问题", null).ToString(), "application/json");
}
//获取进入流程ID
var WorkId = IWorkFlowModel.GetDealWorkId(id, UserInfo.PersonProperty, UserInfo.JobCode);
//受理问题
var DealModel = new ProblemDealModel();
DealModel.ProblemId = id;
DealModel.NextWorkId = WorkId;
DealModel.DealPeronName = UserInfo.Name;
DealModel.DealPeronId = UserInfo.PersonID;
var re = IWorkFlowModel.ProblemAccept(DealModel);
if (re)
{
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");
}
}
///
/// 越级判断
///
///
///
///
private bool CrossJud(string ProblemId, int PersonProperty, string JobCode)
{
return MoblieProblem_obj.CrossJud(ProblemId, PersonProperty, JobCode);
}
///
/// 判断是否为自己处理的问题
///
///
///
public ActionResult IsMyProblem(string id)
{
var json = MoblieProblem_obj.IsMyProblem(id, GetCurrentUser().PersonID);
return Content(json, "application/json");
}
///
/// 问题回退,终止
///
///
///
///
///
public ActionResult ProblemBackSubmit(string id, string type, string Deatil)
{
var UserInfo = GetCurrentUser();
var DealModel = new ProblemDealModel();
DealModel.ProblemId = id;
DealModel.DealPeronName = UserInfo.Name;
DealModel.DealPeronId = UserInfo.PersonID;
DealModel.Describe = Deatil;
bool re = false;
string ProcessId = string.Empty;
///回退问题
if (type == "1")
{
DealModel.NextWorkId = IWorkFlowModel.GetBackProblemWorkFlowID(id);
///如果回退的下个流程不存在
if (DealModel.NextWorkId < 1)
{
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "问题已在最初始状态,无法回退!", null).ToString(), "application/json");
}
re = IWorkFlowModel.ProblemRollBack(DealModel, out ProcessId);
}
///终止问题
else
{
re = IWorkFlowModel.ProblemBreak(DealModel, out ProcessId);
}
//返回
if (re)
{
if (type == "1")
{
DealNotify(DealModel.ProblemId, 1 );
}
var ProblemProcessModel = new ProblemProcessModel()
{
IsBack = (type=="1"),
IsStop= (type != "1"),
ProblemID = DealModel.ProblemId
};
SitePush(ProblemProcessModel);
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, ProcessId, null).ToString(), "application/json");
}
else
{
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "操作失败!", null).ToString(), "application/json");
}
}
///
/// 获取渠道Combobox
///
///
public ActionResult GetChannel()
{
var json = IChannel.GetChannelCombo();
return Content(json, "application/json");
}
///
/// 获取项目Combobox
///
///
///
public ActionResult GetProject(string id)
{
var json = IChannel.GetProjectCombobox(id);
return Content(json, "application/json");
}
///
/// 获取分配人员
///
///
public ActionResult GetDistribuPerson(string search, string problemId)
{
var UserInfo = GetCurrentUser();
var json = MoblieProblem_obj.GetPerson(search, UserInfo.PersonProperty, problemId);
return Content(json, "application/json");
}
///
/// 问题分配
///
///
///
///
///
///
public ActionResult ProblemDistributeSubmit(string id, string PersonID, string PersonName, string Deatil)
{
var UserInfo = GetCurrentUser();
///获取分配人的人员性质和职务
var User = MoblieProblem_obj.GetPersonProperty(PersonID);
///判断分配人是否有处理环节
var IsDealProcess = MoblieProblem_obj.IsDealProcess(id, User.PersonProperty);
if (!IsDealProcess)
{
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "分配失败,分配人未配置环节,请联系管理员!", null).ToString(), "application/json");
}
//获取进入流程ID
var WorkId = IWorkFlowModel.GetDealWorkId(id, User.PersonProperty, User.JobCode);
//分配人员
var DealModel = new ProblemDealModel();
DealModel.ProblemId = id;
DealModel.Describe = Deatil;
DealModel.NextWorkId = WorkId;
DealModel.DealPeronId = UserInfo.PersonID;
DealModel.AssignPersonName = PersonName;
DealModel.AssignPersonId = PersonID;
string ProcessId = string.Empty;
var re = IWorkFlowModel.ProblemAssgin(DealModel, out ProcessId);
if (re)
{
var ProblemProcessModel = new ProblemProcessModel()
{
IsAssign=true,
AssignID= DealModel.AssignPersonId,
ProblemID= id
};
SitePush(ProblemProcessModel);
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, ProcessId, null).ToString(), "application/json");
}
else
{
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "分配失败!", null).ToString(), "application/json");
}
}
///
/// 获取存在产品问题的产品所有版本
///
///
///
public ActionResult GetProblemVison(string id)
{
var json = MoblieProblem_obj.GetProblemVison(id);
return Content(json, "application/json");
}
public ActionResult ProblemDealSubmit(ProblemDealForm Model)
{
var UserInfo = GetCurrentUser();
var DealModel = new ProblemDealModel();
DealModel.ProblemId = Model.ProblemID;
DealModel.Describe = Model.DealDescribe;
DealModel.DealPeronId = UserInfo.PersonID;
DealModel.DealPeronName = UserInfo.Name;
//获取进入流程ID
DealModel.NextWorkId = IWorkFlowModel.GetDealWorkId(Model.ProblemID, UserInfo.PersonProperty, UserInfo.JobCode);
bool re;
string ProcessId = string.Empty;
///如果处理完成
if (Model.Iscomplete)
{
DealModel.Solution = Model.DealDescribe;
DealModel.Version = Model.Vision;
re = IWorkFlowModel.ProblemSolution(DealModel, out ProcessId, UserInfo);
}
//如果未完成
else
{
re = IWorkFlowModel.ProblemDeal(DealModel, out ProcessId);
}
//判断执行状态
if (re)
{
if (Model.Iscomplete)
{
var ProblemProcessModel = new ProblemProcessModel()
{
IsSolve=true,
ProblemID= DealModel.ProblemId
};
SitePush(ProblemProcessModel);
}
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, ProcessId, null).ToString(), "application/json");
}
else
{
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "处理失败!", null).ToString(), "application/json");
}
}
///
/// 问题向上提交
///
///
///
public ActionResult ProblemPutSubmit(string id)
{
var UserInfo = GetCurrentUser();
var DealModel = new ProblemDealModel();
DealModel.ProblemId = id;
DealModel.DealPeronId = UserInfo.PersonID;
//获取提交问题进入流程ID
DealModel.NextWorkId = IWorkFlowModel.GetSubmitProblemWorkFlowID(UserInfo.PersonProperty, id);
var re = IWorkFlowModel.ProblemSubmit(DealModel);
//判断执行状态
if (re)
{
DealNotify(DealModel.ProblemId, 2);
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");
}
}
///
/// 上传附件到FTP并保存到问题附件
///
///
///
///
public ActionResult FlieUploadAndSave(string ProcessId)
{
var files = this.Request.Files;
var rs = false;
var Model = new ProcessFileModel();
Model.Name = GetCurrentUser().Name;
Model.ProcessId = ProcessId;
if (files.Count > 0)
{
for (int i = 0; i < files.Count; i++)
{
using (BinaryReader br = new BinaryReader(files[i].InputStream))
{
byte[] byteData = br.ReadBytes((int)files[i].InputStream.Length);
var uploadFile = files[i];
var fileName = uploadFile.FileName;
string _tp = System.IO.Path.GetExtension(fileName);
//判断附件类型
string fileType = "2";
if (_tp == ".jpg" || _tp == ".png" || _tp == ".jpeg" || _tp == ".bmp")
{
fileType = "1";
}
Model.Type = fileType;
//上传
var UplodResult = UploadFile(byteData, fileName, _tp);
///是否上传成功
if (UplodResult.code == 100)
{
///保存到问题附件表
Model.FileId = UplodResult.data;
rs = IWorkFlowModel.SaveProcessFile(Model);
}
}
}
}
if (rs)
{
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");
}
}
///
/// 上传附件到FTP并保存到问题附件(base64)
///
///
///
public ActionResult Base64UploadAndSave(string ProcessId, string dataURL, string name)
{
var rs = false;
var Model = new ProcessFileModel();
Model.Name = GetCurrentUser().Name;
Model.ProcessId = ProcessId;
Model.Type = "1";
name += ".jpeg";
if (!string.IsNullOrEmpty(dataURL))
{
String base64 = dataURL.Substring(dataURL.IndexOf(",") + 1);
byte[] byteData = Convert.FromBase64String(base64);
//上传
var UplodResult = UploadFile(byteData, name, ".jpeg");
///是否上传成功
if (UplodResult.code == 100)
{
///保存到问题附件表
Model.FileId = UplodResult.data;
rs = IWorkFlowModel.SaveProcessFile(Model);
}
}
if (rs)
{
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");
}
}
//查看附件图像(id:附件id,type:缩略图o原图,s缩略图,m大图)
public ActionResult ViewProblemImage(string id, string type)
{
try
{
if (string.IsNullOrEmpty(type))
{//文件流传输
var obj = DownloadFileBase64(id, string.Empty);
if (obj != null)
{
//将base64转bytes
var data = Convert.FromBase64String(obj.base64);
return File(data, "application/octet-stream", obj.fileName);
}
else
{
Logger.Instance.Warn("未获取到文件对象:" + id);
return View();
}
}
else
{//图像传输
var data = base.DownloadFileBytes(id, type);
return File(data, "image/jpeg");
}
}
catch (Exception ex)
{
Logger.Instance.Warn("问题件服务器出现了异常:" + ex.Message);
return View();
}
}
///
/// 获取图片Base64
///
///
///
public ActionResult GetBase64(string id)
{
var obj = DownloadFileBase64(id, string.Empty);
FTPFileModel model = new FTPFileModel
{
base64 = obj.base64,
fileName = obj.fileName,
format = obj.format
};
return Content(model.base64ToImage, "application/json");
}
///
/// 获取问题信息
///
///
///
public ActionResult GetProblemInfomation(string id)
{
var json = MoblieProblem_obj.GetProblemInfomation(id);
return Content(json, "application/json");
}
///
/// 修改问题
///
///
///
public ActionResult ModifySubmit(SubmitProblemFormModel model)
{
var UserInfo = GetCurrentUser();
model.registrantID = UserInfo.PersonID;
string r;
//判断是否为自己登记的问题(管理员可以修改他人的问题)
var s = MoblieProblem_obj.IsModifyMyProblem(UserInfo.PersonID, model.ProblemId);
if (!s && UserInfo.PersonProperty==3)
{
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "不能修改他人登记的问题!", null).ToString(), "application/json");
}
if (UserInfo.PersonProperty == 3)
{
r = MoblieProblem_obj.ModifySubmitForCustom(model);
}
else
{
r = MoblieProblem_obj.ModifySubmit(model);
}
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");
}
}
///
/// 获取问题登记的附件
///
public ActionResult GetProblemFlie(string id)
{
var json = MoblieProblem_obj.GetProblemFlie(id);
return Content(json, "application/json");
}
#endregion
#region 获取验证码
public ActionResult GetSMSCodeCurrent()
{
bool r = false;
///发送短信
var tele = GetCurrentUser().Account;
//var smsSend = SysCom.Instance.ZlsoftAppSms(tele);
var dt = account_obj.GetTelAccountInfo(tele);
if (dt != null && dt.Rows.Count > 0)
{
}
else
{
Logger.Instance.Info("手机号未注册,就在进行发验证码"+tele);
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "当前手机号未生成账号,请点击右上角先进行注册", null).ToString(), "application/json");
}
var code = "";
var smsSend = SendSMS.SendKuaiZiSMS(tele,ref code);
if (!string.IsNullOrEmpty(code))
{
r = MoblieProblem_obj.GetSMSCode(tele, code);
}
if (r)
{
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "发送成功,10分钟内有效!", null).ToString(), "application/json");
}
else
{
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "短信发送失败,请联系管理员", null).ToString(), "application/json");
}
}
///
/// 修改密码
///
///
///
///
///
public ActionResult PasswordModifySubmit(string Code, string password)
{
var r = MoblieProblem_obj.PasswordModifySubmit(GetCurrentUser().Account, Code, password);
if (r == "1")
{
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "修改成功", null).ToString(), "application/json");
}
else
{
return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, r, null).ToString(), "application/json");
}
}
#endregion
#region 向客户端发送更新操作
///
/// 向客户端发送更新操作
///
/// 问题流程ID
private void RefreshProblem(string id)
{
var HJID = MoblieProblem_obj.GetProblemByProcssId(id);
if (HJID <= 3)
{//更新项目问题管理列表
App_Start.ClientManager.RefreshProblem("1");
}
else if (HJID == 4)
{//更新技术支持
App_Start.ClientManager.RefreshProblem("2");
}
else
{//研发
App_Start.ClientManager.RefreshProblem("3");
}
}
///
/// 向客户端发送更新操作
///
/// 工作流ID
private void RefreshProblemByWorkId(int id)
{
try
{
var HJID = MoblieProblem_obj.GetProblemByWorkId(id);
if (HJID <= 3)
{//更新项目问题管理列表
App_Start.ClientManager.RefreshProblem("1");
}
else if (HJID == 4)
{//更新技术支持
App_Start.ClientManager.RefreshProblem("2");
}
else
{//研发
App_Start.ClientManager.RefreshProblem("3");
}
}
catch(Exception ex)
{
Logger.Instance.Error("更新客户端出错", ex);
}
}
//站点推送
private void SitePush(ProblemProcessModel model)
{
var userInfo = GetCurrentUser();
try
{
if (model.IsAssign)
{//处理成功与指派人员时需要向该被指派人员推送消息
var NotefiyConfigInfo = projectProblems.GetNotifyConfigInfoByUserId(model.AssignID);
if (NotefiyConfigInfo != null && NotefiyConfigInfo.Assign.SendSite)
this.SendDealMessage(model.ProblemID,model.AssignID, "有新的问题指派给您,请注意查收!",1);
}
else if (model.IsSolve)
{
var WTJLModel = projectProblems.GetWTJLModel(model.ProblemID);
var NotefiyConfigInfo = projectProblems.GetNotifyConfigInfoByUserId(WTJLModel.DJRID);
if (NotefiyConfigInfo != null && NotefiyConfigInfo.SolveTime.SendSite)
{
var str = "您的编号为【" + WTJLModel.BH.ToString() + "】的问题已被解决,处理人:" + WTJLModel.SLR;
this.SendDealMessage(model.ProblemID,WTJLModel.DJRID, str,2);
}
}
else if (model.IsBack)
{
var WTJLModel = projectProblems.GetWTJLModel(model.ProblemID);
var NotefiyConfigInfo = projectProblems.GetNotifyConfigInfoByUserId(WTJLModel.DJRID);
if (NotefiyConfigInfo != null && NotefiyConfigInfo.BackTime.SendSite)
{
var str = "您的编号为【" + WTJLModel.BH.ToString() + "】的问题已被回退,处理人:" + userInfo.Name;
this.SendDealMessage(model.ProblemID,WTJLModel.DJRID, str,3);
}
}
else if (model.IsStop)
{
var WTJLModel = projectProblems.GetWTJLModel(model.ProblemID);
var NotefiyConfigInfo = projectProblems.GetNotifyConfigInfoByUserId(WTJLModel.DJRID);
if (NotefiyConfigInfo != null && NotefiyConfigInfo.StopTime.SendSite)
{
var str = "您的编号为【" + WTJLModel.BH.ToString() + "】的问题已被终止,处理人:" + userInfo.Name;
this.SendDealMessage(model.ProblemID,WTJLModel.DJRID, str,4);
}
}
else if (model.IsCommit && !string.IsNullOrEmpty(model.SubID))
{
var NotefiyConfigInfo = projectProblems.GetNotifyConfigInfoByUserId(model.SubID);
if (NotefiyConfigInfo != null && NotefiyConfigInfo.Assign.SendSite)
this.SendDealMessage(model.ProblemID,model.SubID, "有新的问题提交给您,请注意查收!",5);
}
}
catch (Exception ex)
{
Logger.Instance.Error("站点推送失败,原因:" + ex);
}
}
//登记问题获取推送人
private List GetPushPerson(string ProblemId)
{
///通过问题流程Id获取问题Id
var PersonId = GetCurrentUser().PersonID;
var list = projectProblems.GetPushPerson(ProblemId);
//去除自己
list.Remove(PersonId);
return list;
}
///
/// 登记推送
///
///
private void RegistNotify(string id)
{
var PushPerson = GetPushPerson(id);
var PushPersonTask = Task.Factory.StartNew(() => Parallel.ForEach(PushPerson, item => this.RefreshProblemAndSendMessage(item, "有新的问题登记,请注意查收!",id)));
Task.WaitAll(PushPersonTask);
return;
}
///
/// 回退和向上提交的问题推送
///
///
private void DealNotify(string id, int type)
{
string Message;
if (type == 1)
{
//回退
Message = "有新的问题回退,请注意查收!";
}
else
{//提交
Message = "有新的问题向上提交,请注意查收!";
}
var PushPerson = GetPushPerson(id);
var PushPersonTask = Task.Factory.StartNew(() => Parallel.ForEach(PushPerson, item => this.RefreshProblemAndSendMessage(item, Message, id)));
Task.WaitAll(PushPersonTask);
return;
}
#endregion
#region 版本问题查询
public ActionResult VersionProblem()
{
return View();
}
public ActionResult VersionProblemDeatil(string id,string vpid)
{
var UserInfo = GetCurrentUser();
var json = MoblieProblem_obj.ProblemDetail(id, UserInfo.PersonID);
var Model = Strings.JsonToModel(json);
ViewBag.ID = id;
ViewBag.vpid = vpid;
ViewBag.PersonProperty = UserInfo.PersonProperty;
return View(Model);
}
///
/// 获取版本问题说明及其补丁
///
///
///
public ActionResult getVersionPoblemExplain(string id)
{
var json = MoblieProblem_obj.getVersionPoblemExplain(id);
return Content(json, "application/json");
}
///
/// 下载版本附件
///
///
///
///
public ActionResult DownLoadVersionFile(string id, string type,string flieVersionId)
{
if (string.IsNullOrEmpty(type))
{//文件流传输
var obj = DownloadFileBase64(id, string.Empty);
if (obj != null)
{
//将base64转bytes
var data = Convert.FromBase64String(obj.base64);
MoblieProblem_obj.SaveLogger(id, flieVersionId, GetCurrentUser().PersonID);
return File(data, "application/octet-stream", obj.fileName);
}
else
{
Logger.Instance.Warn("未获取到文件对象:" + id);
return View();
}
}
else
{//图像传输
var data = base.DownloadFileBytes(id, type);
return File(data, "image/jpeg");
}
}
#endregion
#region 我的评价
///
/// 我的评价-首页
///
///
public ActionResult MyComments()
{
ViewBag.PersonPropert = GetCurrentUser().PersonProperty;
return View();
}
///
///获取待评价已评价的问题列表
///
///
///
///
public ActionResult GetQuestionList(MyCommModel model)
{
int total = 0;
var user = GetCurrentUser();
model.PersonId = user.PersonID;
var result = MoblieProblem_obj.GetQuestionList(model.PersonId, model.pageindex, model.pagesize,model.Tab, out total);
return Content(result, "application/json");
}
///
/// 获取已评价后的内容
///
/// 问题id
///
public ActionResult GetEvaluationContent(string ProblemID)
{
var user = GetCurrentUser();
var result = MoblieProblem_obj.GetEvaluationContent(user.PersonID, ProblemID);
return Content(result, "application/json");
}
///
/// 问题评价
///
///
///
public ActionResult ProblemReamrk(string id)
{
var UserInfo = GetCurrentUser();
ViewBag.ID = id;
var json = MoblieProblem_obj.ProblemDetail(id, UserInfo.PersonID);
var Model = Strings.JsonToModel(json);
ViewBag.PersonProperty = UserInfo.PersonProperty;
return View(Model);
}///
/// 提交评论
///
///
public ActionResult ProblemReamrkSubmit(commentsModel model)
{
string CommentsId = string.Empty;
var user = GetCurrentUser();
model.CommitPerson = user.Name;
model.CommitPersonId = user.PersonID;
var r = MoblieProblem_obj.ProblemReamrkSubmit(model, out CommentsId);
var json = new
{
Code = r ? "200" : "0",
CommentsId = CommentsId
};
return Content(Strings.ObjectToJson(json), "application/json");
}
public ActionResult CommitUpload(CommitFlie model, string ID)
{
var files = this.Request.Files;
var rs = false;
model.CommitId = ID;
model.Name = GetCurrentUser().Name;
if (files.Count > 0)
{
for (int i = 0; i < files.Count; i++)
{
using (BinaryReader br = new BinaryReader(files[i].InputStream))
{
byte[] byteData = br.ReadBytes((int)files[i].InputStream.Length);
var uploadFile = files[i];
var fileName = uploadFile.FileName;
string _tp = System.IO.Path.GetExtension(fileName);
//判断附件类型
string fileType = "2";
if (_tp == ".jpg" || _tp == ".png" || _tp == ".jpeg" || _tp == ".bmp")
{
fileType = "1";
}
model.FlieType = fileType;
//上传
var UplodResult = UploadFile(byteData, fileName, _tp);
///是否上传成功
if (UplodResult.code == 100)
{
///保存到评价附件表
model.FlieID = UplodResult.data;
rs = MoblieProblem_obj.CommitFlieUplod(model);
}
}
}
}
if (rs)
{
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");
}
}
///
/// 判断是否能够评价
///
///
///
public ActionResult IsCommit(string id)
{
var r = MoblieProblem_obj.IsCommit(id, GetCurrentUser().PersonID);
return Content(r ? "1" : "0");
}
///
/// 获取文件图片
///
/// 评价id
///
public ActionResult GetEvaluationFile(string id)
{
var r = MoblieProblem_obj.GetEvaluationFile(id);
return Content(r, "application/json");
}
#endregion
}
}