diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs
new file mode 100644
index 00000000..e52075d7
--- /dev/null
+++ b/BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs
@@ -0,0 +1,112 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.BasicData.Entities;
+
+///
+/// 标准工时
+///
+[SugarTable("bas_standard_time")]
+public partial class BasStandardTime : BaseEntity
+{
+ public BasStandardTime()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 生产BOMid
+ ///
+ public string? mbom_id { get; set; }
+
+ ///
+ /// 工艺路线id
+ ///
+ public string? routing_id { get; set; }
+
+ ///
+ /// 工序id
+ ///
+ public string? process_id { get; set; }
+
+ ///
+ /// 工位id
+ ///
+ public string? station_id { get; set; }
+
+ ///
+ /// 类型
+ ///
+ public string? type { get; set; }
+
+ ///
+ /// 标准工时
+ ///
+ public string? standard_time { get; set; }
+
+ ///
+ /// 标准工时单位
+ ///
+ public string? standard_time_unit { get; set; }
+
+ ///
+ /// 标准产能
+ ///
+ public string? standard_capacity { get; set; }
+
+ ///
+ /// 标准产能单位
+ ///
+ public string? standard_capacity_unit { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+ ///
+ /// 编号
+ ///
+ public string? code { get; set; }
+
+ ///
+ /// 流程任务Id
+ ///
+ public string? f_flowtaskid { get; set; }
+
+ ///
+ /// 流程引擎Id
+ ///
+ public string? f_flowid { get; set; }
+
+ ///
+ /// 是否启用
+ ///
+ public int? enabled { get; set; }
+
+ ///
+ /// 工序来源选择
+ ///
+ public string? process_source { get; set; }
+
+}
diff --git a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs
index feee5438..2c3cf474 100644
--- a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs
+++ b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs
@@ -103,5 +103,10 @@ public partial class PerProcessStandardsH : BaseEntity
/// 流程引擎Id
///
public string? f_flowid { get; set; }
+
+ ///
+ /// 成型周期
+ ///
+ public decimal? moulding_cycle { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CountEstimatedEndTimeInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CountEstimatedEndTimeInput.cs
new file mode 100644
index 00000000..4f74f496
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CountEstimatedEndTimeInput.cs
@@ -0,0 +1,25 @@
+namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
+{
+ ///
+ /// 排产用于计算预计结束时间
+ ///
+ public class CountEstimatedEndTimeInput
+ {
+ public DateTime estimated_start_date { get; set; }
+
+ public int scheduled_qty { get; set; }
+
+ public string? equip_id { get; set; }
+
+ public string? molds_id { get; set; }
+
+ public string? material_id { get; set; }
+
+ public string? mbom_id { get; set; }
+
+ ///
+ /// 1 注塑挤出排产 2 组装包装排产
+ ///
+ public int type { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordTreeOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordTreeOutput.cs
new file mode 100644
index 00000000..f8cae0d2
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordTreeOutput.cs
@@ -0,0 +1,26 @@
+namespace Tnb.ProductionMgr.Entities.Dto
+{
+ public class FeedingRecordTreeOutput
+ {
+ public string id { get; set; }
+ public string mo_task_code { get; set; }
+ public List children { get; set; } = new List();
+ }
+
+ public class FeedingRecordChildren
+ {
+ public string id { get; set; }
+ public string code { get; set; }
+
+ public string mo_task_id { get; set; }
+
+ public List children { get; set; } = new List();
+ }
+
+ public class FeedingRecordMaterialChildren
+ {
+ public string material_code { get; set; }
+
+ public string material_name { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs
index d337b189..b060203a 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs
@@ -27,5 +27,7 @@ namespace Tnb.ProductionMgr.Entities.Dto
public string? create_id { get; set; } = string.Empty;
public string? create_id_id { get; set; } = string.Empty;
public string? create_time { get; set; } = string.Empty;
+
+ public string? batch { get; set; } = string.Empty;
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs
index c719944a..17e095c4 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs
@@ -21,5 +21,11 @@ namespace Tnb.ProductionMgr.Interfaces
///
///
public Task SaveDataNew(MaterialReceiptNewInput input);
+
+ ///
+ /// 投料记录
+ ///
+ ///
+ public Task GetFeedingRecordTree();
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
index 2a0d6aec..32bc5917 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
@@ -4,10 +4,13 @@ using JNPF.Common.Enums;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
+using JNPF.Extras.CollectiveOAuth.Models;
using JNPF.Extras.CollectiveOAuth.Utils;
using JNPF.FriendlyException;
+using JNPF.Logging;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Interfaces.System;
+using JNPF.VisualDev.Entitys;
using Microsoft.AspNetCore.Mvc;
using Microsoft.ClearScript.Util.Web;
using Newtonsoft.Json;
@@ -163,6 +166,9 @@ namespace Tnb.ProductionMgr
public async Task SaveDataNew(MaterialReceiptNewInput input)
{
var db = _repository.AsSugarClient();
+ PrdFeedingH prdFeedingH = null;
+ List list = new List();
+ DbResult result2 = new DbResult();
DbResult result = await db.Ado.UseTranAsync(async () =>
{
var moTask = await db.Queryable().FirstAsync(x => x.id == input.mo_task_id);
@@ -176,9 +182,8 @@ namespace Tnb.ProductionMgr
.ToListAsync();
-
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE);
- PrdFeedingH prdFeedingH = new PrdFeedingH()
+ prdFeedingH = new PrdFeedingH()
{
code = code,
station_id = input.station_id,
@@ -195,8 +200,7 @@ namespace Tnb.ProductionMgr
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)
@@ -253,8 +257,8 @@ namespace Tnb.ProductionMgr
}
- await db.Insertable(prdFeedingH).ExecuteCommandAsync();
- await db.Insertable(list).ExecuteCommandAsync();
+ // await db.Insertable(prdFeedingH).ExecuteCommandAsync();
+ // await db.Insertable(list).ExecuteCommandAsync();
});
@@ -281,10 +285,69 @@ namespace Tnb.ProductionMgr
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
};
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header);
+ Log.Information(sendResult);
+ AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult);
+ if (authResponse.code != 200)
+ {
+ throw Oops.Bah(authResponse.msg);
+ }
+ else
+ {
+ result2 = await db.Ado.UseTranAsync(async () =>
+ {
+ await db.Insertable(prdFeedingH).ExecuteCommandAsync();
+ await db.Insertable(list).ExecuteCommandAsync();
+ });
+
+ }
}
- if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
- return result.IsSuccess ? "签收成功" : result.ErrorMessage;
+ if(!result2.IsSuccess) throw Oops.Oh(result2.ErrorMessage);
+ return result2.IsSuccess ? "签收成功" : result2.ErrorMessage;
+ }
+
+ [HttpPost]
+ public async Task GetFeedingRecordTree()
+ {
+ var db = _repository.AsSugarClient();
+ var result = await db.Queryable()
+ .Where(a => a.schedule_type == 2 && a.parent_id!=null)
+ .Select(a => new FeedingRecordTreeOutput()
+ {
+ mo_task_code = a.mo_task_code,
+ children = SqlFunc.Subqueryable().Where(b=>a.id==b.mo_task_id).ToList(b=>new FeedingRecordChildren()
+ {
+ id = b.id,
+ code = b.code,
+ // children = SqlFunc.Subqueryable().LeftJoin((c,d)=>c.material_id==d.id)
+ // .Where((c,d)=>SqlFunc.IIF(b==null,"0",b.id)==c.feeding_id).ToList((c,d)=>new FeedingRecordMaterialChildren()
+ // {
+ // // material_code = d.code,
+ // // material_name = d.name,
+ // })
+ // children = new List(),
+ // children = b!=null ? SqlFunc.Subqueryable()
+ // .Where((c)=>"26897270557717"=="26897270557717").ToList((c)=>new FeedingRecordMaterialChildren()
+ // {
+ // // material_code = d.code,
+ // // material_name = d.name,
+ // }) : new List()
+ })
+ }).Mapper(x =>
+ {
+ foreach (var item in x.children)
+ {
+ item.children = db.Queryable()
+ .LeftJoin((c, d) => c.material_id == d.id)
+ .Where((c, d) => item.id == c.feeding_id).Select((c,d) => new FeedingRecordMaterialChildren()
+ {
+ material_code = d.code,
+ material_name = d.name,
+ }).ToList();
+ }
+ })
+ .ToListAsync();
+ return result;
}
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
index 4f2ededd..c56832e0 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
@@ -3,8 +3,10 @@ using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
+using JNPF.Extras.CollectiveOAuth.Models;
using JNPF.Extras.CollectiveOAuth.Utils;
using JNPF.FriendlyException;
+using JNPF.Logging;
using JNPF.RemoteRequest;
using JNPF.Systems.Interfaces.System;
using Mapster;
@@ -48,6 +50,8 @@ namespace Tnb.ProductionMgr
var db = _repository.AsSugarClient();
var location = await db.Queryable().FirstAsync(x => x.location_code == input.location_code);
PrdInstockH prdInstockH = null;
+ List prdInstockDs = new List() { };
+ DbResult result2 = new DbResult();
DbResult result = await db.Ado.UseTranAsync(async () =>
{
prdInstockH = new PrdInstockH()
@@ -63,7 +67,6 @@ namespace Tnb.ProductionMgr
status = 0,
};
- List prdInstockDs = new List() { };
foreach (var item in input.details)
{
prdInstockDs.Add(new PrdInstockD()
@@ -79,12 +82,12 @@ namespace Tnb.ProductionMgr
});
}
- await _repository.InsertAsync(prdInstockH);
-
- if (prdInstockDs.Count > 0)
- {
- await db.Insertable(prdInstockDs).ExecuteCommandAsync();
- }
+ // await _repository.InsertAsync(prdInstockH);
+ //
+ // if (prdInstockDs.Count > 0)
+ // {
+ // await db.Insertable(prdInstockDs).ExecuteCommandAsync();
+ // }
});
@@ -132,11 +135,29 @@ namespace Tnb.ProductionMgr
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
};
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header);
- Console.WriteLine(sendResult);
+ Log.Information(sendResult);
+ AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult);
+ if (authResponse.code != 200)
+ {
+ throw Oops.Bah(authResponse.msg);
+ }
+ else
+ {
+ result2 = await db.Ado.UseTranAsync(async () =>
+ {
+ await _repository.InsertAsync(prdInstockH);
+
+ if (prdInstockDs.Count > 0)
+ {
+ await db.Insertable(prdInstockDs).ExecuteCommandAsync();
+ }
+ });
+
+ }
}
- if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
- return result.IsSuccess ? "保存成功" : result.ErrorMessage;
+ if(!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
+ return result2.IsSuccess ? "保存成功" : result2.ErrorMessage;
}
///
@@ -147,15 +168,26 @@ namespace Tnb.ProductionMgr
public async Task SyncInstock(Dictionary dic)
{
string sourceId = dic.ContainsKey("source_id") ? dic["source_id"] : "";
- if (!string.IsNullOrEmpty(sourceId))
+ var db = _repository.AsSugarClient();
+ DbResult result = await db.Ado.UseTranAsync(async () =>
{
- return await _repository.UpdateAsync(x => new PrdInstockH()
+ if (!string.IsNullOrEmpty(sourceId))
{
- status = 1
- }, x => x.id == sourceId);
- }
+ await _repository.UpdateAsync(x => new PrdInstockH()
+ {
+ status = 1
+ }, x => x.id == sourceId);
+ var details = await db.Queryable().Where(x => x.instock_id == sourceId).ToListAsync();
- return false;
+ foreach (var item in details)
+ {
+ await db.Updateable().SetColumns(x => x.status == 1)
+ .Where(x => x.id == item.report_id).ExecuteCommandAsync();
+ }
+ }
+ });
+
+ return result.IsSuccess;
}
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index b73e6164..45287ded 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -43,6 +43,9 @@ using Microsoft.ClearScript.Util.Web;
using Newtonsoft.Json;
using Tnb.BasicData.Entities.Dto;
using NPOI.SS.Formula.Functions;
+using Tnb.PerMgr.Entities;
+
+// using Tnb.PerMgr.Entities;
namespace Tnb.ProductionMgr
{
@@ -1711,5 +1714,39 @@ namespace Tnb.ProductionMgr
{
return await _db.Queryable().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync();
}
+
+ [HttpPost]
+ public async Task GetEstimatedEndTime(CountEstimatedEndTimeInput input)
+ {
+ var db = _repository.AsSugarClient();
+ if (input.type == 1)
+ {
+ PerProcessStandardsH processStandardsH = await db.Queryable()
+ .Where(x => x.equip_id == input.equip_id && x.molds_id == input.molds_id &&
+ x.output_material_id == input.material_id && x.enabled == 1)
+ .OrderByDescending(x => x.create_time).FirstAsync();
+
+ ToolMolds toolMolds = await db.Queryable().SingleAsync(x => x.id == input.molds_id);
+ if(toolMolds==null) throw Oops.Bah("没找到模具");
+ if(toolMolds?.mold_cavity<=0) throw Oops.Bah("模穴数错误");
+ if (processStandardsH == null) throw Oops.Bah("工艺标准成型周期错误");
+ if (processStandardsH?.moulding_cycle <= 0) throw Oops.Bah("工艺标准成型周期错误");
+
+ decimal? addTime = (input.scheduled_qty * toolMolds.mold_cavity - 1) / processStandardsH?.moulding_cycle + 1;
+ return input.estimated_start_date.AddSeconds((double)addTime.Value).ToString("yyyy-MM-dd HH:mm:ss");
+ }
+ else
+ {
+ var list = await db.Queryable()
+ .LeftJoin((a,b)=>a.process_id==b.process_id)
+ .Where((a,b)=>a.mbom_id==input.mbom_id).Select((a,b)=>b).ToListAsync();
+
+ decimal max = list.Select(x => Convert.ToDecimal(x.standard_time)).Max(x => x);
+ decimal? addTime = input.scheduled_qty * max;
+ return input.estimated_start_date.AddSeconds((double)addTime.Value).ToString("yyyy-MM-dd HH:mm:ss");
+ }
+
+ }
+
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
index 87cd0810..91be4166 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs
@@ -56,9 +56,6 @@ namespace Tnb.ProductionMgr
try
{
var db = _repository.AsSugarClient();
- VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
- await _runService.Create(templateEntity, visualDevModelDataCrInput);
-
MESCreateOutstockInput input = new MESCreateOutstockInput();
input.outstock = new MESWmsOutstockHInput();
@@ -100,7 +97,12 @@ namespace Tnb.ProductionMgr
if (authResponse.code != 200)
{
throw Oops.Bah(authResponse.msg);
- }
+ }
+ else
+ {
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
+ await _runService.Create(templateEntity, visualDevModelDataCrInput);
+ }
return await Task.FromResult(true);
}
catch (Exception e)
diff --git a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs
index 78493934..40f896d0 100644
--- a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs
@@ -126,7 +126,8 @@ namespace Tnb.ProductionMgr
reported_qty = x.reported_qty,
create_id = y.RealName,
create_id_id = x.create_id,
- create_time = x.create_time==null ? "" : x.create_time.Value.ToString("yyyy-MM-dd HH:mm")
+ create_time = x.create_time==null ? "" : x.create_time.Value.ToString("yyyy-MM-dd HH:mm"),
+ batch = x.batch
})
}).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult.SqlSugarPageResult(result);
diff --git a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj
index 6316cd83..6aa07278 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/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs
index 55a83527..1e6c5334 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs
@@ -150,7 +150,8 @@ namespace Tnb.WarehouseMgr
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
.Select(x =>
{
- WmsCarryMat carryMat = new();
+ var arr = x.ToArray();
+ WmsCarryMat carryMat = arr[^arr.Length];
carryMat.need_qty = x.Sum(d => d.need_qty);
return carryMat;
})
@@ -421,7 +422,8 @@ namespace Tnb.WarehouseMgr
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
.Select(x =>
{
- WmsCarryMat carryMat = new();
+ var arr = x.ToArray();
+ WmsCarryMat carryMat = arr[^arr.Length];
carryMat.need_qty = x.Sum(d => d.need_qty);
return carryMat;
})
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs
index 77560665..98a05402 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs
@@ -136,8 +136,9 @@ namespace Tnb.WarehouseMgr
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
.Select(x =>
{
- WmsCarryMat carryMat = new();
- carryMat.need_qty = x.Sum(d => d.need_qty);
+ var arr = x.ToArray();
+ WmsCarryMat carryMat = arr[^arr.Length];
+ carryMat.need_qty = arr.Sum(d => d.need_qty);
return carryMat;
})
.ToList();
@@ -209,7 +210,7 @@ namespace Tnb.WarehouseMgr
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
- if (points?.Count> 0)
+ if (points?.Count > 0)
{
locIds.AddRange(points.Select(x => x.location_id).ToList()!);
}
diff --git a/visualdev/Tnb.VisualDev/RunService.cs b/visualdev/Tnb.VisualDev/RunService.cs
index 00545f6c..214bb0df 100644
--- a/visualdev/Tnb.VisualDev/RunService.cs
+++ b/visualdev/Tnb.VisualDev/RunService.cs
@@ -753,15 +753,15 @@ public class RunService : IRunService, ITransient
dictionarySql.Clear();
tableField.Add("ReturnIdentity", mainId);
dictionarySql.Add("MainTableReturnIdentity", new List>() { tableField });
- }
-
+ }
+
//modify by zhoukeda 20230428 雪花id返回至传入参数中 开始
if (templateInfo.FormModel.primaryKeyPolicy.Equals(1))
{
dataInput.data.Add("ReturnIdentity", mainId);
}
//modify by zhoukeda 20230428 雪花id返回至传入参数中 结束
-
+
// 拼接副表 sql
if (templateInfo.AuxiliaryTableFieldsModelList.Any())
@@ -823,7 +823,11 @@ public class RunService : IRunService, ITransient
{
if (child.Key.Equals("id") && child.Value.IsNotEmptyOrNull())
{
- tableField[childPrimary.field] = child.Value;
+ //modify by ly on 20230720 判断如果子表主键为空的把原主键值赋值给子表主键,直接复制会导致主键重复
+ if(tableField[childPrimary.field].IsNull() || tableField[childPrimary.field].ToString().IsNullOrEmpty())
+ {
+ tableField[childPrimary.field] = child.Value;
+ }
}
else if (child.Key.IsNotEmptyOrNull() && child.Value.IsNotEmptyOrNull() && child.Value.ToString() != "[]")
{
@@ -986,7 +990,7 @@ public class RunService : IRunService, ITransient
// 查找到该控件数据
List>? model = allDataMap[item].ToObject>>();
- if (model != null && model.Count > 0)
+ if (model != null && model.Count >= 0) //modify by ly on 20230720 将Count>0改为>=0,否则最后一条明细数据删除不掉
{
// 利用key去找模板
FieldsModel? fieldsModel = templateInfo.FieldsModelList.Find(f => f.__vModel__ == item);
@@ -1199,7 +1203,7 @@ public class RunService : IRunService, ITransient
var oldTInfo = new TemplateParsingBase(oldFEntity.PropertyJson, oldFEntity.TableJson, (int)oldFEntity.FormType); // 旧模板
var newTInfo = new TemplateParsingBase(newFEntity.PropertyJson, newFEntity.TableJson, (int)newFEntity.FormType); // 新模板
- if(oldFEntity.FormType.Equals(1) || newFEntity.FormType.Equals(1))
+ if (oldFEntity.FormType.Equals(1) || newFEntity.FormType.Equals(1))
{
oldTInfo.AllFieldsModel.ForEach(it =>
{
@@ -1689,7 +1693,7 @@ public class RunService : IRunService, ITransient
Dictionary? newChildData = new Dictionary();
foreach (KeyValuePair item in childmap)
{
- if(item.Key.Equals("id")) newChildData[item.Key] = childmap[item.Key];
+ if (item.Key.Equals("id")) newChildData[item.Key] = childmap[item.Key];
FieldsModel? childFieldsModel = childFieldsModelList.Where(c => c.__vModel__ == item.Key).FirstOrDefault();
if (childFieldsModel != null && childFieldsModel.__vModel__.Equals(item.Key))
{
@@ -1999,7 +2003,7 @@ public class RunService : IRunService, ITransient
///
private string GetPrimary(DbLinkEntity link, string MainTableName)
{
- // modified by PhilPan
+ // modified by PhilPan
var keys = _databaseService.GetPrimaries(link, MainTableName);
if (keys.Count < 1) throw Oops.Oh(ErrorCode.D1402); // 主表未设置主键
return keys.First();
@@ -2464,7 +2468,7 @@ public class RunService : IRunService, ITransient
}
// 子表字段为空 查询 处理.
- if (templateInfo.ChildTableFields.Any(x => x.Value.Contains(tName + "."))&&(dicList.ToJsonString().Contains("\"ConditionalType\":11") || dicList.ToJsonString().Contains("\"ConditionalType\":14")))
+ if (templateInfo.ChildTableFields.Any(x => x.Value.Contains(tName + ".")) && (dicList.ToJsonString().Contains("\"ConditionalType\":11") || dicList.ToJsonString().Contains("\"ConditionalType\":14")))
queryOrSqlList.Add(string.Format(" OR ( [{0}] NOT IN ( SELECT {1} FROM {2} ) ) ", primaryKey, templateInfo.AllTable.Where(x => x.table.Equals(tName)).First().tableField, tName));
if (!tableWhere.ContainsKey(tName)) tableWhere.Add(tName, new List() { conList });
@@ -2945,7 +2949,7 @@ public class RunService : IRunService, ITransient
// 多选时为模糊查询
if (model.multiple || model.searchMultiple)
{
- var value = item.Value.ToString().Contains("[") ? item.Value.ToObject>():new List