From dd3ca9abd220492188771fc3f5d3e2f0eb0e45dc Mon Sep 17 00:00:00 2001 From: FanLian Date: Fri, 16 Jun 2023 13:48:54 +0800 Subject: [PATCH 01/10] 1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs index 17b746c5..947b0646 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -71,7 +71,6 @@ namespace Tnb.WarehouseMgr var deleteQty = await _db.Deleteable().Where(it => it.carry_id == carry.id ).ExecuteCommandAsync(); - if (deleteQty <= 0) throw Oops.Oh(ErrorCode.COM1002); await _db.Ado.CommitTranAsync(); From 62e7eec79377bc72f0962f1dd862be785c1787b8 Mon Sep 17 00:00:00 2001 From: hlb <894797954@qq.com> Date: Fri, 16 Jun 2023 15:07:57 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=EF=BC=8C=E5=8F=96=E6=B6=88=20=E9=87=8D=E6=96=B0=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=EF=BC=8C=20=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IWareHouseService.cs | 8 +- .../WmsPDAExceptionCompleteService.cs | 85 +++++++++++++++++++ .../WmsPDAExceptionReexcuteService.cs | 78 +++++++++++++++++ 3 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionCompleteService.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionReexcuteService.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs index 72e6fadf..35f0acb4 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs @@ -1,2 +1,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions; -using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Dto;

