| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568 |
- 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 图片上传
- /// <summary>
- /// 图片上传
- /// </summary>
- /// <returns></returns>
- [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);
- }
- /// <summary>
- /// 获取失物记录信息
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <param name="sqlWhere">查询条件</param>
- /// <returns></returns>
- [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 获取站点信息
- /// <summary>
- /// 获取字典信息
- /// </summary>
- /// <returns></returns>
- public ActionResult GetPathInfo()
- {
- SelectInfoTypeModel modelRes = new SelectInfoTypeModel();
- List<T_Sys_DictionaryValue> modelList = new List<T_Sys_DictionaryValue>();
- 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 失物丢失登记
- /// <summary>
- /// 失物丢失登记列表
- /// </summary>
- /// <returns></returns>
- public ActionResult LostGoodsRegistList()
- {
- LostGoodsModel viewModel = new LostGoodsModel();
- //物品种类
- viewModel.GoodsKindsModelList = GetCodeType("WPZL");
- //物品属性
- viewModel.GoodsPropertyModelList = GetCodeType("WPSX");
- return View(viewModel);
- }
- /// <summary>
- /// 失物录入
- /// </summary>
- /// <returns></returns>
- public ActionResult LostGoodsRegist()
- {
- LostGoodsModel viewModel = new LostGoodsModel();
- //物品种类
- viewModel.GoodsKindsModelList = GetCodeType("WPZL");
- //物品属性
- viewModel.GoodsPropertyModelList = GetCodeType("WPSX");
- return View(viewModel);
- }
- /// <summary>
- /// 归还编辑
- /// </summary>
- /// <param name="fid"></param>
- /// <returns></returns>
- public ActionResult LostGoodsRegistEdit(int fid)
- {
- Model.T_Good_Info model = bllGoods.GetModel(fid);
- //物品种类
- model.GoodsKindsModelList = GetCodeType("WPZL");
- //物品属性
- model.GoodsPropertyModelList = GetCodeType("WPSX");
- return View(model);
- }
- /// <summary>
- /// 保存编辑
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- public bool SaveRegistInfoEdit(Model.T_Good_Info model)
- {
-
- return bllGoods.Update(model);
- }
- /// <summary>
- /// 首次录入保存
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 获取失物记录信息
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <param name="sqlWhere">查询条件</param>
- /// <returns></returns>
- [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 待接收物品
- /// <summary>
- /// 失物丢失登记列表
- /// </summary>
- /// <returns></returns>
- public ActionResult LostGoodsReceivedList()
- {
- LostGoodsModel viewModel = new LostGoodsModel();
- //物品种类
- viewModel.GoodsKindsModelList = GetCodeType("WPZL");
- //物品属性
- viewModel.GoodsPropertyModelList = GetCodeType("WPSX");
- return View(viewModel);
- }
- /// <summary>
- /// 获取待接收记录信息
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <param name="sqlWhere">查询条件</param>
- /// <returns></returns>
- [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;
- }
- /// <summary>
- /// 接收物品保存
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- 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 失物归还
- /// <summary>
- /// 归还失物
- /// </summary>
- /// <param name="fid"></param>
- /// <returns></returns>
- public ActionResult RebackLost(int fid)
- {
- Model.T_Good_Info model = bllGoods.GetModel(fid);
- return View(model);
- }
- /// <summary>
- /// 失物详情
- /// </summary>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- /// 归还保存
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- 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 失物转移
- /// <summary>
- /// 失物转移
- /// </summary>
- /// <param name="fid"></param>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- /// 转移保存
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- public bool SaveLostTransferData(Model.T_Good_TransInfo model)
- {
- return bllGoods.TransferGoodList(model);
- }
- #endregion
- #region 销毁
- /// <summary>
- /// 失物销毁
- /// </summary>
- /// <param name="fid"></param>
- /// <returns></returns>
- public bool LostDelete(string keyList)
- {
- return bllGoods.DeleteGoods(keyList);
- }
- /// <summary>
- /// 失物删除
- /// </summary>
- /// <param name="fid"></param>
- /// <returns></returns>
- public bool AdminDeleteGoods(string keyList)
- {
- return bllGoods.AdminDeleteGoods(keyList);
- }
- #endregion
- }
- }
|