using HH.WMS.BLL.Algorithm; using HH.WMS.Common; using HH.WMS.Common.Algorithm; using HH.WMS.Common.External; using HH.WMS.Common.Response; using HH.WMS.DAL; using HH.WMS.DAL.Algorithm; using HH.WMS.Entitys.Algorithm; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HH.WMS.BLL.External { /// /// 入作业区业务 /// public class ExternalInWorkAreaBLL : BaseBLL { private static string _className = "HH.BWMS.BLL.External.ExternalInWorkAreaBLL."; #region 计算转运路径 + CalculateTransPath /// /// 计算转运路径 /// /// /// public static ExecuteInWorkAreaPara CalculateTransPath(ExecuteInWorkAreaPara executeInWorkAreaPara) { _className += "CalculateTransPath"; //获取作业区列表 var workAreaProList = BLLCreator.Create().GetInWorkPosition(executeInWorkAreaPara); if (workAreaProList.Any()) { executeInWorkAreaPara.WorkAreaProEntitys = workAreaProList; } else { executeInWorkAreaPara.BasisResponse = BasisResponse.Error("未找到该库区的作业流转流程!", _className); return executeInWorkAreaPara; } return executeInWorkAreaPara; } #endregion #region 算法计算终点货位 + InAss /// /// 算法计算终点货位 /// /// /// public static ExecuteInWorkAreaPara InAss(ExecuteInWorkAreaPara executeInWorkAreaPara) { _className += ".InAss"; if (string.IsNullOrEmpty(executeInWorkAreaPara.InWorkAreaEntity.endBit)) { var logicAreaCode = string.Empty; if (executeInWorkAreaPara.InWorkAreaEntity.data != null) { //根据物料查找逻辑分区,支持新柴发动机项目 if (!string.IsNullOrEmpty(executeInWorkAreaPara.InWorkAreaEntity.data[0].itemCode)) { List lstLogicEntityByItem = DALCreator.Create().GetPartitionItem(executeInWorkAreaPara.InWorkAreaEntity.data[0].itemCode, 2); logicAreaCode = lstLogicEntityByItem.FirstOrDefault() != null ? lstLogicEntityByItem.First().CN_S_AREA_CODE : ""; } } var aEntity = new InAssignEntity() { objectType = InAssignEntity.ObjectType.托盘, objectCode = executeInWorkAreaPara.InWorkAreaEntity.trayCode, itemCode = (executeInWorkAreaPara.InWorkAreaEntity.data != null && executeInWorkAreaPara.InWorkAreaEntity.data.Count > 0) ? executeInWorkAreaPara.InWorkAreaEntity.data[0].itemCode : "", lstAreaPrior = executeInWorkAreaPara.WorkAreaProEntitys.Select(p => new areaPriorClass { areaCode = p.CN_S_END_AREA_CODE, Prior = p.CN_N_PRIORITY }).ToList(), //lockLocation = endArea != null ? endArea.CN_C_IS_CONTROL_QTY.Equals("Y") : false, //不管控数量时,不锁定目的货位 projectCode = executeInWorkAreaPara.InWorkAreaEntity.projectCode, logicAreaCode = logicAreaCode, //taskNo = executeInWorkAreaPara.InWorkAreaEntity.taskNo, stockCode = executeInWorkAreaPara.InWorkAreaEntity.startStock, callSys = executeInWorkAreaPara.InWorkAreaEntity.sysName }; //根据库区获取货位 InAssignResultEntity resultEntity = BLLCreator.Create().InAssign(aEntity); if (resultEntity.Success) { executeInWorkAreaPara.TransportEntity.CN_C_END_IS_CONTROL_QTY = resultEntity.isControlQty; executeInWorkAreaPara.TransportEntity.CN_S_END_CONTROL_INV = resultEntity.isControlInv; executeInWorkAreaPara.TransportEntity.CN_S_END_AREA_TYPE = resultEntity.areaType; executeInWorkAreaPara.TransportEntity.CN_S_END_AREA = resultEntity.areaCode; executeInWorkAreaPara.TransportEntity.CN_S_END_BIT = resultEntity.locationCode; executeInWorkAreaPara.TransportEntity.CN_S_QTY_INDEX = resultEntity.index; //增加到回滚记录里面 if ((resultEntity.areaType == Constants.Area_Struc_PingStock || resultEntity.areaType == Constants.Area_Struc_LiStock) && resultEntity.isControlQty == "Y") { executeInWorkAreaPara.RollbackLocations.Add(executeInWorkAreaPara.TransportEntity.CN_S_END_BIT); } } else { executeInWorkAreaPara.BasisResponse = BasisResponse.Error("在" + string.Join(",", executeInWorkAreaPara.WorkAreaProEntitys.Select(o => o.CN_S_END_AREA_CODE).ToList()) + "库区中未找到合适的入库货位,详细原因:" + resultEntity.Msg, _className); } } return executeInWorkAreaPara; } #endregion } }