郑许地铁

LostGoodsController.cs 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using ZXDT.CallCenter.Model;
  10. using ZXDT.CallCenter.MVCWeb.Models;
  11. namespace ZXDT.CallCenter.MVCWeb.Controllers
  12. {
  13. public class LostGoodsController : BaseController
  14. {
  15. BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
  16. BLL.T_Good_Info bllGoods = new BLL.T_Good_Info();
  17. BLL.T_Good_TransInfo trgoodBLL = new BLL.T_Good_TransInfo();
  18. #region 图片上传
  19. /// <summary>
  20. /// 图片上传
  21. /// </summary>
  22. /// <returns></returns>
  23. [AcceptVerbs(HttpVerbs.Post)]
  24. public ActionResult UploadFile()
  25. {
  26. try
  27. {
  28. if (Request.Files.Count > 0)
  29. {
  30. string uppath = string.Empty;
  31. string savepath = string.Empty;
  32. HttpPostedFileBase imgFile = Request.Files[0];
  33. if (imgFile != null)
  34. {
  35. //创建图片新的名称
  36. string nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff");
  37. //获得上传图片的路径
  38. string strPath = imgFile.FileName;
  39. //获得上传图片的类型(后缀名)
  40. string type = strPath.Substring(strPath.LastIndexOf(".") + 1).ToLower();
  41. //拼写数据库保存的相对路径字符串
  42. savepath = "/Content/Upload/images/";
  43. //拼写上传图片的路径
  44. uppath = Server.MapPath("~/Content/Upload/images/");
  45. if (!Directory.Exists(Path.GetDirectoryName(uppath)))
  46. {
  47. Directory.CreateDirectory(Path.GetDirectoryName(uppath));
  48. }
  49. uppath += nameImg + "." + type;
  50. savepath += nameImg + "." + type;
  51. //上传图片
  52. imgFile.SaveAs(uppath); //原图片路径
  53. }
  54. return Json(new
  55. {
  56. code = 0,
  57. src = savepath,
  58. msg = "上传成功"
  59. });
  60. }
  61. else
  62. {
  63. return Json(new
  64. {
  65. code = 1,
  66. src = "",
  67. msg = "上传出错 请检查图片名称或图片内容"
  68. });
  69. }
  70. }
  71. catch (Exception ex)
  72. {
  73. return Json(new
  74. {
  75. code = 1,
  76. src = "",
  77. msg = "上传出错: " + ex.Message
  78. });
  79. }
  80. }
  81. #endregion
  82. #region 查询所有失物信息
  83. public ActionResult LostGoodsAllList(int? rightFlag)
  84. {
  85. LostGoodsModel viewModel = new LostGoodsModel();
  86. if (rightFlag == null)
  87. {
  88. viewModel.RightFlag = 1;
  89. }
  90. else
  91. {
  92. viewModel.RightFlag = (int)rightFlag;
  93. }
  94. //物品种类
  95. viewModel.GoodsKindsModelList = GetCodeType("WPZL");
  96. //物品属性
  97. viewModel.GoodsPropertyModelList = GetCodeType("WPSX");
  98. return View(viewModel);
  99. }
  100. /// <summary>
  101. /// 获取失物记录信息
  102. /// </summary>
  103. /// <param name="page">当前页码</param>
  104. /// <param name="limit">每页数据量</param>
  105. /// <param name="sqlWhere">查询条件</param>
  106. /// <returns></returns>
  107. [ActionName("GetRegistALLData")]
  108. [HttpGet]
  109. public string GetRegistALLData(DateTime? NowDateTime, int page, int limit, string getDate, string goodsName, int? goodsProty, int? goodsKinds, string getPlace, string getDetail, int? goodsStatus)
  110. {
  111. //自动销毁
  112. bllGoods.DeleteGoodsBySys();
  113. //数据结果集
  114. ResponseData dataModel = new ResponseData();
  115. string sql = "";
  116. string startDate = "";
  117. string endDate = "";
  118. if (!string.IsNullOrEmpty(getDate))
  119. {
  120. startDate = getDate.Substring(0, 10);
  121. endDate = getDate.Substring(12);
  122. sql += " and F_GetDate>='" + startDate + " 00:00:00'";
  123. sql += " and F_GetDate<='" + endDate + " 23:59:59'";
  124. }
  125. if (!string.IsNullOrEmpty(goodsName))
  126. {
  127. sql += " and F_GoodsName like '%" + goodsName.Trim() + "%'";
  128. }
  129. if (goodsProty != null && goodsProty > 0)
  130. {
  131. sql += " and F_PropertyId=" + goodsProty;
  132. }
  133. if (goodsKinds != null && goodsKinds > 0)
  134. {
  135. sql += " and F_KindsId=" + goodsKinds;
  136. }
  137. if (!string.IsNullOrEmpty(getPlace))
  138. {
  139. sql += " and F_PlaceName like '%" + getPlace.Trim() + "%'";
  140. }
  141. if (!string.IsNullOrEmpty(getDetail))
  142. {
  143. sql += " and F_Remark like '%" + getDetail.Trim() + "%'";
  144. }
  145. if (goodsStatus != null)
  146. {
  147. sql += " and F_Status=" + goodsStatus;
  148. }
  149. sql += " and F_Status<9 ";
  150. DataTable dt = new DataTable();
  151. int recordCount = 0;
  152. dt = BLL.PagerBLL.GetListPager(
  153. "T_Good_Info",
  154. "F_Id",
  155. "*,CONVERT(varchar, F_GetDate, 120) as F_GetDateNew,CONVERT(varchar, F_CreateDate, 120) as F_CreateDateNew",
  156. sql,
  157. "ORDER BY F_Id desc",
  158. limit,
  159. page,
  160. true,
  161. out recordCount);
  162. dataModel.code = 0;
  163. dataModel.count = recordCount;
  164. dataModel.data = dt;
  165. string json = JsonConvert.SerializeObject(dataModel);
  166. return json;
  167. }
  168. #endregion
  169. #region 获取站点信息
  170. /// <summary>
  171. /// 获取字典信息
  172. /// </summary>
  173. /// <returns></returns>
  174. public ActionResult GetPathInfo()
  175. {
  176. SelectInfoTypeModel modelRes = new SelectInfoTypeModel();
  177. List<T_Sys_DictionaryValue> modelList = new List<T_Sys_DictionaryValue>();
  178. BLL.T_Sys_DictionaryValue dicValueBll = new BLL.T_Sys_DictionaryValue();
  179. modelList = dicValueBll.GetModelList("F_DictionaryFlag='ZDXX'");
  180. if (modelList != null && modelList.Count > 0)
  181. {
  182. foreach (T_Sys_DictionaryValue model in modelList)
  183. {
  184. model.DictionaryValueModelList = dicValueBll.GetModelList("F_DictionaryFlag='" + model.F_ValueCode + "'");
  185. }
  186. }
  187. modelRes.modelList = modelList;
  188. return View(modelRes);
  189. }
  190. #endregion
  191. #region 失物丢失登记
  192. /// <summary>
  193. /// 失物丢失登记列表
  194. /// </summary>
  195. /// <returns></returns>
  196. public ActionResult LostGoodsRegistList()
  197. {
  198. LostGoodsModel viewModel = new LostGoodsModel();
  199. //物品种类
  200. viewModel.GoodsKindsModelList = GetCodeType("WPZL");
  201. //物品属性
  202. viewModel.GoodsPropertyModelList = GetCodeType("WPSX");
  203. return View(viewModel);
  204. }
  205. /// <summary>
  206. /// 失物录入
  207. /// </summary>
  208. /// <returns></returns>
  209. public ActionResult LostGoodsRegist()
  210. {
  211. LostGoodsModel viewModel = new LostGoodsModel();
  212. //物品种类
  213. viewModel.GoodsKindsModelList = GetCodeType("WPZL");
  214. //物品属性
  215. viewModel.GoodsPropertyModelList = GetCodeType("WPSX");
  216. return View(viewModel);
  217. }
  218. /// <summary>
  219. /// 归还编辑
  220. /// </summary>
  221. /// <param name="fid"></param>
  222. /// <returns></returns>
  223. public ActionResult LostGoodsRegistEdit(int fid)
  224. {
  225. Model.T_Good_Info model = bllGoods.GetModel(fid);
  226. //物品种类
  227. model.GoodsKindsModelList = GetCodeType("WPZL");
  228. //物品属性
  229. model.GoodsPropertyModelList = GetCodeType("WPSX");
  230. return View(model);
  231. }
  232. /// <summary>
  233. /// 保存编辑
  234. /// </summary>
  235. /// <param name="model"></param>
  236. /// <returns></returns>
  237. public bool SaveRegistInfoEdit(Model.T_Good_Info model)
  238. {
  239. return bllGoods.Update(model);
  240. }
  241. /// <summary>
  242. /// 首次录入保存
  243. /// </summary>
  244. /// <param name="model"></param>
  245. /// <returns></returns>
  246. public bool SaveRegistInfo(Model.T_Good_Info model)
  247. {
  248. BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
  249. BLL.T_Good_Info bllGoods = new BLL.T_Good_Info();
  250. model.F_SaveDepeId = model.F_UserId = F_UserID;
  251. model.F_PlaceName = model.F_SaveDepeName = model.F_UserName = userBLL.GetModel(F_UserID).F_UserName;
  252. model.F_CreateDate = DateTime.Now;
  253. model.F_Status = 0;
  254. model.F_StatusName = "未归还";
  255. return bllGoods.Add(model) > 0;
  256. }
  257. /// <summary>
  258. /// 获取失物记录信息
  259. /// </summary>
  260. /// <param name="page">当前页码</param>
  261. /// <param name="limit">每页数据量</param>
  262. /// <param name="sqlWhere">查询条件</param>
  263. /// <returns></returns>
  264. [ActionName("GetRegistData")]
  265. [HttpGet]
  266. public string GetRegistData(DateTime? NowDateTime, int page, int limit, string getDate, string goodsName, int? goodsProty, int? goodsKinds, string getPlace, string getDetail, int? goodsStatus)
  267. {
  268. //自动销毁
  269. bllGoods.DeleteGoodsBySys();
  270. //数据结果集
  271. ResponseData dataModel = new ResponseData();
  272. string sql = " and F_SaveDepeId=" + F_UserID + " and F_Status<=1 ";
  273. string startDate = "";
  274. string endDate = "";
  275. if (!string.IsNullOrEmpty(getDate))
  276. {
  277. startDate = getDate.Substring(0, 10);
  278. endDate = getDate.Substring(12);
  279. sql += " and F_GetDate>='" + startDate + " 00:00:00'";
  280. sql += " and F_GetDate<='" + endDate + " 23:59:59'";
  281. }
  282. if (!string.IsNullOrEmpty(goodsName))
  283. {
  284. sql += " and F_GoodsName like '%" + goodsName.Trim() + "%'";
  285. }
  286. if (goodsProty != null && goodsProty > 0)
  287. {
  288. sql += " and F_PropertyId=" + goodsProty;
  289. }
  290. if (goodsKinds != null && goodsKinds > 0)
  291. {
  292. sql += " and F_KindsId=" + goodsKinds;
  293. }
  294. if (!string.IsNullOrEmpty(getPlace))
  295. {
  296. sql += " and F_PlaceName like '%" + getPlace.Trim() + "%'";
  297. }
  298. if (!string.IsNullOrEmpty(getDetail))
  299. {
  300. sql += " and F_Remark like '%" + getDetail.Trim() + "%'";
  301. }
  302. if (goodsStatus != null)
  303. {
  304. sql += " and F_Status=" + goodsStatus;
  305. }
  306. DataTable dt = new DataTable();
  307. int recordCount = 0;
  308. dt = BLL.PagerBLL.GetListPager(
  309. "T_Good_Info",
  310. "F_Id",
  311. "*,(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",
  312. sql,
  313. "ORDER BY F_Id desc",
  314. limit,
  315. page,
  316. true,
  317. out recordCount);
  318. dataModel.code = 0;
  319. dataModel.count = recordCount;
  320. dataModel.data = dt;
  321. string json = JsonConvert.SerializeObject(dataModel);
  322. return json;
  323. }
  324. #endregion
  325. #region 待接收物品
  326. /// <summary>
  327. /// 失物丢失登记列表
  328. /// </summary>
  329. /// <returns></returns>
  330. public ActionResult LostGoodsReceivedList()
  331. {
  332. LostGoodsModel viewModel = new LostGoodsModel();
  333. //物品种类
  334. viewModel.GoodsKindsModelList = GetCodeType("WPZL");
  335. //物品属性
  336. viewModel.GoodsPropertyModelList = GetCodeType("WPSX");
  337. return View(viewModel);
  338. }
  339. /// <summary>
  340. /// 获取待接收记录信息
  341. /// </summary>
  342. /// <param name="page">当前页码</param>
  343. /// <param name="limit">每页数据量</param>
  344. /// <param name="sqlWhere">查询条件</param>
  345. /// <returns></returns>
  346. [ActionName("GetRegistReceivedData")]
  347. [HttpGet]
  348. public string GetRegistReceivedData(DateTime? NowDateTime, int page, int limit, string getDate, string goodsName, int? goodsProty, int? goodsKinds, string getPlace)
  349. {
  350. //自动销毁
  351. bllGoods.DeleteGoodsBySys();
  352. //数据结果集
  353. ResponseData dataModel = new ResponseData();
  354. string sql = " and F_Status=1 ";
  355. string startDate = "";
  356. string endDate = "";
  357. if (!string.IsNullOrEmpty(getDate))
  358. {
  359. startDate = getDate.Substring(0, 10);
  360. endDate = getDate.Substring(12);
  361. sql += " and F_GetDate>='" + startDate + " 00:00:00'";
  362. sql += " and F_GetDate<='" + endDate + " 23:59:59'";
  363. }
  364. if (!string.IsNullOrEmpty(goodsName))
  365. {
  366. sql += " and F_GoodsName like '%" + goodsName.Trim() + "%'";
  367. }
  368. if (goodsProty != null && goodsProty > 0)
  369. {
  370. sql += " and F_PropertyId=" + goodsProty;
  371. }
  372. if (goodsKinds != null && goodsKinds > 0)
  373. {
  374. sql += " and F_KindsId=" + goodsKinds;
  375. }
  376. if (!string.IsNullOrEmpty(getPlace))
  377. {
  378. sql += " and F_PlaceName like '%" + getPlace.Trim() + "%'";
  379. }
  380. DataTable dt = new DataTable();
  381. int recordCount = 0;
  382. dt = BLL.PagerBLL.GetListPager(
  383. "(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",
  384. "F_Id",
  385. "*,CONVERT(varchar, F_GetDate, 120) as F_GetDateNew,CONVERT(varchar, F_CreateDate, 120) as F_CreateDateNew",
  386. sql,
  387. "ORDER BY F_Id desc",
  388. limit,
  389. page,
  390. true,
  391. out recordCount);
  392. dataModel.code = 0;
  393. dataModel.count = recordCount;
  394. dataModel.data = dt;
  395. string json = JsonConvert.SerializeObject(dataModel);
  396. return json;
  397. }
  398. /// <summary>
  399. /// 接收物品保存
  400. /// </summary>
  401. /// <param name="model"></param>
  402. /// <returns></returns>
  403. public bool SaveReceivedData(string keyList, int status)
  404. {
  405. Model.T_Good_TransInfo model = new T_Good_TransInfo();
  406. model.KeyList = keyList;
  407. model.F_RecivedDepId = F_UserID;
  408. model.F_RecivedDepName = userBLL.GetModel(F_UserID).F_UserName;
  409. return bllGoods.TransferGoodReceivedList(model, status);
  410. }
  411. #endregion
  412. #region 失物归还
  413. /// <summary>
  414. /// 归还失物
  415. /// </summary>
  416. /// <param name="fid"></param>
  417. /// <returns></returns>
  418. public ActionResult RebackLost(int fid)
  419. {
  420. Model.T_Good_Info model = bllGoods.GetModel(fid);
  421. return View(model);
  422. }
  423. /// <summary>
  424. /// 失物详情
  425. /// </summary>
  426. /// <returns></returns>
  427. public ActionResult LostGoodsView(int fid)
  428. {
  429. Model.T_Good_Info model = bllGoods.GetModel(fid);
  430. if (model != null && model.F_Id > 0)
  431. {
  432. model.TransInfoModelList = trgoodBLL.GetModelList(" F_GoodInfoId=" + fid);
  433. }
  434. return View(model);
  435. }
  436. /// <summary>
  437. /// 归还保存
  438. /// </summary>
  439. /// <param name="model"></param>
  440. /// <returns></returns>
  441. public bool SaveRebackData(Model.T_Good_Info model)
  442. {
  443. BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
  444. BLL.T_Good_Info bllGoods = new BLL.T_Good_Info();
  445. model.F_Status = 2;
  446. model.F_StatusName = "已归还";
  447. return bllGoods.RebackGoods(model);
  448. }
  449. #endregion
  450. #region 失物转移
  451. /// <summary>
  452. /// 失物转移
  453. /// </summary>
  454. /// <param name="fid"></param>
  455. /// <returns></returns>
  456. public ActionResult LostTransfer(string keyList)
  457. {
  458. BLL.T_Sys_Department deptBll = new BLL.T_Sys_Department();
  459. //实例化基础信息表
  460. LostGoodsModel lostGoodsModel = new LostGoodsModel();
  461. //获取部门列表
  462. lostGoodsModel.DepartmentList = deptBll.GetModelList("F_ParentId=0");
  463. lostGoodsModel.KeyList = keyList;
  464. return View(lostGoodsModel);
  465. }
  466. /// <summary>
  467. /// 转移保存
  468. /// </summary>
  469. /// <param name="model"></param>
  470. /// <returns></returns>
  471. public bool SaveLostTransferData(Model.T_Good_TransInfo model)
  472. {
  473. return bllGoods.TransferGoodList(model);
  474. }
  475. #endregion
  476. #region 销毁
  477. /// <summary>
  478. /// 失物销毁
  479. /// </summary>
  480. /// <param name="fid"></param>
  481. /// <returns></returns>
  482. public bool LostDelete(string keyList)
  483. {
  484. return bllGoods.DeleteGoods(keyList);
  485. }
  486. /// <summary>
  487. /// 失物删除
  488. /// </summary>
  489. /// <param name="fid"></param>
  490. /// <returns></returns>
  491. public bool AdminDeleteGoods(string keyList)
  492. {
  493. return bllGoods.AdminDeleteGoods(keyList);
  494. }
  495. #endregion
  496. }
  497. }