using logtxtWrite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using wcftest.BussinessExtension.Common;
using wcftest.BussinessExtension.Handle;
using wcftest.EnumDefine;
using wcftest.EnumDefine.Sys;
using wcftest.Model;
using wcftest.orm;
namespace wcftest.BussinessExtension
{
public class ExtendHelper
{
///
/// 验证库位号是否规范正确
///
///
///
///
public static bool ValidateIsRightForPositionName(string positionName, ref string msg)
{
if (positionName != SysGlole.PositionName_SHZCQ)
{//正常库位 1-01-02-06
string[] arr_positionName = positionName.Trim().Split('-');
if (arr_positionName.Length != 4)
{
msg = "库位号不符合长度!" + positionName;
return false;
}
}
return true;
}
///
/// 拼盘出库,清空库存
///
///
///
///
public static void RemoveProductPositionForPinPan(dbModel mod, string containerCode, string creator)
{
List productPositionList = mod.Base_ProductPosition.Where(x => x.PlateCode == containerCode).ToList();
if (productPositionList.Count < 1)
{
logtxt.txtWrite("类名:taskApi,函数名:madeDish Base_ProductPosition组盘出库 找不到托盘数据:" + containerCode, 2);
throw new Exception("根据托盘号" + containerCode + "没有找到库存,无法将拼盘出库的库存清空");
}
foreach (var itemRemove in productPositionList)
{
mod.Base_ProductPosition.Remove(itemRemove);
//增加出入库记录 【EditBy shaocx,2022-03-07】
OutInStockTaskHandler.AddOutInStockTask22(creator, mod, OutInStockTaskName.清库任务, itemRemove.ProductStorage, itemRemove, "拼盘,清空库存", "", "");
}
}
///
/// 获取入库日期
///
///
///
///
public static DateTime GetInStorageDate(Purchase_Shelve shelve, Purchase_ShelveList item)
{
DateTime dt = DateTime.Now;
if (shelve.ShelveType == ShelveTypeEnum.拼盘上架.ToString())
{
if (item.InStorageDate != null)
{
dt = (DateTime)item.InStorageDate;
}
}
return dt;
}
///
/// 转换PLC任务号
///
///
///
public static int ConvertPlcNO(int taskId)
{
if (taskId >= 65535)
{
taskId %= 65535;
}
taskId += 1;//自增加1
if (taskId <= 0)// 增加验证 【Editby shaocx,2023-03-18】
{
throw new Exception("生成的任务号不能为0!");
}
if (taskId > 65535)// 增加验证 【Editby shaocx,2023-03-18】
{
throw new Exception("生成的任务号不能大于65535!");
}
return taskId;
}
///
/// 获取基础数据的叠盘机编号
///
///
///
public static DiePanJiModel GetDeviceCodeForDiePanJi(int plateType)
{
DiePanJiModel model = null;
//根据表Base_Equipment的配置得来
Sys_containerType _Sys_containerType = (Sys_containerType)Enum.Parse(typeof(Sys_containerType), plateType.ToString());
switch (_Sys_containerType)
{
case Sys_containerType.大托盘:
model = new DiePanJiModel()
{
DeviceCode = "D001",
DeviceName = "大叠盘机",
FullQuantity = 8
};
break;
case Sys_containerType.小托盘:
model = new DiePanJiModel()
{
DeviceCode = "D002",
DeviceName = "小叠盘机",
FullQuantity = 10
};
break;
}
return model;
}
///
/// 获取要更新OnShelveStatus字段的失败字符串
///
///
///
///
///
public static string GetOnShelveStatusFailMsg(int checkHeight, int height, string findEmptyReason)
{
return "找不到可用空库位-" + "光电检测高度:" + checkHeight + ",系统校验高度:" + height + "," + findEmptyReason;
}
// ///
// /// 根据光电检测高度,得出库区1的高度
// ///
// /// 光电检测高度
// ///
// public static int ConvertHeightForArea1(int checkHeight)
// {
// /*
// * 小堆垛机:
//高度 1、2、3 ,去往 0-975
//高度 4、5、6,去往 975-1850
// */
// return checkHeight > 3 ? 2 : 1;//因为库区1的高度只有两种,所以就转换成了1,2两种
// }
// ///
// /// 根据光电检测高度,得出库区2的高度
// ///
// /// 光电检测高度
// ///
// public static int ConvertHeightForArea2(int checkHeight)
// {
// return checkHeight > 3 ? checkHeight - 1 : checkHeight;//因为库区2的高度只有四种,所以就转换成了1,2,3,4四种
// }
///
/// 根据光电检测高度,得出库区的高度
///
/// 光电检测高度
///
public static int ConvertHeightByArea(int areaCode, int checkHeight)
{
if (areaCode == 1)
{//库区1
/*
* 小堆垛机:
高度 1、2、3 ,去往 0-975
高度 4、5、6,去往 975-1850
*/
return checkHeight > 3 ? 2 : 1;//因为库区1的高度只有两种,所以就转换成了1,2两种
}
else if (areaCode == 2)
{//库区2
return checkHeight > 3 ? checkHeight - 1 : checkHeight;//因为库区2的高度只有四种,所以就转换成了1,2,3,4四种
}
else
{
throw new Exception("无效的库区" + areaCode);
}
}
}
}