|
@@ -12,6 +12,7 @@ using wms.dataservice.IDataSetvice;
|
|
|
using wms.dto;
|
|
|
using wms.dto.request;
|
|
|
using wms.dto.request.fj;
|
|
|
+using wms.dto.request.share;
|
|
|
using wms.dto.response;
|
|
|
using wms.dto.response.fj;
|
|
|
using wms.service.IService;
|
|
@@ -58,6 +59,9 @@ namespace wms.service.Service
|
|
|
/// </summary>
|
|
|
private Repository<BaseContinfo> _baseContinfo => new Repository<BaseContinfo>();
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 当前任务表
|
|
|
+ /// </summary>
|
|
|
private RepositoryTask<WCS_TaskInfo> _taskrepository => new RepositoryTask<WCS_TaskInfo>();
|
|
|
|
|
|
/// <summary>
|
|
@@ -93,7 +97,14 @@ namespace wms.service.Service
|
|
|
/// </summary>
|
|
|
private RepositoryTask<WCS_TaskOld> _wcstaskoldrepository => new RepositoryTask<WCS_TaskOld>();
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 流水表
|
|
|
+ /// </summary>
|
|
|
private Repository<BillInvflow> _billInvflow => new Repository<BillInvflow>();
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 甲方管理系统推送反馈
|
|
|
+ /// </summary>
|
|
|
private Repository<BillPushinfo> _billPushinforepository => new Repository<BillPushinfo>();
|
|
|
|
|
|
/// <summary>
|
|
@@ -574,12 +585,12 @@ namespace wms.service.Service
|
|
|
req.BusType = FJTaskBusType.OneLayerManualPallets;
|
|
|
|
|
|
//TODO:条码长度待定
|
|
|
- if (reqDto.PalletCode.Length != 12)
|
|
|
- {
|
|
|
- res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
|
|
|
- res.ResMsg = "MES上传的RFID长度不等于12位";
|
|
|
- return res;
|
|
|
- }
|
|
|
+ //if (reqDto.PalletCode.Length != 12)
|
|
|
+ //{
|
|
|
+ // res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
|
|
|
+ // res.ResMsg = "MES上传的RFID长度不等于12位";
|
|
|
+ // return res;
|
|
|
+ //}
|
|
|
res = FJEmptyPalletsStockIn(req);
|
|
|
|
|
|
return res;
|
|
@@ -604,23 +615,23 @@ namespace wms.service.Service
|
|
|
}
|
|
|
|
|
|
//验证是否有空余货位
|
|
|
- res = (CopperLineResponse)IsThereAnySpaceVacancy();
|
|
|
+ res = _mapper.Map<CopperLineResponse>(IsThereAnySpaceVacancy());
|
|
|
if (res.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode()) return res;
|
|
|
|
|
|
//检查仓库是否存在
|
|
|
- res = (CopperLineResponse)CheckWareCode(reqDto.WareCode);
|
|
|
+ res = _mapper.Map<CopperLineResponse>(CheckWareCode(reqDto.WareCode));
|
|
|
if (res.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode()) return res;
|
|
|
|
|
|
//验证容器是否存在
|
|
|
- res = (CopperLineResponse)CheckContinfo(reqDto.PalletCode, FJContainerType.ContainerType_Pallet);
|
|
|
+ res = _mapper.Map<CopperLineResponse>(CheckContinfo(reqDto.PalletCode, FJContainerType.ContainerType_Pallet));
|
|
|
if (res.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode()) return res;
|
|
|
|
|
|
//验证托盘是否有未结束的任务
|
|
|
- res = (CopperLineResponse)CheckNoFinishTask(reqDto.PalletCode);
|
|
|
+ res = _mapper.Map<CopperLineResponse>(CheckNoFinishTask(reqDto.PalletCode));
|
|
|
if (res.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode()) return res;
|
|
|
|
|
|
//验证是否存在库存信息
|
|
|
- res = (CopperLineResponse)CheckInvnow(reqDto.PalletCode);
|
|
|
+ res = _mapper.Map<CopperLineResponse>(CheckInvnow(reqDto.PalletCode));
|
|
|
if (res.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode()) return res;
|
|
|
|
|
|
//保存条码信息 空托盘条码即条码表条码
|
|
@@ -642,6 +653,7 @@ namespace wms.service.Service
|
|
|
InvStateCode = FJInvState.InvEcecState_BuildUp.ToString(),
|
|
|
SuppCode = "",
|
|
|
Size = 1,
|
|
|
+ MatCode = reqDto.PalletCode,
|
|
|
AddTime = DateTime.Now,
|
|
|
};
|
|
|
|
|
@@ -661,7 +673,7 @@ namespace wms.service.Service
|
|
|
{
|
|
|
BusType = BusType.GetDescription(),
|
|
|
ContGrpBarCode = reqDto.PalletCode,
|
|
|
- ContGrpId = createStockRes.ResData.ContGrpId,
|
|
|
+ ContGrpId = createStockRes.ResDataList.First().ContGrpId,
|
|
|
Qty = reqDto.PalletNum.ObjToDecimal(),
|
|
|
EquCode = reqDto.StartLoc,
|
|
|
WarehouseCode = reqDto.WareCode,
|
|
@@ -677,7 +689,7 @@ namespace wms.service.Service
|
|
|
return res;
|
|
|
}
|
|
|
//生成流水数据-分解方法
|
|
|
- CreateInvFlow(new List<BillInvnow>() { createStockRes.ResData });
|
|
|
+ CreateInvFlow(createStockRes.ResDataList);
|
|
|
|
|
|
return res;
|
|
|
}
|
|
@@ -794,7 +806,7 @@ namespace wms.service.Service
|
|
|
{
|
|
|
Id = IdFactory.NewId(),
|
|
|
IsStop = 0,
|
|
|
- Code = "fj1northhouse",
|
|
|
+ Code = "1N",
|
|
|
Name = "分拣库1北",
|
|
|
AddTime = DateTime.Now
|
|
|
,
|
|
@@ -810,20 +822,6 @@ namespace wms.service.Service
|
|
|
var codes = new List<string>();
|
|
|
for (int row = 1; row <= 2; row++) //行
|
|
|
{
|
|
|
- //shelfcode = "L";
|
|
|
- ////1 2 是R, 3 4 是 L
|
|
|
- //if (row == 1 || row == 2 || row == 5 || row == 6 || row == 9 || row == 10)
|
|
|
- //{
|
|
|
- // shelfcode = "R";
|
|
|
- //}
|
|
|
-
|
|
|
- //// 23 深度1 , 1 4 5 8 9 12深度2
|
|
|
- //int depth = 1;
|
|
|
- //if (row == 1 || row == 4 || row == 5 || row == 8 || row == 9 || row == 12)
|
|
|
- //{
|
|
|
- // depth = 2;
|
|
|
- //}
|
|
|
-
|
|
|
int tunnel = 1;
|
|
|
|
|
|
//12行 48列9层
|
|
@@ -846,7 +844,7 @@ namespace wms.service.Service
|
|
|
TypeNum = 1,
|
|
|
Size = 1,
|
|
|
Shelf = tunnel.ToString() + shelfcode,
|
|
|
- WarehouseCode = "fj1northhouse",
|
|
|
+ WarehouseCode = BaseWarearea.Code,
|
|
|
Row = row,
|
|
|
Col = col,
|
|
|
Layer = layer,
|
|
@@ -877,7 +875,7 @@ namespace wms.service.Service
|
|
|
{
|
|
|
Id = IdFactory.NewId(),
|
|
|
IsStop = 0,
|
|
|
- Code = "fj1southhouse",
|
|
|
+ Code = "1S",
|
|
|
Name = "分拣库1南",
|
|
|
AddTime = DateTime.Now
|
|
|
,
|
|
@@ -895,20 +893,6 @@ namespace wms.service.Service
|
|
|
var codes = new List<string>();
|
|
|
for (int row = 1; row <= 2; row++) //行
|
|
|
{
|
|
|
- //shelfcode = "L";
|
|
|
- ////1 2 是R, 3 4 是 L
|
|
|
- //if (row == 1 || row == 2 || row == 5 || row == 6 || row == 9 || row == 10)
|
|
|
- //{
|
|
|
- // shelfcode = "R";
|
|
|
- //}
|
|
|
-
|
|
|
- //// 23 深度1 , 1 4 5 8 9 12深度2
|
|
|
- //int depth = 1;
|
|
|
- //if (row == 1 || row == 4 || row == 5 || row == 8 || row == 9 || row == 12)
|
|
|
- //{
|
|
|
- // depth = 2;
|
|
|
- //}
|
|
|
-
|
|
|
int tunnel = 1;
|
|
|
|
|
|
//12行 48列9层
|
|
@@ -931,7 +915,7 @@ namespace wms.service.Service
|
|
|
TypeNum = 1,
|
|
|
Size = 1,
|
|
|
Shelf = tunnel.ToString() + shelfcode,
|
|
|
- WarehouseCode = "fj1southhouse",
|
|
|
+ WarehouseCode = BaseWarearea.Code,
|
|
|
Row = row,
|
|
|
Col = col,
|
|
|
Layer = layer,
|
|
@@ -954,6 +938,202 @@ namespace wms.service.Service
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ #region 巷道及货位分配
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 分配货位
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes<FJApplyStockInLocResponse> ApplyStockInLoc(FJApplyStockInLocRequest reqEntity)
|
|
|
+ {
|
|
|
+ var res = ApplyStockInLocTemp(reqEntity);
|
|
|
+ if (string.IsNullOrEmpty(res.ResData.CellNo))
|
|
|
+ {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var task = _taskrepository.GetFirst(p => p.ID == reqEntity.TaskNum);
|
|
|
+ var stock = _billInvnowrepository.GetFirst(p => p.ContGrpBarCode == task.BarCode && p.InvStateCode == InvState.InvEcecState_BuildUp.ToString());
|
|
|
+ _db.BeginTran();
|
|
|
+
|
|
|
+ //更新货位
|
|
|
+ _basewarecellrepository.UpdateModelColumns(p => new BaseWarecell() { StateNum = LocationState.LocationState_StockIn.GetHashCode(), ContGrpBarCode = "", ContGrpId = 0, EditTime = DateTime.Now },
|
|
|
+ p => p.Code == res.ResData.CellNo);
|
|
|
+ //更新任务
|
|
|
+ //_wcstaskoldrepository.UpdateModelColumns(p => new WCS_TaskOld() { AddrTo = res.ResData.CellNo, EditTime = DateTime.Now },
|
|
|
+ // p => p.ID == reqEntity.TaskNum);
|
|
|
+ //_taskrepository.UpdateModelColumns(p => new WCS_TaskInfo() { AddrTo = res.ResData.CellNo, EditTime = DateTime.Now },
|
|
|
+ // p => p.ID == reqEntity.TaskNum);
|
|
|
+ _db.CommitTran();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _db.RollbackTran();
|
|
|
+ _logger.LogInformation(ex.ToString());
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 分配货位
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes<FJApplyStockInLocResponse> ApplyStockInLocTemp(FJApplyStockInLocRequest reqEntity)
|
|
|
+ {
|
|
|
+ var result = new SRes<FJApplyStockInLocResponse>()
|
|
|
+ {
|
|
|
+ ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode(),
|
|
|
+ ResMsg = ResponseStatusCodeEnum.Sucess.GetDescription(),
|
|
|
+ ResData = new FJApplyStockInLocResponse()
|
|
|
+ };
|
|
|
+ //检擦任务是否异常
|
|
|
+ var wcstask = _wcstaskoldrepository.AsQueryable().SplitTable(tabs => tabs.Take(3)).Where(p => p.ID == reqEntity.TaskNum).First(); ;
|
|
|
+ if (wcstask == null)
|
|
|
+ {
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.WcsTaskNotExist.GetHashCode();
|
|
|
+ result.ResMsg = ResponseStatusCodeEnum.WcsTaskNotExist.GetDescription();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if (wcstask.Type == TaskType.OutDepot)
|
|
|
+ {
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.ErrParam.GetHashCode();
|
|
|
+ result.ResMsg = "该任务是出库任务,不能分配货位;wms任务号" + wcstask.ID;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrEmpty(wcstask.AddrTo) && wcstask.AddrTo != "SRM")//如果目标地址不是堆垛机
|
|
|
+ {
|
|
|
+ result.ResData.TunnelNum = wcstask.Tunnel;
|
|
|
+ result.ResData.CellNo = wcstask.AddrTo;
|
|
|
+ result.ResData.Row = wcstask.AddrTo.Split('-')[0] != null ? int.Parse(wcstask.AddrTo.Split('-')[0]) : 0;
|
|
|
+ result.ResData.Colomn = wcstask.AddrTo.Split('-')[1] != null ? int.Parse(wcstask.AddrTo.Split('-')[1]) : 0;
|
|
|
+ result.ResData.Layer = wcstask.AddrTo.Split('-')[2] != null ? int.Parse(wcstask.AddrTo.Split('-')[2]) : 0;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if (reqEntity.TunnelNum <= 0)
|
|
|
+ {
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.NotTunnelNum.GetHashCode();
|
|
|
+ result.ResMsg = ResponseStatusCodeEnum.NotTunnelNum.GetDescription();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ //验证仓库信息
|
|
|
+ var warehouse = _basewarehouserepository.GetFirst(p => p.Code == wcstask.WarehouseCode);
|
|
|
+ if (warehouse == null)
|
|
|
+ {
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.WarehouseCodeNotExist.GetHashCode();
|
|
|
+ result.ResMsg = ResponseStatusCodeEnum.WarehouseCodeNotExist.GetDescription();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ //验证库存
|
|
|
+ var stock = _billInvnowrepository.GetFirst(p => p.ContGrpBarCode == wcstask.BarCode && p.InvStateCode == InvState.InvEcecState_BuildUp.ToString());
|
|
|
+ if (stock == null)
|
|
|
+ {
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.StockNotExist.GetHashCode();
|
|
|
+ result.ResMsg = ResponseStatusCodeEnum.StockNotExist.GetDescription();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if (reqEntity.TunnelNum <= 0)
|
|
|
+ {
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.ErrParam.GetHashCode();
|
|
|
+ result.ResMsg = "没有传巷道值";
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ return ApplyLoc(new FJApplyLocRequest()
|
|
|
+ {
|
|
|
+ MaterialId = stock.MatId,
|
|
|
+ MaterialCode = stock.MatCode,
|
|
|
+ Size = stock.Size,
|
|
|
+ TunnelNum = reqEntity.TunnelNum,
|
|
|
+ WarehuoseId = warehouse.Id,
|
|
|
+ IsMove = wcstask.Type == TaskType.TransferDepot
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 分配货位
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="reqEntity"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes<FJApplyStockInLocResponse> ApplyLoc(FJApplyLocRequest reqEntity)
|
|
|
+ {
|
|
|
+ var result = new SRes<FJApplyStockInLocResponse>()
|
|
|
+ {
|
|
|
+ ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode(),
|
|
|
+ ResMsg = ResponseStatusCodeEnum.Sucess.GetDescription(),
|
|
|
+ ResData = new FJApplyStockInLocResponse()
|
|
|
+ };
|
|
|
+
|
|
|
+ //预留货位数量
|
|
|
+ var emptyLoc = _basewarecellrepository.GetList(p => p.IsStop == 0
|
|
|
+ && p.StateNum == LocationState.LocationState_Empty.GetHashCode()
|
|
|
+ && p.TypeNum == LocationType.LocationType_StorageLocation.GetHashCode()
|
|
|
+ && p.Tunnel == reqEntity.TunnelNum
|
|
|
+ && p.WarehouseId == reqEntity.WarehuoseId
|
|
|
+ && p.Size == reqEntity.Size
|
|
|
+ );
|
|
|
+
|
|
|
+ //判断是否移库
|
|
|
+ if (!reqEntity.IsMove && (emptyLoc == null || emptyLoc.Count < 2))
|
|
|
+ {
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.NotEnoughLocation.GetHashCode();
|
|
|
+ result.ResMsg = ResponseStatusCodeEnum.NotEnoughLocation.GetDescription();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ //找到可用货位
|
|
|
+ var loc1ist = _basewarecellrepository.Context
|
|
|
+ .Queryable<BaseWarecell>()
|
|
|
+ .Where((loc1) => loc1.IsStop == 0
|
|
|
+ && loc1.StateNum == LocationState.LocationState_Empty.GetHashCode()
|
|
|
+ && loc1.TypeNum == LocationType.LocationType_StorageLocation.GetHashCode()
|
|
|
+ && loc1.Tunnel == reqEntity.TunnelNum
|
|
|
+ && loc1.WarehouseId == reqEntity.WarehuoseId
|
|
|
+ && loc1.Size == reqEntity.Size
|
|
|
+ && loc1.Depth == 1)
|
|
|
+ .Where((loc1) => loc1.Tunnel == reqEntity.TunnelNum)
|
|
|
+ .Select((loc1) => new
|
|
|
+ {
|
|
|
+ loc1.Code,
|
|
|
+ loc1.Id,
|
|
|
+ loc1.Row,
|
|
|
+ loc1.Col,
|
|
|
+ loc1.Layer,
|
|
|
+ loc1.Tunnel,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (loc1ist != null)
|
|
|
+ {
|
|
|
+ var resloc = loc1ist.ToList().OrderBy(p => p.Layer).ThenBy(p => p.Col).ThenBy(p => p.Row).First();
|
|
|
+ result.ResData.TunnelNum = resloc.Tunnel.ToString();
|
|
|
+ result.ResData.CellNo = resloc.Code;
|
|
|
+ result.ResData.Row = resloc.Row;
|
|
|
+ result.ResData.Colomn = resloc.Col;
|
|
|
+ result.ResData.Layer = resloc.Layer;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (loc1ist == null || !loc1ist.Any())
|
|
|
+ {
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.NotEnoughLocation.GetHashCode();
|
|
|
+ result.ResMsg = ResponseStatusCodeEnum.NotEnoughLocation.GetDescription();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ var loc = loc1ist.First();
|
|
|
+ result.ResData.TunnelNum = loc.Tunnel.ToString();
|
|
|
+ result.ResData.CellNo = loc.Code;
|
|
|
+ result.ResData.Row = loc.Row;
|
|
|
+ result.ResData.Colomn = loc.Col;
|
|
|
+ result.ResData.Layer = loc.Layer;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion 巷道及货位分配
|
|
|
+
|
|
|
#region 容器、物料、条码、库存检测及创建,创建流水信息
|
|
|
|
|
|
/// <summary>
|
|
@@ -1213,7 +1393,7 @@ namespace wms.service.Service
|
|
|
Device = "",
|
|
|
SrmStation = "",
|
|
|
AddrFrom = reqDto.EquCode,
|
|
|
- AddrTo = "srm",
|
|
|
+ AddrTo = "SRM",
|
|
|
LastInteractionPoint = "",
|
|
|
BarCode = reqDto.ContGrpBarCode,
|
|
|
Floor = reqDto.Floor,
|
|
@@ -1223,12 +1403,12 @@ namespace wms.service.Service
|
|
|
DocID = 0,
|
|
|
PalletType = 1,
|
|
|
ProdLine = 0,
|
|
|
- AddWho = "wms",
|
|
|
+ AddWho = "WMS",
|
|
|
WarehouseCode = reqDto.WarehouseCode,
|
|
|
Enabled = true,
|
|
|
- WorkBench = reqDto.EquCode,
|
|
|
- MaterialCode = reqDto.MaterialCode,
|
|
|
- MatCode = reqDto.MatCode,
|
|
|
+ //WorkBench = reqDto.EquCode,
|
|
|
+ //MaterialCode = reqDto.MaterialCode,
|
|
|
+ //MatCode = reqDto.MatCode,
|
|
|
BusType = reqDto.BusType
|
|
|
};
|
|
|
var wcstaskhis = _mapper.Map<WCS_TaskOld>(wcstask);
|
|
@@ -1244,10 +1424,10 @@ namespace wms.service.Service
|
|
|
ID = Guid.NewGuid(),
|
|
|
CurPoint = reqDto.EquCode,
|
|
|
AddTime = DateTime.Now,
|
|
|
- AddWho = "wms",
|
|
|
+ AddWho = "WMS",
|
|
|
Enabled = true,
|
|
|
ParentTaskCode = task.ID,
|
|
|
- Desc = reqDto.EquCode + "分拣一楼空托入库",
|
|
|
+ Desc = reqDto.EquCode + "分拣库一楼空托盘入库",
|
|
|
};
|
|
|
_taskdetailrepository.InsertableSplitTable(taskdetail);
|
|
|
_db.CommitTran();
|
|
@@ -1265,5 +1445,378 @@ namespace wms.service.Service
|
|
|
}
|
|
|
|
|
|
#endregion 容器、物料、条码、库存检测及创建,创建流水信息
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 手动出库
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public string ManualTask(FJManualTaskRequest request)
|
|
|
+ {
|
|
|
+ var res = new SRes();
|
|
|
+
|
|
|
+ //必须要有货位信息
|
|
|
+ if (!request.Location.Any())
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.ErrParamNotNull.GetHashCode();
|
|
|
+ res.ResMsg = "货位" + ResponseStatusCodeEnum.ErrParamNotNull.GetDescription();
|
|
|
+ return res.ToCamelCaseString();
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ foreach (var item in request.Location)
|
|
|
+ {
|
|
|
+ //货位信息验证
|
|
|
+ var location = _basewarecellrepository.GetSingle(p => p.Code == item);
|
|
|
+ if (location == null)
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.WareLocationCodeNotExist.GetHashCode();
|
|
|
+ res.ResMsg = item + ResponseStatusCodeEnum.WareLocationCodeNotExist.GetDescription();
|
|
|
+ return res.ToCamelCaseString();
|
|
|
+ }
|
|
|
+ if (location.StateNum != FJLocationState.LocationState_Full.GetHashCode())
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
|
|
|
+ res.ResMsg = item + ResponseStatusCodeEnum.Fail.GetDescription() + "货位状态不满足出库条件";
|
|
|
+ return res.ToCamelCaseString();
|
|
|
+ }
|
|
|
+ if (location.IsStop == 1)
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
|
|
|
+ res.ResMsg = ResponseStatusCodeEnum.Fail.GetDescription() + item + "被禁用";
|
|
|
+ return res.ToCamelCaseString();
|
|
|
+ }
|
|
|
+
|
|
|
+ //库存信息验证
|
|
|
+ var stock = _billInvnowrepository.GetSingle(p => p.ContGrpBarCode == location.ContGrpBarCode && p.InvStateCode == InvState.InvEcecState_In.ToString());
|
|
|
+ if (stock == null)
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.StockNotExist.GetHashCode();
|
|
|
+ res.ResMsg = ResponseStatusCodeEnum.StockNotExist.GetDescription();
|
|
|
+ return res.ToCamelCaseString();
|
|
|
+ }
|
|
|
+ if (stock.InvStateCode != InvState.InvEcecState_In.ToString())
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
|
|
|
+ res.ResMsg = item + "组盘状态不是已入库";
|
|
|
+ return res.ToCamelCaseString();
|
|
|
+ }
|
|
|
+
|
|
|
+ WCS_TaskInfo billTask = new WCS_TaskInfo();
|
|
|
+ billTask.Status = TaskStatus.NewBuild;
|
|
|
+ billTask.Type = TaskType.OutDepot;
|
|
|
+ billTask.Priority = 0;
|
|
|
+ billTask.Device = "SRM" + location.Tunnel;
|
|
|
+ billTask.AddrFrom = item;
|
|
|
+ billTask.BarCode = stock.ContGrpBarCode;
|
|
|
+ billTask.StartTime = DateTime.Now;
|
|
|
+ billTask.AddTime = DateTime.Now;
|
|
|
+ billTask.EditTime = DateTime.Now;
|
|
|
+ billTask.AddWho = "WMS";
|
|
|
+ billTask.WarehouseCode = location.WarehouseCode;
|
|
|
+ billTask.Enabled = true;
|
|
|
+ billTask.Floor = 2;
|
|
|
+ billTask.Tunnel = location.Tunnel.ToString();
|
|
|
+ billTask.PalletType = 1;
|
|
|
+ billTask.Length = stock.LengthQty;
|
|
|
+ billTask.MaterialCode = stock.MatCode;
|
|
|
+ billTask.OutType = OutTypeEnum.半自动手动出库任务;
|
|
|
+ billTask.BusType = FJTaskBusType.TaskBusType_FJ_ManualOut.GetDescription();
|
|
|
+
|
|
|
+ _db.BeginTran();
|
|
|
+
|
|
|
+ var wcs = _taskrepository.InsertReturnEntity(billTask);
|
|
|
+ var wcshistory = _mapper.Map<WCS_TaskOld>(wcs);
|
|
|
+ _wcstaskoldrepository.InsertableSplitTable(wcshistory);
|
|
|
+ var taskdetail = new WCS_TaskDtl()
|
|
|
+ {
|
|
|
+ ID = Guid.NewGuid(),
|
|
|
+ CurPoint = item,
|
|
|
+ AddTime = DateTime.Now,
|
|
|
+ AddWho = "wms",
|
|
|
+ Enabled = true,
|
|
|
+ ParentTaskCode = wcs.ID,
|
|
|
+ Desc = wcs.OutType.ToString(),
|
|
|
+ };
|
|
|
+ _taskdetailrepository.InsertableSplitTable(taskdetail);
|
|
|
+ _db.CommitTran();
|
|
|
+
|
|
|
+ _basewarecellrepository.UpdateSetColumnsTrue(p => new BaseWarecell()
|
|
|
+ {
|
|
|
+ StateNum = LocationState.LocationState_StockOut.GetHashCode(),
|
|
|
+ EditTime = DateTime.Now
|
|
|
+ }, p => p.Code == item);
|
|
|
+ _billInvnowrepository.UpdateSetColumnsTrue(p => new BillInvnow()
|
|
|
+ {
|
|
|
+ InvStateCode = InvState.InvEcecState_OutGoing.ToString(),
|
|
|
+ EditTime = DateTime.Now
|
|
|
+ }, p => p.ContGrpBarCode == stock.ContGrpBarCode);
|
|
|
+
|
|
|
+ var flow = _mapper.Map<BillInvflow>(stock);
|
|
|
+ flow.Id = IdFactory.NewId();
|
|
|
+ flow.InvStateCode = InvState.InvEcecState_OutGoing.ToString();
|
|
|
+ flow.EditTime = DateTime.Now;
|
|
|
+ _billInvflow.Insert(flow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _db.RollbackTran();
|
|
|
+ _logger.LogInformation("手动出库异常:" + ex.Message);
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.DataSaveErr.GetHashCode();
|
|
|
+ res.ResMsg = ResponseStatusCodeEnum.DataSaveErr.GetDescription();
|
|
|
+ return res.ToCamelCaseString();
|
|
|
+ }
|
|
|
+ return res.ToCamelCaseString();
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 完成/取消任务
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 完成任务
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="reqDto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes<int> CompleteTask(CompleteTaskRequest reqDto)
|
|
|
+ {
|
|
|
+ var result = new SRes<int>()
|
|
|
+ {
|
|
|
+ ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode(),
|
|
|
+ ResMsg = ResponseStatusCodeEnum.Sucess.GetDescription(),
|
|
|
+ ResData = reqDto.TaskNum
|
|
|
+ };
|
|
|
+
|
|
|
+ //检查历史任务表是否有任务
|
|
|
+ var task = _wcstaskoldrepository.AsQueryable().SplitTable(tabs => tabs.Take(3)).Where(p => p.ID == reqDto.TaskNum).First();
|
|
|
+ if (task == null)
|
|
|
+ {
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.WcsTaskNotExist.GetHashCode();
|
|
|
+ result.ResMsg = reqDto.TaskNum + ResponseStatusCodeEnum.WcsTaskNotExist.GetDescription();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (task.Type)
|
|
|
+ {
|
|
|
+ case TaskType.SetPlate:
|
|
|
+ break;
|
|
|
+
|
|
|
+ case TaskType.EnterDepot:
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //检擦库存信息是否正确
|
|
|
+ var stock = _billInvnowrepository.GetFirst(p => p.ContGrpBarCode == task.BarCode && p.InvStateCode == InvState.InvEcecState_BuildUp.ToString());
|
|
|
+ if (stock == null)
|
|
|
+ {
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.StockNotExist.GetHashCode();
|
|
|
+ result.ResMsg = task.BarCode + "没有已组盘的信息";
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ var warehouse = _basewarehouserepository.GetSingle(p => p.Code == task.WarehouseCode);
|
|
|
+ _db.BeginTran();
|
|
|
+ int row = int.Parse(task.AddrTo.Split('-')[0]);
|
|
|
+ int col = int.Parse(task.AddrTo.Split('-')[1]);
|
|
|
+ int layer = int.Parse(task.AddrTo.Split('-')[2]);
|
|
|
+
|
|
|
+ //更新库存
|
|
|
+ _billInvnowrepository.UpdateModelColumns(p => new BillInvnow()
|
|
|
+ {
|
|
|
+ InvStateCode = InvState.InvEcecState_In.ToString(),
|
|
|
+ PutRow = row,
|
|
|
+ PutCol = col,
|
|
|
+ PutLayer = layer,
|
|
|
+ OneInTime = DateTime.Now,
|
|
|
+ EditTime = DateTime.Now
|
|
|
+ }, p => p.ContGrpBarCode == task.BarCode && p.InvStateCode == InvState.InvEcecState_BuildUp.ToString());
|
|
|
+
|
|
|
+ //更新货位
|
|
|
+ _basewarecellrepository.UpdateModelColumns(p => new BaseWarecell()
|
|
|
+ {
|
|
|
+ StateNum = LocationState.LocationState_Full.GetHashCode(),
|
|
|
+ ContGrpBarCode = stock.ContGrpBarCode,
|
|
|
+ ContGrpId = stock.ContGrpId,
|
|
|
+ EditTime = DateTime.Now
|
|
|
+ }, p => p.Code.Contains(task.AddrTo));
|
|
|
+
|
|
|
+ //增加流水信息
|
|
|
+ var enterDepotstocklist = _billInvnowrepository.GetList(p => p.ContGrpBarCode == task.BarCode && p.InvStateCode == InvState.InvEcecState_In.ToString());
|
|
|
+ foreach (var item in enterDepotstocklist)
|
|
|
+ {
|
|
|
+ item.Id = IdFactory.NewId();
|
|
|
+ item.AddTime = DateTime.Now;
|
|
|
+ }
|
|
|
+ _billInvflow.InsertRange(_mapper.Map<List<BillInvflow>>(enterDepotstocklist));
|
|
|
+
|
|
|
+ //TODO:暂未处理甲方管理系统相关内容
|
|
|
+ //var list = new List<BillPushinfo>();
|
|
|
+ //string pushtype = FackbeekType.InterfaceType_HJ_1F_StockIn.ToString();
|
|
|
+ //if (stock.IsBack)
|
|
|
+ //{
|
|
|
+ // pushtype = FackbeekType.InterfaceType_HJ_2F_BackStockIn.ToString();
|
|
|
+ //}
|
|
|
+ //else if (stock.IsSurplus)
|
|
|
+ //{
|
|
|
+ // pushtype = FackbeekType.InterfaceType_HJ_2F_LeftStockIn.ToString();
|
|
|
+ //}
|
|
|
+ ////else if()
|
|
|
+ ////回调数据
|
|
|
+ //foreach (var item in stocklist)
|
|
|
+ //{
|
|
|
+ // list.Add(new BillPushinfo
|
|
|
+ // {
|
|
|
+ // DocsNo = stock.ExecDocsNo,
|
|
|
+ // TypeCode = pushtype,
|
|
|
+ // RFIDBarCode = stock.ContGrpBarCode,
|
|
|
+ // HWBarCode = stock.ContGrpBarCode,
|
|
|
+ // CLBarCode = item.CLBarCode,
|
|
|
+ // WarehouseId = warehouse.Id,
|
|
|
+ // WarehouseCode = warehouse.Code,
|
|
|
+ // WareCellId = 0,
|
|
|
+ // WareCellCode = task.AddrTo,
|
|
|
+ // MatId = item.MatId,
|
|
|
+ // MatCode = item.MatCode,
|
|
|
+ // MatName = item.MatName,
|
|
|
+ // TolWQty = item.TolWQty,
|
|
|
+ // NetWQty = item.NetWQty,
|
|
|
+ // TareWQty = item.TareWQty,
|
|
|
+ // ReqNo = Guid.NewGuid().ToString()
|
|
|
+ // });
|
|
|
+ //}
|
|
|
+ //if (stock.ContGrpType == ContGrpType.Material.GetHashCode())
|
|
|
+ //{
|
|
|
+ // _billPushinforepository.InsertRange(list);
|
|
|
+ //}
|
|
|
+ _db.CommitTran();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _db.RollbackTran();
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.InnerServerErr.GetHashCode();
|
|
|
+ result.ResMsg = task.ID + "完成任务异常";
|
|
|
+ _logger.LogInformation("完成任务异常" + ex.ToString());
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case TaskType.OutDepot:
|
|
|
+ //验证库存信息
|
|
|
+ var stocklist = _billInvnowrepository.GetList(p => p.ContGrpBarCode == task.BarCode && p.InvStateCode == InvState.InvEcecState_OutGoing.ToString());
|
|
|
+ if (stocklist == null || !stocklist.Any())
|
|
|
+ {
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.StockNotExist.GetHashCode();
|
|
|
+ result.ResMsg = reqDto.TaskNum + ResponseStatusCodeEnum.StockNotExist.GetDescription();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ var flowlist = _mapper.Map<List<BillInvflow>>(stocklist);
|
|
|
+ foreach (var item in flowlist)
|
|
|
+ {
|
|
|
+ item.Id = IdFactory.NewId();
|
|
|
+ item.InvStateCode = InvState.InvEcecState_Out.ToString();
|
|
|
+ item.AddTime = DateTime.Now;
|
|
|
+ item.Memo = "任务完成";
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ _db.BeginTran();
|
|
|
+ //删除库存及条码信息
|
|
|
+ _billInvnowrepository.Delete(p => stocklist.Select(p => p.Id).ToList().Contains(p.Id));
|
|
|
+ _billInvinitrepository.Delete(p => p.ContGrpBarCode == task.BarCode);
|
|
|
+ //更新货位信息
|
|
|
+ _basewarecellrepository.UpdateModelColumns(p => new BaseWarecell()
|
|
|
+ {
|
|
|
+ StateNum = LocationState.LocationState_Empty.GetHashCode(),
|
|
|
+ ContGrpBarCode = "",
|
|
|
+ ContGrpId = 0,
|
|
|
+ EditTime = DateTime.Now
|
|
|
+ }, p => p.StateNum == LocationState.LocationState_StockOut.GetHashCode() && p.ContGrpId == flowlist.First().ContGrpId && p.Code.Contains(task.AddrFrom));
|
|
|
+
|
|
|
+ //更新流水信息
|
|
|
+ _billInvflow.InsertRange(flowlist);
|
|
|
+ _db.CommitTran();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _db.RollbackTran();
|
|
|
+ _logger.LogInformation(ex.ToString());
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.InnerServerErr.GetHashCode();
|
|
|
+ result.ResMsg = task.ID + "完成任务异常";
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case TaskType.TransferDepot:
|
|
|
+
|
|
|
+ var fromcell = _basewarecellrepository.GetFirst(p => p.Code == task.AddrFrom);
|
|
|
+ var grcontid = fromcell.ContGrpId;
|
|
|
+ var grcontcode = fromcell.ContGrpBarCode;
|
|
|
+ var fromcellno = fromcell.Code;
|
|
|
+ var tocellno = task.AddrTo;
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ _db.BeginTran();
|
|
|
+ //更新货位信息
|
|
|
+ //起始货位
|
|
|
+ _basewarecellrepository.UpdateModelColumns(p => new BaseWarecell()
|
|
|
+ {
|
|
|
+ StateNum = LocationState.LocationState_Empty.GetHashCode(),
|
|
|
+ ContGrpBarCode = "",
|
|
|
+ ContGrpId = 0,
|
|
|
+ EditTime = DateTime.Now
|
|
|
+ }, p => p.Code.Contains(fromcellno));
|
|
|
+ //目标货位
|
|
|
+ _basewarecellrepository.UpdateModelColumns(p => new BaseWarecell()
|
|
|
+ {
|
|
|
+ StateNum = LocationState.LocationState_Full.GetHashCode(),
|
|
|
+ ContGrpBarCode = grcontcode,
|
|
|
+ ContGrpId = grcontid,
|
|
|
+ EditTime = DateTime.Now
|
|
|
+ }, p => p.Code.Contains(tocellno));
|
|
|
+
|
|
|
+ //更新库存信息
|
|
|
+ int row = int.Parse(tocellno.Split('-')[0]);
|
|
|
+ int col = int.Parse(tocellno.Split('-')[1]);
|
|
|
+ int layer = int.Parse(tocellno.Split('-')[2]);
|
|
|
+ _billInvnowrepository.UpdateModelColumns(p => new BillInvnow()
|
|
|
+ {
|
|
|
+ PutRow = row,
|
|
|
+ PutCol = col,
|
|
|
+ PutLayer = layer
|
|
|
+ }, p => p.ContGrpId == grcontid && p.InvStateCode == InvState.InvEcecState_In.ToString());
|
|
|
+
|
|
|
+ //更新流水信息
|
|
|
+ var stock = _billInvnowrepository.GetFirst(p => p.ContGrpId == grcontid && p.ContGrpBarCode == grcontcode && p.InvStateCode == InvState.InvEcecState_In.ToString());
|
|
|
+ var flow = _mapper.Map<BillInvflow>(stock);
|
|
|
+ flow.Id = IdFactory.NewId();
|
|
|
+ flow.AddTime = DateTime.Now;
|
|
|
+ flow.Memo = grcontcode + "移库(" + fromcellno + "至" + tocellno + ")";
|
|
|
+ _billInvflow.Insert(flow);
|
|
|
+ _db.CommitTran();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _db.RollbackTran();
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.InnerServerErr.GetHashCode();
|
|
|
+ result.ResMsg = task.ID + "完成任务异常";
|
|
|
+ _logger.LogInformation("完成任务异常" + ex.ToString());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case TaskType.Delivery:
|
|
|
+ break;
|
|
|
+
|
|
|
+ case TaskType.EmptyInit:
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ result.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
|
|
|
+ result.ResMsg = reqDto.TaskNum + ResponseStatusCodeEnum.Fail.GetDescription();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion 完成/取消任务
|
|
|
}
|
|
|
}
|