1
dengjunjie
2025-09-29 d9c99e0480b4910cdb134778dd5c314b35ec4cf2
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_ShuttleCar/ShuttleCarService.cs
@@ -1,7 +1,11 @@
using AutoMapper;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using SqlSugar;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Const;
using WIDESEAWCS_Core.DB;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_IShuttleCar;
using WIDESEAWCS_IShuttleCarInfoRepository;
using WIDESEAWCS_Model.Models;
@@ -46,5 +50,34 @@
        {
            return BaseDal.QueryFirst(x => x.ShuttleCarCode != ShuttleCarCode);
        }
        public override WebResponseContent UpdateData(SaveModel saveModel)
        {
            WebResponseContent responseContent = new WebResponseContent().OK();
            try
            {
                Dt_ShuttleCar shuttleCar = BaseDal.QueryFirst(x => x.ShuttleCarId == saveModel.MainData["shuttleCarId"].ObjToInt());
                var Position = saveModel.MainData["shuttleCarPosition"].ToString();
                if (BaseDal.QueryData(x => x.ShuttleCarPosition == Position && x.ShuttleCarId != shuttleCar.ShuttleCarId).Any())
                    throw new Exception($"位置【{Position}】已存在穿梭车");
                SqlSugarClient WMSsugarClient = new SqlSugarClient(new ConnectionConfig
                {
                    ConfigId = MainDb.CurrentDbConnId,
                    ConnectionString = AppSettings.Get("WMSConnectionString").DecryptDES(AppSecret.DB),
                    IsAutoCloseConnection = true,
                    DbType = DbType.SqlServer,
                });
                var getLocation = WMSsugarClient.Queryable("Dt_LocationInfo", "x").Where("LocationCode", "=", Position).Any();
                if (!getLocation) throw new Exception($"未找到位置【{Position}】");
                shuttleCar.ShuttleCarPosition = Position;
                shuttleCar.ShuttleCarPosition1 = Position;
                BaseDal.UpdateData(shuttleCar);
            }
            catch (Exception ex)
            {
                responseContent.Error(ex.Message);
            }
            return responseContent;
        }
    }
}