去除引用common.props
This commit is contained in:
@@ -1,19 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Models.VisualDev;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.JsonSerialization;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
@@ -28,7 +17,7 @@ namespace Tnb.BasicData
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class BasCalendarService: IBasCalendarService, IDynamicApiController, ITransient
|
||||
public class BasCalendarService : IBasCalendarService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<BasCalendar> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
@@ -38,6 +27,7 @@ namespace Tnb.BasicData
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存工作日历
|
||||
/// </summary>
|
||||
@@ -46,17 +36,20 @@ namespace Tnb.BasicData
|
||||
[HttpPost]
|
||||
public async Task SaveData(CalendarInput CalendarInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
await db.Deleteable<BasCalendar>(p=>p.datetext== CalendarInput.datetext).ExecuteCommandAsync();
|
||||
BasCalendar BasCalendar = new BasCalendar();
|
||||
BasCalendar.datetext = CalendarInput.datetext;
|
||||
BasCalendar.datetype = CalendarInput.datetype;
|
||||
BasCalendar.workhour = CalendarInput.workhour;
|
||||
BasCalendar.worktype = CalendarInput.worktype;
|
||||
BasCalendar.create_id = _userManager.UserId;
|
||||
BasCalendar.create_time = DateTime.Now;
|
||||
await db.Insertable(BasCalendar).ExecuteCommandAsync();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
_ = await db.Deleteable<BasCalendar>(p => p.datetext == CalendarInput.datetext).ExecuteCommandAsync();
|
||||
BasCalendar BasCalendar = new()
|
||||
{
|
||||
datetext = CalendarInput.datetext,
|
||||
datetype = CalendarInput.datetype,
|
||||
workhour = CalendarInput.workhour,
|
||||
worktype = CalendarInput.worktype,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
_ = await db.Insertable(BasCalendar).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取工作日历
|
||||
/// </summary>
|
||||
@@ -64,95 +57,31 @@ namespace Tnb.BasicData
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetWorkData(CalendarInput CalendarInput)
|
||||
{
|
||||
List<CalendarOut> CalendarOuts = new List<CalendarOut>();
|
||||
List<CalendarOut> CalendarOuts = new();
|
||||
if (CalendarInput.calendartype == (int)EnumCalendarType.分类)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var lists = await db.Queryable<BasCalendar>().Where(p => p.worktype == CalendarInput.content).ToListAsync();
|
||||
|
||||
foreach (var list in lists)
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
List<BasCalendar> lists = await db.Queryable<BasCalendar>().Where(p => p.worktype == CalendarInput.content).ToListAsync();
|
||||
|
||||
foreach (BasCalendar list in lists)
|
||||
{
|
||||
CalendarOut CalendarOut = new CalendarOut();
|
||||
CalendarOut.datetext = list.datetext;
|
||||
CalendarOut.datetype = list.datetype;
|
||||
CalendarOut.workhour = JSON.Deserialize<List<WorkHour>>(list.workhour);
|
||||
CalendarOut.worktype = list.worktype;
|
||||
CalendarOut CalendarOut = new()
|
||||
{
|
||||
datetext = list.datetext,
|
||||
datetype = list.datetype,
|
||||
workhour = JSON.Deserialize<List<WorkHour>>(list.workhour),
|
||||
worktype = list.worktype
|
||||
};
|
||||
CalendarOuts.Add(CalendarOut);
|
||||
}
|
||||
}
|
||||
else if (CalendarInput.calendartype == (int)EnumCalendarType.班组)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var Shifts = await db.Queryable<BasShiftWorkgroup>().Where(p => p.workgroup_id == CalendarInput.content).Select(p=>p.shift_id).ToListAsync();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
List<string> Shifts = await db.Queryable<BasShiftWorkgroup>().Where(p => p.workgroup_id == CalendarInput.content).Select(p => p.shift_id).ToListAsync();
|
||||
if (Shifts != null && Shifts.Count > 0)
|
||||
{
|
||||
var BasTimePeriods = await db.Queryable<BasTimePeriod, BasShift>((a, b) => new object[] { JoinType.Inner, a.shifttype_id == b.id })
|
||||
.Where((a,b) => Shifts.Contains(a.shifttype_id!))
|
||||
.Select((a, b) =>
|
||||
new Shift
|
||||
{
|
||||
startday = b.shiftb_time,
|
||||
endday = b.shifte_time,
|
||||
workhour = new WorkHour { start=a.tpb_time,end=a.tpe_time },
|
||||
}
|
||||
).ToListAsync();
|
||||
|
||||
|
||||
var BasTimePeriodRests = await db.Queryable<BasTimePeriodRest, BasShift>((a, b) => new object[] { JoinType.Inner, a.shift_type_id == b.id })
|
||||
.Where((a, b) => Shifts.Contains(a.shift_type_id!))
|
||||
.Select((a, b) =>
|
||||
new Shift
|
||||
{
|
||||
startday = b.shiftb_time,
|
||||
endday = b.shifte_time,
|
||||
workhour = new WorkHour { start = a.tp_b_time, end = a.tp_e_time },
|
||||
}).ToListAsync();
|
||||
foreach (var BasTimePeriod in BasTimePeriods)
|
||||
{
|
||||
var start = DateTime.Parse(BasTimePeriod.startday!);
|
||||
var end = DateTime.Parse(BasTimePeriod.endday!);
|
||||
for (DateTime date = start; date <= end; date = date.AddDays(1))
|
||||
{
|
||||
if (CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).Any())
|
||||
CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).First().workhour!.Add(BasTimePeriod.workhour!);
|
||||
else
|
||||
{
|
||||
CalendarOut CalendarOut = new CalendarOut();
|
||||
CalendarOut.datetext = date.ToString("yyyy-MM-dd");
|
||||
CalendarOut.datetype = "workDay";
|
||||
CalendarOut.workhour = new List<WorkHour> { BasTimePeriod.workhour! };
|
||||
CalendarOuts.Add(CalendarOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var BasTimePeriodRest in BasTimePeriodRests)
|
||||
{
|
||||
var start = DateTime.Parse(BasTimePeriodRest.startday!);
|
||||
var end = DateTime.Parse(BasTimePeriodRest.endday!);
|
||||
for (DateTime date = start; date <= end; date = date.AddDays(1))
|
||||
{
|
||||
if (CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).Any())
|
||||
CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).First().workhour!.Add(BasTimePeriodRest.workhour!);
|
||||
else
|
||||
{
|
||||
CalendarOut CalendarOut = new CalendarOut();
|
||||
CalendarOut.datetext = date.ToString("yyyy-MM-dd");
|
||||
CalendarOut.datetype = "dayOff";
|
||||
CalendarOut.workhour = new List<WorkHour> { BasTimePeriodRest.workhour! };
|
||||
CalendarOuts.Add(CalendarOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (CalendarInput.calendartype == (int)EnumCalendarType.个人)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var groups = await db.Queryable<BasWorkgroupEmployee>().Where(p => p.employee_id == CalendarInput.content).Select(p => p.group_id).ToListAsync();
|
||||
var Shifts = await db.Queryable<BasShiftWorkgroup>().Where(p => groups.Contains(p.workgroup_id)).Select(p => p.shift_id).ToListAsync();
|
||||
if (Shifts != null && Shifts.Count > 0)
|
||||
{
|
||||
var BasTimePeriods = await db.Queryable<BasTimePeriod, BasShift>((a, b) => new object[] { JoinType.Inner, a.shifttype_id == b.id })
|
||||
List<Shift> BasTimePeriods = await db.Queryable<BasTimePeriod, BasShift>((a, b) => new object[] { JoinType.Inner, a.shifttype_id == b.id })
|
||||
.Where((a, b) => Shifts.Contains(a.shifttype_id!))
|
||||
.Select((a, b) =>
|
||||
new Shift
|
||||
@@ -163,8 +92,7 @@ namespace Tnb.BasicData
|
||||
}
|
||||
).ToListAsync();
|
||||
|
||||
|
||||
var BasTimePeriodRests = await db.Queryable<BasTimePeriodRest, BasShift>((a, b) => new object[] { JoinType.Inner, a.shift_type_id == b.id })
|
||||
List<Shift> BasTimePeriodRests = await db.Queryable<BasTimePeriodRest, BasShift>((a, b) => new object[] { JoinType.Inner, a.shift_type_id == b.id })
|
||||
.Where((a, b) => Shifts.Contains(a.shift_type_id!))
|
||||
.Select((a, b) =>
|
||||
new Shift
|
||||
@@ -173,38 +101,119 @@ namespace Tnb.BasicData
|
||||
endday = b.shifte_time,
|
||||
workhour = new WorkHour { start = a.tp_b_time, end = a.tp_e_time },
|
||||
}).ToListAsync();
|
||||
foreach (var BasTimePeriod in BasTimePeriods)
|
||||
foreach (Shift? BasTimePeriod in BasTimePeriods)
|
||||
{
|
||||
var start = DateTime.Parse(BasTimePeriod.startday!);
|
||||
var end = DateTime.Parse(BasTimePeriod.endday!);
|
||||
DateTime start = DateTime.Parse(BasTimePeriod.startday!);
|
||||
DateTime end = DateTime.Parse(BasTimePeriod.endday!);
|
||||
for (DateTime date = start; date <= end; date = date.AddDays(1))
|
||||
{
|
||||
if (CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).Any())
|
||||
{
|
||||
CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).First().workhour!.Add(BasTimePeriod.workhour!);
|
||||
}
|
||||
else
|
||||
{
|
||||
CalendarOut CalendarOut = new CalendarOut();
|
||||
CalendarOut.datetext = date.ToString("yyyy-MM-dd");
|
||||
CalendarOut.datetype = "workDay";
|
||||
CalendarOut.workhour = new List<WorkHour> { BasTimePeriod.workhour! };
|
||||
CalendarOut CalendarOut = new()
|
||||
{
|
||||
datetext = date.ToString("yyyy-MM-dd"),
|
||||
datetype = "workDay",
|
||||
workhour = new List<WorkHour> { BasTimePeriod.workhour! }
|
||||
};
|
||||
CalendarOuts.Add(CalendarOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var BasTimePeriodRest in BasTimePeriodRests)
|
||||
foreach (Shift? BasTimePeriodRest in BasTimePeriodRests)
|
||||
{
|
||||
var start = DateTime.Parse(BasTimePeriodRest.startday!);
|
||||
var end = DateTime.Parse(BasTimePeriodRest.endday!);
|
||||
DateTime start = DateTime.Parse(BasTimePeriodRest.startday!);
|
||||
DateTime end = DateTime.Parse(BasTimePeriodRest.endday!);
|
||||
for (DateTime date = start; date <= end; date = date.AddDays(1))
|
||||
{
|
||||
if (CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).Any())
|
||||
{
|
||||
CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).First().workhour!.Add(BasTimePeriodRest.workhour!);
|
||||
}
|
||||
else
|
||||
{
|
||||
CalendarOut CalendarOut = new CalendarOut();
|
||||
CalendarOut.datetext = date.ToString("yyyy-MM-dd");
|
||||
CalendarOut.datetype = "dayOff";
|
||||
CalendarOut.workhour = new List<WorkHour> { BasTimePeriodRest.workhour! };
|
||||
CalendarOut CalendarOut = new()
|
||||
{
|
||||
datetext = date.ToString("yyyy-MM-dd"),
|
||||
datetype = "dayOff",
|
||||
workhour = new List<WorkHour> { BasTimePeriodRest.workhour! }
|
||||
};
|
||||
CalendarOuts.Add(CalendarOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (CalendarInput.calendartype == (int)EnumCalendarType.个人)
|
||||
{
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
List<string> groups = await db.Queryable<BasWorkgroupEmployee>().Where(p => p.employee_id == CalendarInput.content).Select(p => p.group_id).ToListAsync();
|
||||
List<string> Shifts = await db.Queryable<BasShiftWorkgroup>().Where(p => groups.Contains(p.workgroup_id)).Select(p => p.shift_id).ToListAsync();
|
||||
if (Shifts != null && Shifts.Count > 0)
|
||||
{
|
||||
List<Shift> BasTimePeriods = await db.Queryable<BasTimePeriod, BasShift>((a, b) => new object[] { JoinType.Inner, a.shifttype_id == b.id })
|
||||
.Where((a, b) => Shifts.Contains(a.shifttype_id!))
|
||||
.Select((a, b) =>
|
||||
new Shift
|
||||
{
|
||||
startday = b.shiftb_time,
|
||||
endday = b.shifte_time,
|
||||
workhour = new WorkHour { start = a.tpb_time, end = a.tpe_time },
|
||||
}
|
||||
).ToListAsync();
|
||||
|
||||
List<Shift> BasTimePeriodRests = await db.Queryable<BasTimePeriodRest, BasShift>((a, b) => new object[] { JoinType.Inner, a.shift_type_id == b.id })
|
||||
.Where((a, b) => Shifts.Contains(a.shift_type_id!))
|
||||
.Select((a, b) =>
|
||||
new Shift
|
||||
{
|
||||
startday = b.shiftb_time,
|
||||
endday = b.shifte_time,
|
||||
workhour = new WorkHour { start = a.tp_b_time, end = a.tp_e_time },
|
||||
}).ToListAsync();
|
||||
foreach (Shift? BasTimePeriod in BasTimePeriods)
|
||||
{
|
||||
DateTime start = DateTime.Parse(BasTimePeriod.startday!);
|
||||
DateTime end = DateTime.Parse(BasTimePeriod.endday!);
|
||||
for (DateTime date = start; date <= end; date = date.AddDays(1))
|
||||
{
|
||||
if (CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).Any())
|
||||
{
|
||||
CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).First().workhour!.Add(BasTimePeriod.workhour!);
|
||||
}
|
||||
else
|
||||
{
|
||||
CalendarOut CalendarOut = new()
|
||||
{
|
||||
datetext = date.ToString("yyyy-MM-dd"),
|
||||
datetype = "workDay",
|
||||
workhour = new List<WorkHour> { BasTimePeriod.workhour! }
|
||||
};
|
||||
CalendarOuts.Add(CalendarOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (Shift? BasTimePeriodRest in BasTimePeriodRests)
|
||||
{
|
||||
DateTime start = DateTime.Parse(BasTimePeriodRest.startday!);
|
||||
DateTime end = DateTime.Parse(BasTimePeriodRest.endday!);
|
||||
for (DateTime date = start; date <= end; date = date.AddDays(1))
|
||||
{
|
||||
if (CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).Any())
|
||||
{
|
||||
CalendarOuts.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).First().workhour!.Add(BasTimePeriodRest.workhour!);
|
||||
}
|
||||
else
|
||||
{
|
||||
CalendarOut CalendarOut = new()
|
||||
{
|
||||
datetext = date.ToString("yyyy-MM-dd"),
|
||||
datetype = "dayOff",
|
||||
workhour = new List<WorkHour> { BasTimePeriodRest.workhour! }
|
||||
};
|
||||
CalendarOuts.Add(CalendarOut);
|
||||
}
|
||||
}
|
||||
@@ -213,6 +222,7 @@ namespace Tnb.BasicData
|
||||
}
|
||||
return CalendarOuts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量保存工作日历
|
||||
/// </summary>
|
||||
@@ -220,37 +230,39 @@ namespace Tnb.BasicData
|
||||
/// <returns></returns>
|
||||
public async Task SaveBatchData(CalendarBatchInput CalendarBatchInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
DateTime start = DateTime.Parse(CalendarBatchInput.startenday![0]);
|
||||
DateTime end = DateTime.Parse(CalendarBatchInput.startenday![1]);
|
||||
List<BasCalendar> BasCalendars = new List<BasCalendar>();
|
||||
var lists=await db.Queryable<BasCalendar>().Where(p=>start<=DateTime.Parse(p.datetext!)&&end>= DateTime.Parse(p.datetext!)&& p.worktype== CalendarBatchInput.worktype).ToListAsync();
|
||||
var updatelist=new List<BasCalendar>();
|
||||
List<BasCalendar> BasCalendars = new();
|
||||
List<BasCalendar> lists = await db.Queryable<BasCalendar>().Where(p => start <= DateTime.Parse(p.datetext!) && end >= DateTime.Parse(p.datetext!) && p.worktype == CalendarBatchInput.worktype).ToListAsync();
|
||||
List<BasCalendar> updatelist = new();
|
||||
for (DateTime date = start; date <= end; date = date.AddDays(1))
|
||||
{
|
||||
if (CalendarBatchInput.weekday!.Contains((int)date.DayOfWeek))
|
||||
{
|
||||
if (lists.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).Any())
|
||||
{
|
||||
var BasCalendar = lists.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).First();
|
||||
BasCalendar BasCalendar = lists.Where(p => p.datetext == date.ToString("yyyy-MM-dd")).First();
|
||||
BasCalendar.datetype = CalendarBatchInput.datetype;
|
||||
updatelist.Add(BasCalendar);
|
||||
updatelist.Add(BasCalendar);
|
||||
}
|
||||
else
|
||||
{
|
||||
BasCalendar BasCalendar = new BasCalendar();
|
||||
BasCalendar.datetext = date.ToString("yyyy-MM-dd");
|
||||
BasCalendar.datetype = CalendarBatchInput.datetype;
|
||||
BasCalendar.workhour = CalendarBatchInput.workhour;
|
||||
BasCalendar.worktype = CalendarBatchInput.worktype;
|
||||
BasCalendar.create_id = _userManager.UserId;
|
||||
BasCalendar.create_time = DateTime.Now;
|
||||
BasCalendar BasCalendar = new()
|
||||
{
|
||||
datetext = date.ToString("yyyy-MM-dd"),
|
||||
datetype = CalendarBatchInput.datetype,
|
||||
workhour = CalendarBatchInput.workhour,
|
||||
worktype = CalendarBatchInput.worktype,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
BasCalendars.Add(BasCalendar);
|
||||
}
|
||||
}
|
||||
}
|
||||
await db.Updateable(updatelist).ExecuteCommandAsync();
|
||||
await db.Insertable(BasCalendars).ExecuteCommandAsync();
|
||||
_ = await db.Updateable(updatelist).ExecuteCommandAsync();
|
||||
_ = await db.Insertable(BasCalendars).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,10 @@ using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
@@ -16,14 +15,14 @@ namespace Tnb.BasicData
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class BasDefectService: IBasDefectService,IDynamicApiController, ITransient
|
||||
public class BasDefectService : IBasDefectService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<BasDefect> _repository;
|
||||
private readonly DataBaseManager _dbManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
|
||||
|
||||
public BasDefectService(
|
||||
ISqlSugarRepository<BasDefect> repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService)
|
||||
ISqlSugarRepository<BasDefect> repository, DataBaseManager dbManager, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_repository = repository;
|
||||
_dbManager = dbManager;
|
||||
@@ -34,16 +33,16 @@ namespace Tnb.BasicData
|
||||
public async Task<dynamic> GetDefectListByProcessId(Dictionary<string, string> dic)
|
||||
{
|
||||
string processId = dic["processId"];
|
||||
var db = _repository.AsSugarClient();
|
||||
List<string> defectIds = await db.Queryable<BasProcessDefective>().Where(x=>x.process_id==processId).Select(x=>x.defective_id).ToListAsync();
|
||||
List<string?> defectTypeIds = await db.Queryable<BasDefect>().Where(x=>defectIds.Contains(x.id) && x.enabled==1).Select(x=>x.defect_type_id).ToListAsync();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
List<string> defectIds = await db.Queryable<BasProcessDefective>().Where(x => x.process_id == processId).Select(x => x.defective_id).ToListAsync();
|
||||
List<string?> defectTypeIds = await db.Queryable<BasDefect>().Where(x => defectIds.Contains(x.id) && x.enabled == 1).Select(x => x.defect_type_id).ToListAsync();
|
||||
return await _repository.AsSugarClient().Queryable<BasDefectType>()
|
||||
.Where((a) => defectTypeIds.Contains(a.id))
|
||||
.Select(a => new
|
||||
{
|
||||
defect_type_id = a.id,
|
||||
defect_type_name = a.defect_type_name,
|
||||
children = SqlFunc.Subqueryable<BasDefect>().Where(x=>x.defect_type_id==a.id && defectIds.Contains(x.id)).ToList(x=>new DefectOutput()
|
||||
a.defect_type_name,
|
||||
children = SqlFunc.Subqueryable<BasDefect>().Where(x => x.defect_type_id == a.id && defectIds.Contains(x.id)).ToList(x => new DefectOutput()
|
||||
{
|
||||
id = x.id,
|
||||
defect_code = x.defect_code,
|
||||
|
||||
@@ -6,7 +6,6 @@ using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -24,13 +23,13 @@ namespace Tnb.BasicData
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModelId)]
|
||||
public class BasESopService : IBasESopService,IOverideVisualDevService,IDynamicApiController, ITransient
|
||||
public class BasESopService : IBasESopService, IOverideVisualDevService, IDynamicApiController, ITransient
|
||||
{
|
||||
public const string ModelId = "26919620992277";
|
||||
private readonly ISqlSugarRepository<BasESop> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
|
||||
public BasESopService(
|
||||
IUserManager userManager,
|
||||
ISqlSugarRepository<BasESop> repository)
|
||||
@@ -39,7 +38,7 @@ namespace Tnb.BasicData
|
||||
_userManager = userManager;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ESOP列表
|
||||
/// </summary>
|
||||
@@ -48,12 +47,12 @@ namespace Tnb.BasicData
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, object>? queryJson = string.IsNullOrEmpty(input.queryJson) ? null : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||
string? code = queryJson!=null && queryJson.ContainsKey("code") ? queryJson["code"].ToString() : "";
|
||||
string? name = queryJson!=null && queryJson.ContainsKey("name") ? queryJson["name"].ToString() : "";
|
||||
string? version = queryJson!=null && queryJson.ContainsKey("version") ? queryJson["version"].ToString() : "";
|
||||
var list = await db.Queryable<BasESop, BasMbom, BasMbomProcess, UserEntity,BasProcess>((a, b, c, d,e) => new object[]
|
||||
string? code = queryJson != null && queryJson.ContainsKey("code") ? queryJson["code"].ToString() : "";
|
||||
string? name = queryJson != null && queryJson.ContainsKey("name") ? queryJson["name"].ToString() : "";
|
||||
string? version = queryJson != null && queryJson.ContainsKey("version") ? queryJson["version"].ToString() : "";
|
||||
SqlSugarPagedList<ESopListOutput> list = await db.Queryable<BasESop, BasMbom, BasMbomProcess, UserEntity, BasProcess>((a, b, c, d, e) => new object[]
|
||||
{
|
||||
JoinType.Left, a.mbom_id == b.id,
|
||||
JoinType.Left, a.mbom_process_id == c.id,
|
||||
@@ -63,8 +62,8 @@ namespace Tnb.BasicData
|
||||
.WhereIF(!string.IsNullOrEmpty(code), (a, b, c, d) => a.code.Contains(code!))
|
||||
.WhereIF(!string.IsNullOrEmpty(name), (a, b, c, d) => a.name.Contains(name!))
|
||||
.WhereIF(!string.IsNullOrEmpty(version), (a, b, c, d) => a.version.Contains(version!))
|
||||
.Where((a,b,c)=>a.enabled==1)
|
||||
.Select((a, b, c, d,e) => new ESopListOutput
|
||||
.Where((a, b, c) => a.enabled == 1)
|
||||
.Select((a, b, c, d, e) => new ESopListOutput
|
||||
{
|
||||
id = a.id,
|
||||
code = a.code,
|
||||
@@ -72,31 +71,31 @@ namespace Tnb.BasicData
|
||||
mbom_id = b.version!,
|
||||
mbom_process_id = e.process_name!,
|
||||
version = a.version,
|
||||
enabled = a.enabled==1 ? "是" : "否",
|
||||
enabled = a.enabled == 1 ? "是" : "否",
|
||||
attachment = a.attachment,
|
||||
remark = a.remark,
|
||||
create_id = d.RealName,
|
||||
create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd"),
|
||||
create_time = a.create_time == null ? "" : a.create_time.Value.ToString("yyyy-MM-dd"),
|
||||
mbom_id_id = a.mbom_id,
|
||||
mbom_process_id_id = a.mbom_process_id
|
||||
}).ToPagedListAsync((input?.currentPage??1), (input?.pageSize??50));
|
||||
}).ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
|
||||
|
||||
return PageResult<ESopListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetHistoryList(EsopHistoryListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, string>? queryJson = new Dictionary<string, string>();
|
||||
if (input!=null && !string.IsNullOrEmpty(input.queryJson))
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, string>? queryJson = new();
|
||||
if (input != null && !string.IsNullOrEmpty(input.queryJson))
|
||||
{
|
||||
queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input?.queryJson ?? "");
|
||||
}
|
||||
string code = queryJson!=null && queryJson.ContainsKey("code") ? queryJson["code"].ToString() : "";
|
||||
string name = queryJson!=null && queryJson.ContainsKey("name") ? queryJson["name"].ToString() : "";
|
||||
string version = queryJson!=null && queryJson.ContainsKey("version") ? queryJson["version"].ToString() : "";
|
||||
var list = await db.Queryable<BasESop, BasMbom, BasMbomProcess, UserEntity,BasProcess>((a, b, c, d,e) => new object[]
|
||||
string code = queryJson != null && queryJson.ContainsKey("code") ? queryJson["code"].ToString() : "";
|
||||
string name = queryJson != null && queryJson.ContainsKey("name") ? queryJson["name"].ToString() : "";
|
||||
string version = queryJson != null && queryJson.ContainsKey("version") ? queryJson["version"].ToString() : "";
|
||||
SqlSugarPagedList<ESopListOutput> list = await db.Queryable<BasESop, BasMbom, BasMbomProcess, UserEntity, BasProcess>((a, b, c, d, e) => new object[]
|
||||
{
|
||||
JoinType.Left, a.mbom_id == b.id,
|
||||
JoinType.Left, a.mbom_process_id == c.id,
|
||||
@@ -106,8 +105,8 @@ namespace Tnb.BasicData
|
||||
.WhereIF(!string.IsNullOrEmpty(code), (a, b, c, d) => a.code.Contains(code))
|
||||
.WhereIF(!string.IsNullOrEmpty(name), (a, b, c, d) => a.name.Contains(name))
|
||||
.WhereIF(!string.IsNullOrEmpty(version), (a, b, c, d) => a.version.Contains(version))
|
||||
.Where((a,b,c)=>a.mbom_id==input!.mbom_id && a.mbom_process_id==input!.mbom_process_id)
|
||||
.Select((a, b, c, d,e) => new ESopListOutput
|
||||
.Where((a, b, c) => a.mbom_id == input!.mbom_id && a.mbom_process_id == input!.mbom_process_id)
|
||||
.Select((a, b, c, d, e) => new ESopListOutput
|
||||
{
|
||||
id = a.id,
|
||||
code = a.code,
|
||||
@@ -115,27 +114,24 @@ namespace Tnb.BasicData
|
||||
mbom_id = b.version!,
|
||||
mbom_process_id = e.process_name!,
|
||||
version = a.version,
|
||||
enabled = a.enabled==1 ? "是" : "否",
|
||||
enabled = a.enabled == 1 ? "是" : "否",
|
||||
attachment = a.attachment,
|
||||
remark = a.remark,
|
||||
create_id = d.RealName,
|
||||
create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd"),
|
||||
create_time = a.create_time == null ? "" : a.create_time.Value.ToString("yyyy-MM-dd"),
|
||||
mbom_id_id = a.mbom_id
|
||||
}).ToPagedListAsync((input?.currentPage??1), (input?.pageSize??50));
|
||||
}).ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
|
||||
|
||||
return PageResult<ESopListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetEntityByMbomProcessId(Dictionary<string, string> dic)
|
||||
public async Task<dynamic?> GetEntityByMbomProcessId(Dictionary<string, string> dic)
|
||||
{
|
||||
string mbomProcessId = dic["mbomProcessId"];
|
||||
if (!string.IsNullOrEmpty(mbomProcessId))
|
||||
{
|
||||
return await _repository.GetFirstAsync(x => x.mbom_process_id == mbomProcessId && x.enabled == 1);
|
||||
}
|
||||
|
||||
return null!;
|
||||
return !string.IsNullOrEmpty(mbomProcessId)
|
||||
? await _repository.GetFirstAsync(x => x.mbom_process_id == mbomProcessId && x.enabled == 1)
|
||||
: (dynamic)null;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@@ -146,15 +142,15 @@ namespace Tnb.BasicData
|
||||
throw Oops.Bah("已存在该版本");
|
||||
}
|
||||
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.UpdateAsync(x => new BasESop()
|
||||
_ = await _repository.UpdateAsync(x => new BasESop()
|
||||
{
|
||||
enabled = 0,
|
||||
}, x => x.mbom_id == input.mbom_id && x.mbom_process_id == input.mbom_process_id);
|
||||
|
||||
BasESop basESop = new BasESop()
|
||||
|
||||
BasESop basESop = new()
|
||||
{
|
||||
code = input.code,
|
||||
name = input.name,
|
||||
@@ -169,13 +165,9 @@ namespace Tnb.BasicData
|
||||
enabled = 1,
|
||||
};
|
||||
|
||||
await _repository.InsertAsync(basESop);
|
||||
|
||||
_ = await _repository.InsertAsync(basESop);
|
||||
});
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
|
||||
return result.IsSuccess ? "上传成功" : result.ErrorMessage;
|
||||
|
||||
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result.IsSuccess ? "上传成功" : result.ErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
@@ -11,7 +10,6 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
using Tnb.BasicData.Entitys.Dto.BasProcess;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
@@ -22,23 +20,22 @@ namespace Tnb.BasicData
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModelId)]
|
||||
public class BasEbomService : IBasEbomService,IOverideVisualDevService,IDynamicApiController, ITransient
|
||||
public class BasEbomService : IBasEbomService, IOverideVisualDevService, IDynamicApiController, ITransient
|
||||
{
|
||||
public const string ModelId = "25487105536805";
|
||||
private readonly ISqlSugarRepository<BasMaterial> _repository;
|
||||
private readonly DataBaseManager _dbManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
|
||||
public BasEbomService(
|
||||
ISqlSugarRepository<BasMaterial> repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService)
|
||||
ISqlSugarRepository<BasMaterial> repository, DataBaseManager dbManager, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_repository = repository;
|
||||
_dbManager = dbManager;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 物料清单列表
|
||||
@@ -47,15 +44,15 @@ namespace Tnb.BasicData
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, object>? queryJson = (input==null || string.IsNullOrEmpty(input.queryJson)) ? null : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, object>? queryJson = (input == null || string.IsNullOrEmpty(input.queryJson)) ? null : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||
string materialInfo = queryJson?["query_info"]?.ToString() ?? "";
|
||||
var list = await db.Queryable<BasEbomH, BasMaterial, BasRouteH>((a, b, c) => new object[]
|
||||
SqlSugarPagedList<EbomListOutput> list = await db.Queryable<BasEbomH, BasMaterial, BasRouteH>((a, b, c) => new object[]
|
||||
{
|
||||
JoinType.Left, a.material_id == b.id,
|
||||
JoinType.Left, a.route_id == c.id,
|
||||
})
|
||||
.WhereIF(!string.IsNullOrEmpty(materialInfo),(a,b,c)=>b.code.Contains(materialInfo) || b.name.Contains(materialInfo))
|
||||
.WhereIF(!string.IsNullOrEmpty(materialInfo), (a, b, c) => b.code.Contains(materialInfo) || b.name.Contains(materialInfo))
|
||||
.Select((a, b, c) => new EbomListOutput
|
||||
{
|
||||
id = a.id,
|
||||
@@ -67,12 +64,11 @@ namespace Tnb.BasicData
|
||||
version = a.version,
|
||||
route_id = c.name,
|
||||
route_id_id = c.id,
|
||||
}).ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
|
||||
|
||||
}).ToPagedListAsync((input?.currentPage ?? 1), (input?.pageSize ?? 50));
|
||||
|
||||
return PageResult<EbomListOutput>.SqlSugarPageResult(list);
|
||||
return PageResult<EbomListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料清单树.
|
||||
/// </summary>
|
||||
@@ -80,9 +76,9 @@ namespace Tnb.BasicData
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetTree(EbomTreeQueryInput queryInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var dic = await _dictionaryDataService.GetDicByKey(DictConst.MeasurementUnit);
|
||||
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, object> dic = await _dictionaryDataService.GetDicByKey(DictConst.MeasurementUnit);
|
||||
|
||||
// var momDbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.FullName == DbName.TNBMON);
|
||||
// if (momDbLink != null)
|
||||
// {
|
||||
@@ -91,14 +87,14 @@ namespace Tnb.BasicData
|
||||
|
||||
if (string.IsNullOrEmpty(queryInput.materialId))
|
||||
{
|
||||
var data = await db.Queryable<BasEbomD>()
|
||||
.LeftJoin<BasEbomH>((a,b)=>a.ebom_id==b.id)
|
||||
.LeftJoin<BasMaterial>((a,b,c)=>a.material_id==c.id)
|
||||
.LeftJoin<BasEbomH>((a,b,c,d)=>a.material_id==d.material_id)
|
||||
.LeftJoin<BasRouteH>((a,b,c,d,e)=>d.route_id==e.id)
|
||||
.LeftJoin<BasMaterial>((a,b,c,d,e,f)=>a.substitute_material_id==f.id)
|
||||
.Where((a,b,c)=>a.ebom_id==queryInput.ebomId)
|
||||
.Select((a,b,c,d,e,f)=>new EbomTreeOutput
|
||||
List<EbomTreeOutput> data = await db.Queryable<BasEbomD>()
|
||||
.LeftJoin<BasEbomH>((a, b) => a.ebom_id == b.id)
|
||||
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||
.LeftJoin<BasEbomH>((a, b, c, d) => a.material_id == d.material_id)
|
||||
.LeftJoin<BasRouteH>((a, b, c, d, e) => d.route_id == e.id)
|
||||
.LeftJoin<BasMaterial>((a, b, c, d, e, f) => a.substitute_material_id == f.id)
|
||||
.Where((a, b, c) => a.ebom_id == queryInput.ebomId)
|
||||
.Select((a, b, c, d, e, f) => new EbomTreeOutput
|
||||
{
|
||||
material_id = c.name,
|
||||
material_id_descrip = c.descrip,
|
||||
@@ -112,7 +108,7 @@ namespace Tnb.BasicData
|
||||
route_name = e.name,
|
||||
version = d.version,
|
||||
substitute_material_id = f.name,
|
||||
hasChildren = SqlFunc.Subqueryable<BasEbomH>().Where(x=>x.material_id==a.material_id).Any(),
|
||||
hasChildren = SqlFunc.Subqueryable<BasEbomH>().Where(x => x.material_id == a.material_id).Any(),
|
||||
}).Mapper(it =>
|
||||
{
|
||||
it.material_id_unit_id = !string.IsNullOrEmpty(it.material_id_unit_id) ? dic[it.material_id_unit_id].ToString() : "";
|
||||
@@ -121,14 +117,14 @@ namespace Tnb.BasicData
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = await db.Queryable<BasEbomD>()
|
||||
.LeftJoin<BasEbomH>((a,b)=>a.ebom_id==b.id)
|
||||
.LeftJoin<BasMaterial>((a,b,c)=>a.material_id==c.id)
|
||||
.LeftJoin<BasEbomH>((a,b,c,d)=>a.material_id==d.material_id)
|
||||
.LeftJoin<BasRouteH>((a,b,c,d,e)=>d.route_id==e.id)
|
||||
.LeftJoin<BasMaterial>((a,b,c,d,e,f)=>a.substitute_material_id==f.id)
|
||||
.Where((a,b,c)=>b.material_id==queryInput.materialId && a.ebom_id==b.id)
|
||||
.Select((a,b,c,d,e,f)=>new EbomTreeOutput
|
||||
List<EbomTreeOutput> data = await db.Queryable<BasEbomD>()
|
||||
.LeftJoin<BasEbomH>((a, b) => a.ebom_id == b.id)
|
||||
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||
.LeftJoin<BasEbomH>((a, b, c, d) => a.material_id == d.material_id)
|
||||
.LeftJoin<BasRouteH>((a, b, c, d, e) => d.route_id == e.id)
|
||||
.LeftJoin<BasMaterial>((a, b, c, d, e, f) => a.substitute_material_id == f.id)
|
||||
.Where((a, b, c) => b.material_id == queryInput.materialId && a.ebom_id == b.id)
|
||||
.Select((a, b, c, d, e, f) => new EbomTreeOutput
|
||||
{
|
||||
material_id = c.name,
|
||||
material_id_descrip = c.descrip,
|
||||
@@ -142,15 +138,13 @@ namespace Tnb.BasicData
|
||||
route_name = e.name,
|
||||
version = d.version,
|
||||
substitute_material_id = f.name,
|
||||
hasChildren = SqlFunc.Subqueryable<BasEbomH>().Where(x=>x.material_id==a.material_id).Any(),
|
||||
hasChildren = SqlFunc.Subqueryable<BasEbomH>().Where(x => x.material_id == a.material_id).Any(),
|
||||
}).Mapper(it =>
|
||||
{
|
||||
it.material_id_unit_id = !string.IsNullOrEmpty(it.material_id_unit_id) ? dic[it.material_id_unit_id].ToString() : "";
|
||||
}).ToListAsync();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -159,11 +153,11 @@ namespace Tnb.BasicData
|
||||
/// <param name="parameters">物料id materialId</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Dictionary<string,string>> GetEbomVersionAndRouteName(Dictionary<string,string> parameters)
|
||||
public async Task<Dictionary<string, string>> GetEbomVersionAndRouteName(Dictionary<string, string> parameters)
|
||||
{
|
||||
string materialId = parameters["materialId"];
|
||||
var db = _repository.AsSugarClient();
|
||||
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
|
||||
// var momDbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(x => x.FullName == DbName.TNBMON);
|
||||
// if (momDbLink != null)
|
||||
// {
|
||||
@@ -171,16 +165,16 @@ namespace Tnb.BasicData
|
||||
// }
|
||||
|
||||
var ebom = await db.Queryable<BasEbomH>()
|
||||
.LeftJoin<BasRouteH>((a,b)=>a.route_id==b.id)
|
||||
.OrderByDescending((a,b)=>a.create_time)
|
||||
.Where((a,b) => a.material_id == materialId)
|
||||
.Select((a,b)=>new
|
||||
.LeftJoin<BasRouteH>((a, b) => a.route_id == b.id)
|
||||
.OrderByDescending((a, b) => a.create_time)
|
||||
.Where((a, b) => a.material_id == materialId)
|
||||
.Select((a, b) => new
|
||||
{
|
||||
a.id,
|
||||
a.version,
|
||||
b.name,
|
||||
}).FirstAsync();
|
||||
return new Dictionary<string,string>()
|
||||
return new Dictionary<string, string>()
|
||||
{
|
||||
["version"] = ebom?.version ?? "",
|
||||
["routeName"] = ebom?.name ?? "",
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entities.Enums;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
|
||||
@@ -32,19 +25,27 @@ namespace Tnb.BasicData
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetUnStoreLocationListByCarryId([FromRoute]string carryId)
|
||||
public async Task<dynamic> GetUnStoreLocationListByCarryId([FromRoute] string carryId)
|
||||
{
|
||||
|
||||
var items = await _db.Queryable<BasLocation>().Where(it => !string.IsNullOrEmpty(it.is_type) && Convert.ToInt32(it.is_type) != (int)EnumLocationType.存储库位).ToListAsync();
|
||||
|
||||
List<BasLocation> items = await _db.Queryable<BasLocation>().Where(it => !string.IsNullOrEmpty(it.is_type) && Convert.ToInt32(it.is_type) != (int)EnumLocationType.存储库位).ToListAsync();
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<BasLocation>> GetLocationInfobyIds(IEnumerable<string> locIds)
|
||||
{
|
||||
if (locIds == null) throw new ArgumentNullException(nameof(locIds));
|
||||
if (!locIds.Any()) throw new ArithmeticException($"parameter locIds.Count is not be empty");
|
||||
var items = await _db.Queryable<BasLocation>().Where(it => locIds.Contains(it.id)).ToListAsync();
|
||||
if (locIds == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(locIds));
|
||||
}
|
||||
|
||||
if (!locIds.Any())
|
||||
{
|
||||
throw new ArithmeticException($"parameter locIds.Count is not be empty");
|
||||
}
|
||||
|
||||
List<BasLocation> items = await _db.Queryable<BasLocation>().Where(it => locIds.Contains(it.id)).ToListAsync();
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,20 +21,20 @@ namespace Tnb.BasicData
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class BasMaterialService : IBasMaterialService,IDynamicApiController, ITransient
|
||||
public class BasMaterialService : IBasMaterialService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<BasMaterial> _repository;
|
||||
private readonly DataBaseManager _dbManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
|
||||
|
||||
public BasMaterialService(
|
||||
ISqlSugarRepository<BasMaterial> repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService)
|
||||
ISqlSugarRepository<BasMaterial> repository, DataBaseManager dbManager, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_repository = repository;
|
||||
_dbManager = dbManager;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 复制物料
|
||||
/// </summary>
|
||||
@@ -44,7 +44,7 @@ namespace Tnb.BasicData
|
||||
{
|
||||
string id = parameters["id"];
|
||||
BasMaterial basMaterial = await _repository.GetByIdAsync(id);
|
||||
|
||||
|
||||
List<BasMaterialUnit> materialUnits = await _repository.AsSugarClient().Queryable<BasMaterialUnit>().Where(x => x.material_id == id).ToListAsync();
|
||||
List<BasMaterialIntoFactorySpecifications> materialIntoFactorySpecifications = await _repository.AsSugarClient().Queryable<BasMaterialIntoFactorySpecifications>().Where(x => x.material_id == id).ToListAsync();
|
||||
|
||||
@@ -53,27 +53,26 @@ namespace Tnb.BasicData
|
||||
basMaterial.code += "_复制的请修改";
|
||||
basMaterial.name += "_复制的请修改";
|
||||
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.InsertAsync(basMaterial);
|
||||
_ = await _repository.InsertAsync(basMaterial);
|
||||
foreach (BasMaterialUnit basMaterialUnit in materialUnits)
|
||||
{
|
||||
basMaterialUnit.id = SnowflakeIdHelper.NextId();
|
||||
basMaterialUnit.material_id = newId;
|
||||
}
|
||||
|
||||
|
||||
foreach (BasMaterialIntoFactorySpecifications basMaterialIntoFactorySpecification in materialIntoFactorySpecifications)
|
||||
{
|
||||
basMaterialIntoFactorySpecification.id = SnowflakeIdHelper.NextId();
|
||||
basMaterialIntoFactorySpecification.material_id = newId;
|
||||
}
|
||||
|
||||
await _repository.AsSugarClient().Insertable<BasMaterialUnit>(materialUnits).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Insertable<BasMaterialIntoFactorySpecifications>(materialIntoFactorySpecifications).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Insertable<BasMaterialUnit>(materialUnits).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Insertable<BasMaterialIntoFactorySpecifications>(materialIntoFactorySpecifications).ExecuteCommandAsync();
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "复制成功" : result.ErrorMessage;
|
||||
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "复制成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,14 +83,17 @@ namespace Tnb.BasicData
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetMaterialSelectInfo(MaterialSelectQueryInput queryInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
if (!string.IsNullOrEmpty(queryInput.ebom_id))
|
||||
{
|
||||
List<string> ids = await GetAllChildrenMaterialId(queryInput.ebom_id,0);
|
||||
List<string> ids = await GetAllChildrenMaterialId(queryInput.ebom_id, 0);
|
||||
BasEbomH ebom = await db.Queryable<BasEbomH>().Where(x => x.id == queryInput.ebom_id).SingleAsync();
|
||||
if(ebom!=null && !string.IsNullOrEmpty(ebom.material_id))
|
||||
if (ebom != null && !string.IsNullOrEmpty(ebom.material_id))
|
||||
{
|
||||
ids.Add(ebom.material_id);
|
||||
var result = await db.Queryable<BasMaterial>()
|
||||
}
|
||||
|
||||
SqlSugarPagedList<MaterialSelectOutput> result = await db.Queryable<BasMaterial>()
|
||||
.LeftJoin<DictionaryTypeEntity>((a, b) => b.EnCode == DictConst.MeasurementUnit && b.DeleteMark == null)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c) => c.DictionaryTypeId == b.Id && a.unit_id == c.EnCode)
|
||||
.WhereIF(!string.IsNullOrEmpty(queryInput.material_info), (a, b, c) => a.code.Contains(queryInput.material_info) || a.name.Contains(queryInput.material_info))
|
||||
@@ -107,11 +109,11 @@ namespace Tnb.BasicData
|
||||
}).ToPagedListAsync(queryInput.currentPage, queryInput.pageSize);
|
||||
|
||||
return PageResult<MaterialSelectOutput>.SqlSugarPageResult(result);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await db.Queryable<BasMaterial>()
|
||||
SqlSugarPagedList<MaterialSelectOutput> result = await db.Queryable<BasMaterial>()
|
||||
.LeftJoin<DictionaryTypeEntity>((a, b) => b.EnCode == DictConst.MeasurementUnit && b.DeleteMark == null)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c) => c.DictionaryTypeId == b.Id && a.unit_id == c.EnCode)
|
||||
.WhereIF(!string.IsNullOrEmpty(queryInput.material_info), (a, b, c) => a.code.Contains(queryInput.material_info) || a.name.Contains(queryInput.material_info))
|
||||
@@ -132,16 +134,16 @@ namespace Tnb.BasicData
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetCanCreateSubWorkOrderMaterial(MaterialSelectQueryInput queryInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
if (!string.IsNullOrEmpty(queryInput.ebom_id))
|
||||
{
|
||||
List<string> ids = await GetAllChildrenMaterialId(queryInput.ebom_id,0);
|
||||
var result = await db.Queryable<BasMaterial>()
|
||||
List<string> ids = await GetAllChildrenMaterialId(queryInput.ebom_id, 0);
|
||||
SqlSugarPagedList<MaterialSelectOutput> result = await db.Queryable<BasMaterial>()
|
||||
.LeftJoin<DictionaryTypeEntity>((a, b) => b.EnCode == DictConst.MeasurementUnit && b.DeleteMark == null)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c) => c.DictionaryTypeId == b.Id && a.unit_id == c.EnCode)
|
||||
.WhereIF(!string.IsNullOrEmpty(queryInput.material_info), (a, b, c) => a.code.Contains(queryInput.material_info) || a.name.Contains(queryInput.material_info))
|
||||
.WhereIF(!string.IsNullOrEmpty(queryInput.ebom_id), (a, b, c) => ids.Contains(a.id))
|
||||
.Where((a,b,c)=>a.is_create_sub_work_order=="1")
|
||||
.Where((a, b, c) => a.is_create_sub_work_order == "1")
|
||||
.Select((a, b, c) => new MaterialSelectOutput()
|
||||
{
|
||||
id = a.id,
|
||||
@@ -153,7 +155,7 @@ namespace Tnb.BasicData
|
||||
}).ToPagedListAsync(queryInput.currentPage, queryInput.pageSize);
|
||||
|
||||
return PageResult<MaterialSelectOutput>.SqlSugarPageResult(result);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -166,32 +168,32 @@ namespace Tnb.BasicData
|
||||
{
|
||||
string types = dic["types"];
|
||||
string[] typeArr = types.Split(",");
|
||||
List<BasMaterial> list = await _repository.AsSugarClient().Queryable<BasMaterial>().Where(x => x.state=="1").ToListAsync();
|
||||
List<BasMaterial> result = new List<BasMaterial>();
|
||||
foreach (var type in typeArr)
|
||||
List<BasMaterial> list = await _repository.AsSugarClient().Queryable<BasMaterial>().Where(x => x.state == "1").ToListAsync();
|
||||
List<BasMaterial> result = new();
|
||||
foreach (string type in typeArr)
|
||||
{
|
||||
result.AddRange(list.Where(x=>x.category_id.Contains(type)));
|
||||
result.AddRange(list.Where(x => x.category_id.Contains(type)));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetMaterialByQueryJson(MaterialQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, string>? queryJson = new Dictionary<string, string>();
|
||||
if (input!=null && !string.IsNullOrEmpty(input.queryJson))
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, string>? queryJson = new();
|
||||
if (input != null && !string.IsNullOrEmpty(input.queryJson))
|
||||
{
|
||||
queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input?.queryJson ?? "");
|
||||
}
|
||||
|
||||
List<string> typeList = new List<string>();
|
||||
if(!string.IsNullOrEmpty(input!.types))
|
||||
List<string> typeList = new();
|
||||
if (!string.IsNullOrEmpty(input!.types))
|
||||
{
|
||||
typeList = JsonConvert.DeserializeObject<List<string>>((input?.types??"")) ?? new List<string>();
|
||||
typeList = JsonConvert.DeserializeObject<List<string>>(input?.types ?? "") ?? new List<string>();
|
||||
}
|
||||
var query = db.Queryable<BasMaterial>()
|
||||
ISugarQueryable<BasMaterial> query = db.Queryable<BasMaterial>()
|
||||
.Where(x => x.state == "1")
|
||||
.WhereIF(queryJson != null && queryJson.ContainsKey("name"), x => x.name.Contains(queryJson!["name"]))
|
||||
.WhereIF(queryJson != null && queryJson.ContainsKey("code"), x => x.code.Contains(queryJson!["code"]))
|
||||
@@ -199,43 +201,51 @@ namespace Tnb.BasicData
|
||||
x => x.material_standard!.Contains(queryJson!["material_standard"]))
|
||||
.Select(x => x);
|
||||
|
||||
var list = new List<ISugarQueryable<BasMaterial>>();
|
||||
foreach (var type in typeList)
|
||||
List<ISugarQueryable<BasMaterial>> list = new();
|
||||
foreach (string type in typeList)
|
||||
{
|
||||
list.Add(query.Clone().Where(x=>x.category_id.Contains(type)));
|
||||
list.Add(query.Clone().Where(x => x.category_id.Contains(type)));
|
||||
}
|
||||
|
||||
if (list.Count <= 0)
|
||||
{
|
||||
var result = await query.ToPagedListAsync((input?.currentPage??1), (input?.pageSize??50));
|
||||
SqlSugarPagedList<BasMaterial> result = await query.ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
|
||||
return PageResult<BasMaterial>.SqlSugarPageResult(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await db.UnionAll(list).Select<BasMaterial>().ToPagedListAsync((input?.currentPage??1), (input?.pageSize??50));
|
||||
SqlSugarPagedList<BasMaterial> result = await db.UnionAll(list).Select<BasMaterial>().ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
|
||||
return PageResult<BasMaterial>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料清单下所子集物料id
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<List<string>> GetAllChildrenMaterialId(string ebomId,int index)
|
||||
private async Task<List<string>> GetAllChildrenMaterialId(string ebomId, int index)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ebomId)) return new List<string>();
|
||||
List<string> ids = new List<string>();
|
||||
if (index++ > 10) return ids;
|
||||
var list = await _repository.AsSugarClient().Queryable<BasEbomD>().Where(x => x.ebom_id == ebomId)
|
||||
if (string.IsNullOrEmpty(ebomId))
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
List<string> ids = new();
|
||||
if (index++ > 10)
|
||||
{
|
||||
return ids;
|
||||
}
|
||||
|
||||
List<string> list = await _repository.AsSugarClient().Queryable<BasEbomD>().Where(x => x.ebom_id == ebomId)
|
||||
.Select<string>(x => x.material_id).ToListAsync();
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
foreach (var id in list)
|
||||
foreach (string id in list)
|
||||
{
|
||||
//获取最新创建的物料清单
|
||||
var ebom = await _repository.AsSugarClient().Queryable<BasEbomH>().Where(x=>x.material_id==id).OrderByDescending(x=>x.create_time).FirstAsync();
|
||||
ids.AddRange(await GetAllChildrenMaterialId(ebom?.id ?? "",index));
|
||||
BasEbomH ebom = await _repository.AsSugarClient().Queryable<BasEbomH>().Where(x => x.material_id == id).OrderByDescending(x => x.create_time).FirstAsync();
|
||||
ids.AddRange(await GetAllChildrenMaterialId(ebom?.id ?? "", index));
|
||||
}
|
||||
ids.AddRange(list);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
@@ -11,10 +12,8 @@ using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
using NPOI.OpenXmlFormats.Dml;
|
||||
using JNPF.Common.Extension;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
@@ -56,10 +55,10 @@ namespace Tnb.BasicData
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, object>? queryJson = string.IsNullOrEmpty(input.queryJson) ? null : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||
string materialInfo = queryJson?["query_info"]?.ToString() ?? "";
|
||||
var list = await db.Queryable<BasMbom, BasMaterial, BasEbomH, BasRouteH>((a, b, c, d) => new object[]
|
||||
SqlSugarPagedList<MbomListOutput> list = await db.Queryable<BasMbom, BasMaterial, BasEbomH, BasRouteH>((a, b, c, d) => new object[]
|
||||
{
|
||||
JoinType.Left, a.material_id == b.id,
|
||||
JoinType.Left, a.ebom_id == c.id,
|
||||
@@ -75,8 +74,8 @@ namespace Tnb.BasicData
|
||||
ebom_id = c.version,
|
||||
route_id = d.name,
|
||||
route_id_id = c.id,
|
||||
start_time = a.start_time==null ? "" : a.start_time.Value.ToString("yyyy-MM-dd"),
|
||||
end_time = a.end_time==null ? "" : a.end_time.Value.ToString("yyyy-MM-dd"),
|
||||
start_time = a.start_time == null ? "" : a.start_time.Value.ToString("yyyy-MM-dd"),
|
||||
end_time = a.end_time == null ? "" : a.end_time.Value.ToString("yyyy-MM-dd"),
|
||||
is_first = SqlFunc.IIF(a.is_first == 0, "否", "是"),
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
|
||||
@@ -90,13 +89,13 @@ namespace Tnb.BasicData
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> GetInfo(string id)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
BasMbom mbom = await _repository.GetSingleAsync(x => x.id == id);
|
||||
List<BasMbomProcess> processes = await db.Queryable<BasMbomProcess>().Where(x => x.mbom_id == id).OrderBy(x=>x.ordinal).ToListAsync();
|
||||
List<BasMbomProcess> processes = await db.Queryable<BasMbomProcess>().Where(x => x.mbom_id == id).OrderBy(x => x.ordinal).ToListAsync();
|
||||
List<BasMbomInput> inputs = await db.Queryable<BasMbomInput>().Where(x => x.mbom_id == id).ToListAsync();
|
||||
List<BasMbomOutput> outputs = await db.Queryable<BasMbomOutput>().Where(x => x.mbom_id == id).ToListAsync();
|
||||
MbomDataOutput mbomDataOutput = new MbomDataOutput();
|
||||
List<MbomProcessOutDto> mbomProcessOutDtos = new List<MbomProcessOutDto>();
|
||||
MbomDataOutput mbomDataOutput = new();
|
||||
List<MbomProcessOutDto> mbomProcessOutDtos = new();
|
||||
|
||||
mbomDataOutput.id = mbom.id;
|
||||
mbomDataOutput.ebom_id = mbom.ebom_id;
|
||||
@@ -158,9 +157,12 @@ namespace Tnb.BasicData
|
||||
public async Task<dynamic> GetSubMoListByBomId([FromRoute] string bomId)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(bomId)) throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty");
|
||||
if (string.IsNullOrEmpty(bomId))
|
||||
{
|
||||
throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty");
|
||||
}
|
||||
|
||||
var result = await _db.Queryable<BasMbom>()
|
||||
List<SubBomListOutput> result = await _db.Queryable<BasMbom>()
|
||||
.LeftJoin<BasMbomProcess>((a, b) => a.id == b.mbom_id)
|
||||
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||
// .LeftJoin<BasRouteD>((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id)
|
||||
@@ -182,7 +184,7 @@ namespace Tnb.BasicData
|
||||
})
|
||||
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -194,7 +196,7 @@ namespace Tnb.BasicData
|
||||
.Where(x => x.mbom_process_id == id)
|
||||
.Select(x => new
|
||||
{
|
||||
material_id = x.material_id,
|
||||
x.material_id,
|
||||
}).ToListAsync();
|
||||
return result;
|
||||
|
||||
@@ -231,13 +233,13 @@ namespace Tnb.BasicData
|
||||
material_name = b.name,
|
||||
start_time = a.start_time.HasValue ? a.start_time.Value.ToString(DbTimeFormat.SS) : null,
|
||||
end_time = a.end_time.HasValue ? a.end_time.Value.ToString(DbTimeFormat.SS) : null,
|
||||
version = a.version,
|
||||
a.version,
|
||||
route_id = c.id,
|
||||
route_name = c.name,
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// 保存生产bom
|
||||
// /// </summary>
|
||||
@@ -512,7 +514,7 @@ namespace Tnb.BasicData
|
||||
// }
|
||||
// return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||
// }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存生产bom
|
||||
/// </summary>
|
||||
@@ -529,7 +531,7 @@ namespace Tnb.BasicData
|
||||
{
|
||||
string mbomId = SnowflakeIdHelper.NextId();
|
||||
string orgId = _userManager.GetUserInfo().Result.organizeId;
|
||||
BasMbom mbom = new BasMbom()
|
||||
BasMbom mbom = new()
|
||||
{
|
||||
id = mbomId,
|
||||
org_id = orgId,
|
||||
@@ -554,15 +556,15 @@ namespace Tnb.BasicData
|
||||
errorCode = ErrorCode.COM1004;
|
||||
throw Oops.Oh(ErrorCode.COM1004);
|
||||
}
|
||||
await _repository.InsertAsync(mbom);
|
||||
List<BasMbomProcess> processes = new List<BasMbomProcess>();
|
||||
List<BasMbomInput> inputs = new List<BasMbomInput>();
|
||||
List<BasMbomOutput> outputs = new List<BasMbomOutput>();
|
||||
_ = await _repository.InsertAsync(mbom);
|
||||
List<BasMbomProcess> processes = new();
|
||||
List<BasMbomInput> inputs = new();
|
||||
List<BasMbomOutput> outputs = new();
|
||||
|
||||
if (mbomSaveDataInput != null && mbomSaveDataInput.processes != null)
|
||||
{
|
||||
int index = 0;
|
||||
foreach (var process in mbomSaveDataInput.processes)
|
||||
int index = 0;
|
||||
foreach (MbomProcessDto? process in mbomSaveDataInput.processes)
|
||||
{
|
||||
string mbomProcessId = SnowflakeIdHelper.NextId();
|
||||
processes.Add(new BasMbomProcess()
|
||||
@@ -586,7 +588,7 @@ namespace Tnb.BasicData
|
||||
|
||||
if (process.inputs != null)
|
||||
{
|
||||
foreach (var input in process.inputs)
|
||||
foreach (BasMbomInput input in process.inputs)
|
||||
{
|
||||
string inputId = SnowflakeIdHelper.NextId();
|
||||
inputs.Add(new BasMbomInput()
|
||||
@@ -605,7 +607,7 @@ namespace Tnb.BasicData
|
||||
|
||||
if (process.outputs != null)
|
||||
{
|
||||
foreach (var output in process.outputs)
|
||||
foreach (BasMbomOutput output in process.outputs)
|
||||
{
|
||||
string outputId = SnowflakeIdHelper.NextId();
|
||||
outputs.Add(new BasMbomOutput()
|
||||
@@ -626,17 +628,17 @@ namespace Tnb.BasicData
|
||||
|
||||
if (processes.Count > 0)
|
||||
{
|
||||
await _repository.AsSugarClient().Insertable<BasMbomProcess>(processes).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Insertable<BasMbomProcess>(processes).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (inputs.Count > 0)
|
||||
{
|
||||
await _repository.AsSugarClient().Insertable<BasMbomInput>(inputs).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Insertable<BasMbomInput>(inputs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (outputs.Count > 0)
|
||||
{
|
||||
await _repository.AsSugarClient().Insertable<BasMbomOutput>(outputs).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Insertable<BasMbomOutput>(outputs).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else//修改
|
||||
@@ -651,7 +653,7 @@ namespace Tnb.BasicData
|
||||
string orgId = _userManager.GetUserInfo().Result.organizeId;
|
||||
if (mbomSaveDataInput != null)
|
||||
{
|
||||
await _repository.UpdateAsync(x => new BasMbom()
|
||||
_ = await _repository.UpdateAsync(x => new BasMbom()
|
||||
{
|
||||
// org_id = orgId,
|
||||
material_id = mbomSaveDataInput.material_id,
|
||||
@@ -670,12 +672,12 @@ namespace Tnb.BasicData
|
||||
}, x => x.id == mbomSaveDataInput.id);
|
||||
}
|
||||
// List<BasMbomProcess> processes = new List<BasMbomProcess>();
|
||||
List<BasMbomInput> inputs = new List<BasMbomInput>();
|
||||
List<BasMbomOutput> outputs = new List<BasMbomOutput>();
|
||||
List<BasMbomInput> inputs = new();
|
||||
List<BasMbomOutput> outputs = new();
|
||||
|
||||
if (mbomSaveDataInput != null && mbomSaveDataInput.processes != null)
|
||||
{
|
||||
foreach (var process in mbomSaveDataInput.processes)
|
||||
foreach (MbomProcessDto? process in mbomSaveDataInput.processes)
|
||||
{
|
||||
string mbomProcessId = process.id;
|
||||
// string mbomProcessId = SnowflakeIdHelper.NextId();
|
||||
@@ -692,9 +694,9 @@ namespace Tnb.BasicData
|
||||
// route_detail_id = process.route_detail_id,
|
||||
//
|
||||
// });
|
||||
|
||||
|
||||
decimal preparation_time = process?.preparation_time ?? 0;
|
||||
await _repository.AsSugarClient().Updateable<BasMbomProcess>()
|
||||
_ = await _repository.AsSugarClient().Updateable<BasMbomProcess>()
|
||||
.SetColumns(x => x.preparation_time == preparation_time)
|
||||
.SetColumns(x => x.station == process!.station)
|
||||
.SetColumns(x => x.byproduct_status == process!.byproduct_status)
|
||||
@@ -703,7 +705,7 @@ namespace Tnb.BasicData
|
||||
|
||||
if (process!.inputs != null)
|
||||
{
|
||||
foreach (var input in process.inputs)
|
||||
foreach (BasMbomInput input in process.inputs)
|
||||
{
|
||||
string inputId = SnowflakeIdHelper.NextId();
|
||||
inputs.Add(new BasMbomInput()
|
||||
@@ -722,7 +724,7 @@ namespace Tnb.BasicData
|
||||
|
||||
if (process.outputs != null)
|
||||
{
|
||||
foreach (var output in process.outputs)
|
||||
foreach (BasMbomOutput output in process.outputs)
|
||||
{
|
||||
string outputId = SnowflakeIdHelper.NextId();
|
||||
outputs.Add(new BasMbomOutput()
|
||||
@@ -744,9 +746,9 @@ namespace Tnb.BasicData
|
||||
|
||||
if (mbomSaveDataInput != null && !string.IsNullOrEmpty(mbomSaveDataInput.id))
|
||||
{
|
||||
// await _repository.AsSugarClient().Deleteable<BasMbomProcess>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Deleteable<BasMbomInput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Deleteable<BasMbomOutput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
// await _repository.AsSugarClient().Deleteable<BasMbomProcess>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Deleteable<BasMbomInput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Deleteable<BasMbomOutput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
}
|
||||
// if (processes.Count > 0)
|
||||
// {
|
||||
@@ -755,12 +757,12 @@ namespace Tnb.BasicData
|
||||
|
||||
if (inputs.Count > 0)
|
||||
{
|
||||
await _repository.AsSugarClient().Insertable<BasMbomInput>(inputs).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Insertable<BasMbomInput>(inputs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (outputs.Count > 0)
|
||||
{
|
||||
await _repository.AsSugarClient().Insertable<BasMbomOutput>(outputs).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Insertable<BasMbomOutput>(outputs).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
@@ -7,20 +6,15 @@ using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entitys.Dto.BasProcess;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
@@ -64,21 +58,16 @@ namespace Tnb.BasicData
|
||||
/// <returns></returns>
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var result = new SqlSugarPagedList<ProcessListOutput>();
|
||||
var db = _repository.AsSugarClient();
|
||||
var organize = await db.Queryable<OrganizeEntity>().FirstAsync(it => it.EnCode == input.station_code && it.Category == DictConst.RegionCategoryStationCode);
|
||||
SqlSugarPagedList<ProcessListOutput> result = new();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
OrganizeEntity organize = await db.Queryable<OrganizeEntity>().FirstAsync(it => it.EnCode == input.station_code && it.Category == DictConst.RegionCategoryStationCode);
|
||||
if (organize != null)
|
||||
{
|
||||
var whereExpr = Expressionable.Create<BasProcess, BasProcessStation>();
|
||||
var curProcessIds = await db.Queryable<BasProcessStation>().Where(it => it.station_id == organize.Id).Select(it => it.process_id).Distinct().ToListAsync();
|
||||
if (curProcessIds?.Count > 0)
|
||||
{
|
||||
whereExpr = whereExpr.And((a, b) => curProcessIds.Contains(a.id)).Or((a, b) => string.IsNullOrEmpty(b.process_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
whereExpr = whereExpr.And((a, b) => string.IsNullOrEmpty(b.process_id));
|
||||
}
|
||||
Expressionable<BasProcess, BasProcessStation> whereExpr = Expressionable.Create<BasProcess, BasProcessStation>();
|
||||
List<string> curProcessIds = await db.Queryable<BasProcessStation>().Where(it => it.station_id == organize.Id).Select(it => it.process_id).Distinct().ToListAsync();
|
||||
whereExpr = curProcessIds?.Count > 0
|
||||
? whereExpr.And((a, b) => curProcessIds.Contains(a.id)).Or((a, b) => string.IsNullOrEmpty(b.process_id))
|
||||
: whereExpr.And((a, b) => string.IsNullOrEmpty(b.process_id));
|
||||
result = await db.Queryable<BasProcess>().LeftJoin<BasProcessStation>((a, b) => a.id == b.process_id).Where(whereExpr.ToExpression()).Select(a => new ProcessListOutput
|
||||
{
|
||||
id = a.id,
|
||||
@@ -118,8 +107,8 @@ namespace Tnb.BasicData
|
||||
|
||||
string processId = visualDevModelDataCrInput.data["ReturnIdentity"].ToString() ?? "";
|
||||
|
||||
List<BasProcessStation> list = new List<BasProcessStation>();
|
||||
foreach (var item in (JArray)visualDevModelDataCrInput.data["station"])
|
||||
List<BasProcessStation> list = new();
|
||||
foreach (JToken item in (JArray)visualDevModelDataCrInput.data["station"])
|
||||
{
|
||||
|
||||
string processStationId = SnowflakeIdHelper.NextId();
|
||||
@@ -134,11 +123,10 @@ namespace Tnb.BasicData
|
||||
});
|
||||
}
|
||||
|
||||
await _repository.AsSugarClient().Insertable<BasProcessStation>(list).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Insertable<BasProcessStation>(list).ExecuteCommandAsync();
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result.IsSuccess ? "保存成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
@@ -28,7 +26,7 @@ namespace Tnb.BasicData
|
||||
public async Task<dynamic> Stop(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
await _repository.UpdateAsync(x => new BasPushRuleLog()
|
||||
_ = await _repository.UpdateAsync(x => new BasPushRuleLog()
|
||||
{
|
||||
is_push = 0,
|
||||
}, x => x.biz_id == id);
|
||||
|
||||
@@ -6,8 +6,6 @@ using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
using Tnb.BasicData.Entitys.Dto.BasProcess;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
@@ -19,14 +17,14 @@ namespace Tnb.BasicData
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class BasQrcodeService : IBasQrcodeService,IDynamicApiController, ITransient
|
||||
public class BasQrcodeService : IBasQrcodeService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<BasMaterial> _repository;
|
||||
private readonly DataBaseManager _dbManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
|
||||
|
||||
public BasQrcodeService(
|
||||
ISqlSugarRepository<BasMaterial> repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService)
|
||||
ISqlSugarRepository<BasMaterial> repository, DataBaseManager dbManager, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_repository = repository;
|
||||
_dbManager = dbManager;
|
||||
@@ -34,22 +32,26 @@ namespace Tnb.BasicData
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetQrcodeByCode(Dictionary<string, string> dic)
|
||||
public async Task<dynamic?> GetQrcodeByCode(Dictionary<string, string> dic)
|
||||
{
|
||||
string code = dic.ContainsKey("code") ? dic["code"] : "";
|
||||
if (string.IsNullOrEmpty(code)) return null;
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = await _repository.AsSugarClient().Queryable<BasQrcode>()
|
||||
.LeftJoin<OrganizeEntity>((a, b) => a.source_id == b.Id)
|
||||
.LeftJoin<EqpEquipment>((a, b, c) => a.source_id == c.id)
|
||||
.LeftJoin<ToolLocation>((a, b, c, d) => a.source_id == d.id)
|
||||
.LeftJoin<BasLocation>((a,b,c,d,e)=>a.source_id==e.id)
|
||||
.LeftJoin<WmsCarryH>((a,b,c,d,e,f)=>a.source_id==f.id)
|
||||
.LeftJoin<BasLocation>((a, b, c, d, e) => a.source_id == e.id)
|
||||
.LeftJoin<WmsCarryH>((a, b, c, d, e, f) => a.source_id == f.id)
|
||||
.Where((a, b, c, d) => a.code == code)
|
||||
.Select((a, b, c, d,e,f) => new
|
||||
.Select((a, b, c, d, e, f) => new
|
||||
{
|
||||
id = a.id,
|
||||
source_id = a.source_id,
|
||||
source_name = a.source_name,
|
||||
a.id,
|
||||
a.source_id,
|
||||
a.source_name,
|
||||
org_code = b.EnCode,
|
||||
org_name = b.FullName,
|
||||
equip_code = a.code,
|
||||
@@ -57,27 +59,31 @@ namespace Tnb.BasicData
|
||||
tool_location_code = d.location_code,
|
||||
bas_location_name = e.location_name,
|
||||
bas_location_code = e.location_code,
|
||||
carry_name = f.carry_name,
|
||||
carry_code = f.carry_code,
|
||||
f.carry_name,
|
||||
f.carry_code,
|
||||
}).FirstAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetWorkStationByCode(Dictionary<string, string> dic)
|
||||
public async Task<dynamic?> GetWorkStationByCode(Dictionary<string, string> dic)
|
||||
{
|
||||
string code = dic.ContainsKey("code") ? dic["code"] : "";
|
||||
if (string.IsNullOrEmpty(code)) return null;
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = await _repository.AsSugarClient().Queryable<BasQrcode>()
|
||||
.LeftJoin<OrganizeEntity>((a, b) => a.source_id == b.Id)
|
||||
.LeftJoin<OrganizeRelationEntity>((a,b,c)=>a.source_id==c.ObjectId && c.ObjectType=="Eqp")
|
||||
.LeftJoin<OrganizeEntity>((a,b,c,d)=>c.OrganizeId==d.Id)
|
||||
.LeftJoin<OrganizeRelationEntity>((a, b, c) => a.source_id == c.ObjectId && c.ObjectType == "Eqp")
|
||||
.LeftJoin<OrganizeEntity>((a, b, c, d) => c.OrganizeId == d.Id)
|
||||
.Where((a, b, c) => a.code == code)
|
||||
.Select((a, b, c,d) => new
|
||||
.Select((a, b, c, d) => new
|
||||
{
|
||||
id = a.id,
|
||||
source_id = a.source_id,
|
||||
source_name = a.source_name,
|
||||
a.id,
|
||||
a.source_id,
|
||||
a.source_name,
|
||||
org_id = b.Id,
|
||||
org_code = b.EnCode,
|
||||
org_name = b.FullName,
|
||||
|
||||
@@ -9,8 +9,8 @@ using JNPF.FriendlyException;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
@@ -19,11 +19,11 @@ namespace Tnb.BasicData
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 701)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class BasRouteService : IBasRouteService,IDynamicApiController, ITransient
|
||||
public class BasRouteService : IBasRouteService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<BasRouteH> _repository;
|
||||
|
||||
|
||||
|
||||
|
||||
public BasRouteService(
|
||||
UserManager userManager,
|
||||
ISqlSugarRepository<BasRouteH> repository)
|
||||
@@ -40,12 +40,12 @@ namespace Tnb.BasicData
|
||||
{
|
||||
string id = parameters["id"];
|
||||
|
||||
await _repository.UpdateAsync(x => new BasRouteH()
|
||||
_ = await _repository.UpdateAsync(x => new BasRouteH()
|
||||
{
|
||||
status = "1",
|
||||
}, x => x.id == id);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 复制工艺路线
|
||||
/// </summary>
|
||||
@@ -55,7 +55,7 @@ namespace Tnb.BasicData
|
||||
{
|
||||
string id = parameters["id"];
|
||||
BasRouteH basRouteH = await _repository.GetByIdAsync(id);
|
||||
|
||||
|
||||
List<BasRouteD> basRouteDs = await _repository.AsSugarClient().Queryable<BasRouteD>().Where(x => x.route_id == id).ToListAsync();
|
||||
|
||||
string newId = SnowflakeIdHelper.NextId();
|
||||
@@ -64,42 +64,41 @@ namespace Tnb.BasicData
|
||||
basRouteH.name += "_复制的请修改";
|
||||
basRouteH.status = "0";
|
||||
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.InsertAsync(basRouteH);
|
||||
_ = await _repository.InsertAsync(basRouteH);
|
||||
foreach (BasRouteD basRouteD in basRouteDs)
|
||||
{
|
||||
basRouteD.id = SnowflakeIdHelper.NextId();
|
||||
basRouteD.route_id = newId;
|
||||
}
|
||||
|
||||
await _repository.AsSugarClient().Insertable<BasRouteD>(basRouteDs).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Insertable<BasRouteD>(basRouteDs).ExecuteCommandAsync();
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "复制成功" : result.ErrorMessage;
|
||||
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "复制成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取有效的已发布的工艺路线
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetValidRouteList([FromBody]VisualDevDataFieldDataListInput pageInput)
|
||||
public async Task<dynamic> GetValidRouteList([FromBody] VisualDevDataFieldDataListInput pageInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var result = await db.Queryable<BasRouteH>()
|
||||
.Where(x => x.status == "1"
|
||||
&& ((x.start_time != null && x.start_time.Value <= DateTime.Now && x.end_time != null && x.end_time.Value>=DateTime.Now)
|
||||
|| (x.start_time==null && x.end_time>=DateTime.Now)
|
||||
|| (x.end_time==null && x.start_time<=DateTime.Now)
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
SqlSugarPagedList<VaildRouteOutput> result = await db.Queryable<BasRouteH>()
|
||||
.Where(x => x.status == "1"
|
||||
&& ((x.start_time != null && x.start_time.Value <= DateTime.Now && x.end_time != null && x.end_time.Value >= DateTime.Now)
|
||||
|| (x.start_time == null && x.end_time >= DateTime.Now)
|
||||
|| (x.end_time == null && x.start_time <= DateTime.Now)
|
||||
|| (x.start_time == null && x.end_time == null)
|
||||
)).Select(x=>new VaildRouteOutput()
|
||||
)).Select(x => new VaildRouteOutput()
|
||||
{
|
||||
id = x.id,
|
||||
code = x.code,
|
||||
name = x.name,
|
||||
start_time = x.start_time==null ? "" : x.start_time.Value.ToString("yyyy-MM-dd"),
|
||||
end_time = x.end_time==null ? "" : x.end_time.Value.ToString("yyyy-MM-dd"),
|
||||
start_time = x.start_time == null ? "" : x.start_time.Value.ToString("yyyy-MM-dd"),
|
||||
end_time = x.end_time == null ? "" : x.end_time.Value.ToString("yyyy-MM-dd"),
|
||||
}).ToPagedListAsync(pageInput.currentPage, pageInput.pageSize);
|
||||
return PageResult<VaildRouteOutput>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$(SolutionDir)\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
||||
Reference in New Issue
Block a user