jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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
{
    /// <summary>
    /// 入作业区业务
    /// </summary>
    public class ExternalInWorkAreaBLL : BaseBLL
    {
        private static string _className = "HH.BWMS.BLL.External.ExternalInWorkAreaBLL.";
 
        #region 计算转运路径 + CalculateTransPath
 
        /// <summary>
        /// 计算转运路径
        /// </summary>
        /// <param name="executeInWorkAreaPara"></param>
        /// <returns></returns>
        public static ExecuteInWorkAreaPara CalculateTransPath(ExecuteInWorkAreaPara executeInWorkAreaPara)
        {
            _className += "CalculateTransPath";
 
            //获取作业区列表
            var workAreaProList = BLLCreator.Create<TaskTransferBLL>().GetInWorkPosition(executeInWorkAreaPara);
            if (workAreaProList.Any())
            {
                executeInWorkAreaPara.WorkAreaProEntitys = workAreaProList;
            }
            else
            {
                executeInWorkAreaPara.BasisResponse = BasisResponse.Error("未找到该库区的作业流转流程!", _className);
                return executeInWorkAreaPara;
            }
 
            return executeInWorkAreaPara;
        }
 
        #endregion
 
        #region 算法计算终点货位 + InAss
 
        /// <summary>
        /// 算法计算终点货位
        /// </summary>
        /// <param name="executeInWorkAreaPara"></param>
        /// <returns></returns>
        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<AutoBomPartition_Item_REntity> lstLogicEntityByItem = DALCreator.Create<TN_WMS_AREADAL>().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<In_AlgorBLL>().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
 
    }
}