This commit is contained in:
FanLian
2023-07-20 15:07:03 +08:00
15 changed files with 368 additions and 49 deletions

View File

@@ -0,0 +1,112 @@
using JNPF.Common.Contracts;
using JNPF.Common.Security;
using SqlSugar;
namespace Tnb.BasicData.Entities;
/// <summary>
/// 标准工时
/// </summary>
[SugarTable("bas_standard_time")]
public partial class BasStandardTime : BaseEntity<string>
{
public BasStandardTime()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 生产BOMid
/// </summary>
public string? mbom_id { get; set; }
/// <summary>
/// 工艺路线id
/// </summary>
public string? routing_id { get; set; }
/// <summary>
/// 工序id
/// </summary>
public string? process_id { get; set; }
/// <summary>
/// 工位id
/// </summary>
public string? station_id { get; set; }
/// <summary>
/// 类型
/// </summary>
public string? type { get; set; }
/// <summary>
/// 标准工时
/// </summary>
public string? standard_time { get; set; }
/// <summary>
/// 标准工时单位
/// </summary>
public string? standard_time_unit { get; set; }
/// <summary>
/// 标准产能
/// </summary>
public string? standard_capacity { get; set; }
/// <summary>
/// 标准产能单位
/// </summary>
public string? standard_capacity_unit { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string? modify_id { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? modify_time { get; set; }
/// <summary>
/// 所属组织
/// </summary>
public string? org_id { get; set; }
/// <summary>
/// 编号
/// </summary>
public string? code { get; set; }
/// <summary>
/// 流程任务Id
/// </summary>
public string? f_flowtaskid { get; set; }
/// <summary>
/// 流程引擎Id
/// </summary>
public string? f_flowid { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public int? enabled { get; set; }
/// <summary>
/// 工序来源选择
/// </summary>
public string? process_source { get; set; }
}

View File

@@ -104,4 +104,9 @@ public partial class PerProcessStandardsH : BaseEntity<string>
/// </summary> /// </summary>
public string? f_flowid { get; set; } public string? f_flowid { get; set; }
/// <summary>
/// 成型周期
/// </summary>
public decimal? moulding_cycle { get; set; }
} }

View File

@@ -0,0 +1,25 @@
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
{
/// <summary>
/// 排产用于计算预计结束时间
/// </summary>
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; }
/// <summary>
/// 1 注塑挤出排产 2 组装包装排产
/// </summary>
public int type { get; set; }
}
}

View File

@@ -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<FeedingRecordChildren> children { get; set; } = new List<FeedingRecordChildren>();
}
public class FeedingRecordChildren
{
public string id { get; set; }
public string code { get; set; }
public string mo_task_id { get; set; }
public List<FeedingRecordMaterialChildren> children { get; set; } = new List<FeedingRecordMaterialChildren>();
}
public class FeedingRecordMaterialChildren
{
public string material_code { get; set; }
public string material_name { get; set; }
}
}

View File

@@ -27,5 +27,7 @@ namespace Tnb.ProductionMgr.Entities.Dto
public string? create_id { get; set; } = string.Empty; public string? create_id { get; set; } = string.Empty;
public string? create_id_id { get; set; } = string.Empty; public string? create_id_id { get; set; } = string.Empty;
public string? create_time { get; set; } = string.Empty; public string? create_time { get; set; } = string.Empty;
public string? batch { get; set; } = string.Empty;
} }
} }

View File

@@ -21,5 +21,11 @@ namespace Tnb.ProductionMgr.Interfaces
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
public Task<dynamic> SaveDataNew(MaterialReceiptNewInput input); public Task<dynamic> SaveDataNew(MaterialReceiptNewInput input);
/// <summary>
/// 投料记录
/// </summary>
/// <returns></returns>
public Task<dynamic> GetFeedingRecordTree();
} }
} }

View File

