刘磊
2025-06-25 2de09bec5cc05bf875543fa8956167ca7db73021
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -1,6 +1,7 @@
using log4net.Core;
using Masuit.Tools;
using System.Collections.Generic;
using System.Net;
using WIDESEA_Common;
using WIDESEA_Core.Const;
using WIDESEA_DTO.WMS;
@@ -39,10 +40,23 @@
            var inWheelsInfo = _InWheels_MesRepository.QueryFirst(x => x.Wheels_CurrentStatue == "0");
            //查询创建的制动盘信息
            var inZDPInfo = _InZdp_MesRepository.QueryFirst(x => x.Zdp_CurrentStatue == "0");
            //查询创建的制动盘信息
            //var inBrakeInfo = _InWheels_MesRepository.QueryFirst(x => x.Wheels_CurrentStatue == "0");
            //if (inBrakeInfo == null) throw new Exception("当前无车轮或制动盘入库信息");
            if (inWheelsInfo == null /*&& inBrakeInfo == null*/) throw new Exception("当前无车轮或制动盘入库信息");
            //当车轮信息与制动盘信息同时出现需要入库的,则不可入库
            if(inWheelsInfo != null && inZDPInfo != null) throw new Exception("当前出现制动盘与车轮同时入库申请,申请错误,请确保只有一个执行入库");
            if (inWheelsInfo == null && inZDPInfo == null) throw new Exception("当前无车轮或制动盘入库信息");
            //默认为车轮入库,但是当车轮信息为空则为制动盘入库
            int rktype = 1;
            if(inWheelsInfo == null)
            {
                 rktype = 2;
            }
            var newtask = new Dt_Task
            {
@@ -54,16 +68,16 @@
                MaterialNo = "",
                NextAddress = input.Roadways,
                OrderNo = null,
                PalletCode = inWheelsInfo.Wheels_Num,
                PalletCode = rktype==1?inWheelsInfo.Wheels_Num: inZDPInfo.Zdp_code,
                SourceAddress = input.Position,
                TaskState = (int)TaskInStatusEnum.InNew,
                TaskType = (int)TaskInboundTypeEnum.InWheels,  //inWheelsInfo == null ? (int)TaskInboundTypeEnum.InBrake :
                TaskType = rktype == 1 ? (int)TaskInboundTypeEnum.InWheels: (int)TaskInboundTypeEnum.InBrake,  //inWheelsInfo == null ? (int)TaskInboundTypeEnum.InBrake :
                TaskNum = await BaseDal.GetTaskNo(),
                CarType = inWheelsInfo.Wheels_CarType,
                CarType = rktype == 1 ? inWheelsInfo.Wheels_CarType:inZDPInfo.Zdp_chexing,
                IsCheck = true,
                wheels_mttype = inWheelsInfo.Wheels_mttype,
                wheels_gkcc = inWheelsInfo.Wheels_gkcc,
                WheelsNewOrOld = inWheelsInfo.Wheels_NewOrOld,
                wheels_mttype = rktype == 1 ? inWheelsInfo.Wheels_mttype:"",
                wheels_gkcc = rktype == 1 ? inWheelsInfo.Wheels_gkcc: inZDPInfo.Zdp_GKJZ,
                WheelsNewOrOld = rktype == 1 ? inWheelsInfo.Wheels_NewOrOld : inZDPInfo.Zdp_neworold,
                Creater = "Systeam"
            };
@@ -93,8 +107,17 @@
                    WheelsLX = newtask.WheelsLX,
                };
                if (rktype == 2)
                {
                    inZDPInfo.Zdp_CurrentStatue = "1";
                    _InZdp_MesRepository.UpdateData(inZDPInfo);
                }
                else
                {
                inWheelsInfo.Wheels_CurrentStatue = "1";
                _InWheels_MesRepository.UpdateData(inWheelsInfo);
                }
                content.OK(data: taskDTO);
            }
@@ -236,19 +259,52 @@
        WebResponseContent content = new WebResponseContent();
        try
        {
            var cacheinfo = await _CacheInfoRepository.QueryFirstAsync(x => x.czh == input.PalletCode);
            /*var cacheinfo = await BaseDal.QueryFirstAsync(x => x.task_CZInfo == input.PalletCode);
            if (cacheinfo == null) throw new Exception($"未找到{input.PalletCode}车轴缓存位信息");
            return content.OK(data: cacheinfo.targetAddress);
            if(cacheinfo.Towhereabouts =="" && cacheinfo.Towhereabouts == null) throw new Exception($"{input.PalletCode}运输目标地址为空");
            return content.OK(data: cacheinfo.Towhereabouts);*/
            var task = await BaseDal.QueryFirstAsync(x => x.PalletCode == input.PalletCode);
            if (task == null) throw new Exception($"未找到{input.PalletCode}托盘信息");
            if (task.Towhereabouts == "" && task.Towhereabouts == null) throw new Exception($"{input.PalletCode}运输目标地址为空");
            return content.OK(data: task.Towhereabouts);
        }
        catch (Exception err)
        {
            // å¦‚果发生异常,则调用content.Error方法,记录错误信息,并输出错误信息
            content.Error(err.Message);
            Console.WriteLine($"车轮流向分配失败:{err.Message}");
            Console.WriteLine($"车轮流向分配失败:{err.Message},托盘条码:{input.PalletCode}");
            return content;
        }
    }
    public WebResponseContent UpWheelsFlow(SaveModel saveModel)
    {
        WebResponseContent webResponse = new WebResponseContent();
        try
        {
            string CZTM = saveModel.MainData["CZTM"].ToString();
            string TargetAddress = saveModel.MainData["TargetAddress"].ToString();
            List<Dt_Task> taskt = BaseDal.QueryData(x => x.task_CZInfo == CZTM).ToList();
            if (taskt.Count() == 0)
                return webResponse.Error($"未找到对应车轴:{CZTM}的车轮出库信息");
            foreach (var item in taskt)
            {
                item.Towhereabouts = TargetAddress;
            }
            BaseDal.UpdateData(taskt);
            return webResponse.OK();
        }
        catch (Exception ex)
        {
            // å¦‚果发生异常,则调用content.Error方法,记录错误信息,并输出错误信息
            webResponse.Error(ex.Message);
            return webResponse;
        }
    }
    #endregion
}