using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEA_Core;
|
using WIDESEA_Core.BaseServices;
|
using WIDESEA_Core.DB;
|
using WIDESEA_Core.Enums;
|
using WIDESEA_Core.Seed;
|
using WIDESEA_IRecordRepository;
|
using WIDESEA_IRecordService;
|
using WIDESEA_Model.Models;
|
|
namespace WIDESEA_RecordService
|
{
|
public partial class LocationStatusChangeRecordSetvice : ServiceBase<Dt_LocationStatusChangeRecord, ILocationStatusChangeRecordRepository>, ILocationStatusChangeRecordSetvice
|
{
|
public void AddLocationStatusChangeRecord(Dt_LocationInfo locationInfo, int lastStatus, int changeType, string? orderNo, int? taskNum)
|
{
|
try
|
{
|
Dt_LocationStatusChangeRecord locationStatusChangeRecord = new Dt_LocationStatusChangeRecord()
|
{
|
AfterStatus = locationInfo.LocationStatus,
|
BeforeStatus = lastStatus,
|
ChangeType = changeType,
|
LocationCode = locationInfo.LocationCode,
|
LocationId = locationInfo.Id,
|
TaskNum = taskNum,
|
OrderNo = orderNo ?? "",
|
Creater = App.User.UserId == 0 ? "" : "WCS",
|
CreateDate = App.User.UserId == 0 ? DateTime.Now : DateTime.Now,
|
};
|
|
BaseDal.AddData(locationStatusChangeRecord);
|
}
|
catch (Exception ex)
|
{
|
throw new Exception($"{ex.Message}");
|
}
|
}
|
|
public void AddLocationStatusChangeRecord(List<Dt_LocationInfo> locationInfos, int newStatus, int changeType, string? orderNo, List<int>? taskNums)
|
{
|
try
|
{
|
List<Dt_LocationStatusChangeRecord> records = new List<Dt_LocationStatusChangeRecord>();
|
for (int i = 0; i < locationInfos.Count; i++)
|
{
|
Dt_LocationInfo locationInfo = locationInfos[i];
|
int? taskNum = (taskNums != null && taskNums.Count > 0 && taskNums.Count == locationInfos.Count) ? taskNums[i] : null;
|
Dt_LocationStatusChangeRecord locationStatusChangeRecord = new Dt_LocationStatusChangeRecord()
|
{
|
AfterStatus = newStatus,
|
BeforeStatus = locationInfo.LocationStatus,
|
ChangeType = changeType,
|
LocationCode = locationInfo.LocationCode,
|
LocationId = locationInfo.Id,
|
TaskNum = taskNum,
|
OrderNo = orderNo ?? ""
|
};
|
records.Add(locationStatusChangeRecord);
|
}
|
|
|
BaseDal.AddData(records);
|
}
|
catch (Exception ex)
|
{
|
throw new Exception($"{ex.Message}");
|
}
|
}
|
|
public WebResponseContent GetLocationState(int id)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
List<Dt_LocationStatusChangeRecord> location=BaseDal.QueryData(x=>x.LocationId== id).ToList();
|
|
return content = WebResponseContent.Instance.OK(data: location);
|
}
|
catch (Exception ex)
|
{
|
return content = WebResponseContent.Instance.Error(ex.Message);
|
}
|
}
|
}
|
}
|