@@ -4,10 +4,13 @@ using JNPF.Common.Enums;
using JNPF.Common.Security; using JNPF.Common.Security;
using JNPF.DependencyInjection; using JNPF.DependencyInjection;
using JNPF.DynamicApiController; using JNPF.DynamicApiController;
using JNPF.Extras.CollectiveOAuth.Models;
using JNPF.Extras.CollectiveOAuth.Utils; using JNPF.Extras.CollectiveOAuth.Utils;
using JNPF.FriendlyException; using JNPF.FriendlyException;
using JNPF.Logging;
using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Interfaces.System; using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev.Entitys;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.ClearScript.Util.Web; using Microsoft.ClearScript.Util.Web;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -163,6 +166,9 @@ namespace Tnb.ProductionMgr
public async Task<dynamic> SaveDataNew(MaterialReceiptNewInput input) public async Task<dynamic> SaveDataNew(MaterialReceiptNewInput input)
{ {
var db = _repository.AsSugarClient(); var db = _repository.AsSugarClient();
PrdFeedingH prdFeedingH = null;
List<PrdFeedingD> list = new List<PrdFeedingD>();
DbResult<bool> result2 = new DbResult<bool>();
DbResult<bool> result = await db.Ado.UseTranAsync(async () => DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{ {
var moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id); var moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
@@ -176,9 +182,8 @@ namespace Tnb.ProductionMgr
.ToListAsync(); .ToListAsync();
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE); string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE);
PrdFeedingH prdFeedingH = new PrdFeedingH() prdFeedingH = new PrdFeedingH()
{ {
code = code, code = code,
station_id = input.station_id, station_id = input.station_id,
@@ -196,7 +201,6 @@ namespace Tnb.ProductionMgr
org_id = _userManager.GetUserInfo().Result.organizeId org_id = _userManager.GetUserInfo().Result.organizeId
}; };
List<PrdFeedingD> list = new List<PrdFeedingD>();
if (input.details != null && input.details.Count > 0) if (input.details != null && input.details.Count > 0)
{ {
foreach (var item in input.details) foreach (var item in input.details)
@@ -253,8 +257,8 @@ namespace Tnb.ProductionMgr
} }
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync(); // await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync(); // await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
}); });
@@ -281,10 +285,69 @@ namespace Tnb.ProductionMgr
["Authorization"] = App.HttpContext.Request.Headers["Authorization"] ["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
}; };
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header); var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header);
Log.Information(sendResult);
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
if (authResponse.code != 200)
{
throw Oops.Bah(authResponse.msg);
}
else
{
result2 = await db.Ado.UseTranAsync(async () =>
{
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
});
}
} }
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage); if(!result2.IsSuccess) throw Oops.Oh(result2.ErrorMessage);
return result.IsSuccess ? "签收成功" : result.ErrorMessage; return result2.IsSuccess ? "签收成功" : result2.ErrorMessage;
}
[HttpPost]
public async Task<dynamic> GetFeedingRecordTree()
{
var db = _repository.AsSugarClient();
var result = await db.Queryable<PrdMoTask>()
.Where(a => a.schedule_type == 2 && a.parent_id!=null)
.Select(a => new FeedingRecordTreeOutput()
{
mo_task_code = a.mo_task_code,
children = SqlFunc.Subqueryable<PrdFeedingH>().Where(b=>a.id==b.mo_task_id).ToList(b=>new FeedingRecordChildren()
{
id = b.id,
code = b.code,
// children = SqlFunc.Subqueryable<PrdFeedingD>().LeftJoin<BasMaterial>((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<FeedingRecordMaterialChildren>(),
// children = b!=null ? SqlFunc.Subqueryable<PrdFeedingD>()
// .Where((c)=>"26897270557717"=="26897270557717").ToList((c)=>new FeedingRecordMaterialChildren()
// {
// // material_code = d.code,
// // material_name = d.name,
// }) : new List<FeedingRecordMaterialChildren>()
})
}).Mapper(x =>
{
foreach (var item in x.children)
{
item.children = db.Queryable<PrdFeedingD>()
.LeftJoin<BasMaterial>((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;
} }
} }
} }

View File

