using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Configuration;
|
|
using System.Web.UI.WebControls;
|
using WZ.Useful.Commons;
|
|
using System.Windows.Forms;
|
using WMS.Model;
|
using Newtonsoft.Json;
|
using WMS.yunneiWCS;
|
|
|
namespace WMS.Untils
|
{
|
/// <summary>
|
/// WMS公共刮工具类
|
/// </summary>
|
public class WMSCommon
|
{
|
/// <summary>
|
/// 是否是呆滞库位
|
/// </summary>
|
/// <param name="basicDataSetForStayMonths"></param>
|
/// <param name="store"></param>
|
/// <returns></returns>
|
public static bool isStatyMonths(string basicDataSetForStayMonths, MyVproductStock store)
|
{
|
if (store.createTime != null)
|
{
|
if (store.createTime <= DateTime.Now.AddMonths(-Convert.ToInt32(basicDataSetForStayMonths)))
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
/// <summary>
|
/// 是否是空托盘
|
/// </summary>
|
/// <param name="store"></param>
|
/// <returns></returns>
|
public static bool isEmptySalver(MyVproductStock store)
|
{
|
if (!string.IsNullOrEmpty(store.materialCode) && (
|
store.materialCode == "GT-KTP" || store.materialCode == "GG-KTP"
|
))
|
{
|
return true;
|
}
|
return false;
|
}
|
|
/// <summary>
|
/// 是否是货物
|
/// </summary>
|
/// <param name="store"></param>
|
/// <returns></returns>
|
public static bool isCatogroy(MyVproductStock store)
|
{
|
if (!string.IsNullOrEmpty(store.materialCode) && (
|
store.materialCode != "GT-KTP" && store.materialCode != "GG-KTP"
|
))
|
{
|
return true;
|
}
|
return false;
|
}
|
|
/// <summary>
|
/// 公共处理发送AGV的结果
|
/// </summary>
|
/// <param name="result"></param>
|
public static void SendToAGVResult(string result)
|
{
|
if (string.IsNullOrEmpty(result))
|
{//成功
|
//MessageBox.Show("发送AGV任务成功");
|
}
|
else
|
{
|
AgvRetModel agvRet = JsonConvert.DeserializeObject<AgvRetModel>(result);
|
if (agvRet != null)
|
{
|
MessageBox.Show("发送AGV任务失败," + agvRet.message);
|
}
|
else
|
{
|
MessageBox.Show("发送AGV任务失败");
|
}
|
}
|
}
|
|
/// <summary>
|
/// 根据语言配置分页显示
|
/// </summary>
|
/// <param name="maxPage"></param>
|
/// <param name="dataCount"></param>
|
/// <returns></returns>
|
public static string ChangeLanguagForPage(int maxPage, int dataCount)
|
{
|
if (WMSFrmMain.LanguageFlg == 0)
|
{
|
//中文
|
return string.Format("共{0}页,共{1}条", maxPage, dataCount);
|
}
|
//英文
|
return string.Format("page count:{0},data count:{1}", maxPage, dataCount);
|
}
|
#region 【尝试修改版,周二测试,先将屏幕高度拉平,居中】 出入库提示界面,居中显示到第二个屏幕上
|
|
|
/// <summary>
|
/// 居中显示到第二个屏幕上
|
/// </summary>
|
/// <param name="frm"></param>
|
public static void ShowScreen2ForCenter(Form frm)
|
{
|
var screens = Screen.AllScreens;
|
if (screens.Length > 1)
|
{//如果是两个屏幕,则默认要显示到副屏幕上
|
//设置居中屏幕显示
|
//if (WMSFrmMain.currentStoreId == 1)
|
//{//A区屏幕
|
// var secondeScreen = GetSeconedScreen();
|
// frm.Top = (secondeScreen.Bounds.Height - frm.Height) / 2;
|
// //frm.Left = Screen.PrimaryScreen.WorkingArea.Width + (secondeScreen.Bounds.Width - frm.Width) / 2;
|
// frm.Left = (0 - secondeScreen.WorkingArea.Width * 2) + (secondeScreen.WorkingArea.Width * 2 - frm.Width) / 2;//修改 【EditBy shaocx,2021-07-12】
|
//}
|
//else
|
//{//C区屏幕
|
// var secondeScreen = GetSeconedScreen();
|
// frm.Top = (secondeScreen.Bounds.Height - frm.Height) / 2;
|
// frm.Left = (0 - secondeScreen.WorkingArea.Width * 2) + (secondeScreen.WorkingArea.Width * 2 - frm.Width) / 2;
|
//}
|
}
|
else
|
{
|
//设置居中屏幕显示
|
frm.Top = (screens[0].Bounds.Height - frm.Height) / 2;
|
frm.Left = (Screen.PrimaryScreen.WorkingArea.Width - frm.Width) / 2;
|
}
|
}
|
|
//*/
|
|
#endregion
|
|
|
|
/// <summary>
|
/// 显示到第二个屏幕上(副屏上)
|
/// </summary>
|
/// <param name="frm"></param>
|
public static void ShowScreen2(Form frm)
|
{
|
var screens = Screen.AllScreens;
|
if (screens.Length > 1)
|
{//如果是两个屏幕,则默认要显示到副屏幕上
|
//if (WMSFrmMain.currentStoreId == 1)
|
//{//A区屏幕
|
// //设置居中屏幕显示
|
// frm.Top = 0;
|
// //frm.Left = Screen.PrimaryScreen.WorkingArea.Width;
|
// frm.Left = 0 - Screen.PrimaryScreen.WorkingArea.Width;//修改 【EditBy shaocx,2021-07-12】
|
//}
|
//else
|
//{//C区屏幕
|
// //设置居中屏幕显示
|
// frm.Top = 0;
|
// var secondeScreen = GetSeconedScreen();
|
// frm.Left = 0 - secondeScreen.WorkingArea.Width;
|
//}
|
}
|
}
|
|
/// <summary>
|
/// 获取副屏幕对象
|
/// </summary>
|
/// <returns></returns>
|
private static Screen GetSeconedScreen()
|
{
|
var screens = Screen.AllScreens;
|
if (screens.Length > 1)
|
{
|
foreach (var item in screens)
|
{
|
if (!item.Primary)
|
{
|
return item;
|
}
|
}
|
}
|
return screens[0];
|
}
|
|
/// <summary>
|
/// 下拉框绑定库位号
|
/// </summary>
|
/// <param name="cb"></param>
|
public static void LoadAllSotreId(System.Windows.Forms.ComboBox cb)
|
{
|
//try
|
//{
|
// cb.Items.Clear();
|
// var _StoreEnum = StoreEnum.一号库;
|
// cb.Items.Add(new ListItem(_StoreEnum.ToString(), Convert.ToInt32(_StoreEnum).ToString()));
|
// _StoreEnum = StoreEnum.二号库;
|
// cb.Items.Add(new ListItem(_StoreEnum.ToString(), Convert.ToInt32(_StoreEnum).ToString()));
|
// return true;
|
//}
|
//catch (Exception ex)
|
//{
|
// MessageUtil.ShowError("绑定库位号出现错误:" + ex.Message);
|
// return false;
|
//}
|
}
|
|
/// <summary>
|
/// 下拉框绑定库位号
|
/// </summary>
|
/// <param name="cb"></param>
|
public static bool LoadSotreId(System.Windows.Forms.ComboBox cb)
|
{
|
try
|
{
|
//cb.Items.Clear();
|
//var _StoreEnum = Convert.ToInt32(StoreEnum.一号库);
|
//cb.Items.Add(new ListItem(_StoreEnum.ToString(), Convert.ToInt32(_StoreEnum).ToString()));
|
//var _StoreEnum2 = Convert.ToInt32(StoreEnum.二号库);
|
//cb.Items.Add(new ListItem(_StoreEnum2.ToString(), Convert.ToInt32(_StoreEnum2).ToString()));
|
return true;
|
}
|
catch (Exception ex)
|
{
|
MessageUtil.ShowError("绑定库位号出现错误:" + ex.Message);
|
return false;
|
}
|
}
|
|
/// <summary>
|
/// 下拉框绑定库位号
|
/// </summary>
|
/// <param name="cb"></param>
|
public static bool LoadSotreIdLocal(System.Windows.Forms.ComboBox cb)
|
{
|
try
|
{
|
//cb.Items.Clear();
|
//var _StoreEnum = BBConfigHelper.GetCurrentStoreIdConfig();
|
//cb.Items.Add(new ListItem(_StoreEnum.ToString(), Convert.ToInt32(_StoreEnum).ToString()));
|
return true;
|
}
|
catch (Exception ex)
|
{
|
MessageUtil.ShowError("绑定库位号出现错误:" + ex.Message);
|
return false;
|
}
|
}
|
|
/// <summary>
|
/// 获取当前程序配置的管理员密码
|
/// </summary>
|
/// <returns></returns>
|
public static string GetCurrentManagerPassword()
|
{
|
var _ManagerPassword = System.Configuration.ConfigurationManager.AppSettings["ManagerPassword"].ToString();
|
|
|
if (string.IsNullOrEmpty(_ManagerPassword))
|
{
|
throw new Exception("没有找到管理员密码的配置,请检查!");
|
}
|
|
return _ManagerPassword;
|
}
|
|
///// <summary>
|
///// 获取当前程序配置的库位号
|
///// </summary>
|
///// <returns></returns>
|
//public static StoreEnum GetCurrentStoreIdConfig(string storeid)
|
//{
|
// var currentStoreId = System.Configuration.ConfigurationManager.AppSettings[storeid].ToString();
|
|
|
// if (string.IsNullOrEmpty(currentStoreId))
|
// {
|
// throw new Exception("没有找到库存的配置,请检查!");
|
// }
|
|
// if (!System.Enum.IsDefined(typeof(StoreEnum), Convert.ToInt32(currentStoreId)))
|
// {
|
// throw new Exception("库位代码" + currentStoreId + "不在指定的范围内");
|
// }
|
// return (StoreEnum)System.Enum.Parse(typeof(StoreEnum), currentStoreId);
|
//}
|
}
|
}
|