刘磊
2024-12-26 827880621d3d78b0c075c37751eeaab2fe1925b3
Merge branch 'master' of http://115.159.85.185:8098/r/HuaYiZhongHeng/BaiBuLiKu
已修改10个文件
244 ■■■■■ 文件已修改
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicRepository/Location/ILocationStatusChangeRecordRepository.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -562,6 +562,13 @@
                    }
                    else if (task.TaskState == (int)TaskInStatusEnum.SC_InFinish)
                    {
                        if (App.User.UserId > 0)
                        {
                            content = StackCraneTaskCompleted(task.TaskNum);
                            return content;
                        }
                        task.ModifyDate = DateTime.Now;
                        task.Modifier = "System";
Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js
@@ -108,7 +108,7 @@
    // icon: 'el-icon-printer',
    type: 'primary',
    // plain: true,
    color: '#529b2e',
    // color: '#529b2e',
    value: 'TaskHandComplete',
    onClick: function () {
      
@@ -118,11 +118,19 @@
    // icon: 'el-icon-printer',
    type: 'primary',
    // plain: true,
    color: '#529b2e',
    // color: '#529b2e',
    value: 'OutBound',
    onClick: function () {
      
    }
  },{
    name: '初始化库位',
    type: 'primary',
    // color: '#529b2e',
    value: 'initializeLocation',
    onClick: function () {
    }
  }
]
Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx
@@ -33,6 +33,24 @@
        //       this.$Message.success('点击了按钮');
        //     }
        //   });
        var btninitializeLocation = this.buttons.find(x => x.value == "initializeLocation");
        if (btninitializeLocation != null) {
            btninitializeLocation.onClick = () => {
                let rows = this.$refs.table.getSelected();
                if (rows.length == 0) return this.$error("请选择数据!");
                this.http
                    .post("api/LocationInfo/initializeLocation?locationID="+rows[0].id, "","数据处理中...")
                    .then((x) => {
                        if (x.status) {
                            this.$Message.success('成功.');
                            this.refresh();
                        } else {
                            return this.$error(x.message);
                        }
                    });
            }
        }
        var btnEnableLocation = this.buttons.find(x => x.value == "EnableLocation");
            if (btnEnableLocation != null) {
                btnEnableLocation.onClick = () => {
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicRepository/Location/ILocationStatusChangeRecordRepository.cs
@@ -10,4 +10,8 @@
    /// <param name="changeRecordDto">数据模型</param>
    /// <returns></returns>
    bool AddStatusChangeRecord(LocationChangeRecordDto changeRecordDto);
    void AddLocationStatusChangeRecord(DtLocationInfo locationInfo, int lastStatus, int changeType, int? taskNum);
    void AddLocationStatusChangeRecord(List<DtLocationInfo> locationInfos, int newStatus, int changeType, List<int>? taskNums);
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs
@@ -11,5 +11,7 @@
    /// <returns>任务对象</returns>
    Task<Dt_Task> TransferCheckAsync(int taskNum);
    Task<WebResponseContent> initializeLocation(int locationID);
    WebResponseContent CreateLocation(int x, int y, int z, int locType, int areaId);
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs
@@ -1,4 +1,6 @@
using WIDESEA_DTO;
using WIDESEA_Core;
using WIDESEA_DTO;
using WIDESEA_Model.Models;
namespace WIDESEA_StorageBasicRepository
{
@@ -27,5 +29,64 @@
            };
            return AddData(dtLocationStatusChangeRecord) > 0;
        }
        /// <summary>
        /// 添加货位变动记录
        /// </summary>
        /// <param name="locationInfo">更新实体</param>
        /// <param name="lastStatus">变动前状态</param>
        /// <param name="changeType">变动类型</param>
        /// <param name="taskNum">任务号</param>
        /// <exception cref="Exception"></exception>
        public void AddLocationStatusChangeRecord(DtLocationInfo locationInfo, int lastStatus, int changeType, int? taskNum)
        {
            try
            {
                DtLocationStatusChangeRecord locationStatusChangeRecord = new DtLocationStatusChangeRecord()
                {
                    AfterStatus = locationInfo.LocationStatus,
                    BeforeStatus = lastStatus,
                    ChangeType = changeType,
                    LocationCode = locationInfo.LocationCode,
                    LocationId = locationInfo.Id,
                    TaskNum = taskNum,
                    Creater = "System",
                    CreateDate = DateTime.Now,
                };
                base.AddData(locationStatusChangeRecord);
            }
            catch (Exception ex)
            {
                throw new Exception($"{ex.Message}");
            }
        }
        public void AddLocationStatusChangeRecord(List<DtLocationInfo> locationInfos, int newStatus, int changeType, List<int>? taskNums)
        {
            try
            {
                List<DtLocationStatusChangeRecord> records = new List<DtLocationStatusChangeRecord>();
                for (int i = 0; i < locationInfos.Count; i++)
                {
                    DtLocationInfo locationInfo = locationInfos[i];
                    int? taskNum = (taskNums != null && taskNums.Count > 0 && taskNums.Count == locationInfos.Count) ? taskNums[i] : null;
                    DtLocationStatusChangeRecord locationStatusChangeRecord = new DtLocationStatusChangeRecord()
                    {
                        AfterStatus = newStatus,
                        BeforeStatus = locationInfo.LocationStatus,
                        ChangeType = changeType,
                        LocationCode = locationInfo.LocationCode,
                        LocationId = locationInfo.Id,
                        TaskNum = taskNum,
                    };
                    records.Add(locationStatusChangeRecord);
                }
                AddData(records);
            }
            catch (Exception ex)
            {
                throw new Exception($"{ex.Message}");
            }
        }
    }
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs
@@ -1,5 +1,10 @@
using WIDESEA_Common;
using AngleSharp.Dom;
using Mapster;
using System.Threading.Tasks;
using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_DTO;
using WIDESEA_Model.Models;
namespace WIDESEA_StorageBasicService;
@@ -8,11 +13,14 @@
    private readonly LogFactory LogFactory = new LogFactory();
    private readonly IUnitOfWorkManage _unitOfWorkManage;
    private readonly IDt_TaskRepository _taskRepository;
    private readonly IDt_TaskService _taskService;
    private readonly IStockInfoRepository _stockInfoRepository;
    private readonly IStockInfoDetailRepository _stockInfoDetailRepository;
    private readonly IDt_WareAreaInfoRepository _wareAreaInfoRepository;
    private readonly IPointStackerRelationRepository _pointStackerRelationRepository;
    private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository;
    private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository;
    private readonly IMapper _mapper;
    public LocationInfoService(ILocationInfoRepository BaseDal,
                                    IUnitOfWorkManage unitOfWorkManage,
@@ -21,7 +29,10 @@
                                    IDt_WareAreaInfoRepository wareAreaInfoRepository,
                                    IPointStackerRelationRepository pointStackerRelationRepository,
                                    ITaskExecuteDetailRepository taskExecuteDetailRepository,
                                    ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository) : base(BaseDal)
                                    ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository,
                                    IStockInfoDetailRepository stockInfoDetailRepository,
                                    IMapper mapper,
                                    IDt_TaskService taskService) : base(BaseDal)
    {
        _unitOfWorkManage = unitOfWorkManage;
        _taskRepository = taskRepository;
@@ -30,6 +41,9 @@
        _pointStackerRelationRepository = pointStackerRelationRepository;
        _taskExecuteDetailRepository = taskExecuteDetailRepository;
        _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository;
        _stockInfoDetailRepository = stockInfoDetailRepository;
        _mapper = mapper;
        _taskService = taskService;
    }
    /// <summary>
