Exemple #1
0
        public async Task <ApiData> ChangeUnitloadLocation(string palletCode, ChangeLocationArgs args)
        {
            Unitload unitload = await _session.Query <Unitload>().Where(x => x.PalletCode == palletCode).SingleOrDefaultAsync();

            if (unitload == null)
            {
                throw new InvalidOperationException("托盘号不存在。");
            }

            Location dest = await _session.Query <Location>().Where(x => x.LocationCode == args.DestinationLocationCode).SingleOrDefaultAsync();

            if (dest == null)
            {
                throw new Exception("货位号不存在。");
            }

            var originalLocationCode = unitload.CurrentLocation?.LocationCode;

            if (originalLocationCode == null)
            {
                originalLocationCode = Cst.None;
            }

            var archived = await _taskHelper.ChangeUnitloadsLocationAsync(unitload, dest, args.Comment + string.Format("user: {0}", this.User?.Identity?.Name ?? "-"));

            _ = await _opHelper.SaveOpAsync("任务号 {0}", archived.TaskCode);

            _logger.Information("已将托盘 {palletCode} 的位置从 {originalLocationCode} 改为 {destinationLocationCode}", palletCode, originalLocationCode, args.DestinationLocationCode);

            return(this.Success());
        }