原材料仓叠盘机
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
|
||||
{
|
||||
public class CommonCreatePretaskInput
|
||||
{
|
||||
public string startlocation_id { get; set; }
|
||||
|
||||
public string endlocation_id { get; set; }
|
||||
|
||||
public string carry_id { get; set; }
|
||||
|
||||
public string carry_code { get; set; }
|
||||
|
||||
public string biz_type { get; set; }
|
||||
|
||||
public string task_type { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Net;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells;
|
||||
@@ -35,6 +37,7 @@ using Tnb.Common.Extension;
|
||||
using Tnb.Common.Redis;
|
||||
using Tnb.Common.Utils;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.QcMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Configs;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
@@ -2249,6 +2252,11 @@ namespace Tnb.WarehouseMgr
|
||||
if (endLocations?.Count > 0)
|
||||
{
|
||||
WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == wmsCarryD.membercarry_code);
|
||||
await _db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
|
||||
{
|
||||
location_id = startLocation.id,
|
||||
location_code = startLocation.location_code,
|
||||
}).Where(r => r.id == carry.id).ExecuteCommandAsync();
|
||||
//if (carry.carry_status == "1")
|
||||
//{
|
||||
// throw new AppFriendlyException("载具已占用!", 500);
|
||||
@@ -2349,5 +2357,145 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 通用接口
|
||||
|
||||
/// <summary>
|
||||
/// 生成预任务接口 CTU需要传task_type
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> CommonCreatePretask(CommonCreatePretaskInput input)
|
||||
{
|
||||
Logger.LogInformation($"【createPretask】 接收到请求 参数:{JsonConvert.SerializeObject(input)}");
|
||||
try
|
||||
{
|
||||
WmsPointH? sPoint = null;
|
||||
WmsPointH? ePoint = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(input.startlocation_id))
|
||||
{
|
||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.startlocation_id);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(input.endlocation_id))
|
||||
{
|
||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.endlocation_id);
|
||||
}
|
||||
|
||||
List<WmsPointH> points = new List<WmsPointH>();
|
||||
if (sPoint.area_code != ePoint.area_code)
|
||||
{
|
||||
points = await PathAlgorithms(sPoint.id, ePoint.id);
|
||||
if (points.Count <= 2)
|
||||
{
|
||||
throw new AppFriendlyException("该路径不存在", 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points.Add(sPoint);
|
||||
points.Add(ePoint);
|
||||
}
|
||||
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
WmsPretaskH preTask = null;
|
||||
string bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
{
|
||||
WmsPointH? sPoint = it.FirstOrDefault();
|
||||
WmsPointH? ePoint = it.LastOrDefault();
|
||||
|
||||
string carry_id = "";
|
||||
string carry_code = "";
|
||||
WmsCarryH wmsCarryH = null;
|
||||
if (!string.IsNullOrEmpty(input.carry_id) && !string.IsNullOrEmpty(input.carry_code))
|
||||
{
|
||||
carry_id = input.carry_id;
|
||||
carry_code = input.carry_code;
|
||||
}
|
||||
// 如果指定了carry_id
|
||||
else if (!string.IsNullOrEmpty(input.carry_id))
|
||||
{
|
||||
wmsCarryH = _db.Queryable<WmsCarryH>().Where(r => r.id == input.carry_id).First();
|
||||
}
|
||||
// carry_code
|
||||
else if (!string.IsNullOrEmpty(input.carry_code))
|
||||
{
|
||||
wmsCarryH = _db.Queryable<WmsCarryH>().Where(r => r.carry_code == input.carry_code).First();
|
||||
}
|
||||
// 如果carry_id和carry_code都没有指定,随机取库位上载具记录的一条
|
||||
else
|
||||
{
|
||||
wmsCarryH = _db.Queryable<BasLocation>().InnerJoin<WmsCarryH>((a, b) => a.id == b.location_id)
|
||||
.Where((a, b) => a.id == sPoint.location_id).Select((a, b) => b).First();
|
||||
}
|
||||
|
||||
if (wmsCarryH != null)
|
||||
{
|
||||
carry_id = wmsCarryH.id;
|
||||
carry_code = wmsCarryH.carry_code;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(carry_id))
|
||||
{
|
||||
throw new AppFriendlyException("起点库位上没有载具", 500);
|
||||
}
|
||||
|
||||
preTask = new()
|
||||
{
|
||||
org_id = _userManager.User.OrganizeId,
|
||||
startlocation_id = sPoint?.location_id!,
|
||||
startlocation_code = sPoint?.location_code!,
|
||||
endlocation_id = ePoint?.location_id!,
|
||||
endlocation_code = ePoint?.location_code!,
|
||||
start_floor = sPoint?.floor.ToString(),
|
||||
end_floor = ePoint?.floor.ToString(),
|
||||
startpoint_id = sPoint?.id!,
|
||||
startpoint_code = sPoint?.point_code!,
|
||||
endpoint_id = ePoint?.id!,
|
||||
endpoint_code = ePoint?.point_code!,
|
||||
bill_code = bill_code,
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||
biz_type = !string.IsNullOrEmpty(input.biz_type) ? input.biz_type : "",
|
||||
task_type = !string.IsNullOrEmpty(input.task_type) ? input.task_type : "",
|
||||
carry_id = carry_id,
|
||||
carry_code = carry_code,
|
||||
area_id = sPoint?.area_id!,
|
||||
area_code = it.Key,
|
||||
require_id = "",
|
||||
require_code = "",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
|
||||
return preTask;
|
||||
}).ToList();
|
||||
//更新页面
|
||||
//赋值签收状态
|
||||
|
||||
Logger.LogInformation($"【createPretask】 开始执行 GenPreTask {JsonConvert.SerializeObject(preTasks)}");
|
||||
bool result = await GenPreTask(preTasks, null!);
|
||||
Logger.LogInformation($"【createPretask】 GenPreTask 结果 {result}");
|
||||
if (result)
|
||||
{
|
||||
Logger.LogInformation($"【createPretask】 成功生成预任务:{preTasks.First().bill_code}");
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, "成功");
|
||||
}
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, "生成预任务失败");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
await GenTaskExecute();
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,10 @@ using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
@@ -20,6 +23,7 @@ using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
@@ -225,5 +229,9 @@ namespace Tnb.WarehouseMgr
|
||||
throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user