public async Task <ResultJSON <string> > ExportExcel(DateTime start, DateTime end) { try { List <MoveStore> list = r.GetAllList(m => m.CreatedAt >= start && m.CreatedAt <= end); if (list == null || list.Count == 0) { return new ResultJSON <string> { Code = 503, Msg = "没有相关数据" } } ; var excellist = new List <MoveStoreExcel>(); MoveStoreExcel me; #region 赋值到excel model foreach (var item in list) { me = new MoveStoreExcel { 单号 = item.Name, 状态 = Enum.GetName(typeof(MoveStoreState), item.State), 生产员 = item.Worker, 转出仓 = item.OutStoreName, 转出油温 = item.OutTemperature, 转出密度 = item.OutDensity, 计划转出升数 = item.OutPlan, 实际转出升数 = item.OutFact, 转入仓 = item.InStoreName, 转入油温 = item.InTemperature, 转入密度 = item.InDensity, 创建时间 = item.CreatedAt.ToString("yyyy-MM-dd hh:mm") }; excellist.Add(me); } #endregion string filePath = Path.Combine(_hostingEnvironment.WebRootPath, @"excel\"); string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "_转仓单.xlsx"; Helper.FileHelper.ExportExcelByEPPlus(excellist, filePath + fileName); string filePathURL = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, @"excel/" + fileName); //推送到“导出数据” this.option.导出数据AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.导出数据Secret); await MassApi.SendTextCardAsync(option.导出数据AccessToken, option.导出数据AgentId, $"{UserName}导出转仓单数据到Excel" , $"<div class=\"gray\">操作时间:{DateTime.Now.ToString()}</div>" + $"<div class=\"gray\">导出时间段:{start.ToString()} - {end.ToString()}</div>" , filePathURL, toUser : "******"); return(new ResultJSON <string> { Code = 0, Data = filePathURL }); } catch (Exception e) { return(new ResultJSON <string> { Code = 503, Msg = e.Message }); } }
public async Task <ResultJSON <string> > ExportExcel(DateTime start, DateTime end) { try { List <Client> list = r.GetClientsForExportExcel(start, end); if (list == null || list.Count == 0) { return new ResultJSON <string> { Code = 503, Msg = "没有相关数据" } } ; var excellist = new List <ClientExcel>(); ClientExcel ce; foreach (var item in list) { ce = new ClientExcel { 个人或公司 = item.Name, 船号或车号 = item.CarNo, 跟进销售 = item.FollowSalesman, 联系人 = item.Contact, 电话 = item.Mobile, 个人账户余额 = item.Balances, 所属公司 = item.Company == null ? "" : item.Company.Name, 陆上或水上 = item.PlaceType == PlaceType.水上 ? "水上" : "陆上", 创建时间 = item.CreatedAt.ToString("yyyy-MM-dd hh:mm"), 备注 = item.Remark }; excellist.Add(ce); } string filePath = Path.Combine(_hostingEnvironment.WebRootPath, @"excel\"); string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "_客户.xlsx"; Helper.FileHelper.ExportExcelByEPPlus(excellist, filePath + fileName); string filePathURL = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, @"excel/" + fileName); //推送到“导出数据” this.option.导出数据AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.导出数据Secret); await MassApi.SendTextCardAsync(option.导出数据AccessToken, option.导出数据AgentId, $"{UserName}导出客户数据到Excel" , $"<div class=\"gray\">操作时间:{DateTime.Now.ToString()}</div>" + $"<div class=\"gray\">导出时间段:{start.ToString()} - {end.ToString()}</div>" , filePathURL, toUser : "******"); return(new ResultJSON <string> { Code = 0, Data = filePathURL }); } catch (Exception e) { return(new ResultJSON <string> { Code = 503, Msg = e.Message }); } }
public async Task <ResultJSON <string> > ExportExcel(DateTime start, DateTime end) { try { List <InAndOutLog> list = r.GetAllList(m => m.CreatedAt >= start && m.CreatedAt <= end); if (list == null || list.Count == 0) { return new ResultJSON <string> { Code = 503, Msg = "没有相关数据" } } ; var excellist = new List <InAndOutLogExcel>(); InAndOutLogExcel me; #region 赋值到excel model foreach (var item in list) { me = new InAndOutLogExcel { 操作 = item.Name, 出仓入仓 = Enum.GetName(typeof(LogType), item.Type), 油仓 = item.Store == null? "" : item.Store.Name, 数量 = item.Value, 单位 = item.Unit, 数量升数 = item.ValueLitre, 操作人员 = item.Operators, 时间 = item.CreatedAt.ToString("yyyy-MM-dd hh:mm") }; excellist.Add(me); } #endregion string filePath = Path.Combine(_hostingEnvironment.WebRootPath, @"excel\"); string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "_出入仓记录.xlsx"; Helper.FileHelper.ExportExcelByEPPlus(excellist, filePath + fileName); string filePathURL = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, @"excel/" + fileName); //推送到“导出数据” this.option.导出数据AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.导出数据Secret); await MassApi.SendTextCardAsync(option.导出数据AccessToken, option.导出数据AgentId, $"{UserName}导出出入仓记录数据到Excel" , $"<div class=\"gray\">操作时间:{DateTime.Now.ToString()}</div>" + $"<div class=\"gray\">导出时间段:{start.ToString()} - {end.ToString()}</div>" , filePathURL, toUser : "******"); return(new ResultJSON <string> { Code = 0, Data = filePathURL }); } catch (Exception e) { return(new ResultJSON <string> { Code = 503, Msg = e.Message }); } }
public async Task <ResultJSON <string> > ExportExcel(DateTime start, DateTime end) { try { List <Survey> list = r.GetAllList(s => s.CreatedAt >= start && s.CreatedAt <= end); if (list == null || list.Count == 0) { return new ResultJSON <string> { Code = 503, Msg = "没有相关数据" } } ; var excellist = new List <SurveyExcel>(); SurveyExcel oe; #region 赋值到excel model foreach (var item in list) { oe = new SurveyExcel { 油仓名称 = item.Store == null? "" : item.Store.Name, 油温 = item.Temperature, 密度 = item.Density, 油高 = item.Temperature, 油高对应升数 = item.Temperature, 测量时间 = item.CreatedAt.ToString("yyyy-MM-dd hh:mm"), }; excellist.Add(oe); } #endregion string filePath = Path.Combine(_hostingEnvironment.WebRootPath, @"excel\"); string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "_测量记录.xlsx"; Helper.FileHelper.ExportExcelByEPPlus(excellist, filePath + fileName); string filePathURL = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, @"excel/" + fileName); //推送到“导出数据” this.option.导出数据AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.导出数据Secret); await MassApi.SendTextCardAsync(option.导出数据AccessToken, option.导出数据AgentId, $"{UserName}导出油仓测量记录数据到Excel" , $"<div class=\"gray\">操作时间:{DateTime.Now.ToString()}</div>" + $"<div class=\"gray\">导出时间段:{start.ToString()} - {end.ToString()}</div>" , filePathURL, toUser : "******"); return(new ResultJSON <string> { Code = 0, Data = filePathURL }); } catch (Exception e) { return(new ResultJSON <string> { Code = 503, Msg = e.Message }); } }
public async Task <ResultJSON <string> > ExportExcel(DateTime start, DateTime end) { try { List <Store> list = r.GetAllList(); if (list == null || list.Count == 0) { return new ResultJSON <string> { Code = 503, Msg = "没有相关数据" } } ; var excellist = new List <StoreExcel>(); StoreExcel se; foreach (var item in list) { se = new StoreExcel { 油仓名称 = item.Name, 容量 = item.Volume, 数量 = item.Value, 最近测量密度 = item.Density, 最近测量时间 = item.LastSurveyAt, 所属 = item.StoreType == null ? "" : item.StoreType.Name, 类型 = Enum.GetName(typeof(StoreClass), item.StoreClass) }; excellist.Add(se); } string filePath = Path.Combine(_hostingEnvironment.WebRootPath, @"excel\"); string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "_油仓.xlsx"; Helper.FileHelper.ExportExcelByEPPlus(excellist, filePath + fileName); string filePathURL = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, @"excel/" + fileName); //推送到“导出数据” this.option.导出数据AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.导出数据Secret); await MassApi.SendTextCardAsync(option.导出数据AccessToken, option.导出数据AgentId, $"{UserName}导出油仓数据到Excel" , $"<div class=\"gray\">操作时间:{DateTime.Now.ToString()}</div>" , filePathURL, toUser : "******"); return(new ResultJSON <string> { Code = 0, Data = filePathURL }); } catch (Exception e) { return(new ResultJSON <string> { Code = 503, Msg = e.Message }); } }
public static void SendTextCard(string app, string toUser, string title, string desc) { var env = IocManager.Instance.Resolve <IHostingEnvironment>(); var appConfiguration = env.GetAppConfiguration(); string corpId = appConfiguration["SenparcWeixinSetting:CorpId"]; string secret = appConfiguration[string.Format("SenparcWeixinSetting:{0}:Secret", app)]; string agentId = appConfiguration[string.Format("SenparcWeixinSetting:{0}:AgentId", app)]; var accessToken = AccessTokenContainer.GetToken(corpId, secret); MassApi.SendTextCardAsync(accessToken, agentId, title, desc, "work.weixin.qq.com", null, toUser); }
public async Task <ResultJSON <MoveStore> > UpdateInOutFact([FromBody] MoveStore m) { r.CurrentUser = UserName; var result = r.UpdateInOutFact(m); //推送到“油仓情况” this.option.油仓情况AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.油仓情况Secret); await MassApi.SendTextCardAsync(option.油仓情况AccessToken, option.油仓情况AgentId, "转仓生产完工,已更新油仓油量" , $"<div class=\"gray\">单号:{result.Name}</div>" + $"<div class=\"normal\">施工人:{result.LastUpdatedBy}</div>" + $"<div class=\"normal\">转出:{result.OutStoreName} - {result.OutFact}升</div>" + $"<div class=\"normal\">转入:{result.InStoreName} - {result.InFact}升</div>" , $"https://vue.car0774.com/#/oilstore/inout", toUser : "******"); return(new ResultJSON <MoveStore> { Code = 0, Data = result }); }
public async Task <ResultJSON <Order> > Post([FromBody] Order o) { //判断是否重复单号 if (r.Has(od => od.Name == o.Name)) { return new ResultJSON <Order> { Code = 502 } } ; r.CurrentUser = UserName; if (r.Has(od => od.Name == o.Name)) { return new ResultJSON <Order> { Code = 501, Msg = "已存在单号" + o.Name + ",请勿重复提交" } } ; //如果不存在该客户,则新增到Client表中,并关联ClientId if (!cr.Has(cl => cl.CarNo == o.CarNo)) { Client c = cr.Insert(new Client { Name = "个人", CarNo = o.CarNo }); o.ClientId = c.Id; } //如果没有计划,则不用指定销售员,客户需求,不用计算提成 if (!o.SalesPlanId.HasValue) { o.Salesman = ""; } //标识“陆上”和“水上”的单 o.IsWater = o.OrderType == SalesPlanType.水上加油 || o.OrderType == SalesPlanType.水上机油 ? true : false; var result = r.Insert(o); //"水上加油"不再独立施工流程,跳过施工过程直接“完工”状态 if (o.OrderType == SalesPlanType.水上加油) { o.State = OrderState.已完成; o.OilCountLitre = o.Count; o.OilCount = o.Count; var res = r.ChangeState(o); //推送到“油仓情况” this.option.油仓情况AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.油仓情况Secret); await MassApi.SendTextCardAsync(option.油仓情况AccessToken, option.油仓情况AgentId, $"{result.CarNo}加油完工,已更新油仓油量" , $"<div class=\"gray\">单号:{result.Name}</div>" + $"<div class=\"normal\">施工人:{result.Worker}</div>" + $"<div class=\"normal\">数量:{Math.Round(result.OilCountLitre, 2)}升</div>" , $"https://vue.car0774.com/#/sales/order/{result.Id}/order", toUser : "******"); } //推送打印指令 //await _hub.Clients.All.InvokeAsync("printorder", result); //初始化推送需要到的AccessToken this.option.销售单AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.销售单Secret); this.option.加油AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.加油Secret); //#if !DEBUG //推送到“收银” this.option.收银AccessToken = AccessTokenContainer.TryGetToken(this.option.CorpId, this.option.收银Secret); await MassApi.SendTextCardAsync(option.收银AccessToken, option.收银AgentId, "已开单" , $"<div class=\"gray\">单号:{result.Name}</div>" + $"<div class=\"normal\">开单人:{UserName}</div>" + $"<div class=\"normal\">船号/车号/客户名称:{result.CarNo}</div>" , $"https://vue.car0774.com/#/sales/order/{result.Id}/order", toUser : "******"); string strType = "", orderUrl = "", produceUrl = "", carOrBoat = ""; switch (result.OrderType) { case SalesPlanType.水上加油: strType = "水上加油"; orderUrl = $"https://vue.car0774.com/#/sales/order/{result.Id}/order"; produceUrl = $"https://vue.car0774.com/#/produce/load/{result.Id}/0"; carOrBoat = "船号"; break; case SalesPlanType.陆上装车: strType = "陆上装车"; orderUrl = $"https://vue.car0774.com/#/sales/order/{result.Id}/order"; produceUrl = $"https://vue.car0774.com/#/produce/landload/{result.Id}"; carOrBoat = "车号/客户名"; break; case SalesPlanType.汇鸿车辆加油: strType = "汇鸿车辆加油"; orderUrl = $"https://vue.car0774.com/#/sales/order/{result.Id}/order"; produceUrl = $"https://vue.car0774.com/#/produce/load/{result.Id}/4"; carOrBoat = "车号/客户名"; break; case SalesPlanType.外来车辆加油: strType = "外来车加油"; orderUrl = $"https://vue.car0774.com/#/sales/order/{result.Id}/order"; produceUrl = $"https://vue.car0774.com/#/produce/load/{result.Id}/5"; carOrBoat = "车号/客户名"; break; } //推送到“销售单” await MassApi.SendTextCardAsync(option.销售单AccessToken, option.销售单AgentId, $"【{strType}】{UserName}开了销售单" , $"<div class=\"gray\">单号:{result.Name}</div>" + $"<div class=\"normal\">{carOrBoat}:{result.CarNo}</div>" , orderUrl, toUser : "******"); if (result.OrderType != SalesPlanType.水上机油 && result.OrderType != SalesPlanType.水上加油) { //推送到“加油”施工 await MassApi.SendTextCardAsync(option.加油AccessToken, option.加油AgentId, $"{strType},请施工" , $"<div class=\"gray\">单号:{result.Name}</div>" + $"<div class=\"normal\">开单人:{UserName}</div>" + $"<div class=\"normal\">{carOrBoat}:{result.CarNo}</div>" , produceUrl, toUser : "******"); } //#endif return(new ResultJSON <Order> { Code = 0, Data = result }); }