@@ -3,8 +3,10 @@ using JNPF.Common.Core.Manager;
using JNPF.Common.Enums; using JNPF.Common.Enums;
using JNPF.DependencyInjection; using JNPF.DependencyInjection;
using JNPF.DynamicApiController; using JNPF.DynamicApiController;
using JNPF.Extras.CollectiveOAuth.Models;
using JNPF.Extras.CollectiveOAuth.Utils; using JNPF.Extras.CollectiveOAuth.Utils;
using JNPF.FriendlyException; using JNPF.FriendlyException;
using JNPF.Logging;
using JNPF.RemoteRequest; using JNPF.RemoteRequest;
using JNPF.Systems.Interfaces.System; using JNPF.Systems.Interfaces.System;
using Mapster; using Mapster;
@@ -48,6 +50,8 @@ namespace Tnb.ProductionMgr
var db = _repository.AsSugarClient(); var db = _repository.AsSugarClient();
var location = await db.Queryable<BasLocation>().FirstAsync(x => x.location_code == input.location_code); var location = await db.Queryable<BasLocation>().FirstAsync(x => x.location_code == input.location_code);
PrdInstockH prdInstockH = null; PrdInstockH prdInstockH = null;
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
DbResult<bool> result2 = new DbResult<bool>();
DbResult<bool> result = await db.Ado.UseTranAsync(async () => DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{ {
prdInstockH = new PrdInstockH() prdInstockH = new PrdInstockH()
@@ -63,7 +67,6 @@ namespace Tnb.ProductionMgr
status = 0, status = 0,
}; };
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
foreach (var item in input.details) foreach (var item in input.details)
{ {
prdInstockDs.Add(new PrdInstockD() prdInstockDs.Add(new PrdInstockD()
@@ -79,12 +82,12 @@ namespace Tnb.ProductionMgr
}); });
} }
await _repository.InsertAsync(prdInstockH); // await _repository.InsertAsync(prdInstockH);
//
if (prdInstockDs.Count > 0) // if (prdInstockDs.Count > 0)
{ // {
await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync(); // await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
} // }
}); });
@@ -132,11 +135,29 @@ namespace Tnb.ProductionMgr
["Authorization"] = App.HttpContext.Request.Headers["Authorization"] ["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
}; };
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header); var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header);
Console.WriteLine(sendResult); Log.Information(sendResult);
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(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<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
}
});
}
} }
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); if(!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "保存成功" : result.ErrorMessage; return result2.IsSuccess ? "保存成功" : result2.ErrorMessage;
} }
/// <summary> /// <summary>
@@ -147,15 +168,26 @@ namespace Tnb.ProductionMgr
public async Task<dynamic> SyncInstock(Dictionary<string, string> dic) public async Task<dynamic> SyncInstock(Dictionary<string, string> dic)
{ {
string sourceId = dic.ContainsKey("source_id") ? dic["source_id"] : ""; string sourceId = dic.ContainsKey("source_id") ? dic["source_id"] : "";
var db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
if (!string.IsNullOrEmpty(sourceId)) if (!string.IsNullOrEmpty(sourceId))
{ {
return await _repository.UpdateAsync(x => new PrdInstockH() await _repository.UpdateAsync(x => new PrdInstockH()
{ {
status = 1 status = 1
}, x => x.id == sourceId); }, x => x.id == sourceId);
} var details = await db.Queryable<PrdInstockD>().Where(x => x.instock_id == sourceId).ToListAsync();
return false; foreach (var item in details)
{
await db.Updateable<PrdReport>().SetColumns(x => x.status == 1)
.Where(x => x.id == item.report_id).ExecuteCommandAsync();
}
}
});
return result.IsSuccess;
} }
} }
} }

View File

@@ -43,6 +43,9 @@ using Microsoft.ClearScript.Util.Web;
using Newtonsoft.Json; using Newtonsoft.Json;
using Tnb.BasicData.Entities.Dto; using Tnb.BasicData.Entities.Dto;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using Tnb.PerMgr.Entities;
// using Tnb.PerMgr.Entities;
namespace Tnb.ProductionMgr namespace Tnb.ProductionMgr
{ {
@@ -1711,5 +1714,39 @@ namespace Tnb.ProductionMgr
{ {
return await _db.Queryable<PrdMoTask>().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync(); return await _db.Queryable<PrdMoTask>().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync();
} }
[HttpPost]
public async Task<dynamic> GetEstimatedEndTime(CountEstimatedEndTimeInput input)
{
var db = _repository.AsSugarClient();
if (input.type == 1)
{
PerProcessStandardsH processStandardsH = await db.Queryable<PerProcessStandardsH>()
.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<ToolMolds>().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<BasMbomProcess>()
.LeftJoin<BasStandardTime>((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");
}
}
} }
} }

