Browse Source

开发入库接口 inputrequest:

1.添加新entity:manage main,productInformation,V_MANAGE_IN_COUNT,V_WH_CELL_ENABLE
2.添加数据持久层;
3.添加货位服务和任务服务类
master
taoleite 1 week ago
parent
commit
dd98dc6ead
  1. 257
      Controllers/InputRequestController.cs
  2. 16
      Data/MichelinDbContext.cs
  3. 5
      Entities/MANAGE_MAIN.cs
  4. 5
      Entities/ProductInformation.cs
  5. 19
      Entities/V_MANAGE_IN_COUNT.cs
  6. 37
      Entities/V_WH_CELL_ENABLE.cs
  7. 100
      Entities/WH_CELL.cs
  8. 33
      Repositories/Implement/IoControlRouteRepository.cs
  9. 89
      Repositories/Implement/ProductInformationRepository.cs
  10. 33
      Repositories/Implement/WhCellRepository.cs
  11. 6
      Repositories/Interface/IIoControlRouteRepository.cs
  12. 5
      Repositories/Interface/IManageMainRepository.cs
  13. 13
      Repositories/Interface/IProductInformationRepository.cs
  14. 10
      Repositories/Interface/IWhCellRepository.cs
  15. 144
      TaskServices/CellLogicService.cs
  16. 58
      TaskServices/ManageTaskService.cs

257
Controllers/InputRequestController.cs