namespace Tnb.WarehouseMgr.Interfaces
{
 /// 
 /// 库房业务(出入库)接口
 /// 
 public interface IWareHouseService
 {
 /// 
 /// 入库策略
 /// 
 /// 
 /// 
 Task> InStockStrategy([FromQuery] InStockStrategyQuery input);
 /// 
 /// 出库策略
 /// 
 /// 
 /// 
 //Task> OutStockStrategy([FromQuery] OutStockStrategyQuery input);
 /// 
 /// 路径算法
 /// 
 /// 
 /// 
 /// 
 Task> PathAlgorithms(string pStartId, string pEndId);
 /// 
 /// 生成预任务
 /// 
 /// 
 /// 
 Task GenPreTask(List preTasks,List preTaskCodes);
 /// 
 /// 生成预任务成功后操作
 /// 
 /// 
 /// 
 Task GenInStockTaskHandleAfter(GenPreTaskUpInput input,Expression> setCarryColumnsExp,Expression> setLocaionColumbExp);
 }
}
 \ No newline at end of file +using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Dto.Inputs; + +namespace Tnb.WarehouseMgr.Interfaces
{ + /// 
 /// 库房业务(出入库)接口
 /// 
 public interface IWareHouseService
 {
 /// 
 /// 入库策略
 /// 
 /// 
 /// 
 Task> InStockStrategy([FromQuery] InStockStrategyQuery input);
 /// 
 /// 出库策略
 /// 
 /// 
 /// 
 //Task> OutStockStrategy([FromQuery] OutStockStrategyQuery input);
 /// 
 /// 路径算法
 /// 
 /// 
 /// 
 /// 
 Task> PathAlgorithms(string pStartId, string pEndId);
 /// 
 /// 生成预任务
 /// 
 /// 
 /// 
 Task GenPreTask(List preTasks,List preTaskCodes);
 /// 
 /// 生成预任务成功后操作
 /// 
 /// 
 /// 
 Task GenInStockTaskHandleAfter(GenPreTaskUpInput input,Expression> setCarryColumnsExp,Expression> setLocaionColumbExp);
 /// 
 /// 任务完成
 /// 
 /// 
 /// + Task TaskComplate(TaskCompleUpInput input); + }
}
 \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionCompleteService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionCompleteService.cs new file mode 100644 index 00000000..550289fb --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionCompleteService.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Enums; +using JNPF.Common.Extension; +using JNPF.Common.Security; +using JNPF.FriendlyException; +using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using Microsoft.CodeAnalysis; +using SqlSugar; +using Tnb.BasicData.Entities; +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.Interfaces; +namespace Tnb.WarehouseMgr +{ + + /// + /// 异常取消 + /// + [OverideVisualDev(ModuleConsts.MODULE_WMSEXCPTIONCOMPLETEPDA_ID)] + public class WmsPDAExceptionCompleteService : BaseWareHouseService + { + private readonly ISqlSugarClient _db; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + private readonly IWareHouseService _wareHouseService; + private readonly IBillRullService _billRullService; + private readonly IUserManager _userManager; + public WmsPDAExceptionCompleteService( + ISqlSugarRepository repository, + IRunService runService, + IVisualDevService visualDevService, + IWareHouseService wareHouseService, + IUserManager userManager, + IBillRullService billRullService) + { + _db = repository.AsSugarClient(); + _runService = runService; + _visualDevService = visualDevService; + _wareHouseService = wareHouseService; + _userManager = userManager; + _billRullService = billRullService; + OverideFuncs.CreateAsync = ExceptionCancel; + } + + private async Task ExceptionCancel(VisualDevModelDataCrInput input) + { + + try + { + await _db.Ado.BeginTranAsync(); + var taskCompleUpInput = new TaskCompleUpInput(); + List list = new(); + if (input.data.ContainsKey(nameof(WmsDistaskH.id))) + { + list.Add(input.data[nameof(WmsDistaskH.id)].ToString()); + taskCompleUpInput.disTaskIds = list; + await _wareHouseService.TaskComplate(taskCompleUpInput); + } + + await _db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + await _db.Ado.RollbackTranAsync(); + throw; + } + return Task.FromResult(true); + } + } + +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionReexcuteService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionReexcuteService.cs new file mode 100644 index 00000000..10551597 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionReexcuteService.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Enums; +using JNPF.Common.Extension; +using JNPF.Common.Security; +using JNPF.FriendlyException; +using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using Microsoft.CodeAnalysis; +using SqlSugar; +using Tnb.BasicData.Entities; +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 +{ + + /// + /// 异常取消 + /// + [OverideVisualDev(ModuleConsts.MODULE_WMSEXCPTIONREEXCUTEPDA_ID)] + public class WmsPDAExceptionReexcuteService : BaseWareHouseService + { + private readonly ISqlSugarClient _db; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + private readonly IWareHouseService _wareHouseService; + private readonly IBillRullService _billRullService; + private readonly IUserManager _userManager; + public WmsPDAExceptionReexcuteService( + ISqlSugarRepository repository, + IRunService runService, + IVisualDevService visualDevService, + IWareHouseService wareHouseService, + IUserManager userManager, + IBillRullService billRullService) + { + _db = repository.AsSugarClient(); + _runService = runService; + _visualDevService = visualDevService; + _wareHouseService = wareHouseService; + _userManager = userManager; + _billRullService = billRullService; + OverideFuncs.CreateAsync = ExceptionCancel; + } + + private async Task ExceptionCancel(VisualDevModelDataCrInput input) + { + + try + { + await _db.Ado.BeginTranAsync(); + var items = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsDistaskH.id)].ToString()); + //items.agreement + //获取任务的协议,进行重新下发 + await _db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + await _db.Ado.RollbackTranAsync(); + throw; + } + return Task.FromResult(true); + } + } + +} From 9129277f96de50462e0ffeca6bdec1a0383436b6 Mon Sep 17 00:00:00 2001 From: FanLian Date: Fri, 16 Jun 2023 15:08:11 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BD=BD=E5=85=B7?= =?UTF-8?q?=E8=A7=A3=E7=BB=91,=E8=BD=BD=E5=85=B7=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsCarryBindService.cs | 44 ++- .../WmsCarryReplaceService.cs | 250 +++++++++--------- .../Tnb.WarehouseMgr/WmsCarryUnbindService.cs | 30 ++- .../WmsPDACarryReplaceService.cs | 176 ++++++++++++ 4 files changed, 363 insertions(+), 137 deletions(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryReplaceService.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index 647e5794..7d486bf9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -57,7 +57,7 @@ namespace Tnb.WarehouseMgr private async Task CarryBind(VisualDevModelDataCrInput input) { - + var isOk = false; try { await _db.Ado.BeginTranAsync(); @@ -66,19 +66,45 @@ namespace Tnb.WarehouseMgr await _runService.Create(templateEntity, input); if (input == null) throw new ArgumentNullException(nameof(input)); - var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsCarrybindH.carry_id)].ToString()); - var subCarry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsCarrybindH.membercarry_id)].ToString()); - //更新主载具明细表,增加新的数据 - var insert_id = await _db.Insertable(new WmsCarryD { + var carryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : ""; + var subCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : ""; + var carry = await _db.Queryable().FirstAsync(it => it.id == carryId); + var subCarry = await _db.Queryable().FirstAsync(it => it.id == subCarryId); + WmsCarrybindH wmsCarrybindH = carry.Adapt(); + if (carryId != null && subCarryId != null) + { + wmsCarrybindH.id = SnowflakeIdHelper.NextId(); + wmsCarrybindH.org_id = carry.org_id; + wmsCarrybindH.carry_id = carry.id; + wmsCarrybindH.membercarry_id = subCarry.id; + wmsCarrybindH.membercarry_code = subCarry.carry_code; + wmsCarrybindH.loc = input.data[nameof(WmsCarrybindH.loc)].ParseToInt(1); + wmsCarrybindH.create_id = _userManager.UserId; + wmsCarrybindH.create_time = DateTime.Now; + var row = await _db.Insertable(wmsCarrybindH).ExecuteCommandAsync(); + carry.carry_status = "1"; + row = await _db.Updateable(carry).ExecuteCommandAsync(); + subCarry.carry_status = "1"; + row = await _db.Updateable(subCarry).ExecuteCommandAsync(); + isOk = (row > 0); + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + + } + /* //更新主载具明细表,增加新的数据 + var row = await _db.Insertable(new WmsCarryD { + id = SnowflakeIdHelper.NextId(), + org_id = carry.org_id, carry_id = carry.id, membercarry_id = subCarry.id, membercarry_code = subCarry.carry_code, - loc = input.data[nameof(WmsCarrybindH.loc)].ToString() + loc = input.data[nameof(WmsCarrybindH.loc)].ToString(), + create_id = _userManager.UserId, + create_time = DateTime.Now }) .ExecuteCommandAsync(); - if (insert_id<=0) throw Oops.Oh(ErrorCode.COM1000); - - await _db.Ado.CommitTranAsync(); + if (row <= 0) throw Oops.Oh(ErrorCode.COM1000); + _db.Updateable().SetColumns(it=>it.carry_status == "1").Where(it=>it.id == input.data[nameof(WmsCarrybindH.carry_id)].ToString());*/ + await _db.Ado.CommitTranAsync(); } catch (Exception ex) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryReplaceService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryReplaceService.cs index d11b4122..bd3368d2 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryReplaceService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryReplaceService.cs @@ -1,169 +1,175 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using JNPF.Common.Contracts; using JNPF.Common.Core.Manager; using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Enums; -using JNPF.Common.Extension; using JNPF.Common.Security; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.Logging; using JNPF.Systems.Interfaces.System; using JNPF.VisualDev; -using JNPF.VisualDev.Entitys; -using JNPF.VisualDev.Interfaces; using Mapster; using Microsoft.AspNetCore.Mvc; using SqlSugar; -using Tnb.BasicData.Entities; +using Tnb.Common.Utils; using Tnb.WarehouseMgr.Entities; -using Tnb.WarehouseMgr.Entities.Attributes; using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Enums; using Tnb.WarehouseMgr.Interfaces; namespace Tnb.WarehouseMgr { /// - /// 载具移出 + /// 载具服务 /// - [OverideVisualDev(ModuleConsts.MODULE_WMSCARRYREPLACE_ID)] - public class WmsCarryReplaceService : BaseWareHouseService + [OverideVisualDev(ModuleId)] + public class WmsCarryReplaceService : BaseWareHouseService, IWmsCarryService { + private const string ModuleId = "26188532491557"; private readonly ISqlSugarClient _db; - private readonly IRunService _runService; - private readonly IVisualDevService _visualDevService; - private readonly IWareHouseService _wareHouseService; - private readonly IBillRullService _billRullService; private readonly IUserManager _userManager; - public WmsCarryReplaceService( - ISqlSugarRepository repository, - IRunService runService, - IVisualDevService visualDevService, - IWareHouseService wareHouseService, - IUserManager userManager, - IBillRullService billRullService) + private readonly IBillRullService _billRullService; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + public WmsCarryReplaceService(ISqlSugarRepository repository, IUserManager userManager, IBillRullService billRullService) { _db = repository.AsSugarClient(); - _runService = runService; - _visualDevService = visualDevService; - _wareHouseService = wareHouseService; _userManager = userManager; _billRullService = billRullService; OverideFuncs.CreateAsync = CarryReplace; } - private async Task CarryReplace(VisualDevModelDataCrInput input) + /// + /// 更换载具 + /// + /// + /// 输入参数: + ///
{ + ///
old_carry_id:老载具id + ///
new_carry_id:新载具ID + ///
} + /// + /// + /// + [HttpPost] + public async Task CarryReplace(VisualDevModelDataCrInput input) { - + var isOk = false; try { await _db.Ado.BeginTranAsync(); + var oldCarryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : ""; + var newCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : ""; + var oldCarry = await _db.Queryable().FirstAsync(it => it.id == oldCarryId); + var newCarry = await _db.Queryable().FirstAsync(it => it.id == newCarryId); + if (oldCarry != null && newCarry != null) + { + ExChangeCarryInput carryInput = new() { old_carry_id = oldCarry.id, new_carry_id = newCarry.id }; + isOk = await _updateSubCarry(carryInput); + isOk = await _updateSubCarry(carryInput); + isOk = await _updateSubCarry(carryInput); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true); - await _runService.Create(templateEntity, input); - if (input == null) throw new ArgumentNullException(nameof(input)); - var oldCarry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsCarryReplaceH.carry_id)].ToString()); - var newCarry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsCarryReplaceH.newcarry_id)].ToString()); - if (oldCarry.carrystd_id != newCarry.carrystd_id) - { - string errorMessege = "新老载具规格应相同"; - throw Oops.Oh(errorMessege); - } - if (oldCarry.carrystd_id == newCarry.carrystd_id) - { - var isOk = await _db.Updateable().SetColumns(it => it.carry_id == newCarry.id).Where(it => it.carry_id == oldCarry.id).ExecuteCommandHasChangeAsync(); - if (!isOk) throw Oops.Oh(ErrorCode.COM1001); - isOk = await _db.Updateable().SetColumns(it => it.carry_id == newCarry.id).Where(it => it.carry_id == oldCarry.id).ExecuteCommandHasChangeAsync(); + newCarry.status = oldCarry.status; + newCarry.carry_status = oldCarry.carry_status; + newCarry.location_id = oldCarry.location_id; + newCarry.location_code = oldCarry.location_code; + newCarry.is_lock = oldCarry.is_lock; + newCarry.out_status = oldCarry.out_status; + newCarry.is_check = oldCarry.is_check; + newCarry.bale_num = oldCarry.bale_num; + newCarry.collocation_scheme_id = oldCarry.collocation_scheme_id; + newCarry.collocation_scheme_code = oldCarry.collocation_scheme_code; + newCarry.source_id = oldCarry.source_id; + newCarry.source_code = oldCarry.source_code; + newCarry.create_id = _userManager.UserId; + newCarry.create_time = DateTime.Now; + var row = await _db.Updateable(newCarry).ExecuteCommandAsync(); + WmsCarryReplaceH wmsCarryReplaceH = oldCarry.Adapt(); + wmsCarryReplaceH.id = SnowflakeIdHelper.NextId(); + wmsCarryReplaceH.org_id = oldCarry.org_id; + wmsCarryReplaceH.bill_code = await _billRullService.GetBillNumber(WmsCarryConst.WMS_CARRY_REPLACE_ENCODE); + wmsCarryReplaceH.carry_id = oldCarry.id; + wmsCarryReplaceH.carry_code = oldCarry.carry_code; + wmsCarryReplaceH.newcarry_id = newCarry.id; + wmsCarryReplaceH.newcarry_code = newCarry.carry_code; + row = await _db.Insertable(wmsCarryReplaceH).ExecuteCommandAsync(); + row = await UpdateNullCarry(oldCarry); + isOk = (row > 0); if (!isOk) throw Oops.Oh(ErrorCode.COM1001); } + else + { + if (oldCarry == null) + { + throw new AppFriendlyException("没有可用的旧载具", 500); + } + if (newCarry == null) + { + throw new AppFriendlyException("没有可用的新载具", 500); + } - /* - * db.Updateable(WmsCarryD).SetColumns(it => it.carry_id == newCarry.id).Where(it=>it.carry_id == oldCarry.id).ExecuteCommand(); - */ - - /* //入库取终点 - //var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString(), Size = 1 }; - //var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString()); - WmsPointH sPoint = null; - WmsPointH ePoint = null; - if (input.data.ContainsKey(nameof(WmsPointH.location_id))) - { - ePoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString()); - } - if (carry != null) - { - sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); - } - - if (sPoint != null && ePoint != null) - { - var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) - if (points?.Count > 0) - { - if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); - 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.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); - preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; - preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSMOOUTSTK_ID; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; - preTask.carry_id = input.data[nameof(preTask.carry_id)]?.ToString()!; - preTask.carry_code = input.data[nameof(preTask.carry_code)]?.ToString()!; - preTask.area_id = sPoint?.area_id; - preTask.area_code = it.Key; - preTask.require_id = input.data["ReturnIdentity"].ToString(); - preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!; - preTask.create_id = _userManager.UserId; - preTask.create_time = DateTime.Now; - return preTask; - }).ToList(); - var isOk = await _wareHouseService.GenPreTask(preTasks); - if (isOk) - { - var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString(); - preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!; - preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id; - preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code; - preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList(); - preTaskUpInput.PreTaskRecords = preTasks.Adapt>(); - preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, null, null); - - } - } - - }*/ - - + } await _db.Ado.CommitTranAsync(); } catch (Exception ex) { + Log.Error("载具更换失败", ex); await _db.Ado.RollbackTranAsync(); throw; } - return Task.FromResult(true); + return isOk; } - /* public override async Task ModifyAsync(WareHouseUpInput input) + + public async Task UpdateNullCarry(WmsCarryH carryObj) { - if (input == null) throw new ArgumentNullException(nameof(input)); - var isOk = await _db.Updateable().SetColumns(it => new WmsCarryReplaceH { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); - if (!isOk) throw Oops.Oh(ErrorCode.COM1001); - }*/ + var row = -1; + try + { + carryObj.status = 0; + carryObj.carry_status = "0"; + carryObj.location_id = null; + carryObj.location_code = null; + carryObj.out_status = "0"; + carryObj.is_check = 0; + carryObj.status = 1; + carryObj.bale_num = null; + carryObj.collocation_scheme_id = null; + carryObj.collocation_scheme_code = null; + carryObj.source_id = null; + carryObj.source_code = null; + row = await _db.Updateable(carryObj).ExecuteCommandAsync(); + } + catch (Exception ex) + { + + } + return row; + } + + private async Task _updateSubCarry(ExChangeCarryInput input) where T : BaseEntity, IWmsCarryEntity, new() + { + var row = -1; + var items = await _db.Queryable().Where(it => it.carry_id == input.old_carry_id).ToListAsync(); + if (items?.Count > 0) + { + List newItems = DeepCopyHelper.DeepCopyList(items); + if (newItems?.Count > 0) + { + newItems.ForEach(x => + { + x.id = SnowflakeIdHelper.NextId(); + x.carry_id = input.new_carry_id; + + }); + row = await _db.Insertable(newItems).ExecuteCommandAsync(); + } + if (row > 0) + { + row = await _db.Deleteable(items).ExecuteCommandAsync(); + } + } + return (row > 0); + } } -} +} \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs index 947b0646..6ffdd5b1 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -57,7 +57,7 @@ namespace Tnb.WarehouseMgr private async Task CarryUnbind(VisualDevModelDataCrInput input) { - + var isOk = false; try { await _db.Ado.BeginTranAsync(); @@ -66,12 +66,30 @@ namespace Tnb.WarehouseMgr await _runService.Create(templateEntity, input); if (input == null) throw new ArgumentNullException(nameof(input)); - var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsCarryunbindH.carry_id)].ToString()); - var subCarry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsCarryunbindH.membercarry_id)].ToString()); + var carryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : ""; + var subCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : ""; + var carry = await _db.Queryable().FirstAsync(it => it.id == carryId); + var subCarry = await _db.Queryable().FirstAsync(it => it.id == subCarryId); + //WmsCarryunbindH wmsCarryUnbindH = carry.Adapt(); + if (carryId != null && subCarryId != null) + { + //wmsCarryUnbindH.id = SnowflakeIdHelper.NextId(); + //wmsCarryUnbindH.org_id = carry.org_id; + //wmsCarryUnbindH.carry_id = carry.id; + //wmsCarryUnbindH.membercarry_id = subCarry.id; + //wmsCarryUnbindH.membercarry_code = subCarry.carry_code; + //wmsCarryUnbindH.loc = input.data[nameof(WmsCarryunbindH.loc)].ParseToInt(1); + //wmsCarryUnbindH.create_id = _userManager.UserId; + //wmsCarryUnbindH.create_time = DateTime.Now; + var row = await _db.Deleteable().Where(it=>it.carry_id == subCarry.id).ExecuteCommandAsync(); + carry.carry_status = "0"; + row = await _db.Updateable(carry).ExecuteCommandAsync(); + subCarry.carry_status = "0"; + row = await _db.Updateable(subCarry).ExecuteCommandAsync(); + isOk = (row > 0); + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); - - var deleteQty = await _db.Deleteable().Where(it => it.carry_id == carry.id ).ExecuteCommandAsync(); - if (deleteQty <= 0) throw Oops.Oh(ErrorCode.COM1002); + } await _db.Ado.CommitTranAsync(); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryReplaceService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryReplaceService.cs new file mode 100644 index 00000000..e8b7e20a --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryReplaceService.cs @@ -0,0 +1,176 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Enums; +using JNPF.Common.Security; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.Logging; +using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.Common.Utils; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Attributes; +using Tnb.WarehouseMgr.Entities.Consts; +using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Enums; +using Tnb.WarehouseMgr.Interfaces; + +namespace Tnb.WarehouseMgr +{ + /// + /// 载具服务 + /// + [OverideVisualDev(ModuleConsts.MODULE_WMSCARRYREPLACEPDA_ID)] + public class WmsPDACarryReplaceService : BaseWareHouseService, IWmsCarryService + { + //private const string ModuleId = "26188532491557"; + private readonly ISqlSugarClient _db; + private readonly IUserManager _userManager; + private readonly IBillRullService _billRullService; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + public WmsPDACarryReplaceService(ISqlSugarRepository repository, IUserManager userManager, IBillRullService billRullService) + { + _db = repository.AsSugarClient(); + _userManager = userManager; + _billRullService = billRullService; + OverideFuncs.CreateAsync = PDACarryReplace; + } + + /// + /// 更换载具 + /// + /// + /// 输入参数: + ///
{ + ///
old_carry_id:老载具id + ///
new_carry_id:新载具ID + ///
} + /// + /// + /// + [HttpPost] + public async Task PDACarryReplace(VisualDevModelDataCrInput input) + { + var isOk = false; + try + { + await _db.Ado.BeginTranAsync(); + var oldCarryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : ""; + var newCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : ""; + var oldCarry = await _db.Queryable().FirstAsync(it => it.id == oldCarryId); + var newCarry = await _db.Queryable().FirstAsync(it => it.id == newCarryId); + if (oldCarry != null && newCarry != null) + { + ExChangeCarryInput carryInput = new() { old_carry_id = oldCarry.id, new_carry_id = newCarry.id }; + isOk = await _updateSubCarry(carryInput); + isOk = await _updateSubCarry(carryInput); + isOk = await _updateSubCarry(carryInput); + + newCarry.status = oldCarry.status; + newCarry.carry_status = oldCarry.carry_status; + newCarry.location_id = oldCarry.location_id; + newCarry.location_code = oldCarry.location_code; + newCarry.is_lock = oldCarry.is_lock; + newCarry.out_status = oldCarry.out_status; + newCarry.is_check = oldCarry.is_check; + newCarry.bale_num = oldCarry.bale_num; + newCarry.collocation_scheme_id = oldCarry.collocation_scheme_id; + newCarry.collocation_scheme_code = oldCarry.collocation_scheme_code; + newCarry.source_id = oldCarry.source_id; + newCarry.source_code = oldCarry.source_code; + newCarry.create_id = _userManager.UserId; + newCarry.create_time = DateTime.Now; + var row = await _db.Updateable(newCarry).ExecuteCommandAsync(); + WmsCarryReplaceH wmsCarryReplaceH = oldCarry.Adapt(); + wmsCarryReplaceH.id = SnowflakeIdHelper.NextId(); + wmsCarryReplaceH.org_id = oldCarry.org_id; + wmsCarryReplaceH.bill_code = await _billRullService.GetBillNumber(WmsCarryConst.WMS_CARRY_REPLACE_ENCODE); + wmsCarryReplaceH.carry_id = oldCarry.id; + wmsCarryReplaceH.carry_code = oldCarry.carry_code; + wmsCarryReplaceH.newcarry_id = newCarry.id; + wmsCarryReplaceH.newcarry_code = newCarry.carry_code; + row = await _db.Insertable(wmsCarryReplaceH).ExecuteCommandAsync(); + row = await UpdateNullCarry(oldCarry); + isOk = (row > 0); + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + } + else + { + if (oldCarry == null) + { + throw new AppFriendlyException("没有可用的旧载具", 500); + } + if (newCarry == null) + { + throw new AppFriendlyException("没有可用的新载具", 500); + } + + } + await _db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + Log.Error("载具更换失败", ex); + await _db.Ado.RollbackTranAsync(); + throw; + } + return isOk; + } + + public async Task UpdateNullCarry(WmsCarryH carryObj) + { + var row = -1; + try + { + carryObj.status = 0; + carryObj.carry_status = "0"; + carryObj.location_id = null; + carryObj.location_code = null; + carryObj.out_status = "0"; + carryObj.is_check = 0; + carryObj.status = 1; + carryObj.bale_num = null; + carryObj.collocation_scheme_id = null; + carryObj.collocation_scheme_code = null; + carryObj.source_id = null; + carryObj.source_code = null; + row = await _db.Updateable(carryObj).ExecuteCommandAsync(); + } + catch (Exception ex) + { + + } + return row; + } + + private async Task _updateSubCarry(ExChangeCarryInput input) where T : BaseEntity, IWmsCarryEntity, new() + { + var row = -1; + var items = await _db.Queryable().Where(it => it.carry_id == input.old_carry_id).ToListAsync(); + if (items?.Count > 0) + { + List newItems = DeepCopyHelper.DeepCopyList(items); + if (newItems?.Count > 0) + { + newItems.ForEach(x => + { + x.id = SnowflakeIdHelper.NextId(); + x.carry_id = input.new_carry_id; + + }); + row = await _db.Insertable(newItems).ExecuteCommandAsync(); + } + if (row > 0) + { + row = await _db.Deleteable(items).ExecuteCommandAsync(); + } + } + return (row > 0); + } + } +} \ No newline at end of file From f967ee2a5981dfd5409ee3e04917802a0c0cdcf1 Mon Sep 17 00:00:00 2001 From: FanLian Date: Fri, 16 Jun 2023 15:08:33 +0800 Subject: [PATCH 04/10] 1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs index 6ffdd5b1..dbb7daf3 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -73,14 +73,6 @@ namespace Tnb.WarehouseMgr //WmsCarryunbindH wmsCarryUnbindH = carry.Adapt(); if (carryId != null && subCarryId != null) { - //wmsCarryUnbindH.id = SnowflakeIdHelper.NextId(); - //wmsCarryUnbindH.org_id = carry.org_id; - //wmsCarryUnbindH.carry_id = carry.id; - //wmsCarryUnbindH.membercarry_id = subCarry.id; - //wmsCarryUnbindH.membercarry_code = subCarry.carry_code; - //wmsCarryUnbindH.loc = input.data[nameof(WmsCarryunbindH.loc)].ParseToInt(1); - //wmsCarryUnbindH.create_id = _userManager.UserId; - //wmsCarryUnbindH.create_time = DateTime.Now; var row = await _db.Deleteable().Where(it=>it.carry_id == subCarry.id).ExecuteCommandAsync(); carry.carry_status = "0"; row = await _db.Updateable(carry).ExecuteCommandAsync(); From 034d5746dedc2228ced9ee35bf1053ea0f16f4bc Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 16 Jun 2023 15:10:11 +0800 Subject: [PATCH 05/10] =?UTF-8?q?wms=E6=89=AB=E7=A0=81=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/WmsInstockCode.cs | 27 ++++++-- .../Tnb.WarehouseMgr/WareHouseService.cs | 9 ++- .../WmsPDAEmptyInstockService.cs | 2 +- .../WmsPDAEmptyOutstockService .cs | 2 +- .../Tnb.WarehouseMgr/WmsPDAInStockService.cs | 65 +++++++++++++------ system/Tnb.OAuth/OAuthService.cs | 5 +- .../Entity/Permission/UserEntity.cs | 2 +- .../Entity/Permission/UserEntity.part.cs | 16 +++++ 8 files changed, 96 insertions(+), 32 deletions(-) create mode 100644 system/Tnb.Systems.Entitys/Entity/Permission/UserEntity.part.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsInstockCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsInstockCode.cs index c80e2eba..9db06d08 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsInstockCode.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsInstockCode.cs @@ -27,7 +27,7 @@ public partial class WmsInstockCode : BaseEntity /// /// 行号 /// - public int bill_line { get; set; } + public int? bill_line { get; set; } /// /// 入库单明细ID @@ -37,7 +37,7 @@ public partial class WmsInstockCode : BaseEntity /// /// 入库单明细行号 /// - public int bill_d_line { get; set; } + public int? bill_d_line { get; set; } /// /// 明细状态 @@ -72,7 +72,7 @@ public partial class WmsInstockCode : BaseEntity /// /// 是否锁定 /// - public int is_lock { get; set; } + public int? is_lock { get; set; } /// /// 是否结束 @@ -87,7 +87,7 @@ public partial class WmsInstockCode : BaseEntity /// /// 单位代码 /// - public string unit_code { get; set; } = string.Empty; + public string? unit_code { get; set; } /// /// 来源单据ID @@ -132,12 +132,12 @@ public partial class WmsInstockCode : BaseEntity /// /// 创建用户 /// - public string create_id { get; set; } = string.Empty; + public string? create_id { get; set; } /// /// 创建时间 /// - public DateTime create_time { get; set; } = DateTime.Now; + public DateTime? create_time { get; set; } /// /// 修改用户 @@ -149,4 +149,19 @@ public partial class WmsInstockCode : BaseEntity /// public DateTime? modify_time { get; set; } + /// + /// 生产工单号 + /// + public string? mo_code { get; set; } + + /// + /// 生产工单行号 + /// + public int? mo_line { get; set; } + + /// + /// 生产工单BOM明细Id + /// + public string? mo_bom_detail_id { get; set; } + } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 50d91966..bc391286 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -11,6 +11,7 @@ using Aop.Api.Domain; using Aspose.Cells.Drawing; using Dm; using JNPF.Common.Contracts; +using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Extension; using JNPF.Common.Security; @@ -49,11 +50,13 @@ namespace Tnb.WarehouseMgr private readonly ISqlSugarClient _db; private readonly IDictionaryDataService _dictionaryDataService; private readonly IBillRullService _billRullService; - public WareHouseService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService, IBillRullService billRullService) + private readonly IUserManager _userManager; + public WareHouseService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService, IBillRullService billRullService, IUserManager userManager) { _db = repository.AsSugarClient(); _dictionaryDataService = dictionaryDataService; _billRullService = billRullService; + _userManager = userManager; } /// /// 根据载具Id带出库位、仓库信息 @@ -438,9 +441,9 @@ namespace Tnb.WarehouseMgr { foreach (var dt in disTasks) { - if (!input.prefix.IsNullOrWhiteSpace()) + if (_userManager.User.LoginType == "App") { - dt.biz_type = $"{input.prefix}{dt.biz_type}"; + dt.biz_type = $"pda{dt.biz_type}"; } var upInput = new WareHouseUpInput { bizTypeId = dt.biz_type, requireId = dt.require_id }; if (dt.is_chain == 0) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs index 18b333d0..9a748c50 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs @@ -34,7 +34,7 @@ namespace Tnb.WarehouseMgr public class WmsPDAEmptyInstockService : BaseWareHouseService { - private const string BizTypeId = "26121986416677"; + private const string BizTypeId = "pda26121986416677"; private readonly ISqlSugarClient _db; private readonly IRunService _runService; private readonly IVisualDevService _visualDevService; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs index ab432e88..e8e0d87e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs @@ -34,7 +34,7 @@ namespace Tnb.WarehouseMgr public class WmsPDAEmptyOutstockService : BaseWareHouseService { - private const string BizTypeId = "26121986416677"; + private const string BizTypeId = "pda26121986416677"; private readonly ISqlSugarClient _db; private readonly IRunService _runService; private readonly IVisualDevService _visualDevService; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs index 1cbe6da2..3e6da716 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs @@ -17,6 +17,7 @@ using JNPF.VisualDev.Interfaces; using Mapster; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; +using NPOI.OpenXmlFormats.Vml; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; @@ -35,7 +36,7 @@ namespace Tnb.WarehouseMgr [ServiceModule(BizTypeId)] public class WmsPDAInStockService : BaseWareHouseService { - private const string BizTypeId = "pda26121988909861"; + private const string BizTypeId = "pda26191496816421"; private readonly ISqlSugarClient _db; private readonly IRunService _runService; private readonly IVisualDevService _visualDevService; @@ -72,7 +73,6 @@ namespace Tnb.WarehouseMgr { jArr = JArray.Parse(input.data["tablefield115"].ToString()); } - //入库取终点 //出库起点 var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString(), Size = 1 }; var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); @@ -98,7 +98,7 @@ namespace Tnb.WarehouseMgr { var sPoint = it.FirstOrDefault(); var ePoint = it.LastOrDefault(); - + WmsPretaskH preTask = new(); preTask.org_id = _userManager.User.OrganizeId; preTask.startlocation_id = sPoint?.location_id; @@ -145,17 +145,20 @@ namespace Tnb.WarehouseMgr var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes); if (isOk) { + var requireIdField = "require_id"; + var requireCodeField = "require_code"; + var preTaskUpInput = new GenPreTaskUpInput(); preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString(); preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!; preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id; preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code; preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList(); - if (input.data.ContainsKey("bill_id") && input.data["bill_id"].IsNotEmptyOrNull()) + if (input.data.ContainsKey(requireIdField) && input.data[requireIdField].IsNotEmptyOrNull()) { //创建预任务操作记录 var operBillId = string.Empty; - var instockH = await _db.Queryable().FirstAsync(it => it.id == input.data["bill_id"].ToString()); + var instockH = await _db.Queryable().FirstAsync(it => it.id == input.data[requireIdField].ToString()); if (instockH != null) { var handleH = instockH.Adapt(); @@ -166,7 +169,7 @@ namespace Tnb.WarehouseMgr preTaskUpInput.PreTaskRecord = handleH; } //创建预任务条码操作记录 - jArr = JArray.Parse(input.data["tablefield115"].ToString()); + jArr = JArray.Parse(input.data["tablefield115"].ToString()!); if (jArr?.Children().Count() > 0) { foreach (var jo in jArr.Children()) @@ -176,8 +179,8 @@ namespace Tnb.WarehouseMgr handleCode.org_id = _userManager.User.OrganizeId; handleCode.bill_id = operBillId; handleCode.material_id = materialId; - handleCode.material_code = jo.Value(nameof(WmsHandleCode.material_code)); - handleCode.barcode = jo.Value(nameof(WmsHandleCode.barcode)); + handleCode.material_code = jo.Value(nameof(WmsHandleCode.material_code))!; + handleCode.barcode = jo.Value(nameof(WmsHandleCode.barcode))!; handleCode.code_batch = jo.Value(nameof(WmsHandleCode.code_batch)); handleCode.codeqty = jo.Value(nameof(WmsHandleCode.codeqty)); handleCode.unit_id = _db.Queryable().Single(it => it.id == materialId).unit_id; @@ -194,12 +197,38 @@ namespace Tnb.WarehouseMgr x.is_out = 0; }); //生成入库申请条码 - - await _db.Insertable(preTaskUpInput.PreTaskRecord).ExecuteCommandAsync(); + var instockDetails = await _db.Queryable() + .Where(b => b.bill_id == input.data[requireIdField].ToString()) + .ToListAsync(); + var items = instockDetails.Adapt>(); + List instockCOdes = new(); + jArr = JArray.Parse(input.data["tablefield115"].ToString()!); + if (jArr?.Children().Count() > 0) + { + foreach (var jo in jArr.Children()) + { + var materialId = jo.Value(nameof(WmsInstockCode.material_id)); + var materialCode = jo.Value(nameof(WmsInstockCode.material_code)); + var codeBatch = jo.Value(nameof(WmsInstockCode.code_batch)); + var b = items.Find(x => x.material_code == materialCode && x.code_batch == codeBatch); + if (b != null) + { + b.barcode = jo.Value(nameof(WmsInstockCode.barcode)); + b.barcode_qty = jo.Value(nameof(WmsInstockCode.barcode_qty)); + instockCOdes.Add(b); + } + } + } + await _db.Insertable(carryCodes).ExecuteCommandAsync(); + await _db.Insertable(instockCOdes).ExecuteCommandAsync(); + await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, + it => new WmsCarryH { carry_code = input.data[nameof(WmsCarryH.carry_code)].ToString()!, is_lock = 1, status = (int)EnumCarryStatus.占用, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode }, + it => new BasLocation { is_lock = 1, is_use = "1" }); + if (instockCOdes?.Count > 0) + { + await _db.Updateable().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCOdes.Select(x => x.bill_d_id).Contains(it.id)).ExecuteCommandAsync(); + } } - - await _db.Updateable().SetColumns(it => new WmsCarryH { carry_code = input.data[nameof(WmsCarryH.carry_code)].ToString(), is_lock = (int)EnumCarryStatus.占用, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode }).Where(it => it.id == preTaskUpInput.CarryId).ExecuteCommandAsync(); - } } } @@ -214,11 +243,9 @@ namespace Tnb.WarehouseMgr return Task.FromResult(true); } - //public override async Task ModifyAsync(WareHouseUpInput input) - //{ - // if (input == null) throw new ArgumentNullException(nameof(input)); - // var isOk = await _db.Updateable().SetColumns(it => new WmsMoveInstock { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); - // if (!isOk) throw Oops.Oh(ErrorCode.COM1001); - //} + public override async Task ModifyAsync(WareHouseUpInput input) + { + + } } } diff --git a/system/Tnb.OAuth/OAuthService.cs b/system/Tnb.OAuth/OAuthService.cs index f494dee3..5780322a 100644 --- a/system/Tnb.OAuth/OAuthService.cs +++ b/system/Tnb.OAuth/OAuthService.cs @@ -279,6 +279,8 @@ public class OAuthService : IDynamicApiController, ITransient public async Task GetCurrentUser(string type) { if (type.IsNullOrEmpty()) type = "Web"; // 默认为Web端菜单目录 + //modify by ly on 20230616 用于区分pc与 pda + _userManager.User.LoginType = type; var userId = _userManager.UserId; @@ -669,7 +671,8 @@ public class OAuthService : IDynamicApiController, ITransient } } - return new { + return new + { theme = user.Theme == null ? "classic" : user.Theme, token = string.Format("Bearer {0}", accessToken) }; diff --git a/system/Tnb.Systems.Entitys/Entity/Permission/UserEntity.cs b/system/Tnb.Systems.Entitys/Entity/Permission/UserEntity.cs index 26b6aecc..dbae17a6 100644 --- a/system/Tnb.Systems.Entitys/Entity/Permission/UserEntity.cs +++ b/system/Tnb.Systems.Entitys/Entity/Permission/UserEntity.cs @@ -8,7 +8,7 @@ namespace JNPF.Systems.Entitys.Permission; /// 用户信息基类. /// [SugarTable("BASE_USER")] -public class UserEntity : CLDEntityBase +public partial class UserEntity : CLDEntityBase { /// /// 账户. diff --git a/system/Tnb.Systems.Entitys/Entity/Permission/UserEntity.part.cs b/system/Tnb.Systems.Entitys/Entity/Permission/UserEntity.part.cs new file mode 100644 index 00000000..e6e41ea0 --- /dev/null +++ b/system/Tnb.Systems.Entitys/Entity/Permission/UserEntity.part.cs @@ -0,0 +1,16 @@ +using JNPF.Common.Const; +using JNPF.Common.Contracts; +using SqlSugar; + +namespace JNPF.Systems.Entitys.Permission; + +/// +/// 用户信息基类. +/// +public partial class UserEntity +{ + /// + /// 登录类型 + /// + public string LoginType { get; set; } +} \ No newline at end of file From 90156f4dfde449056c294576edb14a4fc9f4c79a Mon Sep 17 00:00:00 2001 From: FanLian Date: Fri, 16 Jun 2023 15:15:19 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E8=BD=BD=E5=85=B7=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E3=80=81=E8=BD=BD=E5=85=B7=E8=A7=A3=E7=BB=91=EF=BC=9A=E6=B8=85?= =?UTF-8?q?=E7=90=86=E4=B8=8D=E7=94=A8=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs | 8 +------- WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs | 9 ++------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index 7d486bf9..d3a395a2 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -35,23 +35,17 @@ namespace Tnb.WarehouseMgr private readonly ISqlSugarClient _db; private readonly IRunService _runService; private readonly IVisualDevService _visualDevService; - private readonly IWareHouseService _wareHouseService; - private readonly IBillRullService _billRullService; private readonly IUserManager _userManager; public WmsCarryBindService( ISqlSugarRepository repository, IRunService runService, IVisualDevService visualDevService, - IWareHouseService wareHouseService, - IUserManager userManager, - IBillRullService billRullService) + IUserManager userManager) { _db = repository.AsSugarClient(); _runService = runService; _visualDevService = visualDevService; - _wareHouseService = wareHouseService; _userManager = userManager; - _billRullService = billRullService; OverideFuncs.CreateAsync = CarryBind; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs index dbb7daf3..cfa60d8b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -35,23 +35,18 @@ namespace Tnb.WarehouseMgr private readonly ISqlSugarClient _db; private readonly IRunService _runService; private readonly IVisualDevService _visualDevService; - private readonly IWareHouseService _wareHouseService; - private readonly IBillRullService _billRullService; private readonly IUserManager _userManager; public WmsCarryUnbindService( ISqlSugarRepository repository, IRunService runService, IVisualDevService visualDevService, - IWareHouseService wareHouseService, - IUserManager userManager, - IBillRullService billRullService) + + IUserManager userManager) { _db = repository.AsSugarClient(); _runService = runService; _visualDevService = visualDevService; - _wareHouseService = wareHouseService; _userManager = userManager; - _billRullService = billRullService; OverideFuncs.CreateAsync = CarryUnbind; } From 5f8ab0c9e27efefaa3cf5e27626d7123557b3186 Mon Sep 17 00:00:00 2001 From: hlb <894797954@qq.com> Date: Fri, 16 Jun 2023 15:21:07 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=B1=BB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs | 2 +- .../Tnb.WarehouseMgr/WmsPDAExceptionCompleteService.cs | 4 ++-- .../Tnb.WarehouseMgr/WmsPDAExceptionReexcuteService.cs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs index 103d3016..7362a54b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs @@ -57,7 +57,7 @@ namespace Tnb.WarehouseMgr _runService = runService; _visualDevService = visualDevService; _basLocationService = basLocationService; - //OverideFuncs.CreateAsync = Create; + OverideFuncs.CreateAsync = Create; } /// /// 根据载具编号获取起始库位点 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs index e75fab6a..88b53868 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs @@ -56,7 +56,7 @@ namespace Tnb.WarehouseMgr _runService = runService; _visualDevService = visualDevService; _basLocationService = basLocationService; - //OverideFuncs.CreateAsync = Create; + OverideFuncs.CreateAsync = Create; } /// /// 根据载具编号获取起始库位点 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionCompleteService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionCompleteService.cs index 550289fb..1bfe6b43 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionCompleteService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionCompleteService.cs @@ -53,10 +53,10 @@ namespace Tnb.WarehouseMgr _wareHouseService = wareHouseService; _userManager = userManager; _billRullService = billRullService; - OverideFuncs.CreateAsync = ExceptionCancel; + OverideFuncs.CreateAsync = ExceptionComplete; } - private async Task ExceptionCancel(VisualDevModelDataCrInput input) + private async Task ExceptionComplete(VisualDevModelDataCrInput input) { try diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionReexcuteService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionReexcuteService.cs index 10551597..0ce755de 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionReexcuteService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAExceptionReexcuteService.cs @@ -52,10 +52,10 @@ namespace Tnb.WarehouseMgr _wareHouseService = wareHouseService; _userManager = userManager; _billRullService = billRullService; - OverideFuncs.CreateAsync = ExceptionCancel; + OverideFuncs.CreateAsync = ExceptionReexcute; } - private async Task ExceptionCancel(VisualDevModelDataCrInput input) + private async Task ExceptionReexcute(VisualDevModelDataCrInput input) { try From 4229d602713c84aa76e0cc3523476327d0897d71 Mon Sep 17 00:00:00 2001 From: FanLian Date: Fri, 16 Jun 2023 15:46:23 +0800 Subject: [PATCH 08/10] 1 --- .../Tnb.WarehouseMgr/WmsCarryBindService.cs | 42 ++++++++++++------- .../Tnb.WarehouseMgr/WmsCarryUnbindService.cs | 12 +++++- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index d3a395a2..0cebc9d1 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -84,21 +84,33 @@ namespace Tnb.WarehouseMgr if (!isOk) throw Oops.Oh(ErrorCode.COM1001); } - /* //更新主载具明细表,增加新的数据 - var row = await _db.Insertable(new WmsCarryD { - id = SnowflakeIdHelper.NextId(), - org_id = carry.org_id, - carry_id = carry.id, - membercarry_id = subCarry.id, - membercarry_code = subCarry.carry_code, - loc = input.data[nameof(WmsCarrybindH.loc)].ToString(), - create_id = _userManager.UserId, - create_time = DateTime.Now - }) - .ExecuteCommandAsync(); - if (row <= 0) throw Oops.Oh(ErrorCode.COM1000); - _db.Updateable().SetColumns(it=>it.carry_status == "1").Where(it=>it.id == input.data[nameof(WmsCarrybindH.carry_id)].ToString());*/ - await _db.Ado.CommitTranAsync(); + else + { + if (carry == null) + { + throw new AppFriendlyException("没有可用的主载具", 500); + } + if (subCarry == null) + { + throw new AppFriendlyException("没有可用的子载具", 500); + } + + } + /* //更新主载具明细表,增加新的数据 + var row = await _db.Insertable(new WmsCarryD { + id = SnowflakeIdHelper.NextId(), + org_id = carry.org_id, + carry_id = carry.id, + membercarry_id = subCarry.id, + membercarry_code = subCarry.carry_code, + loc = input.data[nameof(WmsCarrybindH.loc)].ToString(), + create_id = _userManager.UserId, + create_time = DateTime.Now + }) + .ExecuteCommandAsync(); + if (row <= 0) throw Oops.Oh(ErrorCode.COM1000); + _db.Updateable().SetColumns(it=>it.carry_status == "1").Where(it=>it.id == input.data[nameof(WmsCarrybindH.carry_id)].ToString());*/ + await _db.Ado.CommitTranAsync(); } catch (Exception ex) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs index cfa60d8b..0ff573bc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -75,7 +75,17 @@ namespace Tnb.WarehouseMgr row = await _db.Updateable(subCarry).ExecuteCommandAsync(); isOk = (row > 0); if (!isOk) throw Oops.Oh(ErrorCode.COM1001); - + } + else + { + if (carry == null) + { + throw new AppFriendlyException("没有可用的主载具", 500); + } + if (subCarry == null) + { + throw new AppFriendlyException("没有可用的子载具", 500); + } } await _db.Ado.CommitTranAsync(); From 5c21b4fc88e700e970e123d12372303bf4632fa4 Mon Sep 17 00:00:00 2001 From: FanLian Date: Fri, 16 Jun 2023 16:16:06 +0800 Subject: [PATCH 09/10] 1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index b5e68a47..d9723a8d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -77,7 +77,7 @@ namespace Tnb.WarehouseMgr var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);*/ //出库取起点,获取所有符合输入的载具规格的载具 - var setQty = await _db.Queryable().FirstAsync(it => it.bill_code == input.data[nameof(WmsEmptyOutstockH.bill_code)]); + var setQty = await _db.Queryable().FirstAsync(it => it.bill_code == input.data[nameof(WmsEmptyOutstockH.bill_code)].ToString()); var carrys = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id) .Select((a,b) => new { From 32c3de6dac6832e2d76cf5e7de1b2d82ac4c8db8 Mon Sep 17 00:00:00 2001 From: hlb <894797954@qq.com> Date: Fri, 16 Jun 2023 16:28:37 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E5=9B=9E=E6=9B=B4=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WmsCarryMoveOutStockService.cs | 7 ++++- .../Tnb.WarehouseMgr/WmsDeliveryService.cs | 24 ++++++++------- .../WmsEmptyInstockService.cs | 4 ++- .../WmsEmptyOutstockService .cs | 17 +++++------ .../WmsPDACarryMoveInStockService.cs | 7 ++++- .../WmsPDACarryMoveOutStockService.cs | 8 ++++- .../Tnb.WarehouseMgr/WmsPDADeliveryService.cs | 29 ++++++++++++------- .../WmsPDAEmptyInstockService.cs | 5 ++-- .../WmsPDAEmptyOutstockService .cs | 16 +++++----- .../Tnb.WarehouseMgr/WmsPDATransferService.cs | 27 ++++++++++------- .../Tnb.WarehouseMgr/WmsTransferService.cs | 27 ++++++++++------- 11 files changed, 107 insertions(+), 64 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs index 5ded01a5..4def37fe 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs @@ -124,7 +124,12 @@ namespace Tnb.WarehouseMgr preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList(); preTaskUpInput.PreTaskRecords = preTasks.Adapt>(); preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, null, null); + //根据载具移出Id,回更单据状态 + await _db.Updateable().SetColumns(it => new WmsMoveOutstock { 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 }); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs index 7362a54b..a36a1dd7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs @@ -152,16 +152,20 @@ namespace Tnb.WarehouseMgr var isOk = await _wareHouseService.GenPreTask(preTasks,null); if (isOk) { - //不需要插入操作表 - /* var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.PreTaskId = input.data["ReturnIdentity"].ToString(); - preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!; - preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id; - preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code; - preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList(); - preTaskUpInput.PreTaskRecords = preTasks.Adapt>(); - preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - await _wareHouseService.GenTaskHandleAfter(preTaskUpInput);*/ + if (input.data.ContainsKey(nameof(WmsDelivery.startlocation_id)) && input.data.ContainsKey(nameof(WmsDelivery.endlocation_id)) && input.data[nameof(WmsDelivery.endlocation_id)] != null && input.data[nameof(WmsDelivery.endlocation_id)] != null) + { + //查询库位表 + var location = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsDelivery.startlocation_id)].ToString()); + { + //载具加锁,增加库位信息 + await _db.Updateable().SetColumns(it => new WmsCarryH { carry_status = ((int)EnumCarryStatus.占用).ToString(), + is_lock = 1, location_id = input.data[nameof(WmsDelivery.startlocation_id)].ToString(), location_code = location.location_code}).Where(it => it.id == input.data[nameof(WmsDelivery.carry_id)].ToString()).ExecuteCommandAsync(); + } + + //所有库位加锁 + var ids = new[] { input.data[nameof(WmsDelivery.startlocation_id)].ToString(), input.data[nameof(WmsDelivery.endlocation_id)].ToString() }; + await _db.Updateable().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => ids.Contains(it.id)).ExecuteCommandAsync(); + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs index b9052459..883caf0e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs @@ -142,7 +142,9 @@ namespace Tnb.WarehouseMgr //根据空载具入库Id,回更单据状态 await _db.Updateable().SetColumns(it => new WmsEmptyInstock { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync(); - await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,null,null); + await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, + it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode }, + it => new BasLocation { is_lock = 1 }); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index b5e68a47..c4924038 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -21,6 +21,7 @@ using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Attributes; using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Enums; using Tnb.WarehouseMgr.Interfaces; namespace Tnb.WarehouseMgr @@ -141,15 +142,13 @@ namespace Tnb.WarehouseMgr var isOk = await _wareHouseService.GenPreTask(preTasks,null); if (isOk) { - var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString(); - preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!; - preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id; - preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code; - preTaskUpInput.LocationIds = points.Select(x => x.id).ToList(); - preTaskUpInput.PreTaskRecords = preTasks.Adapt>(); - preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,null,null); + //所有载具加锁 + var ids = carrys.Select(x => x.carry_id).ToList(); + await _db.Updateable().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => ids.Contains(it.id)).ExecuteCommandAsync(); + //所有库位加锁 + var loc = carrys.Select(x => x.location_id).ToList(); + await _db.Updateable().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => loc.Contains(it.id)).ExecuteCommandAsync(); + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs index 7aa45c35..2127ef2d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs @@ -127,7 +127,12 @@ namespace Tnb.WarehouseMgr preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList(); preTaskUpInput.PreTaskRecords = preTasks.Adapt>(); preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, null, null); + //根据载具移入Id,回更单据状态 + await _db.Updateable().SetColumns(it => new WmsMoveInstock { 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 }); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs index 7fffb397..3995219f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs @@ -122,9 +122,15 @@ namespace Tnb.WarehouseMgr preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id; preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code; preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList(); + preTaskUpInput.PreTaskRecords = preTasks.Adapt>(); preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,null,null); + //根据载具移出Id,回更单据状态 + await _db.Updateable().SetColumns(it => new WmsMoveOutstock { 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 }); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs index 88b53868..53c2a70d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs @@ -151,16 +151,25 @@ namespace Tnb.WarehouseMgr var isOk = await _wareHouseService.GenPreTask(preTasks,null); if (isOk) { - //不需要插入操作表 - /* var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.PreTaskId = input.data["ReturnIdentity"].ToString(); - preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!; - preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id; - preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code; - preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList(); - preTaskUpInput.PreTaskRecords = preTasks.Adapt>(); - preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - await _wareHouseService.GenTaskHandleAfter(preTaskUpInput);*/ + f(input.data.ContainsKey(nameof(WmsDelivery.startlocation_id)) && input.data.ContainsKey(nameof(WmsDelivery.endlocation_id)) && input.data[nameof(WmsDelivery.endlocation_id)] != null && input.data[nameof(WmsDelivery.endlocation_id)] != null) + { + //查询库位表 + var location = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsDelivery.startlocation_id)].ToString()); + { + //载具加锁,增加库位信息 + await _db.Updateable().SetColumns(it => new WmsCarryH + { + carry_status = ((int)EnumCarryStatus.占用).ToString(), + is_lock = 1, + location_id = input.data[nameof(WmsDelivery.startlocation_id)].ToString(), + location_code = location.location_code + }).Where(it => it.id == input.data[nameof(WmsDelivery.carry_id)].ToString()).ExecuteCommandAsync(); + } + + //所有库位加锁 + var ids = new[] { input.data[nameof(WmsDelivery.startlocation_id)].ToString(), input.data[nameof(WmsDelivery.endlocation_id)].ToString() }; + await _db.Updateable().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => ids.Contains(it.id)).ExecuteCommandAsync(); + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs index 9a748c50..195c4813 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs @@ -140,8 +140,9 @@ namespace Tnb.WarehouseMgr preTaskUpInput.PreTaskRecord = handleH; //根据空载具入库Id,回更单据状态 await _db.Updateable().SetColumns(it => new WmsEmptyInstock { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync(); - - await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,null,null); + await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, + it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode }, + it => new BasLocation { is_lock = 1 }); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs index e8e0d87e..f6086b8d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs @@ -141,15 +141,13 @@ namespace Tnb.WarehouseMgr var isOk = await _wareHouseService.GenPreTask(preTasks,null); if (isOk) { - var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString(); - preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!; - preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id; - preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code; - preTaskUpInput.LocationIds = points.Select(x => x.id).ToList(); - preTaskUpInput.PreTaskRecords = preTasks.Adapt>(); - preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, null, null); + //所有载具加锁 + var ids = carrys.Select(x => x.carry_id).ToList(); + await _db.Updateable().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => ids.Contains(it.id)).ExecuteCommandAsync(); + //所有库位加锁 + var loc = carrys.Select(x => x.location_id).ToList(); + await _db.Updateable().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => loc.Contains(it.id)).ExecuteCommandAsync(); + } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs index 128b1b23..6a4766df 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs @@ -22,6 +22,7 @@ using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Attributes; using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Enums; using Tnb.WarehouseMgr.Interfaces; namespace Tnb.WarehouseMgr { @@ -115,16 +116,22 @@ namespace Tnb.WarehouseMgr var isOk = await _wareHouseService.GenPreTask(preTasks, null); if (isOk) { - //不需要插入操作表 - /* var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.PreTaskId = input.data["ReturnIdentity"].ToString(); - preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!; - preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id; - preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code; - preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList(); - preTaskUpInput.PreTaskRecords = preTasks.Adapt>(); - preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - await _wareHouseService.GenTaskHandleAfter(preTaskUpInput);*/ + //查询库位表 + var location = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsTransfer.startlocation_id)].ToString()); + { + //载具加锁,增加库位信息 + await _db.Updateable().SetColumns(it => new WmsCarryH + { + carry_status = ((int)EnumCarryStatus.占用).ToString(), + is_lock = 1, + location_id = input.data[nameof(WmsTransfer.startlocation_id)].ToString(), + location_code = location.location_code + }).Where(it => it.id == input.data[nameof(WmsTransfer.carry_id)].ToString()).ExecuteCommandAsync(); + } + + //所有库位加锁 + var ids = new[] { input.data[nameof(WmsTransfer.startlocation_id)].ToString(), input.data[nameof(WmsTransfer.endlocation_id)].ToString() }; + await _db.Updateable().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => ids.Contains(it.id)).ExecuteCommandAsync(); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferService.cs index d8f21d47..844c41c6 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferService.cs @@ -22,6 +22,7 @@ using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Attributes; using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Enums; using Tnb.WarehouseMgr.Interfaces; namespace Tnb.WarehouseMgr { @@ -115,16 +116,22 @@ namespace Tnb.WarehouseMgr var isOk = await _wareHouseService.GenPreTask(preTasks,null); if (isOk) { - //不需要插入操作表 - /* var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.PreTaskId = input.data["ReturnIdentity"].ToString(); - preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!; - preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id; - preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code; - preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList(); - preTaskUpInput.PreTaskRecords = preTasks.Adapt>(); - preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - await _wareHouseService.GenTaskHandleAfter(preTaskUpInput);*/ + //查询库位表 + var location = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsTransfer.startlocation_id)].ToString()); + { + //载具加锁,增加库位信息 + await _db.Updateable().SetColumns(it => new WmsCarryH + { + carry_status = ((int)EnumCarryStatus.占用).ToString(), + is_lock = 1, + location_id = input.data[nameof(WmsTransfer.startlocation_id)].ToString(), + location_code = location.location_code + }).Where(it => it.id == input.data[nameof(WmsTransfer.carry_id)].ToString()).ExecuteCommandAsync(); + } + + //所有库位加锁 + var ids = new[] { input.data[nameof(WmsTransfer.startlocation_id)].ToString(), input.data[nameof(WmsTransfer.endlocation_id)].ToString() }; + await _db.Updateable().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => ids.Contains(it.id)).ExecuteCommandAsync(); } }