Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -129,7 +129,7 @@ namespace Tnb.EquipMgr
|
||||
foreach (var item in input.details)
|
||||
{
|
||||
await db.Updateable<EqpMaintainRecordD>()
|
||||
.SetColumns(x => x.repeat_descrip == item["repeat_descrip"])
|
||||
.SetColumnsIF(item.ContainsKey("repeat_descrip"),x => x.repeat_descrip == item["repeat_descrip"])
|
||||
.SetColumns(x => x.repeat_result == item["repeat_result"])
|
||||
.Where(x => x.id == item["id"]).ExecuteCommandAsync();
|
||||
}
|
||||
@@ -187,5 +187,32 @@ namespace Tnb.EquipMgr
|
||||
|
||||
return PageResult<EquipMaintainRecordQueryOutput>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据id获取保养相关信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetEqpMaintainRecordInfoById(Dictionary<string,string> dic)
|
||||
{
|
||||
string id = dic.ContainsKey("id") ? dic["id"] : "";
|
||||
if (string.IsNullOrEmpty(id)) return null;
|
||||
var db = _repository.AsSugarClient();
|
||||
return await db.Queryable<EqpMaintainRecordH>()
|
||||
.LeftJoin<EqpEquipment>((a, b) => a.equip_id==b.id)
|
||||
.Where((a, b) => a.id == id)
|
||||
.Select((a, b) => new
|
||||
{
|
||||
id = a.id,
|
||||
equip_id = a.equip_id,
|
||||
equip_code = b.code,
|
||||
equip_name = b.name,
|
||||
create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
result_remark = a.result_remark,
|
||||
result = a.result,
|
||||
status = a.status,
|
||||
}).FirstAsync();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,5 +162,32 @@ namespace Tnb.EquipMgr
|
||||
|
||||
return PageResult<EquipSpotInsRecordQueryOutput>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据id获取点巡检相关信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetEqpSpotInsRecordInfoById(Dictionary<string,string> dic)
|
||||
{
|
||||
string id = dic.ContainsKey("id") ? dic["id"] : "";
|
||||
if (string.IsNullOrEmpty(id)) return null;
|
||||
var db = _repository.AsSugarClient();
|
||||
return await db.Queryable<EqpSpotInsRecordH>()
|
||||
.LeftJoin<EqpEquipment>((a, b) => a.equip_id==b.id)
|
||||
.Where((a, b) => a.id == id)
|
||||
.Select((a, b) => new
|
||||
{
|
||||
id = a.id,
|
||||
equip_id = a.equip_id,
|
||||
equip_code = b.code,
|
||||
equip_name = b.name,
|
||||
create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
result_remark = a.result_remark,
|
||||
result = a.result,
|
||||
status = a.status,
|
||||
}).FirstAsync();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Extension;
|
||||
using Spire.Pdf.Widget;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Consts
|
||||
{
|
||||
|
||||
public class GenericEnumDicionary<T> where T : Enum
|
||||
{
|
||||
private static string tn = typeof(T).Name;
|
||||
private static ConcurrentDictionary<string, Dictionary<int, string>> enumDescMap = new();
|
||||
private static ConcurrentDictionary<string, FieldInfo[]?> enumMemberMap = new();
|
||||
|
||||
static GenericEnumDicionary()
|
||||
{
|
||||
enumMemberMap.GetOrAdd(tn, f => typeof(T).GetFields(BindingFlags.Public | BindingFlags.Static));
|
||||
if (enumMemberMap[tn]?.All(f => f.GetCustomAttribute<DescriptionAttribute>() != null) ?? false)
|
||||
{
|
||||
enumDescMap.GetOrAdd(tn, dic => typeof(T).GetEnumDescDictionary());
|
||||
}
|
||||
}
|
||||
public static string GetEnumDesc(int enumVal)
|
||||
{
|
||||
return enumDescMap.ContainsKey(tn) ? enumDescMap[tn]?[enumVal] ?? string.Empty : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,4 +181,9 @@ public class ModuleConsts
|
||||
/// </summary>
|
||||
public const string MODULE_WMSPOINT_ID = "26099196480805";
|
||||
|
||||
/// <summary>
|
||||
/// 模块标识-PDA寄存出库
|
||||
/// </summary>
|
||||
public const string MODULE_WMSSCANCODEINSTOCKPDA_ID = "28576495374869";
|
||||
|
||||
}
|
||||
@@ -10,6 +10,13 @@ namespace Tnb.WarehouseMgr.Entities.Consts
|
||||
{
|
||||
public class WmsWareHouseConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 原材料仓ID
|
||||
/// </summary>
|
||||
public const string WAREHOUSE_YCL_ID = "1";
|
||||
/// <summary>
|
||||
/// 中储仓ID
|
||||
/// </summary>
|
||||
public const string WAREHOUSE_ZC_ID = "2";
|
||||
|
||||
/// <summary>
|
||||
@@ -250,7 +257,10 @@ namespace Tnb.WarehouseMgr.Entities.Consts
|
||||
/// </summary>
|
||||
public const string SYNC_STATUS__SYNCFAILED = "26191354152229";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单据类型-来料入库单
|
||||
/// </summary>
|
||||
public const string BILLTYPE_MATERIALINSTOCK_ID = "25103338755861";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto
|
||||
/// <summary>
|
||||
/// 扫描数量
|
||||
/// </summary>
|
||||
public int scan_qty { get; set; }
|
||||
public decimal scan_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto
|
||||
/// <summary>
|
||||
/// 扫描数量
|
||||
/// </summary>
|
||||
public int scan_qty { get; set; }
|
||||
public decimal scan_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 物品代码
|
||||
/// </summary>
|
||||
|
||||
@@ -70,7 +70,7 @@ public partial class WmsInstockCode : BaseEntity<string>, IInOutStockCode
|
||||
/// <summary>
|
||||
/// 条码数量
|
||||
/// </summary>
|
||||
public int codeqty { get; set; }
|
||||
public decimal codeqty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否锁定
|
||||
|
||||
@@ -137,7 +137,7 @@ public partial class WmsInstockD : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 扫描数量
|
||||
/// </summary>
|
||||
public int scan_qty { get; set; }
|
||||
public decimal scan_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
|
||||
@@ -47,7 +47,7 @@ public partial class WmsPretaskCode : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 条码数量
|
||||
/// </summary>
|
||||
public int codeqty { get; set; }
|
||||
public decimal codeqty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位ID
|
||||
|
||||
@@ -6,6 +6,7 @@ using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
||||
using Tnb.Common;
|
||||
using JNPF.Common.Extension;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Mapper
|
||||
{
|
||||
@@ -23,7 +24,7 @@ namespace Tnb.WarehouseMgr.Entities.Mapper
|
||||
config.ForType<WmsCarryH, CarryQueryOutput>()
|
||||
.Map(dest => dest.qc_status, src => src.is_check == 0 ? "不合格" : "合格");
|
||||
config.ForType<WmsCarryCode, CarryCodeQueryOutput>()
|
||||
.Map(dest => dest.check_conclusion, src => src.check_conclusion.ToEnum<EnumCheckConclusion>().GetDescription());
|
||||
.Map(dest => dest.check_conclusion, src => GenericEnumDicionary<EnumCheckConclusion>.GetEnumDesc(src.check_conclusion));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,18 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Manager;
|
||||
using JNPF.Common.Net;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.EventBus;
|
||||
using JNPF.EventHandler;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -33,12 +40,22 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IWareHouseService _wareHouseService;
|
||||
|
||||
private readonly ICacheManager _cacheManager;
|
||||
private readonly IEventPublisher _eventPublisher;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public DeviceProviderService(ISqlSugarRepository<WmsInstockH> repository, IWareHouseService wareHouseService)
|
||||
|
||||
public DeviceProviderService(ISqlSugarRepository<WmsInstockH> repository, IWareHouseService wareHouseService,
|
||||
ICacheManager cacheManager,
|
||||
IEventPublisher eventPublisher,
|
||||
IUserManager userManger
|
||||
)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_wareHouseService = wareHouseService;
|
||||
_cacheManager = cacheManager;
|
||||
_eventPublisher = eventPublisher;
|
||||
_userManager = userManger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -101,7 +118,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// 任务链状态上报
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost, NonUnify,AllowAnonymous]
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Result> TaskChainCallBack(TaskChainCallBackInput input)
|
||||
{
|
||||
try
|
||||
@@ -110,8 +127,9 @@ namespace Tnb.WarehouseMgr
|
||||
switch (input.status)
|
||||
{
|
||||
case "CREATED": break;
|
||||
case "ALLOCATED":break;
|
||||
case "ALLOCATED": break;
|
||||
case "PROCESSING":
|
||||
//if (await _cacheManager.GetAsync($"{input.taskChainCode}") == "任务链状态上报,上报状态PROCESSING") break;
|
||||
if (input.taskChainCode.Trim().IsNullOrEmpty()) break;
|
||||
var disTasks = await _db.Queryable<WmsDistaskH>().Where(it => it.bill_code.Contains(input.taskChainCode)).ToListAsync();
|
||||
var eps = await _db.Queryable<EqpEquipment>().Where(it => it.code.Contains(input.deviceID)).ToListAsync();
|
||||
@@ -127,6 +145,24 @@ namespace Tnb.WarehouseMgr
|
||||
case "FINISHED": break;
|
||||
default: break;
|
||||
}
|
||||
//写入redis
|
||||
//await _cacheManager.SetAsync($"{input.taskChainCode}", $"任务链状态上报,上报状态{input.status}");
|
||||
var opts = App.GetOptions<ConnectionConfigOptions>();
|
||||
UserAgent userAgent = new(App.HttpContext);
|
||||
//写系统日志
|
||||
await _eventPublisher.PublishAsync(new LogEventSource("Log:CreateOpLog", opts, new SysLogEntity
|
||||
{
|
||||
Id = SnowflakeIdHelper.NextId(),
|
||||
Category = 4,
|
||||
UserId = _userManager.UserId,
|
||||
UserName = _userManager.User.RealName,
|
||||
IPAddress = NetHelper.Ip,
|
||||
RequestURL = App.HttpContext.Request.Path,
|
||||
RequestMethod = App.HttpContext.Request.Method,
|
||||
Json = $"任务链状态上报,任务链编号:{input.taskChainCode},上报状态:{input.status},设备编号:{input.deviceID}",
|
||||
PlatForm = string.Format("{0}-{1}", userAgent.OS.ToString(), userAgent.RawValue),
|
||||
CreatorTime = DateTime.Now
|
||||
}));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@@ -360,7 +360,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
dynamic reqBody = new ExpandoObject();
|
||||
reqBody.taskChainCode = k;
|
||||
reqBody.type = (int)EnumTaskChainType.KIVA;
|
||||
reqBody.type = (int)EnumTaskChainType.AGV;
|
||||
reqBody.sequential = false;
|
||||
reqBody.taskChainPriority = 0;
|
||||
reqBody.taskList = v;
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Tnb.WarehouseMgr
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSCARRYBIND_ID)]
|
||||
public class WmsCarryBindService : BaseWareHouseService, IWmsCarryBindService
|
||||
{
|
||||
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
|
||||
@@ -34,7 +34,7 @@ using Tnb.WarehouseMgr.Interfaces;
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// PDA载具移入
|
||||
/// PDA一般入库
|
||||
/// </summary>
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSINSTOCKPDA_ID)]
|
||||
[ServiceModule(BizTypeId)]
|
||||
|
||||
290
WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs
Normal file
290
WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs
Normal file
@@ -0,0 +1,290 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using Mapster;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// PDA扫码入库模块
|
||||
/// </summary>
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSSCANCODEINSTOCKPDA_ID)]
|
||||
[ServiceModule(BizTypeId)]
|
||||
public class WmsPDAScanInStockService : BaseWareHouseService, IPdaStroage
|
||||
{
|
||||
private const string BizTypeId = "26191496816421";
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IWareHouseService _wareHouseService;
|
||||
private readonly IBillRullService _billRullService;
|
||||
private readonly IPrdInstockService _prdInstockService;
|
||||
public WmsPDAScanInStockService(
|
||||
ISqlSugarRepository<WmsInstockH> repository,
|
||||
IDictionaryDataService dictionaryDataService,
|
||||
IUserManager userManager,
|
||||
IBillRullService billRullService,
|
||||
IWareHouseService wareHouseService,
|
||||
IPrdInstockService prdInstockService,
|
||||
ITaskMessageNotify taskMessageNotify
|
||||
) : base(taskMessageNotify.Writer)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
_userManager = userManager;
|
||||
_billRullService = billRullService;
|
||||
_wareHouseService = wareHouseService;
|
||||
_prdInstockService = prdInstockService;
|
||||
OverideFuncs.CreateAsync = ScanInStock;
|
||||
}
|
||||
|
||||
private async Task<dynamic> ScanInStock(VisualDevModelDataCrInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
var item = input.data.Adapt<WmsInstockCode>();
|
||||
if (item.codeqty == 0) throw new AppFriendlyException("请输入入库数量", 500);
|
||||
var carryCode = item.barcode;
|
||||
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.carry_code == carryCode);
|
||||
if (carry == null) throw new AppFriendlyException("载具有误", 500);
|
||||
var mat = await _db.Queryable<BasMaterial>().FirstAsync(it => it.code == item.material_code);
|
||||
if (mat == null) throw new AppFriendlyException("物料有误", 500);
|
||||
var loc = await _db.Queryable<BasLocation>().FirstAsync(it => it.location_code == item.extras);
|
||||
if (loc == null) throw new AppFriendlyException("库位有误", 500);
|
||||
|
||||
WmsInstockH instock = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
org_id = _userManager.UserId,
|
||||
carry_code = carryCode,
|
||||
carry_id = carry.id,
|
||||
location_id = loc.id,
|
||||
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_INSTOCK_ENCODE).GetAwaiter().GetResult(),
|
||||
bill_type = WmsWareHouseConst.BILLTYPE_MATERIALINSTOCK_ID,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSINSTOCK_ID,
|
||||
bill_date = DateTime.Today,
|
||||
warehouse_id = "26103372441637",
|
||||
status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
generate_type = "1",
|
||||
sync_status = "0",
|
||||
print_status = "0",
|
||||
is_check = 1,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
WmsInstockD instockD = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = instock.id,
|
||||
line_status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
material_id = mat.id,
|
||||
material_code = mat.code,
|
||||
unit_id = mat.unit_id,
|
||||
pr_qty = item.codeqty,
|
||||
qty = 0,
|
||||
warehouse_id = "26103372441637",
|
||||
print_qty = item.codeqty,
|
||||
scan_qty = item.codeqty,
|
||||
print_id = "",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
WmsInstockCode instockCode = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = instock.id,
|
||||
bill_d_id = instockD.id,
|
||||
line_status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
material_id = mat.id,
|
||||
material_code = mat.code,
|
||||
unit_id = mat.unit_id,
|
||||
barcode = carryCode,
|
||||
code_batch = item.code_batch,
|
||||
codeqty = item.codeqty,
|
||||
is_lock = 0,
|
||||
is_end = 0,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
|
||||
await _db.Insertable(instock).ExecuteCommandAsync();
|
||||
await _db.Insertable(instockD).ExecuteCommandAsync();
|
||||
await _db.Insertable(instockCode).ExecuteCommandAsync();
|
||||
|
||||
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = "26103372441637", Size = 1 };
|
||||
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
WmsPointH sPoint = new();
|
||||
WmsPointH ePoint = new();
|
||||
if (endLocations?.Count > 0)
|
||||
{
|
||||
var eloc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, eloc);
|
||||
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
||||
}
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
{
|
||||
var sPoint = it.FirstOrDefault();
|
||||
var ePoint = it.LastOrDefault();
|
||||
|
||||
WmsPretaskH preTask = new();
|
||||
preTask.org_id = _userManager.User.OrganizeId!;
|
||||
preTask.startlocation_id = sPoint?.location_id!;
|
||||
preTask.startlocation_code = sPoint?.location_code!;
|
||||
preTask.endlocation_id = ePoint?.location_id!;
|
||||
preTask.endlocation_code = ePoint?.location_code!;
|
||||
preTask.start_floor = sPoint?.floor.ToString();
|
||||
preTask.end_floor = ePoint?.floor.ToString();
|
||||
preTask.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
|
||||
preTask.biz_type = WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID;
|
||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
|
||||
preTask.carry_id = carry.id;
|
||||
preTask.carry_code = carry.carry_code;
|
||||
preTask.area_id = sPoint?.area_id!;
|
||||
preTask.area_code = it.Key;
|
||||
preTask.require_id = instock.id;
|
||||
preTask.require_code = instock.bill_code;
|
||||
preTask.create_id = _userManager.UserId;
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
var isOk = await _wareHouseService.GenPreTask(preTasks, null!);
|
||||
if (isOk)
|
||||
{
|
||||
var preTaskUpInput = new GenPreTaskUpInput();
|
||||
preTaskUpInput.RquireId = instock.id;
|
||||
preTaskUpInput.CarryId = carry.id;
|
||||
preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()!.location_id!;
|
||||
preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()!.location_code!;
|
||||
preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList()!;
|
||||
|
||||
WmsHandleH handleH = new();
|
||||
handleH.org_id = _userManager.User.OrganizeId;
|
||||
handleH.startlocation_id = loc.id;
|
||||
handleH.endlocation_id = endLocations![0].id;
|
||||
handleH.bill_code = instock.bill_code;
|
||||
handleH.biz_type = instock.biz_type;
|
||||
handleH.carry_id = carry.id;
|
||||
handleH.carry_code = carry.carry_code;
|
||||
handleH.require_id = instock.id;
|
||||
handleH.require_code = instock.bill_code;
|
||||
handleH.create_id = _userManager.UserId;
|
||||
handleH.create_time = DateTime.Now;
|
||||
preTaskUpInput.PreTaskRecord = handleH;
|
||||
//根据载具移入Id,回更单据状态
|
||||
await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
|
||||
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
||||
it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
|
||||
it => new BasLocation { is_lock = 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||
//更具distaskCode的barcode 更新 instockcode 的 is_end 为 1
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
if (input.distaskCodes?.Count > 0)
|
||||
{
|
||||
var barCodes = input.distaskCodes.Select(x => x.barcode);
|
||||
await _db.Updateable<WmsInstockCode>().SetColumns(it => new WmsInstockCode { is_end = 1 }).Where(it => barCodes.Contains(it.barcode)).ExecuteCommandAsync();
|
||||
var instockCodes = await _db.Queryable<WmsInstockCode>().Where(it => barCodes.Contains(it.barcode)).Select(it => new
|
||||
{
|
||||
id = it.bill_d_id,
|
||||
barcode_qty = it.codeqty,
|
||||
}).ToListAsync();
|
||||
var dic = instockCodes.GroupBy(g => g.id).ToDictionary(x => x.Key, x => x.Select(d => d.barcode_qty).ToList());
|
||||
var ids = instockCodes.Select(it => it.id).ToList();
|
||||
var instockDetails = await _db.Queryable<WmsInstockD>().Where(it => ids.Contains(it.id)).ToListAsync();
|
||||
|
||||
foreach (var item in instockDetails)
|
||||
{
|
||||
if (dic.ContainsKey(item.id))
|
||||
{
|
||||
item.qty += dic[item.id].Sum(x => x);
|
||||
if (item.qty >= item.pr_qty)
|
||||
{
|
||||
item.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
await _db.Updateable(instockDetails).ExecuteCommandAsync();
|
||||
var instock = await _db.Queryable<WmsInstockH>().SingleAsync(it => it.id == input.requireId);
|
||||
if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock));
|
||||
if (instock.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
|
||||
{
|
||||
//如果是自动单据,需要回更上层系统
|
||||
Dictionary<string, string> pars = new() { { nameof(WmsInstockH.source_id), instock?.source_id ?? string.Empty } };
|
||||
var callBackRes = await _prdInstockService.SyncInstock(pars);
|
||||
instock!.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED;
|
||||
await _db.Updateable(instock).UpdateColumns(it => it.sync_status).ExecuteCommandAsync();
|
||||
}
|
||||
var allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||
if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
|
||||
{
|
||||
instock.status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
//任务没有结束,更新状态为工作中
|
||||
instock.status = WmsWareHouseConst.BILLSTATUS_ON_ID;
|
||||
}
|
||||
await _db.Updateable(instock).UpdateColumns(it => it.status).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user