diff --git a/BasicData/Tnb.BasicData.Interfaces/IBasMbomService.cs b/BasicData/Tnb.BasicData.Interfaces/IBasMbomService.cs
index 4f85705e..1c048c98 100644
--- a/BasicData/Tnb.BasicData.Interfaces/IBasMbomService.cs
+++ b/BasicData/Tnb.BasicData.Interfaces/IBasMbomService.cs
@@ -5,10 +5,17 @@ namespace Tnb.BasicData.Interfaces
public interface IBasMbomService
{
///
- /// 根据物料id获取对应的子任务列表
+ /// 鏍规嵁鐗╂枡id鑾峰彇瀵瑰簲鐨勫瓙浠诲姟鍒楄〃
///
/// bomid
///
Task GetSubMoListByBomId([FromRoute] string bomId);
+
+ ///
+ /// 鏍规嵁鐢熶骇bom宸ュ簭id鑾峰彇鎶曞叆鐗╂枡
+ ///
+ /// id
+ ///
+ Task GetInputMaterialByMbomProcessId(Dictionary dic);
}
}
\ No newline at end of file
diff --git a/BasicData/Tnb.BasicData/BasMbomService.cs b/BasicData/Tnb.BasicData/BasMbomService.cs
index f92b105c..e16924c5 100644
--- a/BasicData/Tnb.BasicData/BasMbomService.cs
+++ b/BasicData/Tnb.BasicData/BasMbomService.cs
@@ -181,6 +181,20 @@ namespace Tnb.BasicData
return result;
}
+ [HttpPost]
+ public async Task GetInputMaterialByMbomProcessId(Dictionary dic)
+ {
+ string id = dic["id"];
+ var result = await _repository.AsSugarClient().Queryable()
+ .Where(x => x.mbom_process_id == id)
+ .Select(x => new
+ {
+ material_id = x.material_id,
+ }).ToListAsync();
+ return result;
+
+ }
+
///
/// 鏍规嵁鐗╂枡id鑾峰彇鐢熶骇bom
///
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs
new file mode 100644
index 00000000..91ead988
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs
@@ -0,0 +1,64 @@
+namespace Tnb.ProductionMgr.Entities.Dto
+{
+ public class MaterialReceiptInput
+ {
+ public string id { get; set; }
+
+ ///
+ /// 绛炬敹鍗曞彿
+ ///
+ public string code { get; set; } = string.Empty;
+
+ ///
+ /// 宸ヤ綅id
+ ///
+ public string station_id { get; set; } = string.Empty;
+
+ ///
+ /// 浠诲姟鍗昳d
+ ///
+ public string? mo_task_id { get; set; }
+
+ ///
+ /// 宸ュ簭id
+ ///
+ public string? process_id { get; set; }
+
+ ///
+ /// 璁惧id
+ ///
+ public string? equip_id { get; set; }
+
+ ///
+ /// 杞﹂棿id
+ ///
+ public string? workshop_id { get; set; }
+
+ ///
+ /// 杞藉叿id
+ ///
+ public string? carry_id { get; set; }
+
+ ///
+ /// 浜х嚎id
+ ///
+ public string? workline_id { get; set; }
+
+ ///
+ /// 浜岀淮鐮佷俊鎭
+ ///
+ public string? carry_code { get; set; }
+
+ ///
+ /// 澶囨敞
+ ///
+ public string? remark { get; set; }
+
+ ///
+ /// 鐢熶骇bom宸ュ簭id
+ ///
+ public string? mbom_process_id { get; set; }
+
+ public List> details { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs
new file mode 100644
index 00000000..dec2b972
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs
@@ -0,0 +1,42 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.ProductionMgr.Entities;
+
+///
+/// 鐗╂枡绛炬敹瀛愯〃
+///
+[SugarTable("prd_material_receipt_d")]
+public partial class PrdMaterialReceiptD : BaseEntity
+{
+ public PrdMaterialReceiptD()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 鐗╂枡绛炬敹id
+ ///
+ public string material_receipt_id { get; set; } = string.Empty;
+
+ ///
+ /// 鐗╂枡id
+ ///
+ public string material_id { get; set; } = string.Empty;
+
+ ///
+ /// 鏁伴噺
+ ///
+ public decimal num { get; set; }
+
+ ///
+ /// 鎵规
+ ///
+ public string? batch { get; set; }
+
+ ///
+ /// 鍗曚綅id
+ ///
+ public string? unit_id { get; set; }
+
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs
new file mode 100644
index 00000000..94958bc2
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs
@@ -0,0 +1,98 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.ProductionMgr.Entities;
+
+///
+/// 鐗╂枡绛炬敹涓昏〃
+///
+[SugarTable("prd_material_receipt_h")]
+public partial class PrdMaterialReceiptH : BaseEntity
+{
+ public PrdMaterialReceiptH()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+
+ ///
+ /// 绛炬敹鍗曞彿
+ ///
+ public string code { get; set; } = string.Empty;
+
+ ///
+ /// 宸ヤ綅id
+ ///
+ public string station_id { get; set; } = string.Empty;
+
+ ///
+ /// 浠诲姟鍗昳d
+ ///
+ public string? mo_task_id { get; set; }
+
+ ///
+ /// 宸ュ簭id
+ ///
+ public string? process_id { get; set; }
+
+ ///
+ /// 璁惧id
+ ///
+ public string? equip_id { get; set; }
+
+ ///
+ /// 杞﹂棿id
+ ///
+ public string? workshop_id { get; set; }
+
+ ///
+ /// 杞藉叿id
+ ///
+ public string? carry_id { get; set; }
+
+ ///
+ /// 浜х嚎id
+ ///
+ public string? workline_id { get; set; }
+
+ ///
+ /// 鍒涘缓鐢ㄦ埛
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 鍒涘缓鏃堕棿
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 浜岀淮鐮佷俊鎭
+ ///
+ public string? carry_code { get; set; }
+
+ ///
+ /// 澶囨敞
+ ///
+ public string? remark { get; set; }
+
+ ///
+ /// 娴佺▼寮曟搸Id
+ ///
+ public string? f_flowid { get; set; }
+
+ ///
+ /// 娴佺▼浠诲姟Id
+ ///
+ public string? f_flowtaskid { get; set; }
+
+ ///
+ /// 鎵灞炵粍缁
+ ///
+ public string? org_id { get; set; }
+
+ ///
+ /// 鐢熶骇bom宸ュ簭id
+ ///
+ public string? mbom_process_id { get; set; }
+
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMaterialReceiptService.cs
new file mode 100644
index 00000000..3810560c
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMaterialReceiptService.cs
@@ -0,0 +1,19 @@
+using Tnb.ProductionMgr.Entities.Dto;
+
+namespace Tnb.ProductionMgr.Interfaces
+{
+ ///
+ /// 鐗╂枡绛炬敹鏈嶅姟鎺ュ彛
+ ///
+ public interface IPrdMaterialReceiptService
+ {
+ ///
+ /// 鏍规嵁閾佺墖浜岀淮鐮佽幏鍙栦俊鎭
+ ///
+ ///
+ ///
+ public Task GetInfoByQrCode(string qrCode);
+
+ public Task SaveData(MaterialReceiptInput input);
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs
new file mode 100644
index 00000000..5493423d
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs
@@ -0,0 +1,136 @@
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Enums;
+using JNPF.Common.Security;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.FriendlyException;
+using JNPF.Systems.Interfaces.System;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.ClearScript.Util.Web;
+using SqlSugar;
+using Tnb.BasicData.Entities;
+using Tnb.ProductionMgr.Entities;
+using Tnb.ProductionMgr.Entities.Dto;
+using Tnb.ProductionMgr.Entities.Dto.PrdManage;
+using Tnb.ProductionMgr.Interfaces;
+using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Dto;
+using Tnb.WarehouseMgr.Entities.Consts;
+
+namespace Tnb.ProductionMgr
+{
+ ///
+ /// 涓氬姟瀹炵幇:鐗╂枡绛炬敹
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+ public class PrdMaterialReceiptService : IPrdMaterialReceiptService, IDynamicApiController, ITransient
+ {
+ private readonly ISqlSugarRepository _repository;
+ private readonly IUserManager _userManager;
+ private readonly IBillRullService _billRullService;
+
+
+ public PrdMaterialReceiptService(
+ ISqlSugarRepository repository,
+ IBillRullService billRullService,
+ IUserManager userManager
+ )
+ {
+ _repository = repository;
+ _userManager = userManager;
+ _billRullService = billRullService;
+ }
+
+
+ [HttpPost]
+ public async Task GetInfoByQrCode(string qrCode)
+ {
+ var db = _repository.AsSugarClient();
+ var result = await db.Queryable()
+ .Where((a) => a.carry_code == qrCode)
+ .Select(a => new
+ {
+ carry_id = a.id,
+ carry_name = a.carry_name,
+ children = SqlFunc.Subqueryable()
+ .LeftJoin((b,c)=>b.material_id==c.id)
+ .Where((b,c)=>a.id==b.carry_id).ToList((b,c)=>new CarryCodeDetailOutput()
+ {
+ unit_id = c.unit_id,
+ barcode = b.barcode,
+ code_batch = b.code_batch,
+ codeqty = b.codeqty,
+ material_id = b.material_id,
+ material_code = c.code,
+ material_name = c.name
+ })
+ }).FirstAsync();
+ return result;
+ }
+
+ [HttpPost]
+ public async Task SaveData(MaterialReceiptInput input)
+ {
+ var db = _repository.AsSugarClient();
+ DbResult result = await db.Ado.UseTranAsync(async () =>
+ {
+ var moTask = await db.Queryable().FirstAsync(x => x.id == input.mo_task_id);
+ var inputMaterials = await db.Queryable()
+ .Where(x => x.mbom_id == moTask.bom_id && x.mbom_process_id == input.mbom_process_id)
+ .Select(x=>x.material_id)
+ .ToListAsync();
+
+ string code = await _billRullService.GetBillNumber(WmsCarryConst.MATERIAL_RECEIPT_CODE);
+ PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH()
+ {
+ code = code,
+ station_id = input.station_id,
+ mo_task_id = input.mo_task_id,
+ process_id = input.process_id,
+ equip_id = input.equip_id,
+ workshop_id = input.workshop_id,
+ carry_id = input.carry_id,
+ workline_id = input.workline_id,
+ carry_code = input.carry_code,
+ remark = input.remark,
+ mbom_process_id = input.mbom_process_id,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now,
+ org_id = _userManager.GetUserInfo().Result.organizeId
+ };
+
+ List list = new List();
+ if (input.details != null && input.details.Count > 0)
+ {
+ foreach (var item in input.details)
+ {
+ if(!inputMaterials.Contains(item["material_id"]))
+ throw new Exception("璇ョ墿鏂欎笉鏄敓浜om鎶曞叆鐗╂枡锛屼笉鑳界鏀");
+
+ list.Add(new PrdMaterialReceiptD
+ {
+ material_receipt_id = prdMaterialReceiptH.id,
+ material_id = item["material_id"],
+ num = Convert.ToDecimal(item["num"]),
+ batch = item["batch"],
+ unit_id = item["unit_id"],
+ });
+ }
+ }
+ else
+ {
+ throw new Exception("娌℃湁绛炬敹鐗╂枡");
+ }
+
+
+ await db.Insertable(prdMaterialReceiptH).ExecuteCommandAsync();
+ await db.Insertable(list).ExecuteCommandAsync();
+
+ });
+
+ if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
+ return result.IsSuccess ? "绛炬敹鎴愬姛" : result.ErrorMessage;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj
index dc0d6697..0ea7ec46 100644
--- a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj
+++ b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj
@@ -12,6 +12,7 @@
+
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsCarryConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsCarryConst.cs
index 563ee215..468463fd 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsCarryConst.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsCarryConst.cs
@@ -12,5 +12,12 @@ namespace Tnb.WarehouseMgr.Entities.Consts
/// 杞藉叿鏇存崲EnCode涓氬姟缂栫爜
///
public const string WMS_CARRY_REPLACE_ENCODE = "WmsCarryReplace";
+
+ ///
+ /// 鐗╂枡绛炬敹缂栫爜
+ ///
+ public const string MATERIAL_RECEIPT_CODE = "MaterialReceipt";
+
+
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs
index de0a98a1..1eb7a537 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs
@@ -25,7 +25,7 @@ public partial class WmsCarrybindH : BaseEntity
public string? org_id { get; set; }
///
- /// 鎵灞炵粍缁嘔D
+ /// 杞藉叿ID
///
public string? carry_id { get; set; }
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindH.cs
index 58865bce..0e5d78ba 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindH.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindH.cs
@@ -24,6 +24,11 @@ public partial class WmsCarryunbindH : BaseEntity
///
public string? org_id { get; set; }
+ ///
+ /// 杞藉叿ID
+ ///
+ public string? carry_id { get; set; }
+
///
/// 杞藉叿缂栧彿
///
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
index 027be036..7d486bf9 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs
@@ -15,6 +15,7 @@ using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Mapster;
using Microsoft.AspNetCore.Mvc;
+using NPOI.SS.Formula;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
@@ -56,7 +57,7 @@ namespace Tnb.WarehouseMgr
private async Task CarryBind(VisualDevModelDataCrInput input)
{
-
+ var isOk = false;
try
{
await _db.Ado.BeginTranAsync();
@@ -65,101 +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 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);
- //if (oldCarry.carrystd_id != newCarry.carrystd_id)
- //{
- // string errorMessege = "鏂拌佽浇鍏疯鏍煎簲鐩稿悓";
- // throw Oops.Oh(errorMessege);
- //}
-
- //鏇存柊
- var isOk = await _db.Updateable().SetColumns(it => it.membercarry_id == subCarry.id)
- .SetColumns(it => it.membercarry_code == subCarry.carry_code)
- .SetColumns(it => it.loc == input.data[nameof(WmsCarrybindH.loc)].ToString())
- .Where(it => it.id == carry.id)
- .ExecuteCommandHasChangeAsync();
- if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
-
-
-
-
-
-
-
- /*
- * 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();
+ }
+ /* //鏇存柊涓昏浇鍏锋槑缁嗚〃锛屽鍔犳柊鐨勬暟鎹
+ 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/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 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+锘縰sing 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:鑰佽浇鍏穒d
+ ///
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
new file mode 100644
index 00000000..6ffdd5b1
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs
@@ -0,0 +1,110 @@
+锘縰sing 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 NPOI.SS.Formula;
+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_WMSCARRYREPLACE_ID)]
+ public class WmsCarryUnbindService : 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 WmsCarryUnbindService(
+ 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 = CarryUnbind;
+ }
+
+ private async Task CarryUnbind(VisualDevModelDataCrInput input)
+ {
+ var isOk = false;
+ try
+ {
+ await _db.Ado.BeginTranAsync();
+
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true);
+ await _runService.Create(templateEntity, input);
+
+ if (input == null) throw new ArgumentNullException(nameof(input));
+ 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);
+
+ }
+
+ await _db.Ado.CommitTranAsync();
+ }
+ catch (Exception ex)
+ {
+ await _db.Ado.RollbackTranAsync();
+ throw;
+ }
+ 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 WmsCarryReplaceH { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
+ if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
+ }*/
+ }
+}
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 @@
+锘縰sing 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:鑰佽浇鍏穒d
+ ///
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