@ -1,5 +1,12 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using WMS_GIRAF_Interface.Data;
using WMS_GIRAF_Interface.Entities;
using WMS_GIRAF_Interface.Models; using WMS_GIRAF_Interface.Models;
using WMS_GIRAF_Interface.Repositories.Implement;
using WMS_GIRAF_Interface.Repositories.Interface;
using WMS_GIRAF_Interface.TaskServices;
namespace WMS_GIRAF_Interface.Controllers; namespace WMS_GIRAF_Interface.Controllers;
@ -7,20 +14,266 @@ namespace WMS_GIRAF_Interface.Controllers;
/// 入库申请Giraf->WMS /// 入库申请Giraf->WMS
/// </summary> /// </summary>
[ApiController, Route("/Input")] [ApiController, Route("/Input")]
public class InputRequestController : ControllerBase
public class InputRequestController(
ILogger<InputRequestController> logger,
IdestinationIdRepository destinationIdRepository,
ManageTaskService manageTaskService,
IManageMainRepository manageMainRepository,
IWhCellRepository whCellRepository,
IProductInformationRepository productInformationRepository,
CellLogicService cellLogicService)
: ControllerBase
{ {
private readonly ILogger<InputRequestController> _logger = logger;
/// <summary> /// <summary>
/// 入库任务请求 /// 入库任务请求
/// </summary> /// </summary>
/// <param name="inputRequest">轮胎入库任务请求json</param> /// <param name="inputRequest">轮胎入库任务请求json</param>
[HttpPost] [HttpPost]
public void GetInputRequestFromGiraf(InputRequest.RootObject inputRequest)
public InputRequestReturn.RootObject GetInputRequestFromGiraf(InputRequest.RootObject inputRequest)
{ {
bool bResult = true;
string totalResult = "";
string sResult = string.Empty;
//TODO:获取入库任务,并生成到巷道的任务 //TODO:获取入库任务,并生成到巷道的任务
InputRequestReturn.RootObject returnParameter = new InputRequestReturn.RootObject();
//优先判断products是否包含轮胎信息
if (inputRequest!=null)
{
if (!string.IsNullOrEmpty(inputRequest.introductionPost))
{
//检查当前post number是否存在
var checkPost =
destinationIdRepository.GetDestinationId(Convert.ToInt32(inputRequest.introductionPost));
if (checkPost!=null)
{
//创建入库任务
if (inputRequest is { products: { Count: > 0 }, support: not null })
{
string lineWay = string.Empty;
foreach (var inputRequestProduct in inputRequest.products)
{
//更新产品信息
//判断当前入库胎号是否有任务
var checkTireTask =
manageMainRepository.GetManageMain("barcode", inputRequestProduct.identifier);
if (checkTireTask!=null)
{
//tlt:查看是否有物料信息,如果包含物料信息,就进行更新
var checkProductInfo = productInformationRepository.GetProductInformation(
inputRequestProduct.identifier);
if (checkProductInfo != null)
{
//更新物料信息
checkProductInfo.BarCode = inputRequestProduct.identifier;
checkProductInfo.LotNumber = inputRequest.sku;
checkProductInfo.PopulationNumber = inputRequestProduct.productClass;
checkProductInfo.SupportType = [inputRequest.support.type];
checkProductInfo.FabricationDateTimeInUtc = (DateTime)inputRequestProduct.fabricationDate!;
checkProductInfo.DryDateTimeInUtc = (DateTime)inputRequestProduct.maturationDate!;
checkProductInfo.OldDateTimeInUtc = (DateTime)inputRequestProduct.highPriorityDate!;
checkProductInfo.HdvDateTimeInUtc = (DateTime)inputRequestProduct.expirationDate!;
checkProductInfo.IsBlocked = inputRequestProduct.isBlocked;
checkProductInfo.IsPriority = inputRequestProduct.isPriority;
productInformationRepository.UpdateProductInformation(checkProductInfo);
logger.LogInformation($"Update product information:{inputRequestProduct.identifier}");
}
else
{
ProductInformation newProductInfo = new ProductInformation()
{
//新增物料信息
BarCode = inputRequestProduct.identifier,
LotNumber = inputRequest.sku,
PopulationNumber = inputRequestProduct.productClass,
SupportType = [inputRequest.support.type],
FabricationDateTimeInUtc = (DateTime)inputRequestProduct.fabricationDate!,
DryDateTimeInUtc = (DateTime)inputRequestProduct.maturationDate!,
OldDateTimeInUtc = (DateTime)inputRequestProduct.highPriorityDate!,
HdvDateTimeInUtc = (DateTime)inputRequestProduct.expirationDate!,
IsBlocked = inputRequestProduct.isBlocked,
IsPriority = inputRequestProduct.isPriority
};
productInformationRepository.AddProductInformation(newProductInfo);
logger.LogInformation($"Add product information:{inputRequestProduct.identifier};/r/n Json String : {JsonConvert.SerializeObject(newProductInfo)}");
}
if (checkTireTask.MANAGE_TYPE_CODE != "ManageLineMove")
{
//出现问题 生成任务错误
returnParameter.status = "2";
returnParameter.introductionPost = inputRequest.introductionPost;
returnParameter.errorDetails += $"Tire barcode {inputRequestProduct.identifier} already have manual loading task! ;";
}
else
{
//更新任务信息:将当前的信息保存到任务信息中,根据新的起点来更新可用的入库路径信息,筛选一个可用的入库巷道
var cellInfoEnd = whCellRepository.GetCell(checkTireTask.END_CELL_ID);
//判断当前任务终点是否包含在接口可用的终点列表中
if (inputRequest.availableIntroductionPosts != null)
{
if (inputRequest.availableIntroductionPosts.Contains(cellInfoEnd.CELL_CODE))
{
lineWay = cellInfoEnd.LANE_WAY;
}
else
{
//获取当前申请的起点 decision point
var cellInfoStart = whCellRepository.GetCell(inputRequest.introductionPost);
bResult = cellLogicService.GetLaneWayFromDecisionPoint(cellInfoStart,
checkTireTask.CELL_MODEL, checkTireTask.STOCK_BARCODE,
inputRequest.availableIntroductionPosts, checkTireTask.LOTNUMBER,
out int endLaneWay, out sResult);
if (bResult)
{
//更新终点信息到任务中
checkTireTask.END_CELL_ID = endLaneWay;
checkTireTask.requestNumber = inputRequest.inputRequestId;
checkTireTask.CELL_MODEL = inputRequest.support.type;
checkTireTask.START_CELL_ID = cellInfoStart.CELL_ID;
checkTireTask.LOTNUMBER = inputRequest.sku;
checkTireTask.POPULATIONNUMBER = inputRequestProduct.productClass;
checkTireTask.keepRequestInMemoryEventIfLackOfProductIssue = true;
checkTireTask.keepRequestInMemoryEventIfMechanicalIssue = true;
bResult = manageMainRepository.UpdateManageMain(checkTireTask);
if (bResult)
{
//任务更新成功:完成本次
returnParameter.status = "1";
returnParameter.introductionPost = inputRequest.introductionPost;
logger.LogInformation($"Update task info success! tire barcode :{checkTireTask.STOCK_BARCODE};/r/n task info: {JsonConvert.SerializeObject(checkTireTask)} ");
}
else
{
//更新任务信息失败
returnParameter.status = "2";
returnParameter.introductionPost = inputRequest.introductionPost;
returnParameter.errorDetails += $"Tire barcode {inputRequestProduct.identifier} error reason : Insert task failed! ;";
logger.LogError($"Update task info failed! tire barcode :{inputRequestProduct.identifier}; error reason : Insert task failed!");
}
}
else
{
returnParameter.status = "4";
returnParameter.introductionPost = inputRequest.introductionPost;
returnParameter.errorDetails += $"Update task info failed! reason: WMS can not get available input post number!";
logger.LogError($"Update task info failed! tire barcode :{inputRequestProduct.identifier}; error reason : WMS can not get available input post number!");
}
}
}
else
{
//无可用终点,返回错误信息
returnParameter.status = "4";
returnParameter.introductionPost = inputRequest.introductionPost;
returnParameter.errorDetails += $"Update task info failed! reason: Json string parameter availableIntroductionPosts is null!";
logger.LogError($"tire barcode :{inputRequestProduct.identifier} parameter availableIntroductionPosts is null ,can not create task ");
}
}
}
else
{
var cellInfoStart = whCellRepository.GetCell(inputRequest.introductionPost);
if (cellInfoStart != null)
{
int endLaneWay = 0;
//入库申请点位为Decision Point DP
if (cellInfoStart.CELL_MODEL=="DP")
{
bResult = cellLogicService.GetLaneWayFromDecisionPoint(cellInfoStart,
checkTireTask.CELL_MODEL, checkTireTask.STOCK_BARCODE,
inputRequest.availableIntroductionPosts, checkTireTask.LOTNUMBER,
out endLaneWay, out sResult);
}
else//一楼入库时,入库点为VP,CP,EP,CV
{
bResult = cellLogicService.GetCellLocationFromCheckPoint(cellInfoStart,
out endLaneWay, out sResult);
}
if (bResult)
{
//生成任务
bResult = manageTaskService.CreateInputTaskFromGiraf(inputRequestProduct,
inputRequest.introductionPost, endLaneWay, inputRequest.sku, inputRequest.support.type,inputRequest.inputRequestId,
inputRequest.support.IsBlocked, false, false,
out sResult);
if (bResult)
{
//生成任务成功
returnParameter.status = "1";
returnParameter.introductionPost = inputRequest.introductionPost;
returnParameter.errorDetails +=
$"Tire barcode {inputRequestProduct.identifier} created task success! ;";
logger.LogInformation($"Create task info success! tire barcode :{checkTireTask.STOCK_BARCODE};/r/n task info: {JsonConvert.SerializeObject(checkTireTask)} ");
}
else
{
//生成任务错误
//出现问题 生成任务错误
returnParameter.status = "2";
returnParameter.introductionPost = inputRequest.introductionPost;
returnParameter.errorDetails +=
$"Tire barcode {inputRequestProduct.identifier} create task failed! the reason: {sResult} ;";
}
}
else
{
//找不到可用巷道
returnParameter.status = "4";
returnParameter.introductionPost = inputRequest.introductionPost;
returnParameter.errorDetails += $"Update task info failed! reason: WMS can not get available input post number!";
logger.LogError($"Update task info failed! tire barcode :{inputRequestProduct.identifier}; error reason : WMS can not get available input post number!");
}
}
else
{
//找不到对应起点信息
returnParameter.status = "4";
returnParameter.introductionPost = inputRequest.introductionPost;
returnParameter.errorDetails += $"Update task info failed! reason: Json string parameter availableIntroductionPosts is null!";
logger.LogError($"tire barcode :{inputRequestProduct.identifier} parameter availableIntroductionPosts is null ,can not create task ");
}
}
}
}
}
else
{
//出现问题:找不到对应终点
returnParameter.status = "5";
returnParameter.introductionPost = inputRequest.introductionPost;
returnParameter.errorDetails = $"WMS didn't find the post number{inputRequest.introductionPost} ";
}
}
}
else
{
//未收到有效信息
returnParameter.status = "2";
returnParameter.introductionPost = inputRequest.introductionPost;
returnParameter.errorDetails = $"WMS didn't receive the right format input parameters! ";
} }
return returnParameter;
}
/// <summary> /// <summary>
/// 入库轮胎申请 /// 入库轮胎申请
/// /Input/ItemDropped /// /Input/ItemDropped

16
Data/MichelinDbContext.cs

@ -15,10 +15,22 @@ public class MichelinDbContext : DbContext
public DbSet<MANAGE_MAIN?> Manage_Main { get; set; } public DbSet<MANAGE_MAIN?> Manage_Main { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
public DbSet<IO_CONTROL_ROUTE> IoControlRoute { get; set; }
public DbSet<WH_CELL> Wh_Cell { get; set; }
public DbSet<ProductInformation> ProductInformation { get; set; }
public virtual DbSet<V_MANAGE_IN_COUNT> V_ManageInCount { get; set; }
public virtual DbSet<V_WH_CELL_ENABLE> V_WhCellEnable { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
//视图无主键
modelBuilder.Entity<V_MANAGE_IN_COUNT>().HasNoKey();
modelBuilder.Entity<V_WH_CELL_ENABLE>().HasNoKey();
} }
} }