@@ -103,6 +117,52 @@
        return base.UpdateData(saveModel);
    }
    #region 初始化库位
    public async Task<WebResponseContent> initializeLocation(int locationID)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            DtLocationInfo? location = BaseDal.QueryData(x => x.Id == locationID).FirstOrDefault();
            int LastStatus = location.LocationStatus;
            if (location == null)
            {
                return content.Error("未找到货位信息!");
            }
            DtStockInfo stock = _stockInfoRepository.QueryFirst(x => x.LocationId == location.Id);
            if(stock == null)
            {
                location.LocationStatus= (int)LocationEnum.Lock;
                BaseDal.UpdateData(location);
            }
            else
            {
                _unitOfWorkManage.BeginTran();
                DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>();
                stockInfo_Hty.ModifyDate = DateTime.Now;
                await DeleteStockInfoAsync(stock.Id);
                List<DtStockInfoDetail> detail = _stockInfoDetailRepository.QueryData(x => x.StockId == stock.Id).ToList();
                if (detail != null && detail.Count() > 0)
                {
                    await DeleteStockInfoDetailsAsync(detail);
                }
                await AddStockInfoHtyAsync(stockInfo_Hty);
                location.LocationStatus = (int)LocationEnum.Lock;
                BaseDal.UpdateData(location);
                _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, LastStatus, (int)StatusChangeTypeEnum.ManualOperation, 0);
                _unitOfWorkManage.CommitTran();
            }
            return content.OK();
        }
        catch (Exception ex)
        {
            _unitOfWorkManage.RollbackTran();
            return content.Error(ex.Message);
        }
    }
    #endregion
    #region 创建原始货位数据
