| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 |
- /*
- * 仓库库存变动记录
- */
- using System;
- using System.Web;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using MySystem.Models;
- using Library;
- using LitJson;
- using MySystemLib;
- namespace MySystem.Areas.Admin.Controllers
- {
- [Area("Admin")]
- [Route("Admin/[controller]/[action]")]
- public class StoreStockChangeController : BaseController
- {
- public StoreStockChangeController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
- }
- #region 仓库库存变动记录列表
- /// <summary>
- /// 根据条件查询仓库库存变动记录列表
- /// </summary>
- /// <returns></returns>
- public IActionResult Index(StoreStockChange data, string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 根据条件查询仓库库存变动记录列表
- /// <summary>
- /// 仓库库存变动记录列表
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexData(StoreStockChange data, string StoreIdStoreNo, string StoreIdStoreName, string BrandIdSelect, string TransTypeSelect, string StockOpDirectSelect, string SnStatusSelect, string BindStatusSelect, string BindMerchantMerchantNo, string BindMerchantMerchantName, string ActiveStatusSelect, string BrandTypeSelect, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("CreateDate", "3"); //时间
- Fields.Add("SnNo", "1"); //SN编号
- string condition = " and Status>-1";
- //仓库编号
- if (!string.IsNullOrEmpty(StoreIdStoreNo))
- {
- condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdStoreNo + "')";
- }
- //仓库名称
- if (!string.IsNullOrEmpty(StoreIdStoreName))
- {
- condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdStoreName + "')";
- }
- //产品类型
- if (!string.IsNullOrEmpty(BrandIdSelect))
- {
- condition += " and BrandId=" + BrandIdSelect;
- }
- //交易类型
- if (!string.IsNullOrEmpty(TransTypeSelect))
- {
- condition += " and TransType=" + TransTypeSelect;
- }
- //库存操作方向
- if (!string.IsNullOrEmpty(StockOpDirectSelect))
- {
- condition += " and StockOpDirect=" + StockOpDirectSelect;
- }
- //SN状态
- if (!string.IsNullOrEmpty(SnStatusSelect))
- {
- condition += " and SnStatus=" + SnStatusSelect;
- }
- //绑定状态
- if (!string.IsNullOrEmpty(BindStatusSelect))
- {
- condition += " and BindStatus=" + BindStatusSelect;
- }
- //绑定商户商户编号
- if (!string.IsNullOrEmpty(BindMerchantMerchantNo))
- {
- condition += " and BindMerchant in (select BindMerchant from MerchantForCode where Code='" + BindMerchantMerchantNo + "')";
- }
- //绑定商户商户姓名
- if (!string.IsNullOrEmpty(BindMerchantMerchantName))
- {
- condition += " and BindMerchant in (select BindMerchant from MerchantForName where Name='" + BindMerchantMerchantName + "')";
- }
- //激活状态
- if (!string.IsNullOrEmpty(ActiveStatusSelect))
- {
- condition += " and ActiveStatus=" + ActiveStatusSelect;
- }
- //品牌类型
- if (!string.IsNullOrEmpty(BrandTypeSelect))
- {
- condition += " and BrandType=" + BrandTypeSelect;
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreStockChange", Fields, "Id desc", "0", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- //仓库
- int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
- StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
- dic["StoreIdStoreNo"] = storeid_StoreHouse.StoreNo;
- dic["StoreIdStoreName"] = storeid_StoreHouse.StoreName;
- dic.Remove("StoreId");
- //产品类型
- dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
- //交易类型
- int TransType = int.Parse(dic["TransType"].ToString());
- if (TransType == 1) dic["TransType"] = "调拨";
- if (TransType == 2) dic["TransType"] = "出货";
- if (TransType == 3) dic["TransType"] = "退货";
- if (TransType == 0) dic["TransType"] = "采购";
- //库存操作方向
- int StockOpDirect = int.Parse(dic["StockOpDirect"].ToString());
- if (StockOpDirect == 0) dic["StockOpDirect"] = "入库";
- if (StockOpDirect == 1) dic["StockOpDirect"] = "出库";
- //SN状态
- int SnStatus = int.Parse(dic["SnStatus"].ToString());
- if (SnStatus == 0) dic["SnStatus"] = "未拨出";
- if (SnStatus == 1) dic["SnStatus"] = "已拨出";
- //绑定状态
- int BindStatus = int.Parse(dic["BindStatus"].ToString());
- if (BindStatus == 0) dic["BindStatus"] = "未绑定";
- if (BindStatus == 1) dic["BindStatus"] = "已绑定";
- //绑定商户
- int BindMerchant = int.Parse(function.CheckInt(dic["BindMerchant"].ToString()));
- MerchantInfo bindmerchant_MerchantInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == BindMerchant) ?? new MerchantInfo();
- dic["BindMerchantMerchantNo"] = "";
- dic["BindMerchantMerchantName"] = bindmerchant_MerchantInfo.Name;
- dic.Remove("BindMerchant");
- //激活状态
- int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
- if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
- if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
- //品牌类型
- string BrandType = dic["BrandType"].ToString();
- if (BrandType == "KysSignPos") dic["BrandType"] = "快益刷电签POS";
- if (BrandType == "KssSignPos") dic["BrandType"] = "快闪刷电签POS";
- if (BrandType == "") dic["BrandType"] = "";
- }
- return Json(obj);
- }
- #endregion
- #region 增加仓库库存变动记录
- /// <summary>
- /// 增加或修改仓库库存变动记录信息
- /// </summary>
- /// <returns></returns>
- public IActionResult Add(string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 增加仓库库存变动记录
- /// <summary>
- /// 增加或修改仓库库存变动记录信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public string Add(StoreStockChange data)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("SeoTitle", data.SeoTitle);
- Fields.Add("SeoKeyword", data.SeoKeyword);
- Fields.Add("SeoDescription", data.SeoDescription);
- int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("StoreStockChange", Fields, 0);
- AddSysLog(data.Id.ToString(), "StoreStockChange", "add");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 修改仓库库存变动记录
- /// <summary>
- /// 增加或修改仓库库存变动记录信息
- /// </summary>
- /// <returns></returns>
- public IActionResult Edit(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- StoreStockChange editData = db.StoreStockChange.FirstOrDefault(m => m.Id == Id) ?? new StoreStockChange();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 修改仓库库存变动记录
- /// <summary>
- /// 增加或修改仓库库存变动记录信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public string Edit(StoreStockChange data)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("SeoTitle", data.SeoTitle);
- Fields.Add("SeoKeyword", data.SeoKeyword);
- Fields.Add("SeoDescription", data.SeoDescription);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreStockChange", Fields, data.Id);
- AddSysLog(data.Id.ToString(), "StoreStockChange", "update");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 删除仓库库存变动记录信息
- /// <summary>
- /// 删除仓库库存变动记录信息
- /// </summary>
- /// <returns></returns>
- public string Delete(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "StoreStockChange", "del");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("Status", -1);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreStockChange", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 开启
- /// <summary>
- /// 开启
- /// </summary>
- /// <returns></returns>
- public string Open(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "StoreStockChange", "open");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("Status", 1);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreStockChange", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 关闭
- /// <summary>
- /// 关闭
- /// </summary>
- /// <returns></returns>
- public string Close(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "StoreStockChange", "close");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("Status", 0);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreStockChange", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 排序
- /// <summary>
- /// 排序
- /// </summary>
- /// <param name="Id"></param>
- public string Sort(int Id, int Sort)
- {
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("StoreStockChange", Sort, Id);
- AddSysLog(Id.ToString(), "StoreStockChange", "sort");
- return "success";
- }
- #endregion
- #region 导入数据
- /// <summary>
- /// 导入数据
- /// </summary>
- /// <param name="ExcelData"></param>
- public string Import(string ExcelData)
- {
- ExcelData = HttpUtility.UrlDecode(ExcelData);
- JsonData list = JsonMapper.ToObject(ExcelData);
- for (int i = 1; i < list.Count; i++)
- {
- JsonData dr = list[i];
- db.StoreStockChange.Add(new StoreStockChange()
- {
- CreateDate = DateTime.Now,
- UpdateDate = DateTime.Now,
- });
- db.SaveChanges();
- }
- AddSysLog("0", "StoreStockChange", "Import");
- return "success";
- }
- #endregion
- #region 导出Excel
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <returns></returns>
- public JsonResult ExportExcel(StoreStockChange data, string StoreIdStoreNo, string StoreIdStoreName, string BrandIdSelect, string TransTypeSelect, string StockOpDirectSelect, string SnStatusSelect, string BindStatusSelect, string BindMerchantMerchantNo, string BindMerchantMerchantName, string ActiveStatusSelect, string BrandTypeSelect)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("CreateDate", "3"); //时间
- Fields.Add("SnNo", "1"); //SN编号
- string condition = " and Status>-1";
- //仓库编号
- if (!string.IsNullOrEmpty(StoreIdStoreNo))
- {
- condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdStoreNo + "')";
- }
- //仓库名称
- if (!string.IsNullOrEmpty(StoreIdStoreName))
- {
- condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdStoreName + "')";
- }
- //产品类型
- if (!string.IsNullOrEmpty(BrandIdSelect))
- {
- condition += " and BrandId=" + BrandIdSelect;
- }
- //交易类型
- if (!string.IsNullOrEmpty(TransTypeSelect))
- {
- condition += " and TransType=" + TransTypeSelect;
- }
- //库存操作方向
- if (!string.IsNullOrEmpty(StockOpDirectSelect))
- {
- condition += " and StockOpDirect=" + StockOpDirectSelect;
- }
- //SN状态
- if (!string.IsNullOrEmpty(SnStatusSelect))
- {
- condition += " and SnStatus=" + SnStatusSelect;
- }
- //绑定状态
- if (!string.IsNullOrEmpty(BindStatusSelect))
- {
- condition += " and BindStatus=" + BindStatusSelect;
- }
- //绑定商户商户编号
- if (!string.IsNullOrEmpty(BindMerchantMerchantNo))
- {
- condition += " and BindMerchant in (select BindMerchant from MerchantForCode where Code='" + BindMerchantMerchantNo + "')";
- }
- //绑定商户商户姓名
- if (!string.IsNullOrEmpty(BindMerchantMerchantName))
- {
- condition += " and BindMerchant in (select BindMerchant from MerchantForName where Name='" + BindMerchantMerchantName + "')";
- }
- //激活状态
- if (!string.IsNullOrEmpty(ActiveStatusSelect))
- {
- condition += " and ActiveStatus=" + ActiveStatusSelect;
- }
- //品牌类型
- if (!string.IsNullOrEmpty(BrandTypeSelect))
- {
- condition += " and BrandType=" + BrandTypeSelect;
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreStockChange", Fields, "Id desc", "0", 1, 20000, condition, "StoreId,BrandId,TransType,SnNo,StockOpDirect,SnStatus,BindStatus,BindMerchant,ActiveStatus,ExpressNo,BrandType", false);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- //仓库
- int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
- StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
- dic["StoreIdStoreNo"] = storeid_StoreHouse.StoreNo;
- dic["StoreIdStoreName"] = storeid_StoreHouse.StoreName;
- dic.Remove("StoreId");
- //产品类型
- dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
- //交易类型
- int TransType = int.Parse(dic["TransType"].ToString());
- if (TransType == 1) dic["TransType"] = "调拨";
- if (TransType == 2) dic["TransType"] = "出货";
- if (TransType == 3) dic["TransType"] = "退货";
- if (TransType == 0) dic["TransType"] = "采购";
- //库存操作方向
- int StockOpDirect = int.Parse(dic["StockOpDirect"].ToString());
- if (StockOpDirect == 0) dic["StockOpDirect"] = "入库";
- if (StockOpDirect == 1) dic["StockOpDirect"] = "出库";
- //SN状态
- int SnStatus = int.Parse(dic["SnStatus"].ToString());
- if (SnStatus == 0) dic["SnStatus"] = "未拨出";
- if (SnStatus == 1) dic["SnStatus"] = "已拨出";
- //绑定状态
- int BindStatus = int.Parse(dic["BindStatus"].ToString());
- if (BindStatus == 0) dic["BindStatus"] = "未绑定";
- if (BindStatus == 1) dic["BindStatus"] = "已绑定";
- //绑定商户
- int BindMerchant = int.Parse(function.CheckInt(dic["BindMerchant"].ToString()));
- MerchantInfo bindmerchant_MerchantInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == BindMerchant) ?? new MerchantInfo();
- dic["BindMerchantMerchantNo"] = "";
- dic["BindMerchantMerchantName"] = bindmerchant_MerchantInfo.Name;
- dic.Remove("BindMerchant");
- //激活状态
- int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
- if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
- if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
- //品牌类型
- string BrandType = dic["BrandType"].ToString();
- if (BrandType == "KysSignPos") dic["BrandType"] = "快益刷电签POS";
- if (BrandType == "KssSignPos") dic["BrandType"] = "快闪刷电签POS";
- if (BrandType == "") dic["BrandType"] = "";
- }
- Dictionary<string, object> result = new Dictionary<string, object>();
- result.Add("Status", "1");
- result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
- result.Add("Obj", diclist);
- Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
- ReturnFields.Add("StoreIdStoreNo", "仓库编号");
- ReturnFields.Add("StoreIdStoreName", "仓库名称");
- ReturnFields.Add("BrandId", "产品类型");
- ReturnFields.Add("TransType", "交易类型");
- ReturnFields.Add("SnNo", "SN编号");
- ReturnFields.Add("StockOpDirect", "库存操作方向");
- ReturnFields.Add("SnStatus", "SN状态");
- ReturnFields.Add("BindStatus", "绑定状态");
- ReturnFields.Add("BindMerchantMerchantNo", "绑定商户编号");
- ReturnFields.Add("BindMerchantMerchantName", "绑定商户姓名");
- ReturnFields.Add("ActiveStatus", "激活状态");
- ReturnFields.Add("ExpressNo", "快递单号");
- ReturnFields.Add("BrandType", "品牌类型");
- ReturnFields.Add("CreateDate", "变动时间");
- result.Add("Fields", ReturnFields);
- AddSysLog("0", "StoreStockChange", "ExportExcel");
- return Json(result);
- }
- #endregion
- }
- }
|