using System; using System.Linq; using System.Web.Mvc; using DSWeb.SoftMng.Models.MsSoftRequire; using DSWeb.SoftMng.DAL.MsSoftRequire; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using System.Collections.Generic; using HcUtility.Comm; using HcUtility.Core; using DSWeb.Areas.CommMng.DAL; using DSWeb.EntityDA; using DSWeb.MvcShipping.DAL.MsSysParamSet; using DSWeb.Areas.MvcShipping.Helper; namespace DSWeb.SoftMng.Controllers { [JsonRequestBehavior] public class MsSoftRequireController : Controller { // // GET: public ActionResult Index(string projectId = "") { Session["FilterProjectId"] = projectId; return View(); } // // GET: / public ActionResult Edit() { return View(); } public ActionResult MsdsView() { return View(); } // // GET: public ContentResult GetDataList(int start, int limit, string sort, string condition) { if (Session["FilterProjectId"] != null && !string.IsNullOrWhiteSpace(Session["FilterProjectId"].ToString())) { if (!string.IsNullOrWhiteSpace(condition)) { condition += " and "; } condition += $"projectid='{Session["FilterProjectId"].ToString()}'"; } var dataList = MsSoftRequireDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), sort); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetDataListStr(string sort, string condition) { var dataListStr = MsSoftRequireDAL.GetDataListStr(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr }); return new ContentResult() { Content = json }; } // // GET:/TruckMng/MsWlTyreAcc/GetData/ public ContentResult GetData(string handle, string condition) { SoftRequire head = null; if (handle == "edit") { var list = MsSoftRequireDAL.GetDataList(condition, Convert.ToString(Session["USERID"])); if (list.Count > 0) head = list[0]; } if (head == null) { head = new SoftRequire(); head.BSNO = PubSysDAL.GetBillNo("SR01"); head.BSSTATUS = "新建"; head.SALESTATUS = "未审核"; head.INPUTBY = Convert.ToString(Session["USERID"]); head.INPUTBYREF = Convert.ToString(Session["SHOWNAME"]); head.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); head.SOFTVER = "D7"; head.EMERGENCYCLASS = "0"; } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data) { var headData = JsonConvert.Deserialize(data); if (opstatus == "add") { headData.DbOperationType = DbOperationType.DbotIns; headData.INPUTBY = Convert.ToString(Session["USERID"]); headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } else { headData.DbOperationType = DbOperationType.DbotDel; } var GID = headData.GID; if (headData.CUSTDATE == "") headData.CUSTDATE = null; var modb = new ModelObjectDB(); var result = modb.Save(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsSoftRequireDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"])) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SaveSubmit(string opstatus, string data, string type) { var headData = JsonConvert.Deserialize(data); if (opstatus == "add") { headData.DbOperationType = DbOperationType.DbotIns; headData.INPUTBY = Convert.ToString(Session["USERID"]); headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } else { headData.DbOperationType = DbOperationType.DbotDel; } var GID = headData.GID; if (headData.CUSTDATE == "") headData.CUSTDATE = null; if (type == "1") headData.BSSTATUS = "提交审核"; if (type == "0") headData.BSSTATUS = "新建"; var modb = new ModelObjectDB(); var result = modb.Save(headData); if (headData.BSSTATUS == "提交审核" && headData.SALE != "" && headData.REQUIRETYPE != "BUG修改") { var USEDINGDINGMSG = MsSysParamSetDAL.GetData("PARAMNAME='USEDINGDINGMSG'").PARAMVALUE; if (USEDINGDINGMSG == "1") { var mailbody =headData.INPUTBYREF + " 提交工单,工单编号:" + headData.BSNO+ Environment.NewLine + "客户名称:" + headData.CUSTOMERNAME +" 需求:"+headData.REQUIREDETAIL + " 请审核!"; DingTalkHelper.SendMessage(headData.SALE, mailbody); } } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsSoftRequireDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"])) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult Audit(string GID, string type, string auditstr, string modify) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); if (type == "1") { string blUpSQL = "update op_softrequire set BSSTATUS='审核通过',MODIFYBY='" + modify + "',AUDITBY='" + Convert.ToString(Session["USERID"]) + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',AUDITRESULT='" + auditstr + "' where GID='" + GID + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); var USEDINGDINGMSG = MsSysParamSetDAL.GetData("PARAMNAME='USEDINGDINGMSG'").PARAMVALUE; if (USEDINGDINGMSG == "1"&& modify != "") { var headData = MsSoftRequireDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"])); var mailbody = "开发工单,工单编号:" + headData.BSNO + Environment.NewLine + "客户名称:" + headData.CUSTOMERNAME + " 需求:" + headData.REQUIREDETAIL + "已转与你,请安排开发!"; DingTalkHelper.SendMessage(modify, mailbody); } } if (type == "0") { string blUpSQL = "update op_softrequire set BSSTATUS='驳回提交',MODIFYBY='" + modify + "',AUDITBY='" + Convert.ToString(Session["USERID"]) + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',AUDITRESULT='" + auditstr + "' where GID='" + GID + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); var USEDINGDINGMSG = MsSysParamSetDAL.GetData("PARAMNAME='USEDINGDINGMSG'").PARAMVALUE; if (USEDINGDINGMSG == "1") { var headData = MsSoftRequireDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"])); var mailbody = "开发工单,工单编号:" + headData.BSNO + Environment.NewLine + "客户名称:" + headData.CUSTOMERNAME + " 需求:" + headData.REQUIREDETAIL + Environment.NewLine + "已驳回,驳回原因:"+headData.AUDITRESULT; DingTalkHelper.SendMessage(headData.INPUTBY, mailbody); } } var jsonRespose = new JsonResponse { Success = true, Message = "提交成功!", Data = MsSoftRequireDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"])) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SaleAudit(string GID, string type, string auditstr) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); if (type == "1") { string blUpSQL = "update op_softrequire set SALESTATUS='审核通过',SALEAUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',AUDITRESULT='" + auditstr + "' where GID='" + GID + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); } if (type == "0") { string blUpSQL = "update op_softrequire set BSSTATUS='驳回提交',SALESTATUS='驳回提交',SALEAUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',AUDITRESULT='" + auditstr + "' where GID='" + GID + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); } var jsonRespose = new JsonResponse { Success = true, Message = "审核成功!", Data = MsSoftRequireDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"])) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult modify(string GID, string type, string modifystr) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); if (type == "1") { string blUpSQL = "update op_softrequire set BSSTATUS='确认修改',MODIFYSTTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',MODIFYDETAIL='" + modifystr + "' where GID='" + GID + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); } if (type == "2") { string blUpSQL = "update op_softrequire set BSSTATUS='修改完成',MODIFYEDTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',MODIFYDETAIL='" + modifystr + "' where GID='" + GID + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); var USEDINGDINGMSG = MsSysParamSetDAL.GetData("PARAMNAME='USEDINGDINGMSG'").PARAMVALUE; if (USEDINGDINGMSG == "1") { var headData = MsSoftRequireDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"])); var mailbody = "工单编号:" + headData.BSNO + Environment.NewLine + "客户名称:" + headData.CUSTOMERNAME + " 需求:" + headData.REQUIREDETAIL + " 已修改完成!"; DingTalkHelper.SendMessage(headData.INPUTBY, mailbody); if (headData.SALE != "" && headData.SALE != headData.INPUTBY) { DingTalkHelper.SendMessage(headData.SALE, mailbody); } } } if (type == "0") { string blUpSQL = "update op_softrequire set BSSTATUS='审核通过',MODIFYSTTIME=null,MODIFYDETAIL='" + modifystr + "' where GID='" + GID + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); } var jsonRespose = new JsonResponse { Success = true, Message = "提交成功!", Data = MsSoftRequireDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"])) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult Over(string GID, string type) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); if (type == "1") { string blUpSQL = "update op_softrequire set BSSTATUS='确认完成',OVERBY='" + Convert.ToString(Session["USERID"]) + "',OVERTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where GID='" + GID + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); } if (type == "0") { string blUpSQL = "update op_softrequire set BSSTATUS='修改完成',OVERBY='" + Convert.ToString(Session["USERID"]) + "',OVERTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where GID='" + GID + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); } var jsonRespose = new JsonResponse { Success = true, Message = "提交成功!", Data = MsSoftRequireDAL.GetData("GID='" + GID + "'", Convert.ToString(Session["USERID"])) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult Delete(string data) { var headData = JsonConvert.Deserialize>(data); DBResult result = MsSoftRequireDAL.DeleteSoftRequire(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetDetailList(string condition, string sort) { var dataList = MsSoftRequireDAL.GetDetailList(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetDetailData(string handle, string condition) { var dataList = MsSoftRequireDAL.GetDetailData(condition); SoftRequireDetail head = null; if (handle == "edit") { var list = MsSoftRequireDAL.GetDetailList(condition); if (list.Count > 0) head = list[0]; } if (head == null) { head = new SoftRequireDetail(); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult SaveDetail(string opstatus, string data, string PID) { var headData = JsonConvert.Deserialize(data); if (opstatus == "add") { headData.DbOperationType = DbOperationType.DbotIns; headData.GID = Guid.NewGuid().ToString(); headData.LINKGID = PID; headData.INPUTBY = Convert.ToString(Session["USERID"]); headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); headData.MODIFYTIME = headData.INPUTTIME; } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.MODIFYTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } else { headData.DbOperationType = DbOperationType.DbotDel; } var GID = headData.GID; var modb = new ModelObjectDB(); var result = modb.Save(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsSoftRequireDAL.GetDetailData("GID='" + GID + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteDetail(string data) { var headData = JsonConvert.Deserialize>(data); DBResult result = MsSoftRequireDAL.DeleteDetail(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetSoftProject(string condition) { var dataList = MsSoftRequireDAL.GetSoftProject(condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } #region 参照部分 #endregion } }