diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/CheckItemOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/CheckItemOutput.cs
new file mode 100644
index 00000000..c0e04187
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/CheckItemOutput.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.EquipMgr.Entities.Dto
+{
+ public class CheckItemOutput
+ {
+ ///
+ /// 计划ID
+ ///
+ public string plan_id { get; set; }
+ ///
+ /// 模具ID
+ ///
+ public string mold_id { get; set; }
+ ///
+ /// 保养组id
+ ///
+ public string item_group_id { get; set; }
+ ///
+ /// 保养组名称
+ ///
+ public string item_group_name { get; set; }
+ ///
+ /// 保养项id
+ ///
+ public string item_id { get; set; }
+ ///
+ /// 保养项名称
+ ///
+ public string item_name { get; set; }
+ ///
+ /// 保养项,保养状态
+ ///
+ public int status { get; set; } = 0;
+ }
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/CheckItemQueryinput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/CheckItemQueryinput.cs
new file mode 100644
index 00000000..4f286ad7
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/CheckItemQueryinput.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.EquipMgr.Entities.Dto
+{
+ ///
+ /// 根据模具ID、计划ID获取,保养组及项目信息
+ ///
+ public class CheckItemQueryinput
+ {
+ ///
+ /// 计划ID
+ ///
+ public string plan_id { get; set; }
+ ///
+ /// 模具ID
+ ///
+ public string mold_id { get; set; }
+ }
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs
index a286ba6f..be0a99c5 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs
@@ -16,16 +16,26 @@ namespace Tnb.EquipMgr.Entities.Dto
///
public string plan_id { get; set; }
///
- /// 保养项Ids
+ /// 模具id
///
- public ListitemIds { get; set; }
+ public string mold_id { get; set; }
+
///
/// 保养项状态 0,未完成 1,已完成
///
public int? status { get; set; }
+
///
- /// 模具id
+ /// 保养项Ids
///
- public string mold_id { get; set; }
+ public List items { get; set; }
+ }
+
+ public class MaintainItemInfo
+ {
+
+ public string item_group_id { get; set; }
+ public string item_id { get; set; }
+
}
}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItemRecord.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItemRecord.cs
index 34f90a71..9444c8e8 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItemRecord.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainItemRecord.cs
@@ -42,5 +42,9 @@ public partial class ToolMoldMaintainItemRecord : BaseEntity
/// 模具ID
///
public string mold_id { get; set; }
+ ///
+ /// 保养计划ID
+ ///
+ public string plan_id { get; set; }
}
diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs
index 4cfb0c2d..efb856da 100644
--- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs
+++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainGroupService.cs
@@ -83,57 +83,7 @@ namespace Tnb.EquipMgr
[HttpPost]
public async Task RelevanceMaintianGroupAndItem(MoldMaintainGroupItemInput input)
{
- try
- {
- await _db.Ado.BeginTranAsync();
-
- if (input.ids == null || input.ids.Count == 0) throw new ArgumentException($"parameter {nameof(input.ids)} not be null or count not be zero");
- await Relevance(input, nameof(ToolMoldMaintainGroupItem.item_group_id), nameof(ToolMoldMaintainGroupItem.item_id), it => it.item_group_id == input.id);
- List itemRecords = new();
- var grpIds = await _db.Queryable().Where(it => input.ids.Contains(it.item_id)).Select(it => it.item_group_id).Distinct().ToListAsync();
- if (grpIds?.Count > 0)
- {
- var grps = await _db.Queryable().Where(it => grpIds.Contains(it.id)).ToListAsync();
- foreach (var grp in grps)
- {
- var molds = await _db.Queryable().Where(it => it.item_group_id == grp.id).ToListAsync();
- if (molds?.Count > 0)
- {
- foreach (var mold in molds)
- {
- var dbItIds = await _db.Queryable().Where(it => it.mold_id == mold.id && it.item_group_id == grp.id && input.ids.Contains(it.id)).Select(it => it.item_id).ToListAsync();
- input.ids = input.ids.Except(dbItIds).ToList();
- if (input.ids?.Count > 0)
- {
- var items = await _db.Queryable().Where(it => input.ids.Contains(it.id)).ToListAsync();
- if (items?.Count > 0)
- {
- foreach (var item in items)
- {
- ToolMoldMaintainItemRecord record = new();
- record.mold_id = mold.id;
- record.item_group_id = grp.id;
- record.item_group_name = grp.name;
- record.item_id = item.id;
- record.item_name = item.name;
- record.status = 0;
- itemRecords.Add(record);
- }
- }
- }
- }
- }
- }
- await _db.Insertable(itemRecords).ExecuteCommandAsync();
- }
-
- await _db.Ado.CommitTranAsync();
- }
- catch (Exception ex)
- {
- await _db.Ado.RollbackTranAsync();
- throw;
- }
+ await Relevance(input, nameof(ToolMoldMaintainGroupItem.item_group_id), nameof(ToolMoldMaintainGroupItem.item_id), it => it.item_group_id == input.id);
}
///
@@ -145,41 +95,6 @@ namespace Tnb.EquipMgr
public async Task RelevanceMaintianGroupAndMold(MoldMaintainGroupItemRelationInput input)
{
await Relevance(input, nameof(ToolMoldMaintainGroupRelation.item_group_id), nameof(ToolMoldMaintainGroupRelation.mold_id), it => it.item_group_id == input.id);
- List itemRecords = new();
- foreach (var moldId in input.ids)
- {
- var grpIds = await _db.Queryable().Where(it => it.mold_id == moldId).Select(it => it.item_group_id).Distinct().ToListAsync();
- if (grpIds?.Count > 0)
- {
- var grps = await _db.Queryable().Where(it => grpIds.Contains(it.id)).ToListAsync();
- foreach (var grp in grps)
- {
- var itemIds = await _db.Queryable().Where(it => it.item_group_id == grp.id).Select(it => it.item_id).ToListAsync();
- if (itemIds?.Count > 0)
- {
- var dbItemIds = await _db.Queryable().Where(it => it.mold_id == moldId && it.item_group_id == grp.id && itemIds.Contains(it.item_id)).Select(it => it.item_id).ToListAsync();
- itemIds = itemIds.Except(dbItemIds).ToList();
- if (itemIds?.Count > 0)
- {
- var items = await _db.Queryable().Where(it => itemIds.Contains(it.id)).ToListAsync();
- foreach (var item in items)
- {
- ToolMoldMaintainItemRecord record = new();
- record.mold_id = moldId;
- record.item_group_id = grp.id;
- record.item_group_name = grp.name;
- record.item_id = item.id;
- record.item_name = item.name;
- record.status = 0;
- itemRecords.Add(record);
- }
- }
- }
- }
- }
- }
- await _db.Insertable(itemRecords).ExecuteCommandAsync();
-
}
///
/// 删除项目组与模具检查项信息
diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs
index ce87a030..49215a5e 100644
--- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs
+++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs
@@ -94,43 +94,69 @@ namespace Tnb.EquipMgr
return result;
}
///
- /// 根据模具ID获取,保养组及项目信息
+ /// 根据计划Id、模具ID获取,保养组及项目信息
///
- /// 模具ID
- ///
+ ///
+ /// 参数:
+ ///
{
+ ///
plan_id:计划Id
+ ///
mold_id:模具Id
+ ///
}
+ ///
+ ///
+ /// returns:
+ ///
{
+ ///
plan_id:计划ID
+ ///
mold_id:模具ID
+ ///
item_group_id:保养组ID
+ ///
item_group_name:保养组名称
+ ///
item_id:保养项ID
+ ///
item_name:保养项名称
+ ///
}
+ ///
+ ///
[HttpGet]
- public async Task GetCheckItemAndGrpByMoldId([FromRoute] string moldId)
+ public async Task GetCheckItemAndGrpByMoldId([FromQuery] CheckItemQueryinput input)
{
- if (moldId.IsNullOrEmpty()) throw new ArgumentException($"parameter {nameof(moldId)} not be null or empty");
- {
-
- var checkItems = await _db.Queryable().Where(it => it.mold_id == moldId).Select(it => new
+ if (input == null) throw new ArgumentNullException(nameof(input));
+ var items = await _db.Queryable()
+ .InnerJoin((a, b) => a.mold_id == b.mold_id)
+ .InnerJoin((a, b, c) => b.item_group_id == c.item_group_id)
+ .InnerJoin((a, b, c, d) => c.item_group_id == d.id)
+ .InnerJoin((a, b, c, d, e) => c.item_id == e.id)
+ .Where((a) => a.maintain_plan_id == input.plan_id && a.mold_id == input.mold_id)
+ .Select((a, b, c, d, e) => new CheckItemOutput
{
- item_group_id = it.item_group_id,
- item_group_name = it.item_group_name,
- item_id = it.item_id,
- item_name = it.item_name,
- status = it.status,
- }).ToListAsync();
-
- //var checkItems = await _db.Queryable((a, b, c, d) => new JoinQueryInfos
- // (
- // JoinType.Inner, a.item_group_id == b.id,
- // JoinType.Inner, b.id == c.item_group_id,
- // JoinType.Inner, c.item_id == d.id
- // ))
- // .Where(a => a.mold_id == moldId)
- // .Select((a, b, c, d) => new
- // {
- // item_group_id = b.id,
- // item_group_name = b.name,
- // item_id = d.id,
- // item_name = d.name,
- // status = d.status,
- // }).ToListAsync();
- return checkItems;
+ plan_id = a.maintain_plan_id,
+ mold_id = a.mold_id,
+ item_group_id = d.id,
+ item_group_name = d.name,
+ item_id = e.id,
+ item_name = e.name,
+ })
+ .ToListAsync();
+ //items.ForEach(it => it.status = 0);
+ var checkItems = await _db.Queryable().Where(it => it.plan_id == input.plan_id && it.mold_id == input.mold_id).Select(it => new
+ {
+ plan_id = it.plan_id,
+ item_id = it.item_id,
+ item_group_id = it.item_group_id,
+ mold_id = it.mold_id,
+ }).ToListAsync();
+ if (items?.Count > 0 && checkItems?.Count > 0)
+ {
+ foreach (var item in items)
+ {
+ foreach (var checkItem in checkItems)
+ {
+ if (item.plan_id == checkItem.plan_id && item.mold_id == checkItem.mold_id && item.item_group_id == checkItem.item_group_id && item.item_id == checkItem.item_id)
+ {
+ item.status = 1;
+ }
+ }
+ }
}
- return Enumerable.Empty();
+ return items;
}
@@ -220,8 +246,18 @@ namespace Tnb.EquipMgr
public async Task MaintainItemFinish(MoldMaintainRunUpInput input)
{
if (input == null) throw new ArgumentNullException("input");
- if (input.itemIds == null || input.itemIds.Count == 0) throw new ArgumentException($"parameter {nameof(input.itemIds)} not be null or empty");
- var row = await _db.Updateable().SetColumns(it => new ToolMoldMaintainItemRecord { status = 1 }).Where(it => input.itemIds.Contains(it.id)).ExecuteCommandAsync();
+ if (input.items == null || input.items.Count == 0) throw new ArgumentException($"parameter {nameof(input.items)} not be null or empty");
+ List records = new();
+ foreach (var item in input.items)
+ {
+ ToolMoldMaintainItemRecord record = new();
+ record.plan_id = input.plan_id;
+ record.mold_id = input.mold_id;
+ record.item_group_id = item.item_group_id;
+ record.item_id = item.item_id;
+ records.Add(record);
+ }
+ var row = await _db.Insertable(records).ExecuteCommandAsync();
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsCarryConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsCarryConst.cs
new file mode 100644
index 00000000..563ee215
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsCarryConst.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Consts
+{
+ public class WmsCarryConst
+ {
+ ///
+ /// 载具更换EnCode业务编码
+ ///
+ public const string WMS_CARRY_REPLACE_ENCODE = "WmsCarryReplace";
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/CarryCodeDetailOutput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/CarryCodeDetailOutput.cs
new file mode 100644
index 00000000..6dc718df
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/CarryCodeDetailOutput.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Dto
+{
+ ///
+ /// 载具条码明细输出类
+ ///
+ public class CarryCodeDetailOutput
+ {
+ ///
+ /// 条码编号
+ ///
+ public string barcode { get; set; }
+ ///
+ /// 条码批次
+ ///
+ public string code_batch { get; set; }
+ ///
+ /// 条码数量
+ ///
+ public int codeqty { get; set; }
+ ///
+ /// 物料编号
+ ///
+ public string material_code { get; set; }
+ ///
+ /// 物料名称
+ ///
+ public string material_name { get; set; }
+
+ public string material_id { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ExChangeCarryInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ExChangeCarryInput.cs
index cc68bf46..542665fa 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ExChangeCarryInput.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ExChangeCarryInput.cs
@@ -15,10 +15,10 @@ namespace Tnb.WarehouseMgr.Entities.Dto
///
/// 老载具ID
///
- public string old_carry_id { get; set; }
+ public string old_carry_id { get; set; } = string.Empty;
///
/// 新载具ID
///
- public string new_carry_id { get; set; }
+ public string new_carry_id { get; set; } = string.Empty;
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryEntity.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/IWmsCarryEntity.cs
similarity index 70%
rename from WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryEntity.cs
rename to WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/IWmsCarryEntity.cs
index f2d71a03..2130abef 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryEntity.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/IWmsCarryEntity.cs
@@ -4,9 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace Tnb.WarehouseMgr.Interfaces
+namespace Tnb.WarehouseMgr.Entities
{
- public class IWmsCarryEntity
+ public interface IWmsCarryEntity
{
string carry_id { get; set; }
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs
index 84d8360b..4a11cab0 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs
@@ -8,7 +8,7 @@ namespace Tnb.WarehouseMgr.Entities;
/// 载具台账条码表
///
[SugarTable("wms_carry_code")]
-public partial class WmsCarryCode : BaseEntity
+public partial class WmsCarryCode : BaseEntity, IWmsCarryEntity
{
public WmsCarryCode()
{
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.part.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.part.cs
new file mode 100644
index 00000000..9d7f858b
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.part.cs
@@ -0,0 +1,17 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.WarehouseMgr.Entities;
+
+///
+/// 载具台账条码表
+///
+public partial class WmsCarryCode
+{
+ ///
+ /// 物料名称
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string material_name { get; set; }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs
index 553c5500..60b37ded 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs
@@ -8,7 +8,7 @@ namespace Tnb.WarehouseMgr.Entities;
/// 载具台账明细表
///
[SugarTable("wms_carry_d")]
-public partial class WmsCarryD : BaseEntity
+public partial class WmsCarryD : BaseEntity, IWmsCarryEntity
{
public WmsCarryD()
{
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs
index 76092322..94df7398 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs
@@ -42,7 +42,7 @@ public partial class WmsCarryH : BaseEntity
///
/// 载具状态
///
- public int carry_status { get; set; };
+ public string carry_status { get; set; }
///
/// 载具分类ID
@@ -67,7 +67,7 @@ public partial class WmsCarryH : BaseEntity
///
/// 出库类型
///
- public string out_status { get; set; } = string.Empty;
+ public string out_status { get; set; }
///
/// 是否检验
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs
index 283918af..b8bfcb77 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs
@@ -8,7 +8,7 @@ namespace Tnb.WarehouseMgr.Entities;
/// 载具台账物料明细表
///
[SugarTable("wms_carry_mat")]
-public partial class WmsCarryMat : BaseEntity
+public partial class WmsCarryMat : BaseEntity, IWmsCarryEntity
{
public WmsCarryMat()
{
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsFeedingService.cs
new file mode 100644
index 00000000..be7e1b84
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsFeedingService.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Interfaces
+{
+ ///
+ /// 投料业务接口
+ ///
+ public interface IWmsFeedingService
+ {
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsRouteMgrService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsRouteMgrService.cs
new file mode 100644
index 00000000..044523da
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsRouteMgrService.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Interfaces
+{
+ ///
+ /// Wms路径管理业务接口
+ ///
+ public interface IWmsRouteMgrService
+ {
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj b/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj
index 49198cc8..b70c9cce 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj
+++ b/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj
@@ -5,9 +5,11 @@
net6.0
enable
enable
+ True
+
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs
index 5fede318..a25dbeb2 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs
@@ -1,12 +1,20 @@
-using JNPF.Common.Core.Manager;
+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.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
@@ -18,16 +26,22 @@ namespace Tnb.WarehouseMgr
///
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
-
- public class WmsCarryService : IWmsCarryService, IDynamicApiController, ITransient
+ [OverideVisualDev(ModuleId)]
+ public class WmsCarryService : IOverideVisualDevService, IWmsCarryService, IDynamicApiController, ITransient
{
+ private const string ModuleId = "26188532491557";
private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager;
- public WmsCarryService(ISqlSugarRepository repository, IUserManager userManager)
+ private readonly IBillRullService _billRullService;
+ public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
+ public WmsCarryService(ISqlSugarRepository repository, IUserManager userManager, IBillRullService billRullService)
{
_db = repository.AsSugarClient();
_userManager = userManager;
+ _billRullService = billRullService;
+ OverideFuncs.CreateAsync = ExchangeCarry;
}
+
///
/// 更换载具
///
@@ -41,64 +55,27 @@ namespace Tnb.WarehouseMgr
///
///
[HttpPost]
- public async Task Exchange(ExChangeCarryInput input)
+ public async Task ExchangeCarry(VisualDevModelDataCrInput input)
{
- var row = -1;
- if (input == null) throw new ArgumentNullException("input");
- var oldCarry = await _db.Queryable().FirstAsync(it => it.id == input.old_carry_id && it.is_lock == 0 && it.status == 0 && it.carry_status != 0);
- var newCarry = await _db.Queryable().FirstAsync(it => it.id == input.new_carry_id && it.is_lock == 0 && it.status == 0 && it.carry_status == 0);
- if (oldCarry != null && newCarry != null)
+ var isOk = false;
+ try
{
- var subCarrys = await _db.Queryable().Where(it => it.carry_id == oldCarry.id).ToListAsync();
- if (subCarrys?.Count > 0)
+ 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)
{
- List newSubCarrys = DeepCopyHelper.DeepCopyList(subCarrys);
- if (newSubCarrys?.Count > 0)
- {
- newSubCarrys.ForEach(x => x.carry_id = newCarry.id);
- row = await _db.Insertable(newSubCarrys).ExecuteCommandAsync();
- }
- if (row > 0)
- {
- row = await _db.Deleteable(subCarrys).ExecuteCommandAsync();
- }
- }
- var subCarryMats = await _db.Queryable().Where(it => it.carry_id == oldCarry.id).ToListAsync();
- if (subCarryMats?.Count > 0)
- {
- List newCarryMats = DeepCopyHelper.DeepCopyList(subCarryMats);
- if (newCarryMats?.Count > 0)
- {
- newCarryMats.ForEach(x => x.carry_id = newCarry.id);
- row = await _db.Insertable(newCarryMats).ExecuteCommandAsync();
- }
- if (row > 0)
- {
- row = await _db.Deleteable(subCarryMats).ExecuteCommandAsync();
- }
- }
- var subCarryCodes = await _db.Queryable().Where(it => it.carry_id == oldCarry.id).ToListAsync();
- if (subCarryCodes?.Count > 0)
- {
- List newCarrayCodes = DeepCopyHelper.DeepCopyList(subCarryCodes);
- if (newCarrayCodes?.Count > 0)
- {
- newCarrayCodes.ForEach(x => x.carry_id = newCarry.id);
- row = await _db.Insertable(newCarrayCodes).ExecuteCommandAsync();
- }
- if (row > 0)
- {
- row = await _db.Deleteable(subCarryCodes).ExecuteCommandAsync();
- }
- }
- if (row > 0)
- {
- newCarry.carry_name = oldCarry.carry_name;
+ 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.carrystd_id = oldCarry.carrystd_id;
newCarry.location_id = oldCarry.location_id;
- newCarry.carry_code = oldCarry.location_code;
+ newCarry.location_code = oldCarry.location_code;
newCarry.is_lock = oldCarry.is_lock;
newCarry.out_status = oldCarry.out_status;
newCarry.is_check = oldCarry.is_check;
@@ -109,29 +86,91 @@ namespace Tnb.WarehouseMgr
newCarry.source_code = oldCarry.source_code;
newCarry.create_id = _userManager.UserId;
newCarry.create_time = DateTime.Now;
- row = await _db.Updateable(newCarry).ExecuteCommandAsync();
+ var row = await _db.Updateable(newCarry).ExecuteCommandAsync();
+ WmsCarryReplaceH wmsCarryReplaceH = oldCarry.Adapt();
+ 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();
}
- if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
+ catch (Exception ex)
+ {
+ Log.Error("载具更换失败", ex);
+ await _db.Ado.RollbackTranAsync();
+ throw;
+ }
+ return isOk;
}
- public Task UpdateNullCarry(WmsCarryH carryObj)
+ public async Task UpdateNullCarry(WmsCarryH carryObj)
{
- carryObj.carry_name = null;
- carryObj.status = 0;
- carryObj.carry_status = 0;
- carryObj.carrystd_id = null;
- carryObj.location_id = null;
- carryObj.carry_code = null;
- carryObj.out_status = null;
- carryObj.is_check = 0;
- carryObj.bale_num = null;
- carryObj.collocation_scheme_id = null;
- carryObj.collocation_scheme_code = null;
- carryObj.source_id = null;
- carryObj.source_code = null;
- return _db.Updateable(carryObj).ExecuteCommandAsync();
+ 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/WmsFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs
new file mode 100644
index 00000000..47b0d20f
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+using Tnb.BasicData.Entities;
+using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Dto;
+using Tnb.WarehouseMgr.Interfaces;
+
+
+namespace Tnb.WarehouseMgr
+{
+ ///
+ /// 投料记录
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+
+ public class WmsFeedingService : IWmsFeedingService, IDynamicApiController, ITransient
+ {
+ private readonly ISqlSugarClient _db;
+ private static Dictionary dicMaterial = new Dictionary();
+ public WmsFeedingService(ISqlSugarRepository repository)
+ {
+ _db = repository.AsSugarClient();
+ }
+ ///
+ /// 根据载具Id获取载具条码记录
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task GetCarryCodeList([FromRoute] string carryId)
+ {
+ if (dicMaterial.Count < 1)
+ {
+ dicMaterial = await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.name);
+ }
+ var items = await _db.Queryable().Where(it => it.carry_id == carryId)
+ .Select(it => new CarryCodeDetailOutput
+ {
+ barcode = it.barcode,
+ code_batch = it.code_batch,
+ codeqty = it.codeqty,
+ material_code = it.material_code,
+ material_id = it.material_id,
+ })
+ .Mapper(it => it.material_name = dicMaterial.ContainsKey(it.material_id) ? dicMaterial[it.material_id].ToString() : "")
+ .ToListAsync();
+ return items;
+ }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsRouteMgrService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsRouteMgrService.cs
new file mode 100644
index 00000000..e2ff3536
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsRouteMgrService.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Aspose.Cells.Drawing;
+using JNPF.Common.Dtos.VisualDev;
+using JNPF.Common.Enums;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.FriendlyException;
+using JNPF.VisualDev;
+using JNPF.VisualDev.Entitys;
+using JNPF.VisualDev.Interfaces;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Interfaces;
+
+namespace Tnb.WarehouseMgr
+{
+ ///
+ /// 路径管理业务类
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+ [OverideVisualDev(ModuleId)]
+
+ public class WmsRouteMgrService : IOverideVisualDevService, IWmsRouteMgrService, IDynamicApiController, ITransient
+ {
+ private const string ModuleId = "26100621140773";
+ private readonly ISqlSugarClient _db;
+ private readonly IRunService _runService;
+ private readonly IVisualDevService _visualDevService;
+ public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
+
+ public WmsRouteMgrService(ISqlSugarRepository repository, IRunService runService, IVisualDevService visualDevService)
+ {
+ _db = repository.AsSugarClient();
+ _runService = runService;
+ _visualDevService = visualDevService;
+ OverideFuncs.CreateAsync = Create;
+ }
+
+ private async Task Create(VisualDevModelDataCrInput input)
+ {
+ if (input.data.ContainsKey(nameof(WmsRoad.startpoint_id)) && input.data.ContainsKey(nameof(WmsRoad.endpoint_id)))
+ {
+ var startPointId = input.data[nameof(WmsRoad.startpoint_id)].ToString();
+ var endPointId = input.data[nameof(WmsRoad.endpoint_id)].ToString();
+ if (string.Equals(startPointId, endPointId, StringComparison.OrdinalIgnoreCase))
+ {
+ throw new AppFriendlyException("起始点位不能等于终止点位", 500);
+ }
+ }
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
+ await _runService.Create(templateEntity, input);
+ return await Task.FromResult(true);
+ }
+ }
+}
diff --git a/system/Tnb.Systems/System/BillRuleService.cs b/system/Tnb.Systems/System/BillRuleService.cs
index 07e3b943..77a35854 100644
--- a/system/Tnb.Systems/System/BillRuleService.cs
+++ b/system/Tnb.Systems/System/BillRuleService.cs
@@ -311,7 +311,7 @@ public class BillRuleService : IBillRullService, IDynamicApiController, ITransie
if (entity != null)
{
// 处理隔天流水号归0
- if (entity.OutputNumber != null)
+ if (entity.OutputNumber != null)
{
var serialDate = entity.OutputNumber.Remove(entity.OutputNumber.Length - (int)entity.Digit).Replace(entity.Prefix, string.Empty);
var thisDate = entity.DateFormat == "no" ? string.Empty : DateTime.Now.ToString(entity.DateFormat);