using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; using YTSoft.BaseCallCenter.Model; using YTSoft.BaseCallCenter.MVCWeb.Models; namespace YTSoft.BaseCallCenter.MVCWeb.Controllers { public class LostGoodsController : BaseController { BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount(); BLL.T_Good_Info bllGoods = new BLL.T_Good_Info(); BLL.T_Good_TransInfo trgoodBLL = new BLL.T_Good_TransInfo(); #region 图片上传 /// /// 图片上传 /// /// [AcceptVerbs(HttpVerbs.Post)] public ActionResult UploadFile() { try { if (Request.Files.Count > 0) { string uppath = string.Empty; string savepath = string.Empty; HttpPostedFileBase imgFile = Request.Files[0]; if (imgFile != null) { //创建图片新的名称 string nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff"); //获得上传图片的路径 string strPath = imgFile.FileName; //获得上传图片的类型(后缀名) string type = strPath.Substring(strPath.LastIndexOf(".") + 1).ToLower(); //拼写数据库保存的相对路径字符串 savepath = "/Content/Upload/images/"; //拼写上传图片的路径 uppath = Server.MapPath("~/Content/Upload/images/"); if (!Directory.Exists(Path.GetDirectoryName(uppath))) { Directory.CreateDirectory(Path.GetDirectoryName(uppath)); } uppath += nameImg + "." + type; savepath += nameImg + "." + type; //上传图片 imgFile.SaveAs(uppath); //原图片路径 } return Json(new { code = 0, src = savepath, msg = "上传成功" }); } else { return Json(new { code = 1, src = "", msg = "上传出错 请检查图片名称或图片内容" }); } } catch (Exception ex) { return Json(new { code = 1, src = "", msg = "上传出错: " + ex.Message }); } } #endregion #region 查询所有失物信息 public ActionResult LostGoodsAllList(int? rightFlag) { LostGoodsModel viewModel = new LostGoodsModel(); if (rightFlag == null) { viewModel.RightFlag = 1; } else { viewModel.RightFlag = (int)rightFlag; } //物品种类 viewModel.GoodsKindsModelList = GetCodeType("WPZL"); //物品属性 viewModel.GoodsPropertyModelList = GetCodeType("WPSX"); return View(viewModel); } /// /// 获取失物记录信息 /// /// 当前页码 /// 每页数据量 /// 查询条件 /// [ActionName("GetRegistALLData")] [HttpGet] public string GetRegistALLData(DateTime? NowDateTime, int page, int limit, string getDate, string goodsName, int? goodsProty, int? goodsKinds, string getPlace, string getDetail, int? goodsStatus) { //自动销毁 bllGoods.DeleteGoodsBySys(); //数据结果集 ResponseData dataModel = new ResponseData(); string sql = ""; string startDate = ""; string endDate = ""; if (!string.IsNullOrEmpty(getDate)) { startDate = getDate.Substring(0, 10); endDate = getDate.Substring(12); sql += " and F_GetDate>='" + startDate + " 00:00:00'"; sql += " and F_GetDate<='" + endDate + " 23:59:59'"; } if (!string.IsNullOrEmpty(goodsName)) { sql += " and F_GoodsName like '%" + goodsName.Trim() + "%'"; } if (goodsProty != null && goodsProty > 0) { sql += " and F_PropertyId=" + goodsProty; } if (goodsKinds != null && goodsKinds > 0) { sql += " and F_KindsId=" + goodsKinds; } if (!string.IsNullOrEmpty(getPlace)) { sql += " and F_PlaceName like '%" + getPlace.Trim() + "%'"; } if (!string.IsNullOrEmpty(getDetail)) { sql += " and F_Remark like '%" + getDetail.Trim() + "%'"; } if (goodsStatus != null) { sql += " and F_Status=" + goodsStatus; } sql += " and F_Status<9 "; DataTable dt = new DataTable(); int recordCount = 0; dt = BLL.PagerBLL.GetListPager( "T_Good_Info", "F_Id", "*,CONVERT(varchar, F_GetDate, 120) as F_GetDateNew,CONVERT(varchar, F_CreateDate, 120) as F_CreateDateNew", sql, "ORDER BY F_Id desc", limit, page, true, out recordCount); dataModel.code = 0; dataModel.count = recordCount; dataModel.data = dt; string json = JsonConvert.SerializeObject(dataModel); return json; } #endregion #region 获取站点信息 /// /// 获取字典信息 /// /// public ActionResult GetPathInfo() { SelectInfoTypeModel modelRes = new SelectInfoTypeModel(); List modelList = new List(); BLL.T_Sys_DictionaryValue dicValueBll = new BLL.T_Sys_DictionaryValue(); modelList = dicValueBll.GetModelList("F_DictionaryFlag='ZDXX'"); if (modelList != null && modelList.Count > 0) { foreach (T_Sys_DictionaryValue model in modelList) { model.DictionaryValueModelList = dicValueBll.GetModelList("F_DictionaryFlag='" + model.F_ValueCode + "'"); } } modelRes.modelList = modelList; return View(modelRes); } #endregion #region 失物丢失登记 /// /// 失物丢失登记列表 /// /// public ActionResult LostGoodsRegistList() { LostGoodsModel viewModel = new LostGoodsModel(); //物品种类 viewModel.GoodsKindsModelList = GetCodeType("WPZL"); //物品属性 viewModel.GoodsPropertyModelList = GetCodeType("WPSX"); return View(viewModel); } /// /// 失物录入 /// /// public ActionResult LostGoodsRegist() { LostGoodsModel viewModel = new LostGoodsModel(); //物品种类 viewModel.GoodsKindsModelList = GetCodeType("WPZL"); //物品属性 viewModel.GoodsPropertyModelList = GetCodeType("WPSX"); return View(viewModel); } /// /// 归还编辑 /// /// /// public ActionResult LostGoodsRegistEdit(int fid) { Model.T_Good_Info model = bllGoods.GetModel(fid); //物品种类 model.GoodsKindsModelList = GetCodeType("WPZL"); //物品属性 model.GoodsPropertyModelList = GetCodeType("WPSX"); return View(model); } /// /// 保存编辑 /// /// /// public bool SaveRegistInfoEdit(Model.T_Good_Info model) { return bllGoods.Update(model); } /// /// 首次录入保存 /// /// /// public bool SaveRegistInfo(Model.T_Good_Info model) { BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount(); BLL.T_Good_Info bllGoods = new BLL.T_Good_Info(); model.F_SaveDepeId = model.F_UserId = F_UserID; model.F_PlaceName = model.F_SaveDepeName = model.F_UserName = userBLL.GetModel(F_UserID).F_UserName; model.F_CreateDate = DateTime.Now; model.F_Status = 0; model.F_StatusName = "未归还"; return bllGoods.Add(model) > 0; } /// /// 获取失物记录信息 /// /// 当前页码 /// 每页数据量 /// 查询条件 /// [ActionName("GetRegistData")] [HttpGet] public string GetRegistData(DateTime? NowDateTime, int page, int limit, string getDate, string goodsName, int? goodsProty, int? goodsKinds, string getPlace, string getDetail, int? goodsStatus) { //自动销毁 bllGoods.DeleteGoodsBySys(); //数据结果集 ResponseData dataModel = new ResponseData(); string sql = " and F_SaveDepeId=" + F_UserID + " and F_Status<=1 "; string startDate = ""; string endDate = ""; if (!string.IsNullOrEmpty(getDate)) { startDate = getDate.Substring(0, 10); endDate = getDate.Substring(12); sql += " and F_GetDate>='" + startDate + " 00:00:00'"; sql += " and F_GetDate<='" + endDate + " 23:59:59'"; } if (!string.IsNullOrEmpty(goodsName)) { sql += " and F_GoodsName like '%" + goodsName.Trim() + "%'"; } if (goodsProty != null && goodsProty > 0) { sql += " and F_PropertyId=" + goodsProty; } if (goodsKinds != null && goodsKinds > 0) { sql += " and F_KindsId=" + goodsKinds; } if (!string.IsNullOrEmpty(getPlace)) { sql += " and F_PlaceName like '%" + getPlace.Trim() + "%'"; } if (!string.IsNullOrEmpty(getDetail)) { sql += " and F_Remark like '%" + getDetail.Trim() + "%'"; } if (goodsStatus != null) { sql += " and F_Status=" + goodsStatus; } DataTable dt = new DataTable(); int recordCount = 0; dt = BLL.PagerBLL.GetListPager( "T_Good_Info", "F_Id", "*,(select f_id from T_Good_TransInfo WHERE F_TStatus=0 and F_GoodInfoId=T_Good_Info.F_id) as rowKey,CONVERT(varchar, F_GetDate, 120) as F_GetDateNew,CONVERT(varchar, F_CreateDate, 120) as F_CreateDateNew", sql, "ORDER BY F_Id desc", limit, page, true, out recordCount); dataModel.code = 0; dataModel.count = recordCount; dataModel.data = dt; string json = JsonConvert.SerializeObject(dataModel); return json; } #endregion #region 待接收物品 /// /// 失物丢失登记列表 /// /// public ActionResult LostGoodsReceivedList() { LostGoodsModel viewModel = new LostGoodsModel(); //物品种类 viewModel.GoodsKindsModelList = GetCodeType("WPZL"); //物品属性 viewModel.GoodsPropertyModelList = GetCodeType("WPSX"); return View(viewModel); } /// /// 获取待接收记录信息 /// /// 当前页码 /// 每页数据量 /// 查询条件 /// [ActionName("GetRegistReceivedData")] [HttpGet] public string GetRegistReceivedData(DateTime? NowDateTime, int page, int limit, string getDate, string goodsName, int? goodsProty, int? goodsKinds, string getPlace) { //自动销毁 bllGoods.DeleteGoodsBySys(); //数据结果集 ResponseData dataModel = new ResponseData(); string sql = " and F_Status=1 "; string startDate = ""; string endDate = ""; if (!string.IsNullOrEmpty(getDate)) { startDate = getDate.Substring(0, 10); endDate = getDate.Substring(12); sql += " and F_GetDate>='" + startDate + " 00:00:00'"; sql += " and F_GetDate<='" + endDate + " 23:59:59'"; } if (!string.IsNullOrEmpty(goodsName)) { sql += " and F_GoodsName like '%" + goodsName.Trim() + "%'"; } if (goodsProty != null && goodsProty > 0) { sql += " and F_PropertyId=" + goodsProty; } if (goodsKinds != null && goodsKinds > 0) { sql += " and F_KindsId=" + goodsKinds; } if (!string.IsNullOrEmpty(getPlace)) { sql += " and F_PlaceName like '%" + getPlace.Trim() + "%'"; } DataTable dt = new DataTable(); int recordCount = 0; dt = BLL.PagerBLL.GetListPager( "(SELECT t.*,m.F_Id as rowKey FROM T_Good_TransInfo m LEFT JOIN T_Good_Info t ON t.F_Id=m.F_GoodInfoId WHERE m.F_TStatus=0 and F_RecivedDepId=" + F_UserID + ") as t", "F_Id", "*,CONVERT(varchar, F_GetDate, 120) as F_GetDateNew,CONVERT(varchar, F_CreateDate, 120) as F_CreateDateNew", sql, "ORDER BY F_Id desc", limit, page, true, out recordCount); dataModel.code = 0; dataModel.count = recordCount; dataModel.data = dt; string json = JsonConvert.SerializeObject(dataModel); return json; } /// /// 接收物品保存 /// /// /// public bool SaveReceivedData(string keyList, int status) { Model.T_Good_TransInfo model = new T_Good_TransInfo(); model.KeyList = keyList; model.F_RecivedDepId = F_UserID; model.F_RecivedDepName = userBLL.GetModel(F_UserID).F_UserName; return bllGoods.TransferGoodReceivedList(model, status); } #endregion #region 失物归还 /// /// 归还失物 /// /// /// public ActionResult RebackLost(int fid) { Model.T_Good_Info model = bllGoods.GetModel(fid); return View(model); } /// /// 失物详情 /// /// public ActionResult LostGoodsView(int fid) { Model.T_Good_Info model = bllGoods.GetModel(fid); if (model != null && model.F_Id > 0) { model.TransInfoModelList = trgoodBLL.GetModelList(" F_GoodInfoId=" + fid); } return View(model); } /// /// 归还保存 /// /// /// public bool SaveRebackData(Model.T_Good_Info model) { BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount(); BLL.T_Good_Info bllGoods = new BLL.T_Good_Info(); model.F_Status = 2; model.F_StatusName = "已归还"; return bllGoods.RebackGoods(model); } #endregion #region 失物转移 /// /// 失物转移 /// /// /// public ActionResult LostTransfer(string keyList) { BLL.T_Sys_Department deptBll = new BLL.T_Sys_Department(); //实例化基础信息表 LostGoodsModel lostGoodsModel = new LostGoodsModel(); //获取部门列表 lostGoodsModel.DepartmentList = deptBll.GetModelList("F_ParentId=0"); lostGoodsModel.KeyList = keyList; return View(lostGoodsModel); } /// /// 转移保存 /// /// /// public bool SaveLostTransferData(Model.T_Good_TransInfo model) { return bllGoods.TransferGoodList(model); } #endregion #region 销毁 /// /// 失物销毁 /// /// /// public bool LostDelete(string keyList) { return bllGoods.DeleteGoods(keyList); } /// /// 失物删除 /// /// /// public bool AdminDeleteGoods(string keyList) { return bllGoods.AdminDeleteGoods(keyList); } #endregion } }