|
@@ -2,12 +2,15 @@
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using Newtonsoft.Json;
|
|
|
using SqlSugar;
|
|
|
+using SqlSugar.Extensions;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
using System.Linq.Expressions;
|
|
|
-using System.Text;
|
|
|
+using WCS.Entity.fj;
|
|
|
using wms.dataservice.IDataSetvice;
|
|
|
using wms.dto;
|
|
|
+using wms.dto.request;
|
|
|
using wms.dto.request.fj;
|
|
|
using wms.dto.response;
|
|
|
using wms.dto.response.fj;
|
|
@@ -15,57 +18,102 @@ using wms.service.IService;
|
|
|
using wms.sqlsugar;
|
|
|
using wms.sqlsugar.model;
|
|
|
using wms.sqlsugar.model.fj;
|
|
|
-using wms.util.Ext;
|
|
|
-using System.Linq;
|
|
|
-using WCS.Entity.fj;
|
|
|
using wms.util.Check;
|
|
|
+using wms.util.Ext;
|
|
|
|
|
|
namespace wms.service.Service
|
|
|
{
|
|
|
+ /// <summary>
|
|
|
+ /// 分拣服务
|
|
|
+ /// </summary>
|
|
|
public class FJService : IFJService
|
|
|
{
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly ILogger<FJService> _logger;
|
|
|
private readonly IFJDataService _IFJDataService;
|
|
|
-
|
|
|
+
|
|
|
public FJService(IMapper mapper, ILogger<FJService> logger, IFJDataService IFJDataService)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_logger = logger;
|
|
|
_IFJDataService = IFJDataService;
|
|
|
}
|
|
|
- Repository<fjBillDocument> _docrepository => new Repository<fjBillDocument>();
|
|
|
- Repository<fjSysConfig> _sysconfigrepository => new Repository<fjSysConfig>();
|
|
|
- Repository<fjBaseMater> _materrepository => new Repository<fjBaseMater>();
|
|
|
- Repository<fjBillTask> _billTaskrepository => new Repository<fjBillTask>();
|
|
|
- Repository<fjBaseWarehouse> _baseWareHouserepository => new Repository<fjBaseWarehouse>();
|
|
|
- Repository<fjBillBarcode> _billBarcoderepository => new Repository<fjBillBarcode>();
|
|
|
- Repository<fjBillFeedbackPush> _billFbackPushrepository => new Repository<fjBillFeedbackPush>();
|
|
|
- Repository<fjBillBomInfo> _fjBillBomInfoRepository => new Repository<fjBillBomInfo>();
|
|
|
- Repository<fjBillWetStack> _fjBillWetStackRepository => new Repository<fjBillWetStack>();
|
|
|
|
|
|
- ITenant _db => SqlSugarHelper.Db;//处理事务
|
|
|
- Repository<BaseContinfo> _baseContinfo => new Repository<BaseContinfo>();
|
|
|
- RepositoryTask<WCS_TaskInfo> _taskrepository => new RepositoryTask<WCS_TaskInfo>();
|
|
|
+ private ITenant _db => SqlSugarHelper.Db;//处理事务
|
|
|
+
|
|
|
+ #region 初始化仓储
|
|
|
+
|
|
|
+ private Repository<fjBillDocument> _docrepository => new Repository<fjBillDocument>();
|
|
|
+ private Repository<fjSysConfig> _sysconfigrepository => new Repository<fjSysConfig>();
|
|
|
+ private Repository<fjBaseMater> _materrepository => new Repository<fjBaseMater>();
|
|
|
+ private Repository<fjBillTask> _billTaskrepository => new Repository<fjBillTask>();
|
|
|
+ private Repository<fjBaseWarehouse> _baseWareHouserepository => new Repository<fjBaseWarehouse>();
|
|
|
+ private Repository<fjBillBarcode> _billBarcoderepository => new Repository<fjBillBarcode>();
|
|
|
+ private Repository<fjBillFeedbackPush> _billFbackPushrepository => new Repository<fjBillFeedbackPush>();
|
|
|
+ private Repository<fjBillBomInfo> _fjBillBomInfoRepository => new Repository<fjBillBomInfo>();
|
|
|
+ private Repository<fjBillWetStack> _fjBillWetStackRepository => new Repository<fjBillWetStack>();
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 容器表
|
|
|
+ /// </summary>
|
|
|
+ private Repository<BaseContinfo> _baseContinfo => new Repository<BaseContinfo>();
|
|
|
+
|
|
|
+ private RepositoryTask<WCS_TaskInfo> _taskrepository => new RepositoryTask<WCS_TaskInfo>();
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 库存表
|
|
|
+ /// </summary>
|
|
|
+ private Repository<BillInvnow> _billInvnowrepository => new Repository<BillInvnow>();
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 条码表
|
|
|
+ /// </summary>
|
|
|
+ private Repository<BillInvinit> _billInvinitrepository => new Repository<BillInvinit>();
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 物料表
|
|
|
+ /// </summary>
|
|
|
+ private Repository<BaseMatinfo> _basematerrepository => new Repository<BaseMatinfo>();
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 码垛工字轮信息
|
|
|
+ /// </summary>
|
|
|
+ private Repository<BillSpoolTrans> _billSpoolTransrepository => new Repository<BillSpoolTrans>();
|
|
|
+
|
|
|
+ private Repository<BillBominfo> _billBominfoRepository => new Repository<BillBominfo>();
|
|
|
+ private Repository<BillBomsetinfo> _billBomsetinfoRepository => new Repository<BillBomsetinfo>();
|
|
|
|
|
|
- Repository<BillInvnow> _billInvnowrepository => new Repository<BillInvnow>();
|
|
|
- Repository<BillInvinit> _billInvinitrepository => new Repository<BillInvinit>();
|
|
|
- Repository<BaseMatinfo> _basematerrepository => new Repository<BaseMatinfo>();
|
|
|
- Repository<BillSpoolTrans> _billSpoolTransrepository => new Repository<BillSpoolTrans>();
|
|
|
- Repository<BillBominfo> _billBominfoRepository => new Repository<BillBominfo>();
|
|
|
- Repository<BillBomsetinfo> _billBomsetinfoRepository => new Repository<BillBomsetinfo>();
|
|
|
-
|
|
|
- Repository<BillDocsinfo> _billdocrepository => new Repository<BillDocsinfo>();
|
|
|
- RepositoryTask<WCS_TaskOld> _wcstaskoldrepository => new RepositoryTask<WCS_TaskOld>();
|
|
|
- Repository<BillInvflow> _billInvflow => new Repository<BillInvflow>();
|
|
|
- Repository<BillPushinfo> _billPushinforepository => new Repository<BillPushinfo>();
|
|
|
- Repository<BaseWarecell> _basewarecellrepository => new Repository<BaseWarecell>();
|
|
|
- Repository<BaseWarehouse> _basewarehouserepository => new Repository<BaseWarehouse>();
|
|
|
- RepositoryTask<WCS_TaskDtl> _taskdetailrepository => new RepositoryTask<WCS_TaskDtl>();
|
|
|
+ /// <summary>
|
|
|
+ /// 单据表
|
|
|
+ /// </summary>
|
|
|
+ private Repository<BillDocsinfo> _billdocrepository => new Repository<BillDocsinfo>();
|
|
|
|
|
|
- Repository<BillMachinfo> _basemachinforepository => new Repository<BillMachinfo>();
|
|
|
+ /// <summary>
|
|
|
+ /// 任务历史表
|
|
|
+ /// </summary>
|
|
|
+ private RepositoryTask<WCS_TaskOld> _wcstaskoldrepository => new RepositoryTask<WCS_TaskOld>();
|
|
|
|
|
|
+ private Repository<BillInvflow> _billInvflow => new Repository<BillInvflow>();
|
|
|
+ private Repository<BillPushinfo> _billPushinforepository => new Repository<BillPushinfo>();
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 货位表
|
|
|
+ /// </summary>
|
|
|
+ private Repository<BaseWarecell> _basewarecellrepository => new Repository<BaseWarecell>();
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 仓库表
|
|
|
+ /// </summary>
|
|
|
+ private Repository<BaseWarehouse> _basewarehouserepository => new Repository<BaseWarehouse>();
|
|
|
+
|
|
|
+ private RepositoryTask<WCS_TaskDtl> _taskdetailrepository => new RepositoryTask<WCS_TaskDtl>();
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 机台表
|
|
|
+ /// </summary>
|
|
|
+ private Repository<BillMachinfo> _basemachinforepository => new Repository<BillMachinfo>();
|
|
|
+
|
|
|
+ #endregion 初始化仓储
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加单据
|
|
@@ -86,6 +134,7 @@ namespace wms.service.Service
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取配置内容信息
|
|
|
/// </summary>
|
|
@@ -121,7 +170,6 @@ namespace wms.service.Service
|
|
|
return _sysconfigrepository.GetSingle(p => p.Code == code);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 获取物料信息
|
|
|
/// </summary>
|
|
@@ -131,6 +179,7 @@ namespace wms.service.Service
|
|
|
{
|
|
|
return _materrepository.GetSingle(WhereExpression);
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取配置信息
|
|
|
/// </summary>
|
|
@@ -140,6 +189,7 @@ namespace wms.service.Service
|
|
|
{
|
|
|
return _sysconfigrepository.GetSingle(WhereExpression);
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取单据信息
|
|
|
/// </summary>
|
|
@@ -149,6 +199,7 @@ namespace wms.service.Service
|
|
|
{
|
|
|
return _docrepository.GetSingle(WhereExpression);
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取反馈信息
|
|
|
/// </summary>
|
|
@@ -158,6 +209,7 @@ namespace wms.service.Service
|
|
|
{
|
|
|
return _billFbackPushrepository.GetList(WhereExpression);
|
|
|
}
|
|
|
+
|
|
|
///// <summary>
|
|
|
///// 获取单据信息
|
|
|
///// </summary>
|
|
@@ -179,6 +231,7 @@ namespace wms.service.Service
|
|
|
{
|
|
|
return _sysconfigrepository.Update(updateModel.Columns, updateModel.WhereExpression);
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 更新hjBillFeedbackPush表字段
|
|
|
/// </summary>
|
|
@@ -188,12 +241,14 @@ namespace wms.service.Service
|
|
|
{
|
|
|
return _billFbackPushrepository.Update(updateModel.Columns, updateModel.WhereExpression);
|
|
|
}
|
|
|
+
|
|
|
public SRes<bool> DeleteDoc(Expression<Func<fjBillDocument, bool>> whereExpression)
|
|
|
{
|
|
|
var res = new SRes<bool>();
|
|
|
res.ResData = _docrepository.Delete(whereExpression);
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
public bool SyncMaterInfo(List<FJSyncMaterInfoResponseItem> ResData)
|
|
|
{
|
|
|
foreach (var item in ResData)
|
|
@@ -211,13 +266,14 @@ namespace wms.service.Service
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
public bool SyncMachineInfo(List<SyncMachineInfoResponseItem> ResData)
|
|
|
{
|
|
|
foreach (var item in ResData)
|
|
|
{
|
|
|
if (_basemachinforepository.IsAny(p => p.MachNo == item.MacCode))
|
|
|
{
|
|
|
- _basemachinforepository.UpdateModelColumns(p => new BillMachinfo() { GrpCode = item.MacGroup, Direction = item.Direction,Station = item.LocCode,EditTime = DateTime.Now },
|
|
|
+ _basemachinforepository.UpdateModelColumns(p => new BillMachinfo() { GrpCode = item.MacGroup, Direction = item.Direction, Station = item.LocCode, EditTime = DateTime.Now },
|
|
|
p => p.MachNo == item.MacCode);
|
|
|
}
|
|
|
else
|
|
@@ -228,6 +284,7 @@ namespace wms.service.Service
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 帘线工单信息传输
|
|
|
/// </summary>
|
|
@@ -259,6 +316,7 @@ namespace wms.service.Service
|
|
|
_basemachinforepository.UpdateModelColumns(p => new BillMachinfo() { BillCode = reqDto.BillCode, WorkOrder = reqDto.WorkOrder, PlanQty = reqDto.PlanQty, EditTime = DateTime.Now }, p => reqDto.WbList.Contains(p.MachNo));
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 工单启动验证
|
|
|
/// </summary>
|
|
@@ -276,9 +334,11 @@ namespace wms.service.Service
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ #region 湿拉工字轮/帘线芯股信息初始化
|
|
|
+
|
|
|
/// <summary>
|
|
|
- /// 湿拉工字轮/芯股信息传输接口
|
|
|
+ /// 湿拉工字轮/帘线芯股信息初始化
|
|
|
/// </summary>
|
|
|
/// <param name="reqDto"></param>
|
|
|
/// <returns></returns>
|
|
@@ -384,62 +444,24 @@ namespace wms.service.Service
|
|
|
IsBack = reqDto.IsBack,
|
|
|
SilkTypeCode = reqDto.SilkType,
|
|
|
IsCore = reqDto.BusType == "2",
|
|
|
-
|
|
|
};
|
|
|
- _billInvinitrepository.InsertReturnEntity(barinfo);
|
|
|
- _billSpoolTransrepository.InsertReturnEntity(billSpoolTrans);
|
|
|
+ _billInvinitrepository.InsertReturnEntity(barinfo);
|
|
|
+ _billSpoolTransrepository.InsertReturnEntity(billSpoolTrans);
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ #endregion 湿拉工字轮/帘线芯股信息初始化
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 分配分拣库
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public bool AllocationWarehouseSort(AllocationWarehouseSortRequest reqDto)
|
|
|
{
|
|
|
- var list = _billSpoolTransrepository.AsQueryable().Where(p => p.WarehouseSort == 0).Take(reqDto.TaskCount).ToList();
|
|
|
- foreach (var item in list)
|
|
|
- {
|
|
|
- var maclist = _basemachinforepository.AsQueryable().Where(p => p.WorkOrder == item.WorkOrder);
|
|
|
- var warelist = maclist.Select(p => p.WarehouseCode).Distinct();
|
|
|
- if (!warelist.Any())
|
|
|
- {
|
|
|
- _billSpoolTransrepository.UpdateModelColumns(p => new BillSpoolTrans()
|
|
|
- {
|
|
|
- ErrType = 1,
|
|
|
- ErrMsg = "没有配置机台信息",
|
|
|
- EditTime = DateTime.Now
|
|
|
- }, p => p.ConBarCode == item.ConBarCode);
|
|
|
- }
|
|
|
- else if (warelist.Count() == 1)
|
|
|
- {
|
|
|
- int sort = int.Parse(warelist.First().Substring(0, 1));
|
|
|
- _billSpoolTransrepository.UpdateModelColumns(p => new BillSpoolTrans()
|
|
|
- {
|
|
|
- WarehouseSort = sort,
|
|
|
- Direct = warelist.First().Substring(1, 1),
|
|
|
- EditTime = DateTime.Now
|
|
|
- }, p => p.ConBarCode == item.ConBarCode);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var waretemplist = maclist.Select(p => new { p.WarehouseCode,p.WorkOrder,p.BillCode, p.PlanQty }).Distinct();
|
|
|
- var warehouselist = _basewarehouserepository.GetList().Select(p => p.Code);
|
|
|
- foreach (var warehouse in warehouselist)
|
|
|
- {
|
|
|
- var stackdetaillist = _billBomsetinfoRepository.AsQueryable().Where(p => p.WarehouseCode == warehouse);
|
|
|
- getMatProport(item.MatCode, warehouse);
|
|
|
- }
|
|
|
- //根据垛型及库存比例分配
|
|
|
- //找出该物料类型在每个库所要求的所有量
|
|
|
-
|
|
|
-
|
|
|
- //找出该物料库存在当前库所有
|
|
|
- }
|
|
|
- }
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 二次扫码分配输送地址
|
|
|
/// </summary>
|
|
@@ -456,28 +478,17 @@ namespace wms.service.Service
|
|
|
var matcodelist = _billBomsetinfoRepository.AsQueryable().Where(p => p.WarehouseCode == baritem.WarehouseCode);
|
|
|
var curmatrate = matcodelist.Where(p => p.MatCode == baritem.MatCode).Count() / matcodelist.Count();
|
|
|
//需要的总量
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
}
|
|
|
var translist = _billSpoolTransrepository.AsQueryable().Where(p => p.WarehouseCode == baritem.WarehouseCode).ToList();
|
|
|
- foreach (var item in translist.GroupBy(p=>p.ConveyorSort))
|
|
|
+ foreach (var item in translist.GroupBy(p => p.ConveyorSort))
|
|
|
{
|
|
|
-
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- public decimal getMatProport(string matcode, string warehousecode)
|
|
|
- {
|
|
|
- //计算此仓库所有该物料的量
|
|
|
- //每的单子(每盘的数量)*预计盘数
|
|
|
- var stackdetaillist = _billBomsetinfoRepository.AsQueryable().Where(p => p.WarehouseCode == warehousecode);
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 帘线领料出库
|
|
|
/// </summary>
|
|
@@ -486,7 +497,7 @@ namespace wms.service.Service
|
|
|
public SRes CurtainProductionStockOut(CurtainProductionStockOutRequest reqDto)
|
|
|
{
|
|
|
var res = new SRes();
|
|
|
-
|
|
|
+
|
|
|
var warehosue = _baseWareHouserepository.GetSingle(p => p.Code == reqDto.WareCode);
|
|
|
if (warehosue == null)
|
|
|
{
|
|
@@ -516,40 +527,743 @@ namespace wms.service.Service
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
public SRes ProductionBack(FjProductionBackRequest reqDto)
|
|
|
{
|
|
|
var res = new SRes();
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
public SRes ProductionLeftFeedBack(string doccode)
|
|
|
{
|
|
|
var res = new SRes();
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
public SRes ErrorMaterialStockOut(FjErrorMaterialStockOutRequest reqDto)
|
|
|
{
|
|
|
var res = new SRes();
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
public SRes BGradeMaterialStockOut(BGradeMaterialStockOutRequest reqDto)
|
|
|
{
|
|
|
var res = new SRes();
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
public SRes StockChange(FjStockChangeRequest reqDto)
|
|
|
{
|
|
|
var res = new SRes();
|
|
|
return res;
|
|
|
}
|
|
|
- public SRes ManualBuildStockTrans(ManualBuildStockTransRequest reqDto)
|
|
|
+
|
|
|
+ #region 空托盘入库
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 一楼空托盘人工入库任务创建
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="reqDto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes OneFloorWorkerBuildEmptyPalletsStock(FJBuildEmptyPalletsStockRequest reqDto)
|
|
|
+ {
|
|
|
+ var res = new SRes();
|
|
|
+
|
|
|
+ var req = _mapper.Map<FJBuildEmptyPalletsStockDto>(reqDto);
|
|
|
+ req.Floor = 1;
|
|
|
+ req.BusType = FJTaskBusType.OneLayerManualPallets;
|
|
|
+
|
|
|
+ //TODO:条码长度待定
|
|
|
+ if (reqDto.PalletCode.Length != 12)
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
|
|
|
+ res.ResMsg = "MES上传的RFID长度不等于12位";
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res = FJEmptyPalletsStockIn(req);
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 分拣库空托盘入库
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="reqDto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes FJEmptyPalletsStockIn(FJBuildEmptyPalletsStockDto reqDto)
|
|
|
+ {
|
|
|
+ var res = new CopperLineResponse();
|
|
|
+ FJTaskBusType BusType = reqDto.BusType;
|
|
|
+
|
|
|
+ //验证业务类型
|
|
|
+ if (reqDto.BusType <= FJTaskBusType.def || reqDto.BusType > FJTaskBusType.OneLayerAutoPallets)
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.ErrParam.GetHashCode();
|
|
|
+ res.ResMsg = "指令类型" + reqDto.BusType + ResponseStatusCodeEnum.ErrParam.GetDescription();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ //验证是否有空余货位
|
|
|
+ res = (CopperLineResponse)IsThereAnySpaceVacancy();
|
|
|
+ if (res.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode()) return res;
|
|
|
+
|
|
|
+ //检查仓库是否存在
|
|
|
+ res = (CopperLineResponse)CheckWareCode(reqDto.WareCode);
|
|
|
+ if (res.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode()) return res;
|
|
|
+
|
|
|
+ //验证容器是否存在
|
|
|
+ res = (CopperLineResponse)CheckContinfo(reqDto.PalletCode, FJContainerType.ContainerType_Pallet);
|
|
|
+ if (res.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode()) return res;
|
|
|
+
|
|
|
+ //验证托盘是否有未结束的任务
|
|
|
+ res = (CopperLineResponse)CheckNoFinishTask(reqDto.PalletCode);
|
|
|
+ if (res.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode()) return res;
|
|
|
+
|
|
|
+ //验证是否存在库存信息
|
|
|
+ res = (CopperLineResponse)CheckInvnow(reqDto.PalletCode);
|
|
|
+ if (res.ResCode != ResponseStatusCodeEnum.Sucess.GetHashCode()) return res;
|
|
|
+
|
|
|
+ //保存条码信息 空托盘条码即条码表条码
|
|
|
+ var barinfo = _billInvinitrepository.GetSingle(p => p.InvBarCode == reqDto.PalletCode);
|
|
|
+ if (barinfo == null)
|
|
|
+ {
|
|
|
+ var warehosue = _basewarehouserepository.GetSingle(p => p.Code == reqDto.WareCode);
|
|
|
+ barinfo = new BillInvinit()
|
|
|
+ {
|
|
|
+ InvBarCode = reqDto.PalletCode,
|
|
|
+ WarehouseId = warehosue.Id,
|
|
|
+ ContGrpId = IdFactory.NewId(),
|
|
|
+ ContGrpBarCode = reqDto.PalletCode,
|
|
|
+ ExecStateCode = FJInvLockState.InvState_Normal.ToString(),
|
|
|
+ ExecDocsTypeCode = FJDocType.DocType_FJ_EmptyPalletsStockIn.GetHashCode().ToString(),
|
|
|
+ InvInOut = FJInvInOutType.In.GetHashCode(),
|
|
|
+ ExecWho = "WCS",
|
|
|
+ EditTime = DateTime.Now,
|
|
|
+ InvStateCode = FJInvState.InvEcecState_BuildUp.ToString(),
|
|
|
+ SuppCode = "",
|
|
|
+ Size = 1,
|
|
|
+ AddTime = DateTime.Now,
|
|
|
+ };
|
|
|
+
|
|
|
+ barinfo = _billInvinitrepository.InsertReturnEntity(barinfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成库存信息-分解方法
|
|
|
+ var createStockRes = CreateStock(new List<BillInvinit>() { barinfo }, reqDto.PalletCode, FJContainerType.ContainerType_Pallet);
|
|
|
+ if (createStockRes.ResCode != 200)
|
|
|
+ {
|
|
|
+ res.ResCode = createStockRes.ResCode;
|
|
|
+ res.ResMsg = createStockRes.ResMsg;
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ var createStockInWcsTaskReqest = new FJCreateStockInWcsTaskRequest()
|
|
|
+ {
|
|
|
+ BusType = BusType.GetDescription(),
|
|
|
+ ContGrpBarCode = reqDto.PalletCode,
|
|
|
+ ContGrpId = createStockRes.ResData.ContGrpId,
|
|
|
+ Qty = reqDto.PalletNum.ObjToDecimal(),
|
|
|
+ EquCode = reqDto.StartLoc,
|
|
|
+ WarehouseCode = reqDto.WareCode,
|
|
|
+ Floor = reqDto.Floor,
|
|
|
+ };
|
|
|
+
|
|
|
+ //下发wcs任务 - 分解方法
|
|
|
+ var taskres = CreateStockInWcsTask(createStockInWcsTaskReqest);
|
|
|
+ if (taskres.ResCode != 200)
|
|
|
+ {
|
|
|
+ res.ResCode = taskres.ResCode;
|
|
|
+ res.ResMsg = taskres.ResMsg;
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ //生成流水数据-分解方法
|
|
|
+ CreateInvFlow(new List<BillInvnow>() { createStockRes.ResData });
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion 空托盘入库
|
|
|
+
|
|
|
+ #region 满轮同WCS交互
|
|
|
+
|
|
|
+ #region 主线
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 工字轮/芯股进入主线扫码
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes EnteMainLine(FJEnteMainLineRequest reqDto)
|
|
|
+ {
|
|
|
+ var res = new SRes();
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ RedisHelper.LPush(nameof(EnteMainLine), reqDto.IShapedWheelCodes);
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode();
|
|
|
+ res.ResMsg = ResponseStatusCodeEnum.Sucess.GetDescription();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
|
|
|
+ res.ResMsg = ex.Message;
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 分配分拣库
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="code"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes AllocationWarehouseSort(string code)
|
|
|
{
|
|
|
var res = new SRes();
|
|
|
+ //找到码垛工字轮信息
|
|
|
+ var spoolTrans = _billSpoolTransrepository.GetSingle(p => p.ConBarCode == code);
|
|
|
+
|
|
|
+ //通过订单找到对应的机台信息
|
|
|
+ var maclist = _basemachinforepository.AsQueryable().Where(p => p.WorkOrder == spoolTrans.WorkOrder);
|
|
|
+ var warelist = maclist.Select(p => p.WarehouseCode).Distinct().OrderBy(v => v); //找到机台对应的仓库信息
|
|
|
+ if (!warelist.Any()) //当前订单没有对应仓库信息
|
|
|
+ {
|
|
|
+ _billSpoolTransrepository.UpdateModelColumns(p => new BillSpoolTrans()
|
|
|
+ {
|
|
|
+ ErrType = 1,
|
|
|
+ ErrMsg = "没有配置机台信息",
|
|
|
+ EditTime = DateTime.Now
|
|
|
+ }, p => p.ConBarCode == spoolTrans.ConBarCode);
|
|
|
+ }
|
|
|
+ else if (warelist.Count() == 1) //当前订单对应一个仓库信息
|
|
|
+ {
|
|
|
+ int sort = int.Parse(warelist.First().Substring(0, 1));
|
|
|
+ _billSpoolTransrepository.UpdateModelColumns(p => new BillSpoolTrans()
|
|
|
+ {
|
|
|
+ WarehouseSort = sort,
|
|
|
+ Direct = warelist.First().Substring(1, 1),
|
|
|
+ EditTime = DateTime.Now
|
|
|
+ }, p => p.ConBarCode == spoolTrans.ConBarCode);
|
|
|
+ }
|
|
|
+ else //当前订单对应多个仓库信息
|
|
|
+ {
|
|
|
+ var waretemplist = maclist.Select(p => new { p.WarehouseCode, p.WorkOrder, p.BillCode, p.PlanQty }).Distinct();
|
|
|
+
|
|
|
+ var warehouselist = _basewarehouserepository.GetList().Select(p => p.Code);
|
|
|
+ foreach (var warehouse in warehouselist)
|
|
|
+ {
|
|
|
+ var stackdetaillist = _billBomsetinfoRepository.AsQueryable().Where(p => p.WarehouseCode == warehouse);
|
|
|
+ getMatProport(spoolTrans.MatCode, warehouse);
|
|
|
+ }
|
|
|
+ //根据垛型及库存比例分配
|
|
|
+ //找出该物料类型在每个库所要求的所有量
|
|
|
+
|
|
|
+ //找出该物料库存在当前库所有
|
|
|
+ }
|
|
|
+
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 计算物料在该仓库的比例
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="matcode">物料编号</param>
|
|
|
+ /// <param name="warehousecode">仓库编号</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public decimal getMatProport(string matcode, string warehousecode)
|
|
|
+ {
|
|
|
+ //计算此仓库所有该物料的量
|
|
|
+
|
|
|
+ //每的单子(每盘的数量)
|
|
|
+ var stackdetaillist = _billBomsetinfoRepository.AsQueryable().Where(p => p.WarehouseCode == warehousecode);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion 主线
|
|
|
+
|
|
|
+ #endregion 满轮同WCS交互
|
|
|
+
|
|
|
public SRes BomInfoTrans(BomInfoTransRequest reqDto)
|
|
|
{
|
|
|
var res = new SRes();
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ public SRes FJ1NorthAutoGenerateLocation()
|
|
|
+ {
|
|
|
+ SRes res = new SRes();
|
|
|
+ BaseWarehouse BaseWarearea = new BaseWarehouse()
|
|
|
+ {
|
|
|
+ Id = IdFactory.NewId(),
|
|
|
+ IsStop = 0,
|
|
|
+ Code = "fj1northhouse",
|
|
|
+ Name = "分拣库1北",
|
|
|
+ AddTime = DateTime.Now
|
|
|
+,
|
|
|
+ AddWho = "admin",
|
|
|
+ EditTime = DateTime.Now,
|
|
|
+ EditWho = "admin",
|
|
|
+ TypeNum = 1
|
|
|
+ };
|
|
|
+ var baseWareareaEntity = _basewarehouserepository.InsertReturnEntity(BaseWarearea);
|
|
|
+ var dbBaseWarecellLists = _basewarehouserepository.AsQueryable().ToList();
|
|
|
+ var shelfcode = "";
|
|
|
+ var list = new List<BaseWarecell>();
|
|
|
+ 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层
|
|
|
+ for (int layer = 1; layer <= 10; layer++) //层
|
|
|
+ {
|
|
|
+ for (int col = 1; col <= 10; col++) //列
|
|
|
+ {
|
|
|
+ var code = row.ToString().PadLeft(2, '0') + "-" + col.ToString().PadLeft(2, '0') + "-" + layer.ToString().PadLeft(2, '0') + "-" + tunnel;
|
|
|
+ codes.Add(code);
|
|
|
+ var name = row.ToString() + "行" + col.ToString() + "列" + layer.ToString() + "层";
|
|
|
+ list.Add(new BaseWarecell
|
|
|
+ {
|
|
|
+ Id = IdFactory.NewId(),
|
|
|
+ WarehouseId = baseWareareaEntity.Id,
|
|
|
+ WareAreaId = 1669154208777113600,
|
|
|
+ IsStop = 0,
|
|
|
+ Code = code,
|
|
|
+ Name = name,
|
|
|
+ StateNum = 1,
|
|
|
+ TypeNum = 1,
|
|
|
+ Size = 1,
|
|
|
+ Shelf = tunnel.ToString() + shelfcode,
|
|
|
+ WarehouseCode = "fj1northhouse",
|
|
|
+ Row = row,
|
|
|
+ Col = col,
|
|
|
+ Layer = layer,
|
|
|
+ Depth = 1,
|
|
|
+ Tunnel = tunnel,
|
|
|
+ SCRel = "SRM" + tunnel.ToString().PadLeft(2, '0'),
|
|
|
+ ContGrpId = 0,
|
|
|
+ ContGrpBarCode = "",
|
|
|
+ Memo = "",
|
|
|
+ AddWho = "admin",
|
|
|
+ AddTime = DateTime.Now,
|
|
|
+ EditWho = "admin",
|
|
|
+ EditTime = DateTime.Now,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ _basewarecellrepository.InsertRange(list);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public SRes FJSouthAutoGenerateLocation()
|
|
|
+ {
|
|
|
+ SRes res = new SRes();
|
|
|
+
|
|
|
+ BaseWarehouse BaseWarearea = new BaseWarehouse()
|
|
|
+ {
|
|
|
+ Id = IdFactory.NewId(),
|
|
|
+ IsStop = 0,
|
|
|
+ Code = "fj1southhouse",
|
|
|
+ Name = "分拣库1南",
|
|
|
+ AddTime = DateTime.Now
|
|
|
+,
|
|
|
+ AddWho = "admin",
|
|
|
+ EditTime = DateTime.Now,
|
|
|
+ EditWho = "admin",
|
|
|
+ TypeNum = 1
|
|
|
+ };
|
|
|
+
|
|
|
+ var baseWareareaEntity = _basewarehouserepository.InsertReturnEntity(BaseWarearea);
|
|
|
+
|
|
|
+ var dbBaseWarecellLists = _basewarehouserepository.AsQueryable().ToList();
|
|
|
+ var shelfcode = "";
|
|
|
+ var list = new List<BaseWarecell>();
|
|
|
+ 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层
|
|
|
+ for (int layer = 1; layer <= 10; layer++) //层
|
|
|
+ {
|
|
|
+ for (int col = 11; col <= 20; col++) //列
|
|
|
+ {
|
|
|
+ var code = row.ToString().PadLeft(2, '0') + "-" + col.ToString().PadLeft(2, '0') + "-" + layer.ToString().PadLeft(2, '0') + "-" + tunnel;
|
|
|
+ codes.Add(code);
|
|
|
+ var name = row.ToString() + "行" + col.ToString() + "列" + layer.ToString() + "层";
|
|
|
+ list.Add(new BaseWarecell
|
|
|
+ {
|
|
|
+ Id = IdFactory.NewId(),
|
|
|
+ WarehouseId = baseWareareaEntity.Id,
|
|
|
+ WareAreaId = 1669154208777113600,
|
|
|
+ IsStop = 0,
|
|
|
+ Code = code,
|
|
|
+ Name = name,
|
|
|
+ StateNum = 1,
|
|
|
+ TypeNum = 1,
|
|
|
+ Size = 1,
|
|
|
+ Shelf = tunnel.ToString() + shelfcode,
|
|
|
+ WarehouseCode = "fj1southhouse",
|
|
|
+ Row = row,
|
|
|
+ Col = col,
|
|
|
+ Layer = layer,
|
|
|
+ Depth = 1,
|
|
|
+ Tunnel = tunnel,
|
|
|
+ SCRel = "SRM" + tunnel.ToString().PadLeft(2, '0'),
|
|
|
+ ContGrpId = 0,
|
|
|
+ ContGrpBarCode = "",
|
|
|
+ Memo = "",
|
|
|
+ AddWho = "admin",
|
|
|
+ AddTime = DateTime.Now,
|
|
|
+ EditWho = "admin",
|
|
|
+ EditTime = DateTime.Now,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ _basewarecellrepository.InsertRange(list);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 容器、物料、条码、库存检测及创建,创建流水信息
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 检查容器是否存在,不存在则创建
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="contBarCode">容器条码</param>
|
|
|
+ /// <param name="fjContainerType">容器类型</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes CheckContinfo(string contBarCode, FJContainerType fjContainerType)
|
|
|
+ {
|
|
|
+ SRes res = new SRes();
|
|
|
+ var container = _baseContinfo.GetSingle(x => x.ContBarCode == contBarCode);
|
|
|
+ if (container == null)
|
|
|
+ {
|
|
|
+ //创建容器信息
|
|
|
+ var cont = new BaseContinfo
|
|
|
+ {
|
|
|
+ ContBarCode = contBarCode,
|
|
|
+ Name = contBarCode,
|
|
|
+ TypeCode = fjContainerType.ToString(),
|
|
|
+ PrintQty = 1,
|
|
|
+ IsStop = 0,
|
|
|
+ WarehouseId = 0,
|
|
|
+ AddWho = "WMS",
|
|
|
+ AddTime = DateTime.Now
|
|
|
+ };
|
|
|
+ //加载新的容器信息
|
|
|
+ if (!_baseContinfo.Insert(cont))
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.DataSaveErr.GetHashCode();
|
|
|
+ res.ResMsg = "RFID载具初始化失败";
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (container.IsStop != 0)
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
|
|
|
+ res.ResMsg = "容器已停用";
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 跟据库存信息创建流水信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="barlist">库存信息</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes CreateInvFlow(List<BillInvnow> barlist)
|
|
|
+ {
|
|
|
+ var res = new SRes();
|
|
|
+ var listflow = _mapper.Map<List<BillInvflow>>(barlist);
|
|
|
+ foreach (var item in listflow)
|
|
|
+ {
|
|
|
+ item.AddTime = DateTime.Now;
|
|
|
+ item.Id = IdFactory.NewId();
|
|
|
+ }
|
|
|
+ _billInvflow.InsertRange(listflow);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 跟据库存信息创建流水信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="bar">库存信息</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes CreateInvFlow(BillInvnow bar)
|
|
|
+ {
|
|
|
+ var res = new SRes();
|
|
|
+ var flow = _mapper.Map<BillInvflow>(bar);
|
|
|
+ flow.AddTime = DateTime.Now;
|
|
|
+ flow.Id = IdFactory.NewId();
|
|
|
+ _billInvflow.Insert(flow);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 是否有空余货位
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes IsThereAnySpaceVacancy()
|
|
|
+ {
|
|
|
+ var res = new SRes();
|
|
|
+ //验证有剩余货位
|
|
|
+ if (_basewarecellrepository.GetList(p => p.IsStop == 0 && p.StateNum == FJLocationState.LocationState_Empty.GetHashCode()).Count() < 2)
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.NotEnoughLocation.GetHashCode();
|
|
|
+ res.ResMsg = ResponseStatusCodeEnum.NotEnoughLocation.GetDescription();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 检查传入的仓库是否存在
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="wareCode">仓库编号</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes CheckWareCode(string wareCode)
|
|
|
+ {
|
|
|
+ var res = new SRes();
|
|
|
+ //验证是否有对应仓库
|
|
|
+ var warehosue = _basewarehouserepository.GetSingle(p => p.Code == wareCode);
|
|
|
+ if (warehosue == null)
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.WarehouseCodeNotExist.GetHashCode();
|
|
|
+ res.ResMsg = ResponseStatusCodeEnum.WarehouseCodeNotExist.GetDescription();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 验证空托盘是否有未结束的任务
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="PalletCode"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes CheckNoFinishTask(string PalletCode)
|
|
|
+ {
|
|
|
+ SRes res = new SRes();
|
|
|
+ //验证当前托盘是否有未结束的任务
|
|
|
+ var task = _wcstaskoldrepository.AsQueryable().Where(p => p.BarCode == PalletCode && p.Status < TaskStatus.Finish).SplitTable(p => p.Take(2)).First();
|
|
|
+ if (task != null && task.ID > 0)
|
|
|
+ {
|
|
|
+ switch (task.Type)
|
|
|
+ {
|
|
|
+ case TaskType.SetPlate:
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.WcsTaskExist.GetHashCode();
|
|
|
+ res.ResMsg = PalletCode + "该号组盘任务还未完成,请先完成组盘任务";
|
|
|
+ return res;
|
|
|
+
|
|
|
+ case TaskType.EnterDepot:
|
|
|
+ if (task.Status > TaskStatus.WaitingToExecute && task.Status < TaskStatus.Finish)
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.WcsTaskExist.GetHashCode();
|
|
|
+ res.ResMsg = PalletCode + "已有进行中任务,请检查托盘条码是否重复";
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.WcsTaskExist.GetHashCode();
|
|
|
+ res.ResMsg = PalletCode + "任务已创建,请勿重复申请";
|
|
|
+ return res;
|
|
|
+
|
|
|
+ case TaskType.OutDepot:
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.WcsTaskExist.GetHashCode();
|
|
|
+ res.ResMsg = PalletCode + "该号出库任务还未完成,请先完成出库任务";
|
|
|
+ return res;
|
|
|
+
|
|
|
+ case TaskType.TransferDepot:
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.WcsTaskExist.GetHashCode();
|
|
|
+ res.ResMsg = PalletCode + "该号移库任务还未完成,请先完成移库任务";
|
|
|
+ return res;
|
|
|
+
|
|
|
+ case TaskType.Delivery:
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.WcsTaskExist.GetHashCode();
|
|
|
+ res.ResMsg = PalletCode + "该号输送任务还未完成,请先完成输送任务";
|
|
|
+ return res;
|
|
|
+
|
|
|
+ case TaskType.EmptyInit:
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.WcsTaskExist.GetHashCode();
|
|
|
+ res.ResMsg = PalletCode + "该号空轮初始化任务还未完成,请先完成空轮初始化任务";
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 检查是否存在库存信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="code">编码</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes CheckInvnow(string code)
|
|
|
+ {
|
|
|
+ SRes res = new SRes();
|
|
|
+
|
|
|
+ //验证是否没有库存信息
|
|
|
+ var stock = _billInvnowrepository.GetSingle(p => p.ContGrpBarCode == code);
|
|
|
+ if (stock != null && stock.InvStateCode == FJInvState.InvEcecState_In.ToString())
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
|
|
|
+ res.ResMsg = code + "该托盘号已在库中,请检查托盘号是否重复";
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ else if (stock != null && stock.InvStateCode == InvState.InvEcecState_OutGoing.ToString())
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
|
|
|
+ res.ResMsg = code + "该托盘号存在出库中任务,请检查上一个任务是否已经完成";
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ else if (stock != null)
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.GroupStockDetailMaterialBarCodeExist.GetHashCode();
|
|
|
+ res.ResMsg = ResponseStatusCodeEnum.GroupStockDetailMaterialBarCodeExist.GetDescription();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 创建库存信息
|
|
|
+ /// 不验证容器是否存在
|
|
|
+ /// 不验证容器是否有未结束的任务
|
|
|
+ /// 不验条码信息是否存在
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="barList">条码集合</param>
|
|
|
+ /// <param name="containerBarcode">容器编号</param>
|
|
|
+ /// <param name="containerType">容器类型</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes<BillInvnow> CreateStock(List<BillInvinit> barList, string containerBarcode, FJContainerType containerType)
|
|
|
+ {
|
|
|
+ var res = new SRes<BillInvnow>();
|
|
|
+ if (string.IsNullOrEmpty(containerBarcode))
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.ContainerCodeNotEmpty.GetHashCode();
|
|
|
+ res.ResMsg = ResponseStatusCodeEnum.ContainerCodeNotEmpty.GetDescription();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ //将条码表映射到库存表
|
|
|
+ var stocklist = _mapper.Map<List<BillInvnow>>(barList);
|
|
|
+ foreach (var item in stocklist)
|
|
|
+ {
|
|
|
+ item.AddTime = DateTime.Now;
|
|
|
+ item.Id = IdFactory.NewId();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!_billInvnowrepository.InsertRange(stocklist))
|
|
|
+ {
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.DataSaveErr.GetHashCode();
|
|
|
+ res.ResMsg = "托盘库存信息存储失败";
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode();
|
|
|
+ res.ResDataList = stocklist;
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 创建WCS任务
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="reqDto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public SRes<WCS_TaskInfo> CreateStockInWcsTask(FJCreateStockInWcsTaskRequest reqDto)
|
|
|
+ {
|
|
|
+ var res = new SRes<WCS_TaskInfo>();
|
|
|
+ var wcstask = new WCS_TaskInfo()
|
|
|
+ {
|
|
|
+ Type = TaskType.EnterDepot,
|
|
|
+ Status = TaskStatus.NewBuild,
|
|
|
+ Priority = 0,
|
|
|
+ Device = "",
|
|
|
+ SrmStation = "",
|
|
|
+ AddrFrom = reqDto.EquCode,
|
|
|
+ AddrTo = "srm",
|
|
|
+ LastInteractionPoint = "",
|
|
|
+ BarCode = reqDto.ContGrpBarCode,
|
|
|
+ Floor = reqDto.Floor,
|
|
|
+ Length = reqDto.Qty,
|
|
|
+ AddTime = DateTime.Now,
|
|
|
+ StartTime = DateTime.Now,
|
|
|
+ DocID = 0,
|
|
|
+ PalletType = 1,
|
|
|
+ ProdLine = 0,
|
|
|
+ AddWho = "wms",
|
|
|
+ WarehouseCode = reqDto.WarehouseCode,
|
|
|
+ Enabled = true,
|
|
|
+ WorkBench = reqDto.EquCode,
|
|
|
+ MaterialCode = reqDto.MaterialCode,
|
|
|
+ MatCode = reqDto.MatCode,
|
|
|
+ BusType = reqDto.BusType
|
|
|
+ };
|
|
|
+ var wcstaskhis = _mapper.Map<WCS_TaskOld>(wcstask);
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ _db.BeginTran();
|
|
|
+ var task = _taskrepository.InsertReturnEntity(wcstask);
|
|
|
+ wcstaskhis.ID = task.ID;
|
|
|
+ _wcstaskoldrepository.InsertableSplitTable(wcstaskhis);
|
|
|
+ var taskdetail = new WCS_TaskDtl()
|
|
|
+ {
|
|
|
+ ID = Guid.NewGuid(),
|
|
|
+ CurPoint = reqDto.EquCode,
|
|
|
+ AddTime = DateTime.Now,
|
|
|
+ AddWho = "wms",
|
|
|
+ Enabled = true,
|
|
|
+ ParentTaskCode = task.ID,
|
|
|
+ Desc = reqDto.EquCode + "分拣一楼空托入库",
|
|
|
+ };
|
|
|
+ _taskdetailrepository.InsertableSplitTable(taskdetail);
|
|
|
+ _db.CommitTran();
|
|
|
+ res.ResData = task;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _db.RollbackTran();
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.DataSaveErr.GetHashCode();
|
|
|
+ res.ResMsg = ResponseStatusCodeEnum.DataSaveErr.GetDescription();
|
|
|
+ _logger.LogInformation("保存任务异常:" + ex.ToString());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion 容器、物料、条码、库存检测及创建,创建流水信息
|
|
|
}
|
|
|
}
|