@@ -325,5 +385,35 @@
    #endregion 创建初始货位方法
    #region 库存移入历史
    private async Task DeleteStockInfoAsync(int stockId)
    {
        var isStockUpdated = await _stockInfoRepository.DeleteDataByIdAsync(stockId);
        if (!isStockUpdated)
        {
            throw new Exception("库存信息更新失败");
        }
    }
    private async Task AddStockInfoHtyAsync(DtStockInfo_Hty dtStock)
    {
        var isStockAdd = await SqlSugarHelper.Db.InsertNav(dtStock).IncludesAllFirstLayer().ExecuteCommandAsync();
        if (!isStockAdd)
        {
            throw new Exception("库存历史信息添加失败");
        }
    }
    private async Task DeleteStockInfoDetailsAsync(IEnumerable<DtStockInfoDetail> details)
    {
        var ids = details.Select(x => (object)x.Id).ToArray();
        var isStockDetailUpdated = await _stockInfoDetailRepository.DeleteDataByIdsAsync(ids);
        if (!isStockDetailUpdated)
        {
            throw new Exception("库存详情信息更新失败");
        }
    }
    #endregion
    #endregion 内部方法
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1,4 +1,5 @@
using AngleSharp.Dom;
using log4net.Core;
using Mapster;
using Masuit.Tools;
using SixLabors.Fonts.Tables.AdvancedTypographic;
@@ -10,6 +11,7 @@
using WIDESEA_DTO.WMS;
using WIDESEA_IServices;
using WIDESEA_IStoragIntegrationServices;
using WIDESEA_StorageBasicRepository;
using WIDESEA_StoragIntegrationServices;
using WIDESEAWCS_BasicInfoRepository;
@@ -268,11 +270,13 @@
    {
        var location = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway);
        //var details = _stockInfoDetailRepository.QueryData(x => x.StockId == stock.Id);
        int lastStatus = location.LocationStatus;
        location.LocationStatus = (int)LocationEnum.Free;
        task.TaskState = (int)TaskOutStatusEnum.OutFinish;
        //task.CurrentAddress = task.NextAddress;
        //task.NextAddress = task.TargetAddress;
        _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery,task.TaskNum);
        LogFactory.GetLog("任务完成").Info(true, "更新库存状态与任务状态");
        return (location, task);
@@ -348,7 +352,7 @@
        try
        {
            // 更新货位和库存信息
            (DtStockInfo updateStock, DtLocationInfo locationInForm, DtLocationInfo locationInfoTo) = UpdateStockLocation(stock, task);
           (DtStockInfo updateStock, DtLocationInfo locationInForm, DtLocationInfo locationInfoTo) = UpdateStockLocation(stock, task);
            var taskHty = CreateHistoricalTask(task);
            LogFactory.GetLog("任务完成").InfoFormat(true, "移库任务完成", $"货位地址:{task.TargetAddress},修改后库存数据:{JsonConvert.SerializeObject(updateStock)},原先货位数据:{locationInForm}");
@@ -405,6 +409,7 @@
            var boxing = await _boxingInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode);
            var locationInf = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.TargetAddress && x.RoadwayNo == task.Roadway);
            int lastStatus = locationInf.LocationStatus;
            // 更新目标位置状态为库存中
            locationInf.LocationStatus = (int)LocationEnum.InStock;