View File

@@ -56,9 +56,6 @@ namespace Tnb.ProductionMgr
try try
{ {
var db = _repository.AsSugarClient(); var db = _repository.AsSugarClient();
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
await _runService.Create(templateEntity, visualDevModelDataCrInput);
MESCreateOutstockInput input = new MESCreateOutstockInput(); MESCreateOutstockInput input = new MESCreateOutstockInput();
input.outstock = new MESWmsOutstockHInput(); input.outstock = new MESWmsOutstockHInput();
@@ -101,6 +98,11 @@ namespace Tnb.ProductionMgr
{ {
throw Oops.Bah(authResponse.msg); throw Oops.Bah(authResponse.msg);
} }
else
{
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
await _runService.Create(templateEntity, visualDevModelDataCrInput);
}
return await Task.FromResult(true); return await Task.FromResult(true);
} }
catch (Exception e) catch (Exception e)

View File

@@ -126,7 +126,8 @@ namespace Tnb.ProductionMgr
reported_qty = x.reported_qty, reported_qty = x.reported_qty,
create_id = y.RealName, create_id = y.RealName,
create_id_id = x.create_id, 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); }).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<ReportRecordListOutput>.SqlSugarPageResult(result); return PageResult<ReportRecordListOutput>.SqlSugarPageResult(result);

View File

@@ -12,6 +12,7 @@
<ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" /> <ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
<ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" /> <ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" />
<ProjectReference Include="..\..\message\Tnb.Message\Tnb.Message.csproj" /> <ProjectReference Include="..\..\message\Tnb.Message\Tnb.Message.csproj" />
<ProjectReference Include="..\..\PerMgr\Tnb.PerMgr.Entities\Tnb.PerMgr.Entities.csproj" />
<ProjectReference Include="..\..\taskschedule\Tnb.TaskScheduler\Tnb.TaskScheduler.csproj" /> <ProjectReference Include="..\..\taskschedule\Tnb.TaskScheduler\Tnb.TaskScheduler.csproj" />
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" /> <ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr.Entities\Tnb.WarehouseMgr.Entities.csproj" /> <ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr.Entities\Tnb.WarehouseMgr.Entities.csproj" />

View File

@@ -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 }) carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
.Select(x => .Select(x =>
{ {
WmsCarryMat carryMat = new(); var arr = x.ToArray();
WmsCarryMat carryMat = arr[^arr.Length];
carryMat.need_qty = x.Sum(d => d.need_qty); carryMat.need_qty = x.Sum(d => d.need_qty);
return carryMat; 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 }) carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
.Select(x => .Select(x =>
{ {
WmsCarryMat carryMat = new(); var arr = x.ToArray();
WmsCarryMat carryMat = arr[^arr.Length];
carryMat.need_qty = x.Sum(d => d.need_qty); carryMat.need_qty = x.Sum(d => d.need_qty);
return carryMat; return carryMat;
}) })

View File

@@ -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 }) carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
.Select(x => .Select(x =>
{ {
WmsCarryMat carryMat = new(); var arr = x.ToArray();
carryMat.need_qty = x.Sum(d => d.need_qty); WmsCarryMat carryMat = arr[^arr.Length];
carryMat.need_qty = arr.Sum(d => d.need_qty);
return carryMat; return carryMat;
}) })
.ToList(); .ToList();
@@ -209,7 +210,7 @@ namespace Tnb.WarehouseMgr
if (sPoint != null && ePoint != null) if (sPoint != null && ePoint != null)
{ {
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); 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()!); locIds.AddRange(points.Select(x => x.location_id).ToList()!);
} }

View File

