PreSendStockDetailController.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. /*
  2. * 预发货库存明细
  3. */
  4. using System;
  5. using System.Web;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.Linq;
  9. using System.Threading.Tasks;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Microsoft.AspNetCore.Http;
  12. using Microsoft.Extensions.Logging;
  13. using Microsoft.Extensions.Options;
  14. using MySystem.Models;
  15. using Library;
  16. using LitJson;
  17. using MySystemLib;
  18. namespace MySystem.Areas.Admin.Controllers
  19. {
  20. [Area("Admin")]
  21. [Route("Admin/[controller]/[action]")]
  22. public class PreSendStockDetailController : BaseController
  23. {
  24. public PreSendStockDetailController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  25. {
  26. OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  27. }
  28. #region 预发货库存明细列表
  29. /// <summary>
  30. /// 根据条件查询预发货库存明细列表
  31. /// </summary>
  32. /// <returns></returns>
  33. public IActionResult Index(PreSendStockDetail data, string right, string StoreId)
  34. {
  35. ViewBag.RightInfo = RightInfo;
  36. ViewBag.right = right;
  37. ViewBag.StoreId = StoreId;
  38. return View();
  39. }
  40. #endregion
  41. #region 根据条件查询预发货库存明细列表
  42. /// <summary>
  43. /// 预发货库存明细列表
  44. /// </summary>
  45. /// <returns></returns>
  46. public JsonResult IndexData(PreSendStockDetail data, string StoreIdStoreName, string StoreIdStoreNo, string BrandIdSelect, string ToUserIdMakerCode, string ToUserIdRealName, string ToStoreIdStoreNo, string ToStoreIdStoreName, string SourceStoreIdStoreNo, string SourceStoreIdStoreName, string FromUserIdMakerCode, string FromUserIdRealName, string FromStoreIdStoreNo, string FromStoreIdStoreName, int page = 1, int limit = 30)
  47. {
  48. Dictionary<string, string> Fields = new Dictionary<string, string>();
  49. Fields.Add("StoreId", "1");
  50. Fields.Add("CreateDate", "3"); //时间
  51. Fields.Add("SnNo", "1"); //SN编号
  52. Fields.Add("ApplyDate", "3"); //申请时间
  53. string condition = " and Status>-1";
  54. //仓库仓库名称
  55. if (!string.IsNullOrEmpty(StoreIdStoreName))
  56. {
  57. condition += " and StoreId in (select StoreId from SmallStoreHouseForStoreName where StoreName='" + StoreIdStoreName + "')";
  58. }
  59. //仓库仓库编号
  60. if (!string.IsNullOrEmpty(StoreIdStoreNo))
  61. {
  62. condition += " and StoreId in (select StoreId from SmallStoreHouseForStoreNo where StoreNo='" + StoreIdStoreNo + "')";
  63. }
  64. //产品类型
  65. if (!string.IsNullOrEmpty(BrandIdSelect))
  66. {
  67. condition += " and BrandId=" + BrandIdSelect;
  68. }
  69. //收货人创客编号
  70. if (!string.IsNullOrEmpty(ToUserIdMakerCode))
  71. {
  72. condition += " and ToUserId in (select ToUserId from UsersForMakerCode where MakerCode='" + ToUserIdMakerCode + "')";
  73. }
  74. //收货人真实姓名
  75. if (!string.IsNullOrEmpty(ToUserIdRealName))
  76. {
  77. condition += " and ToUserId in (select ToUserId from UsersForRealName where RealName='" + ToUserIdRealName + "')";
  78. }
  79. //收货仓库仓库编号
  80. if (!string.IsNullOrEmpty(ToStoreIdStoreNo))
  81. {
  82. condition += " and ToStoreId in (select ToStoreId from StoreHouseForStoreNo where StoreNo='" + ToStoreIdStoreNo + "')";
  83. }
  84. //收货仓库仓库名称
  85. if (!string.IsNullOrEmpty(ToStoreIdStoreName))
  86. {
  87. condition += " and ToStoreId in (select ToStoreId from StoreHouseForStoreName where StoreName='" + ToStoreIdStoreName + "')";
  88. }
  89. //源仓库编号仓库编号
  90. if (!string.IsNullOrEmpty(SourceStoreIdStoreNo))
  91. {
  92. condition += " and SourceStoreId in (select SourceStoreId from StoreHouseForStoreNo where StoreNo='" + SourceStoreIdStoreNo + "')";
  93. }
  94. //源仓库编号仓库名称
  95. if (!string.IsNullOrEmpty(SourceStoreIdStoreName))
  96. {
  97. condition += " and SourceStoreId in (select SourceStoreId from StoreHouseForStoreName where StoreName='" + SourceStoreIdStoreName + "')";
  98. }
  99. //出货创客创客编号
  100. if (!string.IsNullOrEmpty(FromUserIdMakerCode))
  101. {
  102. condition += " and FromUserId in (select FromUserId from UsersForMakerCode where MakerCode='" + FromUserIdMakerCode + "')";
  103. }
  104. //出货创客真实姓名
  105. if (!string.IsNullOrEmpty(FromUserIdRealName))
  106. {
  107. condition += " and FromUserId in (select FromUserId from UsersForRealName where RealName='" + FromUserIdRealName + "')";
  108. }
  109. //出货仓库仓库编号
  110. if (!string.IsNullOrEmpty(FromStoreIdStoreNo))
  111. {
  112. condition += " and FromStoreId in (select FromStoreId from StoreHouseForStoreNo where StoreNo='" + FromStoreIdStoreNo + "')";
  113. }
  114. //出货仓库仓库名称
  115. if (!string.IsNullOrEmpty(FromStoreIdStoreName))
  116. {
  117. condition += " and FromStoreId in (select FromStoreId from StoreHouseForStoreName where StoreName='" + FromStoreIdStoreName + "')";
  118. }
  119. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PreSendStockDetail", Fields, "Id desc", "0", page, limit, condition);
  120. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  121. foreach (Dictionary<string, object> dic in diclist)
  122. {
  123. //仓库
  124. int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
  125. SmallStoreHouse storeid_SmallStoreHouse = db.SmallStoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new SmallStoreHouse();
  126. dic["StoreIdStoreName"] = storeid_SmallStoreHouse.StoreName;
  127. dic["StoreIdStoreNo"] = storeid_SmallStoreHouse.StoreNo;
  128. dic.Remove("StoreId");
  129. //产品类型
  130. dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  131. //SNID
  132. dic["SnId"] = RelationClass.GetPosMachinesTwoInfo(int.Parse(dic["SnId"].ToString()));
  133. //收货人
  134. int ToUserId = int.Parse(function.CheckInt(dic["ToUserId"].ToString()));
  135. Users touserid_Users = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
  136. dic["ToUserIdMakerCode"] = touserid_Users.MakerCode;
  137. dic["ToUserIdRealName"] = touserid_Users.RealName;
  138. dic.Remove("ToUserId");
  139. //收货仓库
  140. int ToStoreId = int.Parse(function.CheckInt(dic["ToStoreId"].ToString()));
  141. StoreHouse tostoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == ToStoreId) ?? new StoreHouse();
  142. dic["ToStoreIdStoreNo"] = tostoreid_StoreHouse.StoreNo;
  143. dic["ToStoreIdStoreName"] = tostoreid_StoreHouse.StoreName;
  144. dic.Remove("ToStoreId");
  145. //源仓库编号
  146. int SourceStoreId = int.Parse(function.CheckInt(dic["SourceStoreId"].ToString()));
  147. StoreHouse sourcestoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == SourceStoreId) ?? new StoreHouse();
  148. dic["SourceStoreIdStoreNo"] = sourcestoreid_StoreHouse.StoreNo;
  149. dic["SourceStoreIdStoreName"] = sourcestoreid_StoreHouse.StoreName;
  150. dic.Remove("SourceStoreId");
  151. dic["ApplyFlagName"] = dic["ApplyFlag"].ToString() == "1" ? "是" : "否";
  152. //出货创客
  153. int FromUserId = int.Parse(function.CheckInt(dic["FromUserId"].ToString()));
  154. Users fromuserid_Users = db.Users.FirstOrDefault(m => m.Id == FromUserId) ?? new Users();
  155. dic["FromUserIdMakerCode"] = fromuserid_Users.MakerCode;
  156. dic["FromUserIdRealName"] = fromuserid_Users.RealName;
  157. dic.Remove("FromUserId");
  158. //出货仓库
  159. int FromStoreId = int.Parse(function.CheckInt(dic["FromStoreId"].ToString()));
  160. StoreHouse fromstoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == FromStoreId) ?? new StoreHouse();
  161. dic["FromStoreIdStoreNo"] = fromstoreid_StoreHouse.StoreNo;
  162. dic["FromStoreIdStoreName"] = fromstoreid_StoreHouse.StoreName;
  163. dic.Remove("FromStoreId");
  164. dic["CancelFlagName"] = dic["CancelFlag"].ToString() == "1" ? "是" : "否";
  165. }
  166. return Json(obj);
  167. }
  168. #endregion
  169. #region 增加预发货库存明细
  170. /// <summary>
  171. /// 增加或修改预发货库存明细信息
  172. /// </summary>
  173. /// <returns></returns>
  174. public IActionResult Add(string right, string StoreId)
  175. {
  176. ViewBag.RightInfo = RightInfo;
  177. ViewBag.right = right;
  178. ViewBag.StoreId = StoreId;
  179. return View();
  180. }
  181. #endregion
  182. #region 增加预发货库存明细
  183. /// <summary>
  184. /// 增加或修改预发货库存明细信息
  185. /// </summary>
  186. /// <returns></returns>
  187. [HttpPost]
  188. public string Add(PreSendStockDetail data)
  189. {
  190. Dictionary<string, object> Fields = new Dictionary<string, object>();
  191. Fields.Add("StoreId", data.StoreId);
  192. Fields.Add("StoreId", data.StoreId); //仓库
  193. Fields.Add("BrandId", data.BrandId); //产品类型
  194. Fields.Add("SnId", data.SnId); //SNID
  195. Fields.Add("ToUserId", data.ToUserId); //收货人
  196. Fields.Add("ToStoreId", data.ToStoreId); //收货仓库
  197. Fields.Add("SourceStoreId", data.SourceStoreId); //源仓库编号
  198. Fields.Add("ApplyFlag", data.ApplyFlag); //申请标记
  199. Fields.Add("ApplyDate", data.ApplyDate); //申请时间
  200. Fields.Add("FromUserId", data.FromUserId); //出货创客
  201. Fields.Add("FromStoreId", data.FromStoreId); //出货仓库
  202. Fields.Add("CancelFlag", data.CancelFlag); //撤回标记
  203. Fields.Add("CancelDate", data.CancelDate); //撤回时间
  204. Fields.Add("SeoTitle", data.SeoTitle);
  205. Fields.Add("SeoKeyword", data.SeoKeyword);
  206. Fields.Add("SeoDescription", data.SeoDescription);
  207. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("PreSendStockDetail", Fields, 0);
  208. AddSysLog(data.Id.ToString(), "PreSendStockDetail", "add");
  209. db.SaveChanges();
  210. return "success";
  211. }
  212. #endregion
  213. #region 修改预发货库存明细
  214. /// <summary>
  215. /// 增加或修改预发货库存明细信息
  216. /// </summary>
  217. /// <returns></returns>
  218. public IActionResult Edit(string right, string StoreId, int Id = 0)
  219. {
  220. ViewBag.RightInfo = RightInfo;
  221. ViewBag.right = right;
  222. ViewBag.StoreId = StoreId;
  223. PreSendStockDetail editData = db.PreSendStockDetail.FirstOrDefault(m => m.Id == Id) ?? new PreSendStockDetail();
  224. ViewBag.data = editData;
  225. return View();
  226. }
  227. #endregion
  228. #region 修改预发货库存明细
  229. /// <summary>
  230. /// 增加或修改预发货库存明细信息
  231. /// </summary>
  232. /// <returns></returns>
  233. [HttpPost]
  234. public string Edit(PreSendStockDetail data)
  235. {
  236. Dictionary<string, object> Fields = new Dictionary<string, object>();
  237. Fields.Add("StoreId", data.StoreId);
  238. Fields.Add("StoreId", data.StoreId); //仓库
  239. Fields.Add("BrandId", data.BrandId); //产品类型
  240. Fields.Add("SnId", data.SnId); //SNID
  241. Fields.Add("ToUserId", data.ToUserId); //收货人
  242. Fields.Add("ToStoreId", data.ToStoreId); //收货仓库
  243. Fields.Add("SourceStoreId", data.SourceStoreId); //源仓库编号
  244. Fields.Add("ApplyFlag", data.ApplyFlag); //申请标记
  245. Fields.Add("ApplyDate", data.ApplyDate); //申请时间
  246. Fields.Add("FromUserId", data.FromUserId); //出货创客
  247. Fields.Add("FromStoreId", data.FromStoreId); //出货仓库
  248. Fields.Add("CancelFlag", data.CancelFlag); //撤回标记
  249. Fields.Add("CancelDate", data.CancelDate); //撤回时间
  250. Fields.Add("SeoTitle", data.SeoTitle);
  251. Fields.Add("SeoKeyword", data.SeoKeyword);
  252. Fields.Add("SeoDescription", data.SeoDescription);
  253. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, data.Id);
  254. AddSysLog(data.Id.ToString(), "PreSendStockDetail", "update");
  255. db.SaveChanges();
  256. return "success";
  257. }
  258. #endregion
  259. #region 删除预发货库存明细信息
  260. /// <summary>
  261. /// 删除预发货库存明细信息
  262. /// </summary>
  263. /// <returns></returns>
  264. public string Delete(string Id)
  265. {
  266. string[] idlist = Id.Split(new char[] { ',' });
  267. AddSysLog(Id, "PreSendStockDetail", "del");
  268. foreach (string subid in idlist)
  269. {
  270. int id = int.Parse(subid);
  271. Dictionary<string, object> Fields = new Dictionary<string, object>();
  272. Fields.Add("Status", -1);
  273. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, id);
  274. }
  275. db.SaveChanges();
  276. return "success";
  277. }
  278. #endregion
  279. #region 开启
  280. /// <summary>
  281. /// 开启
  282. /// </summary>
  283. /// <returns></returns>
  284. public string Open(string Id)
  285. {
  286. string[] idlist = Id.Split(new char[] { ',' });
  287. AddSysLog(Id, "PreSendStockDetail", "open");
  288. foreach (string subid in idlist)
  289. {
  290. int id = int.Parse(subid);
  291. Dictionary<string, object> Fields = new Dictionary<string, object>();
  292. Fields.Add("Status", 1);
  293. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, id);
  294. }
  295. db.SaveChanges();
  296. return "success";
  297. }
  298. #endregion
  299. #region 关闭
  300. /// <summary>
  301. /// 关闭
  302. /// </summary>
  303. /// <returns></returns>
  304. public string Close(string Id)
  305. {
  306. string[] idlist = Id.Split(new char[] { ',' });
  307. AddSysLog(Id, "PreSendStockDetail", "close");
  308. foreach (string subid in idlist)
  309. {
  310. int id = int.Parse(subid);
  311. Dictionary<string, object> Fields = new Dictionary<string, object>();
  312. Fields.Add("Status", 0);
  313. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, id);
  314. }
  315. db.SaveChanges();
  316. return "success";
  317. }
  318. #endregion
  319. #region 排序
  320. /// <summary>
  321. /// 排序
  322. /// </summary>
  323. /// <param name="Id"></param>
  324. public string Sort(int Id, int Sort)
  325. {
  326. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("PreSendStockDetail", Sort, Id);
  327. AddSysLog(Id.ToString(), "PreSendStockDetail", "sort");
  328. return "success";
  329. }
  330. #endregion
  331. #region 导入数据
  332. /// <summary>
  333. /// 导入数据
  334. /// </summary>
  335. /// <param name="ExcelData"></param>
  336. public string Import(string ExcelData)
  337. {
  338. ExcelData = HttpUtility.UrlDecode(ExcelData);
  339. JsonData list = JsonMapper.ToObject(ExcelData);
  340. for (int i = 1; i < list.Count; i++)
  341. {
  342. JsonData dr = list[i];
  343. db.PreSendStockDetail.Add(new PreSendStockDetail()
  344. {
  345. CreateDate = DateTime.Now,
  346. UpdateDate = DateTime.Now,
  347. });
  348. db.SaveChanges();
  349. }
  350. AddSysLog("0", "PreSendStockDetail", "Import");
  351. return "success";
  352. }
  353. #endregion
  354. #region 导出Excel
  355. /// <summary>
  356. /// 导出Excel
  357. /// </summary>
  358. /// <returns></returns>
  359. public JsonResult ExportExcel(PreSendStockDetail data, string StoreIdStoreName, string StoreIdStoreNo, string BrandIdSelect, string ToUserIdMakerCode, string ToUserIdRealName, string ToStoreIdStoreNo, string ToStoreIdStoreName, string SourceStoreIdStoreNo, string SourceStoreIdStoreName, string FromUserIdMakerCode, string FromUserIdRealName, string FromStoreIdStoreNo, string FromStoreIdStoreName)
  360. {
  361. Dictionary<string, string> Fields = new Dictionary<string, string>();
  362. Fields.Add("CreateDate", "3"); //时间
  363. Fields.Add("SnNo", "1"); //SN编号
  364. Fields.Add("ApplyDate", "3"); //申请时间
  365. string condition = " and Status>-1";
  366. //仓库仓库名称
  367. if (!string.IsNullOrEmpty(StoreIdStoreName))
  368. {
  369. condition += " and StoreId in (select StoreId from SmallStoreHouseForStoreName where StoreName='" + StoreIdStoreName + "')";
  370. }
  371. //仓库仓库编号
  372. if (!string.IsNullOrEmpty(StoreIdStoreNo))
  373. {
  374. condition += " and StoreId in (select StoreId from SmallStoreHouseForStoreNo where StoreNo='" + StoreIdStoreNo + "')";
  375. }
  376. //产品类型
  377. if (!string.IsNullOrEmpty(BrandIdSelect))
  378. {
  379. condition += " and BrandId=" + BrandIdSelect;
  380. }
  381. //收货人创客编号
  382. if (!string.IsNullOrEmpty(ToUserIdMakerCode))
  383. {
  384. condition += " and ToUserId in (select ToUserId from UsersForMakerCode where MakerCode='" + ToUserIdMakerCode + "')";
  385. }
  386. //收货人真实姓名
  387. if (!string.IsNullOrEmpty(ToUserIdRealName))
  388. {
  389. condition += " and ToUserId in (select ToUserId from UsersForRealName where RealName='" + ToUserIdRealName + "')";
  390. }
  391. //收货仓库仓库编号
  392. if (!string.IsNullOrEmpty(ToStoreIdStoreNo))
  393. {
  394. condition += " and ToStoreId in (select ToStoreId from StoreHouseForStoreNo where StoreNo='" + ToStoreIdStoreNo + "')";
  395. }
  396. //收货仓库仓库名称
  397. if (!string.IsNullOrEmpty(ToStoreIdStoreName))
  398. {
  399. condition += " and ToStoreId in (select ToStoreId from StoreHouseForStoreName where StoreName='" + ToStoreIdStoreName + "')";
  400. }
  401. //源仓库编号仓库编号
  402. if (!string.IsNullOrEmpty(SourceStoreIdStoreNo))
  403. {
  404. condition += " and SourceStoreId in (select SourceStoreId from StoreHouseForStoreNo where StoreNo='" + SourceStoreIdStoreNo + "')";
  405. }
  406. //源仓库编号仓库名称
  407. if (!string.IsNullOrEmpty(SourceStoreIdStoreName))
  408. {
  409. condition += " and SourceStoreId in (select SourceStoreId from StoreHouseForStoreName where StoreName='" + SourceStoreIdStoreName + "')";
  410. }
  411. //出货创客创客编号
  412. if (!string.IsNullOrEmpty(FromUserIdMakerCode))
  413. {
  414. condition += " and FromUserId in (select FromUserId from UsersForMakerCode where MakerCode='" + FromUserIdMakerCode + "')";
  415. }
  416. //出货创客真实姓名
  417. if (!string.IsNullOrEmpty(FromUserIdRealName))
  418. {
  419. condition += " and FromUserId in (select FromUserId from UsersForRealName where RealName='" + FromUserIdRealName + "')";
  420. }
  421. //出货仓库仓库编号
  422. if (!string.IsNullOrEmpty(FromStoreIdStoreNo))
  423. {
  424. condition += " and FromStoreId in (select FromStoreId from StoreHouseForStoreNo where StoreNo='" + FromStoreIdStoreNo + "')";
  425. }
  426. //出货仓库仓库名称
  427. if (!string.IsNullOrEmpty(FromStoreIdStoreName))
  428. {
  429. condition += " and FromStoreId in (select FromStoreId from StoreHouseForStoreName where StoreName='" + FromStoreIdStoreName + "')";
  430. }
  431. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PreSendStockDetail", Fields, "Id desc", "0", 1, 20000, condition, "StoreId,BrandId,SnNo,SnId,ToUserId,ToStoreId,SourceStoreId,ApplyFlag,ApplyDate,FromUserId,FromStoreId,CancelFlag,CancelDate", false);
  432. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  433. foreach (Dictionary<string, object> dic in diclist)
  434. {
  435. //仓库
  436. int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
  437. SmallStoreHouse storeid_SmallStoreHouse = db.SmallStoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new SmallStoreHouse();
  438. dic["StoreIdStoreName"] = storeid_SmallStoreHouse.StoreName;
  439. dic["StoreIdStoreNo"] = storeid_SmallStoreHouse.StoreNo;
  440. dic.Remove("StoreId");
  441. //产品类型
  442. dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  443. //SNID
  444. dic["SnId"] = RelationClass.GetPosMachinesTwoInfo(int.Parse(dic["SnId"].ToString()));
  445. //收货人
  446. int ToUserId = int.Parse(function.CheckInt(dic["ToUserId"].ToString()));
  447. Users touserid_Users = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
  448. dic["ToUserIdMakerCode"] = touserid_Users.MakerCode;
  449. dic["ToUserIdRealName"] = touserid_Users.RealName;
  450. dic.Remove("ToUserId");
  451. //收货仓库
  452. int ToStoreId = int.Parse(function.CheckInt(dic["ToStoreId"].ToString()));
  453. StoreHouse tostoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == ToStoreId) ?? new StoreHouse();
  454. dic["ToStoreIdStoreNo"] = tostoreid_StoreHouse.StoreNo;
  455. dic["ToStoreIdStoreName"] = tostoreid_StoreHouse.StoreName;
  456. dic.Remove("ToStoreId");
  457. //源仓库编号
  458. int SourceStoreId = int.Parse(function.CheckInt(dic["SourceStoreId"].ToString()));
  459. StoreHouse sourcestoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == SourceStoreId) ?? new StoreHouse();
  460. dic["SourceStoreIdStoreNo"] = sourcestoreid_StoreHouse.StoreNo;
  461. dic["SourceStoreIdStoreName"] = sourcestoreid_StoreHouse.StoreName;
  462. dic.Remove("SourceStoreId");
  463. dic["ApplyFlagName"] = dic["ApplyFlag"].ToString() == "1" ? "是" : "否";
  464. //出货创客
  465. int FromUserId = int.Parse(function.CheckInt(dic["FromUserId"].ToString()));
  466. Users fromuserid_Users = db.Users.FirstOrDefault(m => m.Id == FromUserId) ?? new Users();
  467. dic["FromUserIdMakerCode"] = fromuserid_Users.MakerCode;
  468. dic["FromUserIdRealName"] = fromuserid_Users.RealName;
  469. dic.Remove("FromUserId");
  470. //出货仓库
  471. int FromStoreId = int.Parse(function.CheckInt(dic["FromStoreId"].ToString()));
  472. StoreHouse fromstoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == FromStoreId) ?? new StoreHouse();
  473. dic["FromStoreIdStoreNo"] = fromstoreid_StoreHouse.StoreNo;
  474. dic["FromStoreIdStoreName"] = fromstoreid_StoreHouse.StoreName;
  475. dic.Remove("FromStoreId");
  476. dic["CancelFlagName"] = dic["CancelFlag"].ToString() == "1" ? "是" : "否";
  477. }
  478. Dictionary<string, object> result = new Dictionary<string, object>();
  479. result.Add("Status", "1");
  480. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  481. result.Add("Obj", diclist);
  482. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  483. ReturnFields.Add("StoreIdStoreName", "仓库仓库名称");
  484. ReturnFields.Add("StoreIdStoreNo", "仓库仓库编号");
  485. ReturnFields.Add("BrandId", "产品类型");
  486. ReturnFields.Add("SnNo", "SN编号");
  487. ReturnFields.Add("SnId", "SNID");
  488. ReturnFields.Add("ToUserIdMakerCode", "收货人创客编号");
  489. ReturnFields.Add("ToUserIdRealName", "收货人真实姓名");
  490. ReturnFields.Add("ToStoreIdStoreNo", "收货仓库仓库编号");
  491. ReturnFields.Add("ToStoreIdStoreName", "收货仓库仓库名称");
  492. ReturnFields.Add("SourceStoreIdStoreNo", "源仓库编号仓库编号");
  493. ReturnFields.Add("SourceStoreIdStoreName", "源仓库编号仓库名称");
  494. ReturnFields.Add("ApplyFlag", "申请标记");
  495. ReturnFields.Add("ApplyDate", "申请时间");
  496. ReturnFields.Add("FromUserIdMakerCode", "出货创客创客编号");
  497. ReturnFields.Add("FromUserIdRealName", "出货创客真实姓名");
  498. ReturnFields.Add("FromStoreIdStoreNo", "出货仓库仓库编号");
  499. ReturnFields.Add("FromStoreIdStoreName", "出货仓库仓库名称");
  500. ReturnFields.Add("CancelFlag", "撤回标记");
  501. ReturnFields.Add("CancelDate", "撤回时间");
  502. result.Add("Fields", ReturnFields);
  503. AddSysLog("0", "PreSendStockDetail", "ExportExcel");
  504. return Json(result);
  505. }
  506. #endregion
  507. }
  508. }