@@ -416,6 +421,10 @@
                await _locationRepository.UpdateDataAsync(locationInf);
                await _task_HtyRepository.AddDataAsync(taskHty);
                await BaseDal.DeleteDataAsync(task);
                //记录货位变动信息
                _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInf, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum);
                return content.OK("入库任务完成成功");
            }
            // 根据是否有组盘信息创建库存实例模型
@@ -425,6 +434,7 @@
            bool isResult = await ExecuteTransaction(stock, taskHty, locationInf, task.TaskId, boxing);
            if (isResult)
            {
                _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInf, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum);
                content.OK("入库任务完成成功");
            }
            else
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -387,10 +387,13 @@
            TaskNum = await BaseDal.GetTaskNo(),
            Creater = "Systeam"
        };
        ConsoleHelper.WriteSuccessLine($"修改前:" + locationInfo.LocationStatus.ToString());
        int lastStatus = locationInfo.LocationStatus;
        ConsoleHelper.WriteSuccessLine($"修改前:" + lastStatus.ToString());
        locationInfo.LocationStatus = (int)LocationEnum.FreeDisable;
        ConsoleHelper.WriteSuccessLine($"修改后:" + locationInfo.LocationStatus.ToString());
        await UpdateLocationAsync(locationInfo);
        _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum);
        return task;
    }
@@ -672,10 +675,15 @@
            var isBox = await _boxingInfoRepository.AddDataNavAsync(boxing);
            ConsoleHelper.WriteSuccessLine($"修改前:" + locationInfo.LocationStatus.ToString());
            int lastStatus = locationInfo.LocationStatus;
            ConsoleHelper.WriteSuccessLine($"修改前:" + lastStatus.ToString());
            locationInfo.LocationStatus = (int)LocationEnum.FreeDisable;
            ConsoleHelper.WriteSuccessLine($"修改后:" + locationInfo.LocationStatus.ToString());
            await UpdateLocationAsync(locationInfo);
            _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum);
            return task;
        }
        catch (Exception ex)
@@ -784,10 +792,13 @@
                            var content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                            if (content.Status)
                            {
                                int lastStatus = item.LocationInfo.LocationStatus;
                                await BaseDal.AddDataAsync(task);
                                // 更新库存位置状态为不可用
                                item.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable;
                                await _locationRepository.UpdateDataAsync(item.LocationInfo);
                                _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(item.LocationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum);
                            }
                        }
                    }
@@ -833,6 +844,7 @@
                    WMSTaskDTO wmsTask = CreateTaskDTO(task);
                    // 更新库存位置状态为不可用
                    int lastStatus = location.LocationStatus;
                    stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable;
                    location.LocationStatus = (int)LocationEnum.Distribute;
                    await _unitOfWorkManage.UseTranAsync(async () =>
@@ -841,6 +853,8 @@
                        await _locationRepository.UpdateDataAsync(stockInfo.LocationInfo);
                        await _locationRepository.UpdateDataAsync(location);
                    });
                    _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum);
                    // 返回成功响应
                    return content.OK(data: wmsTask);
@@ -901,10 +915,14 @@
            WMSTaskDTO taskDTO = CreateTaskDTO(task);
            int lastStatus = locationInfo.LocationStatus;
            BaseDal.AddData(task);
            stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable;
            _locationRepository.UpdateData(stockInfo.LocationInfo);
            _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(stockInfo.LocationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum);
            return content.OK(data: taskDTO);
        }
        catch (Exception ex)
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs
@@ -1,4 +1,5 @@
using WIDESEA_DTO;
using Masuit.Tools.Models;
using WIDESEA_DTO;
namespace WIDESEA_WMSServer.Controllers;
@@ -24,4 +25,9 @@
    {
        return Service.CreateLocation(x, y, z, locType, areaId);
    }
    [HttpPost, AllowAnonymous, Route("initializeLocation")]
    public async Task<WebResponseContent> initializeLocation(int locationID)
    {
        return await Service.initializeLocation(locationID);
    }
}