@@ -822,9 +822,13 @@ public class RunService : IRunService, ITransient
foreach (KeyValuePair<string, object> child in data) foreach (KeyValuePair<string, object> child in data)
{ {
if (child.Key.Equals("id") && child.Value.IsNotEmptyOrNull()) if (child.Key.Equals("id") && child.Value.IsNotEmptyOrNull())
{
//modify by ly on 20230720 判断如果子表主键为空的把原主键值赋值给子表主键,直接复制会导致主键重复
if(tableField[childPrimary.field].IsNull() || tableField[childPrimary.field].ToString().IsNullOrEmpty())
{ {
tableField[childPrimary.field] = child.Value; tableField[childPrimary.field] = child.Value;
} }
}
else if (child.Key.IsNotEmptyOrNull() && child.Value.IsNotEmptyOrNull() && child.Value.ToString() != "[]") else if (child.Key.IsNotEmptyOrNull() && child.Value.IsNotEmptyOrNull() && child.Value.ToString() != "[]")
{ {
var value = _formDataParsing.InsertValueHandle(dbType, tableList, child.Key, child.Value, fieldsModel?.__config__.children, "create", templateInfo.visualDevEntity != null ? templateInfo.visualDevEntity.isShortLink : false); var value = _formDataParsing.InsertValueHandle(dbType, tableList, child.Key, child.Value, fieldsModel?.__config__.children, "create", templateInfo.visualDevEntity != null ? templateInfo.visualDevEntity.isShortLink : false);
@@ -986,7 +990,7 @@ public class RunService : IRunService, ITransient
// 查找到该控件数据 // 查找到该控件数据
List<Dictionary<string, object>>? model = allDataMap[item].ToObject<List<Dictionary<string, object>>>(); List<Dictionary<string, object>>? model = allDataMap[item].ToObject<List<Dictionary<string, object>>>();
if (model != null && model.Count > 0) if (model != null && model.Count >= 0) //modify by ly on 20230720 将Count>0改为>=0否则最后一条明细数据删除不掉
{ {
// 利用key去找模板 // 利用key去找模板
FieldsModel? fieldsModel = templateInfo.FieldsModelList.Find(f => f.__vModel__ == item); 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 oldTInfo = new TemplateParsingBase(oldFEntity.PropertyJson, oldFEntity.TableJson, (int)oldFEntity.FormType); // 旧模板
var newTInfo = new TemplateParsingBase(newFEntity.PropertyJson, newFEntity.TableJson, (int)newFEntity.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 => oldTInfo.AllFieldsModel.ForEach(it =>
{ {
@@ -1689,7 +1693,7 @@ public class RunService : IRunService, ITransient
Dictionary<string, object>? newChildData = new Dictionary<string, object>(); Dictionary<string, object>? newChildData = new Dictionary<string, object>();
foreach (KeyValuePair<string, object> item in childmap) foreach (KeyValuePair<string, object> 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(); FieldsModel? childFieldsModel = childFieldsModelList.Where(c => c.__vModel__ == item.Key).FirstOrDefault();
if (childFieldsModel != null && childFieldsModel.__vModel__.Equals(item.Key)) if (childFieldsModel != null && childFieldsModel.__vModel__.Equals(item.Key))
{ {
@@ -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)); 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<IConditionalModel>() { conList }); if (!tableWhere.ContainsKey(tName)) tableWhere.Add(tName, new List<IConditionalModel>() { conList });
@@ -2945,7 +2949,7 @@ public class RunService : IRunService, ITransient
// 多选时为模糊查询 // 多选时为模糊查询
if (model.multiple || model.searchMultiple) if (model.multiple || model.searchMultiple)
{ {
var value = item.Value.ToString().Contains("[") ? item.Value.ToObject<List<object>>():new List<object>() { item.Value.ToString() }; var value = item.Value.ToString().Contains("[") ? item.Value.ToObject<List<object>>() : new List<object>() { item.Value.ToString() };
var addItems = new List<KeyValuePair<WhereType, ConditionalModel>>(); var addItems = new List<KeyValuePair<WhereType, ConditionalModel>>();
for (int i = 0; i < value.Count; i++) for (int i = 0; i < value.Count; i++)
{ {
@@ -2987,7 +2991,7 @@ public class RunService : IRunService, ITransient
var objIdList = new List<string>(); var objIdList = new List<string>();
if (item.Value.ToString().Contains("[")) objIdList = item.Value.ToObject<List<string>>(); if (item.Value.ToString().Contains("[")) objIdList = item.Value.ToObject<List<string>>();
else objIdList.Add(item.Value.ToString()); else objIdList.Add(item.Value.ToString());
var rIdList = _visualDevRepository.AsSugarClient().Queryable<UserRelationEntity>().Where(x => objIdList.Select(xx=>xx.Replace("--user", string.Empty)).Contains(x.UserId)).Select(x => new { x.ObjectId, x.ObjectType }).ToList(); var rIdList = _visualDevRepository.AsSugarClient().Queryable<UserRelationEntity>().Where(x => objIdList.Select(xx => xx.Replace("--user", string.Empty)).Contains(x.UserId)).Select(x => new { x.ObjectId, x.ObjectType }).ToList();
rIdList.ForEach(x => rIdList.ForEach(x =>
{ {
if (x.ObjectType.Equals("Organize")) if (x.ObjectType.Equals("Organize"))
@@ -3193,7 +3197,7 @@ public class RunService : IRunService, ITransient
var add = new KeyValuePair<WhereType, ConditionalModel>(i == 0 ? WhereType.And : WhereType.Or, new ConditionalModel var add = new KeyValuePair<WhereType, ConditionalModel>(i == 0 ? WhereType.And : WhereType.Or, new ConditionalModel
{ {
FieldName = item.Key, FieldName = item.Key,
ConditionalType = model.multiple ? ConditionalType.Like: ConditionalType.Equal, ConditionalType = model.multiple ? ConditionalType.Like : ConditionalType.Equal,
FieldValue = model.multiple ? value[i].ToJsonString() : value[i].ToString() FieldValue = model.multiple ? value[i].ToJsonString() : value[i].ToString()
}); });
addItems.Add(add); addItems.Add(add);
@@ -3527,7 +3531,7 @@ public class RunService : IRunService, ITransient
dataRuleConditionalList = _visualDevRepository.AsSugarClient().Utilities.JsonToConditionalModels(pList.ToJsonString()); dataRuleConditionalList = _visualDevRepository.AsSugarClient().Utilities.JsonToConditionalModels(pList.ToJsonString());
dataRuleConditionalList = GetIConditionalModelListByTableName(dataRuleConditionalList, item.Key); dataRuleConditionalList = GetIConditionalModelListByTableName(dataRuleConditionalList, item.Key);
var json = dataRuleConditionalList.ToJsonString().Replace(item.Key + ".", string.Empty); var json = dataRuleConditionalList.ToJsonString().Replace(item.Key + ".", string.Empty);
dataRuleConditionalList= _visualDevRepository.AsSugarClient().Utilities.JsonToConditionalModels(json); dataRuleConditionalList = _visualDevRepository.AsSugarClient().Utilities.JsonToConditionalModels(json);
} }
} }
@@ -3875,7 +3879,7 @@ public class RunService : IRunService, ITransient
{ {
Console.WriteLine(item.Value); Console.WriteLine(item.Value);
Console.WriteLine(item.Key.Replace("jnpf_searchType_equals_", "")); Console.WriteLine(item.Key.Replace("jnpf_searchType_equals_", ""));
if (item.Key.Contains("jnpf_searchType_equals_")) resList = resList.Where(x => x[item.Key.Replace("jnpf_searchType_equals_","")].ToString().Equals(item.Value)).ToList(); if (item.Key.Contains("jnpf_searchType_equals_")) resList = resList.Where(x => x[item.Key.Replace("jnpf_searchType_equals_", "")].ToString().Equals(item.Value)).ToList();
else resList = resList.Where(x => x[item.Key].ToString().Contains(item.Value)).ToList(); else resList = resList.Where(x => x[item.Key].ToString().Contains(item.Value)).ToList();
} }
} }