5
Entities/MANAGE_MAIN.cs

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization; using System.Runtime.Serialization;
namespace WMS_GIRAF_Interface.Entities; namespace WMS_GIRAF_Interface.Entities;
@ -10,6 +11,8 @@ public class MANAGE_MAIN
/// 任务编号 /// 任务编号
///</sumary> ///</sumary>
[Column("MANAGE_ID")] [Column("MANAGE_ID")]
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int MANAGE_ID { get; set; } public int MANAGE_ID { get; set; }
///<sumary> ///<sumary>
/// 终点 /// 终点

5
Entities/ProductInformation.cs

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization; using System.Runtime.Serialization;
namespace WMS_GIRAF_Interface.Entities; namespace WMS_GIRAF_Interface.Entities;
@ -6,7 +7,9 @@ namespace WMS_GIRAF_Interface.Entities;
[Table("ProductInformation")] [Table("ProductInformation")]
public class ProductInformation public class ProductInformation
{ {
[Column("BarCode")] [Column("BarCode")]
[Key]
public string BarCode { get; set; } public string BarCode { get; set; }
///<sumary> ///<sumary>

19
Entities/V_MANAGE_IN_COUNT.cs

@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace WMS_GIRAF_Interface.Entities;
[Table("V_MANAGE_IN_COUNT")]
public class V_MANAGE_IN_COUNT
{
[Column("START_DEVICE")]
public string START_DEVICE { get; set; }
[Column("END_DEVICE")]
public string END_DEVICE { get; set; }
[Column("MANAGE_COUNT")]
public string MANAGE_COUNT { get; set; }
[Column("ENABLE_CELL_COUNT")]
public string ENABLE_CELL_COUNT { get; set; }
}

37
Entities/V_WH_CELL_ENABLE.cs

@ -0,0 +1,37 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace WMS_GIRAF_Interface.Entities;
[Table("V_WH_CELL_ENABLE")]
public class V_WH_CELL_ENABLE
{
[Column("PRIORITY")]
public int PRIORITY { get; set; }
[Column("YPRIORITY")]
public int YPRIORITY { get; set; }
[Column("CELL_ID")]
public int CELL_ID { get; set; }
[Column("CELL_TYPE")]
public string CELL_TYPE { get; set; }
[Column("CELL_STATUS")]
public string CELL_STATUS { get; set; }
[Column("RUN_STATUS")]
public string RUN_STATUS { get; set; }
[Column("CELL_CODE")]
public string CELL_CODE { get; set; }
[Column("CELL_X")]
public int CELL_X { get; set; }
[Column("CELL_Y")]
public int CELL_Y { get; set; }
[Column("LANE_WAY")]
public string LANE_WAY { get; set; }
}

100
Entities/WH_CELL.cs

@ -0,0 +1,100 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace WMS_GIRAF_Interface.Entities;
[Table("WH_CELL")]
public class WH_CELL
{
[Column("CELL_ID")]
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int CELL_ID { get; set; }
[Column("WAREHOUSE_ID")]
public int WAREHOUSE_ID { get; set; }
[Column("AREA_ID")]
public int AREA_ID { get; set; }
[Column("LOGIC_ID")]
public int LOGIC_ID { get; set; }
[Column("CELL_NAME")]
public string CELL_NAME { get; set; }
[Column("CELL_CODE")]
public string CELL_CODE { get; set; }
[Column("CELL_TYPE")]
public string CELL_TYPE { get; set; }
[Column("DEVICE_CODE")]
public string DEVICE_CODE { get; set; }
[Column("CELL_Z")]
public int CELL_Z { get; set; }
[Column("CELL_X")]
public int CELL_X { get; set; }
[Column("CELL_Y")]
public int CELL_Y { get; set; }
[Column("CELL_INOUT")]
public string CELL_INOUT { get; set; }
[Column("CELL_MODEL")]
public string CELL_MODEL { get; set; }
[Column("CELL_STATUS")]
public string CELL_STATUS { get; set; }
[Column("RUN_STATUS")]
public string RUN_STATUS { get; set; }
[Column("CELL_FORK_TYPE")]
public string CELL_FORK_TYPE { get; set; }
[Column("CELL_LOGICAL_NAME")]
public string CELL_LOGICAL_NAME { get; set; }
[Column("LANE_WAY")]
public string LANE_WAY { get; set; }
[Column("CELL_GROUP")]
public string CELL_GROUP { get; set; }
[Column("SHELF_TYPE")]
public string SHELF_TYPE { get; set; }
[Column("SHELF_NEIGHBOUR")]
public string SHELF_NEIGHBOUR { get; set; }
[Column("CELL_STORAGE_TYPE")]
public string CELL_STORAGE_TYPE { get; set; }
[Column("LOCK_DEVICE_CODE")]
public string LOCK_DEVICE_CODE { get; set; }
[Column("CELL_WIDTH")]
public int CELL_WIDTH { get; set; }
[Column("CELL_HEIGHT")]
public int CELL_HEIGHT { get; set; }
[Column("LOCK_CELL_ID")]
public string LOCK_CELL_ID { get; set; }
[Column("BELONG_AREA")]
public string BELONG_AREA { get; set; }
[Column("BELONG_ZCQ_ID")]
public int BELONG_ZCQ_ID { get; set; }
[Column("CELL_FLAG")]
public string CELL_FLAG { get; set; }
[Column("CELL_TRANS_FLAG")]
public int CELL_TRANS_FLAG { get; set; }
}

33
Repositories/Implement/IoControlRouteRepository.cs

@ -0,0 +1,33 @@
using WMS_GIRAF_Interface.Data;
using WMS_GIRAF_Interface.Entities;
using WMS_GIRAF_Interface.Repositories.Interface;
namespace WMS_GIRAF_Interface.Repositories.Implement;
public class IoControlRouteRepository:IIoControlRouteRepository
{
private readonly MichelinDbContext _context;
private readonly ILogger<ManageMainRepository> _logger;
public IoControlRouteRepository(MichelinDbContext context, ILogger<ManageMainRepository> logger)
{
_context = context;
_logger = logger;
}
public IO_CONTROL_ROUTE? GetIoControlRoute(int? lineNumber)
{
try
{
var ioControlRoute = _context.IoControlRoute.Where(x => x.CONTROL_ROUTE_TYPE == lineNumber).FirstOrDefault();
return ioControlRoute;
}
catch (Exception ex)
{
_logger.LogError(ex, "Error in GetIoControlRoute");
return null;
}
}
}

89
Repositories/Implement/ProductInformationRepository.cs

@ -0,0 +1,89 @@
using System.Data.SqlTypes;
using WMS_GIRAF_Interface.Data;
using WMS_GIRAF_Interface.Entities;
using WMS_GIRAF_Interface.Repositories.Interface;
namespace WMS_GIRAF_Interface.Repositories.Implement;
public class ProductInformationRepository(MichelinDbContext context) :IProductInformationRepository
{
/// <summary>
/// Get ProductInformation by barCode
/// </summary>
/// <param name="barCode"></param>
/// <returns></returns>
public ProductInformation? GetProductInformation(string barCode)
{
var productInformation = context.ProductInformation.FirstOrDefault(x => x.BarCode == barCode);
return productInformation;
}
/// <summary>
/// Add ProductInformation
/// </summary>
/// <param name="productInformation"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public string AddProductInformation(ProductInformation productInformation)
{
if (productInformation==null)
{
throw new ArgumentNullException(nameof(productInformation));
}
//如果时间为空时间,那就置为系统最小值
if(productInformation.DryDateTimeInUtc.Year < 2000)
{
productInformation.DryDateTimeInUtc = SqlDateTime.MinValue.Value;
}
if (productInformation.HdvDateTimeInUtc.Year < 2000)
{
productInformation.HdvDateTimeInUtc = SqlDateTime.MinValue.Value;
}
if (productInformation.OldDateTimeInUtc.Year < 2000)
{
productInformation.OldDateTimeInUtc = SqlDateTime.MinValue.Value;
}
var checkAdd= context.ProductInformation.Add(productInformation);
context.SaveChanges();
return checkAdd.Entity.BarCode;
}
/// <summary>
/// 修改产品信息
/// </summary>
/// <param name="productInformation"></param>
/// <exception cref="ArgumentNullException"></exception>
public void UpdateProductInformation(ProductInformation productInformation)
{
if (productInformation == null)
{
throw new ArgumentNullException(nameof(productInformation));
}
if (productInformation.DryDateTimeInUtc.Year < 2000)
{
productInformation.DryDateTimeInUtc = SqlDateTime.MinValue.Value;
}
if (productInformation.HdvDateTimeInUtc.Year < 2000)
{
productInformation.HdvDateTimeInUtc = SqlDateTime.MinValue.Value;
}
if (productInformation.OldDateTimeInUtc.Year < 2000)
{
productInformation.OldDateTimeInUtc = SqlDateTime.MinValue.Value;
}
context.ProductInformation.Update(productInformation);
context.SaveChanges();
}
}

33
Repositories/Implement/WhCellRepository.cs

@ -0,0 +1,33 @@
using WMS_GIRAF_Interface.Data;
using WMS_GIRAF_Interface.Entities;
namespace WMS_GIRAF_Interface.Repositories.Implement;
public class WhCellRepository(MichelinDbContext context)
{
public WH_CELL? GetCell(int cellId)
{
var cell = context.Wh_Cell.First(x => x.CELL_ID == cellId);
return cell;
}
public WH_CELL? GetCell(string cellCode)
{
var cell = context.Wh_Cell.FirstOrDefault(x => x.CELL_CODE == cellCode);
return cell;
}
public bool UpdateCellStatus(WH_CELL whCell)
{
if (whCell == null)
{
throw new ArgumentNullException(nameof(whCell));
}
context.Wh_Cell.Update(whCell);
context.SaveChanges();
return true;
}
}

6
Repositories/Interface/IIoControlRouteRepository.cs

@ -0,0 +1,6 @@
namespace WMS_GIRAF_Interface.Repositories.Interface;
public interface IIoControlRouteRepository
{
}

5
Repositories/Interface/IManageMainRepository.cs

@ -5,4 +5,9 @@ namespace WMS_GIRAF_Interface.Repositories.Interface;
public interface IManageMainRepository public interface IManageMainRepository
{ {
public MANAGE_MAIN? GetManageMain(string type,string filterInfo); public MANAGE_MAIN? GetManageMain(string type,string filterInfo);
public bool AddManageMain(MANAGE_MAIN manageMain, out int manageId);
public bool UpdateManageMain(MANAGE_MAIN manageMain);
public void DeleteManageMain(MANAGE_MAIN manageMain);
} }

13
Repositories/Interface/IProductInformationRepository.cs

@ -0,0 +1,13 @@
using WMS_GIRAF_Interface.Entities;
namespace WMS_GIRAF_Interface.Repositories.Interface;
public interface IProductInformationRepository
{
public ProductInformation? GetProductInformation(string barCode);
public string AddProductInformation(ProductInformation productInformation);
public void UpdateProductInformation(ProductInformation productInformation);
}

10
Repositories/Interface/IWhCellRepository.cs

@ -0,0 +1,10 @@
using WMS_GIRAF_Interface.Entities;
namespace WMS_GIRAF_Interface.Repositories.Interface;
public interface IWhCellRepository
{
public WH_CELL? GetCell(int cellId);
public WH_CELL? GetCell(string cellCode);
public bool UpdateCellStatus(WH_CELL whCell);
}

144
TaskServices/CellLogicService.cs

@ -0,0 +1,144 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using WMS_GIRAF_Interface.Data;
using WMS_GIRAF_Interface.Entities;
using WMS_GIRAF_Interface.Repositories.Implement;
using WMS_GIRAF_Interface.Repositories.Interface;
namespace WMS_GIRAF_Interface.TaskServices;
public class CellLogicService(MichelinDbContext context,IWhCellRepository whCellRepository, ILogger<CellLogicService> logger)
{
/// <summary>
/// 自动入库 获取line way number
/// </summary>
/// <param name="startCell"></param>
/// <param name="cellModel"></param>
/// <param name="stockBarcode"></param>
/// <param name="endLineNumbers"></param>
/// <param name="lotNumber"></param>
/// <param name="sResult"></param>
/// <returns></returns>
public bool GetLaneWayFromDecisionPoint(WH_CELL startCell,
string cellModel,
string stockBarcode,
string[] endLineNumbers,
string lotNumber, out int selectedLaneWay , out string sResult)
{
selectedLaneWay = 0;
sResult = string.Empty;
string endDeviceList = "";
foreach (var endLineNumber in endLineNumbers)
{
if (endDeviceList=="")
{
endDeviceList = $"'{endLineNumber}'";
}
else
{
endDeviceList += $",'{endLineNumber}'";
}
}
string endDeviceCode = "";
var getSelectedLaneWay =
context.V_ManageInCount.FromSqlRaw($@"SELECT
t3.START_DEVICE,
t3.END_DEVICE,
t3.MANAGE_COUNT,
t3.ENABLE_CELL_COUNT
FROM
(
SELECT
top 4 t1.*,
ISNULL( t2.LOTCOUNTS, 0 ) LOTCOUNTS
FROM
(
( SELECT * FROM V_MANAGE_IN_COUNT WHERE START_DEVICE = '{startCell.DEVICE_CODE}' AND ENABLE_CELL_COUNT > 0
AND END_DEVICE in (SELECT DEVICE_CODE FROM WH_CELL WHERE CELL_TYPE = 'Cell' and LANE_WAY in ({endDeviceList}))) t1
LEFT JOIN ( SELECT ISNULL( COUNT ( DEVICE_CODE ), 0 ) LOTCOUNTS, DEVICE_CODE FROM V_STORAGE_LIST t2
WHERE LOTNUMBER = '{lotNumber}' GROUP BY DEVICE_CODE ) t2 ON t1.END_DEVICE = t2.DEVICE_CODE
)
ORDER BY
LOTCOUNTS,
ENABLE_CELL_COUNT DESC,
END_DEVICE DESC
) t3").ToList();
if (getSelectedLaneWay.Count > 0)
{
endDeviceCode = getSelectedLaneWay[0].END_DEVICE;
selectedLaneWay = whCellRepository.GetCell(endDeviceCode)!.CELL_ID;
return true;
}
else
{
sResult = "did not find the enable lane way";
return false;
}
}
/// <summary>
/// 手工入库获取终点货位信息
/// </summary>
/// <param name="startCell">起始位置</param>
/// <param name="endCellId">终点ID</param>
/// <param name="sResult">错误信息</param>
/// <returns></returns>
public bool GetCellLocationFromCheckPoint(WH_CELL startCell, out int endCellId, out string sResult)
{
bool bResult = true;
sResult = string.Empty;
endCellId = 0;
switch (startCell.CELL_MODEL)
{
case "CP":
var getPosition = context.Wh_Cell
.FromSqlRaw(
$@"SELECT TOP 1 CELL_ID,CELL_CODE FROM WH_CELL
WHERE CELL_STATUS = 'Nohave' AND RUN_STATUS = 'Enable' AND CELL_TYPE = 'Cell' AND LANE_WAY = '{startCell.LANE_WAY}'
ORDER BY CELL_X,CELL_Y")
.ToList();
if (getPosition is { Count: > 0 })
{
endCellId = getPosition[0].CELL_ID;
sResult = $"{startCell.CELL_CODE} (CP): get right end position:{getPosition[0].CELL_CODE}";
}
else
{
sResult = $"cell_model:{startCell.CELL_CODE} (CP); not find the enable position !";
bResult = false;
}
break;
case "MP":
case "EP":
var getManualPosition = context.V_WhCellEnable
.FromSqlRaw(
$@"SELECT TOP 1 CELL_ID,CELL_CODE FROM V_WH_CELL_ENABLE
WHERE LANE_WAY = '{startCell.LANE_WAY}'
ORDER BY PRIORITY,CELL_X,YPRIORITY,CELL_Y")
.ToList();
if (getManualPosition is { Count : >0})
{
endCellId = getManualPosition[0].CELL_ID;
sResult = $"{startCell.CELL_CODE} (EP): get right end position:{getManualPosition[0].CELL_CODE}";
}
else
{
sResult = $"cell_model:{startCell.CELL_CODE} (EP); not find the enable position !";
bResult = false;
}
break;
default:
goto case "EP";
break;
}
logger.LogInformation(sResult);
return bResult;
}
}

58
TaskServices/ManageTaskService.cs

@ -1,5 +1,7 @@
using WMS_GIRAF_Interface.Data; using WMS_GIRAF_Interface.Data;
using WMS_GIRAF_Interface.Entities;
using WMS_GIRAF_Interface.Models; using WMS_GIRAF_Interface.Models;
using WMS_GIRAF_Interface.Repositories.Implement;
using WMS_GIRAF_Interface.Repositories.Interface; using WMS_GIRAF_Interface.Repositories.Interface;
namespace WMS_GIRAF_Interface.TaskServices; namespace WMS_GIRAF_Interface.TaskServices;
@ -10,22 +12,70 @@ public class ManageTaskService(MichelinDbContext context,IManageMainRepository m
private readonly IManageMainRepository _mangeMainRepository = mangeMainRepository; private readonly IManageMainRepository _mangeMainRepository = mangeMainRepository;
/// <summary> /// <summary>
/// 生成入库到line任务逻辑
/// 生成入库到line任务逻辑/一楼手工入库的任务逻辑
/// </summary> /// </summary>
/// <param name="inputRequest"></param>
public bool CreateInputTaskFromGiraf( InputRequest.Product inputRequest,bool trans,bool IssendControl ,out string sResult)
/// <param name="inputRequest">产品信息</param>
/// <param name="startPostNumber">起始post number</param>
/// <param name="supportType">类型信息</param>
/// <param name="isBlocked">block属性</param>
/// <param name="trans">事务属性</param>
/// <param name="IssendControl">是否生成控制任务</param>
/// <param name="sResult">返回信息</param>
public bool CreateInputTaskFromGiraf( InputRequest.Product inputRequest,string startPostNumber,int endLaneWay,string sku,string supportType,string requestNumber,bool isBlocked,bool trans,bool IssendControl ,out string sResult)
{ {
bool bResult = true; bool bResult = true;
sResult = string.Empty; sResult = string.Empty;
//判断当前胎号是否有任务 //判断当前胎号是否有任务
var cellInfoStart = _context.Wh_Cell.FirstOrDefault(x => x.CELL_CODE == startPostNumber);
//获取起点信息
if (cellInfoStart != null)
{
var manageMain = _mangeMainRepository.GetManageMain("barcode", inputRequest.identifier); var manageMain = _mangeMainRepository.GetManageMain("barcode", inputRequest.identifier);
if (manageMain!=null)
if (manageMain != null)
{ {
//更新当前任务信息
manageMain.END_CELL_ID = endLaneWay;
manageMain.requestNumber = requestNumber;
manageMain.CELL_MODEL = supportType;
manageMain.START_CELL_ID = cellInfoStart.CELL_ID;
manageMain.LOTNUMBER = sku;
manageMain.POPULATIONNUMBER = inputRequest.productClass;
manageMain.keepRequestInMemoryEventIfLackOfProductIssue = true;
manageMain.keepRequestInMemoryEventIfMechanicalIssue = true;
bResult = _mangeMainRepository.UpdateManageMain(manageMain);
} }
else else
{ {
//创建任务
var newManageMain = new MANAGE_MAIN
{
STOCK_BARCODE = inputRequest.identifier,
requestNumber = requestNumber,
MANAGE_TYPE_CODE = cellInfoStart.CELL_MODEL == "DP" ? "ManageLineMove" : "ManageInlocal",
MANAGE_STATUS = "WaitingSend",
MANAGE_OPERATOR = "AUTO",
MANAGE_BEGIN_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
CELL_MODEL = supportType,
START_CELL_ID = cellInfoStart.CELL_ID,
END_CELL_ID = endLaneWay,
LOTNUMBER = sku,
POPULATIONNUMBER = inputRequest.productClass,
keepRequestInMemoryEventIfLackOfProductIssue = true,
keepRequestInMemoryEventIfMechanicalIssue = true,
};
}
}
else
{
//起点信息出问题
} }
return bResult; return bResult;

Loading…
Cancel
Save