You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/Storage/Helper/StorageHelper.cs

129 lines
5.7 KiB
C#

using DSWeb.Areas.Storage.DB;
using DSWeb.Areas.Storage.Models;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Web;
namespace DSWeb.Areas.Storage.Helper
{
public class StorageHelper
{
private static string appid = ConfigurationManager.AppSettings["BeitongDispatchAppId"];
private static string dispatchServerUrl = ConfigurationManager.AppSettings["BeitongDispatchServerUrl"];
/// <summary>
/// 抢单
/// </summary>
/// <param name="leid"></param>
/// <returns></returns>
//public static bool SendIndoMessage(string leid, out string message)
//{
// DataContext dataContext = new DataContext();
// var query = from i in dataContext.IndoInfo
// join d in dataContext.Drivers on i.SHORTNAME equals d.InfoClient
// where i.ISTRUCK
// select new
// {
// d.OpenId,
// d.InfoClient
// };
// var infoList = query.ToList();
// var truckInfo = dataContext.OpLetterTrucks.FirstOrDefault(t => t.LE_ID == leid);
// //如果重复发电,删除先前的
// dataContext.Grabs.RemoveRange(dataContext.Grabs.Where(g => g.LE_ID == leid));
// //插入发单信息
// foreach (var item in infoList)
// {
// GrabInfo grab = new GrabInfo();
// grab.GID = Guid.NewGuid().ToString();
// grab.InfoClient = item.InfoClient;
// grab.LE_ID = truckInfo.LE_ID;
// grab.SendTime = DateTime.Now;
// grab.IsGrab = false;
// dataContext.Grabs.Add(grab);
// }
// dataContext.SaveChanges();
// StringBuilder sbErr = new StringBuilder();
// bool allSuccess = true;
// #region 微信禁止板消息群发,暂注释
// //保存完数据后,再发送消息
// //foreach (var item in infoList)
// //{
// // List<Tuple<string, string, string>> values = new List<Tuple<string, string, string>>();
// // values.Add(new Tuple<string, string, string>("TITLE", "您有一条新的抢单通知", "#FF0000"));
// // values.Add(new Tuple<string, string, string>("XX", truckInfo.CTNS, ""));
// // values.Add(new Tuple<string, string, string>("DW", truckInfo.KGS, ""));
// // values.Add(new Tuple<string, string, string>("ZHSJ", truckInfo.FACTRYTIME, ""));
// // values.Add(new Tuple<string, string, string>("JGSJ", truckInfo.CLOSINGDATE.HasValue ? truckInfo.CLOSINGDATE.Value.ToString("yyyy-MM-dd") : "", ""));
// // values.Add(new Tuple<string, string, string>("GCDZ", truckInfo.FACTRYADDR, ""));
// // values.Add(new Tuple<string, string, string>("FOOTTER", "点击查看详情", "#0000FF"));
// // string mess = string.Empty;
// // bool success = TemplateMessageHelper.SendTemplateMessage(appid, "5zWCiYhS44naUs1dolJuMtAhzqvrfpdHUK6JQJdtkLw", values, item.OpenId, $"{dispatchServerUrl}/Dispatch/Dispatch/GrabDetail?leid={truckInfo.LE_ID}&openid={item.OpenId}", out mess);
// // if (!success)
// // {
// // sbErr.AppendLine(mess);
// // allSuccess = false;
// // }
// //}
// #endregion
// message = sbErr.ToString();
// return allSuccess;
//}
/// <summary>
/// 派车
/// </summary>
/// <param name="leid"></param>
/// <returns></returns>
public static bool SendOutdoMessage(string wmsid, out string message)
{
DataContext dataContext = new DataContext();
var opseae = dataContext.OutdoInfo.FirstOrDefault(o => o.WMSID == wmsid);
//todo:发送消息
List<Tuple<string, string, string>> values = new List<Tuple<string, string, string>>();
values.Add(new Tuple<string, string, string>("first", "您有一条新的出库通知\r\n", ""));
values.Add(new Tuple<string, string, string>("keyword1", opseae.MBLNO, ""));
values.Add(new Tuple<string, string, string>("keyword2", opseae.GOODSNAME, ""));
values.Add(new Tuple<string, string, string>("keyword3", opseae.DODATE, ""));
values.Add(new Tuple<string, string, string>("keyword4", $"{opseae.PKGS}", ""));
values.Add(new Tuple<string, string, string>("keyword4", $"{opseae.KGS}", ""));
//values.Add(new Tuple<string, string, string>("keyword5", DateTime.Today.ToString("yyyy-MM-dd"), ""));
//if (truckInfo.CLOSINGDATE.HasValue)
//{
// values.Add(new Tuple<string, string, string>("remark", $"截港时间:{truckInfo.CLOSINGDATE.Value.ToString("yyyy-MM-dd")}\r\n\r\n请按时到场站拉货", ""));
//}
//else
//{
// values.Add(new Tuple<string, string, string>("remark", $"请按时到场站拉货", ""));
//}
string mess = string.Empty;
bool success = TemplateMessageHelper.SendTemplateMessage(appid, "hHh9N9xY1sVK6d8wxS-ObEV-0gWsPh_iCR13K447VXU", values, "", $"{dispatchServerUrl}/Storage/Storage/StorageDetail?wmsid={wmsid}&openid={""}", out mess);
if (!success)
{
message = mess;
return false;
}
else
{
message = "";
return true;
}
}
}
}