Browse Source
1.添加新entity:manage main,productInformation,V_MANAGE_IN_COUNT,V_WH_CELL_ENABLE 2.添加数据持久层; 3.添加货位服务和任务服务类master
16 changed files with 823 additions and 13 deletions
@ -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; } |
|||
} |
@ -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; } |
|||
} |
@ -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; } |
|||
} |
@ -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; |
|||
} |
|||
} |
|||
|
|||
} |
@ -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(); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
} |
@ -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; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,6 @@ |
|||
namespace WMS_GIRAF_Interface.Repositories.Interface; |
|||
|
|||
public interface IIoControlRouteRepository |
|||
{ |
|||
|
|||
} |
@ -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); |
|||
} |
@ -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); |
|||
} |
@ -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; |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue