This commit is contained in:
DEVICE8\12494
2023-05-17 17:56:25 +08:00
139 changed files with 27149 additions and 899 deletions

View File

@@ -0,0 +1,111 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.VisualDev.Interfaces;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.EquipMgr.Entities;
using Tnb.EquipMgr.Interfaces;
using Tnb.EquipMgr.Entities.Dto;
namespace Tnb.EquipMgr
{
/// <summary>
/// 点巡检模板管理
/// </summary>
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
public class EqpSpotInsTemService : IEqpSpotInsTemService, IDynamicApiController, ITransient
{
private const string ModuleId = "26123080740885";
private readonly ISqlSugarRepository<EqpSpotInsTemH> _repository;
private readonly IUserManager _userManager;
public EqpSpotInsTemService(ISqlSugarRepository<EqpSpotInsTemH> repository,
IUserManager userManager,
IVisualDevService visualDevService)
{
_repository = repository;
_userManager = userManager;
}
public async Task<string> Publish(SpotInsTemPublishInput input)
{
var db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
EqpSpotInsTemH eqpSpotInsTemH = await _repository.GetSingleAsync(x => x.id == input.id);
List<EqpSpotInsTemD> eqpSpotInsTemDs = await db.Queryable<EqpSpotInsTemD>().Where(x=>x.spot_ins_item_id==input.id).ToListAsync();
if (input.equipIds != null && input.equipIds.Length > 0)
{
List<EqpSpotInsTemEquipH> insertEqpSpotInsTemEquipHs = new List<EqpSpotInsTemEquipH>();
List<EqpSpotInsTemEquipD> insertEqpSpotInsTemEquipDs = new List<EqpSpotInsTemEquipD>();
foreach (var equipId in input.equipIds)
{
string id = SnowflakeIdHelper.NextId();
string code = $"{DateTime.Now.ToString("yyyy-MM-dd") + equipId}";
EqpSpotInsTemEquipH eqpSpotInsTemEquipH = new EqpSpotInsTemEquipH()
{
id = id,
code = code,
name = eqpSpotInsTemH.name+equipId,
plan_cycle = eqpSpotInsTemH.plan_cycle,
plan_cycle_unit = eqpSpotInsTemH.plan_cycle_unit,
plan_run_notice = eqpSpotInsTemH.plan_run_notice,
plan_delay = eqpSpotInsTemH.plan_delay,
start_time = eqpSpotInsTemH.start_time,
is_start = eqpSpotInsTemH.is_start.ToString(),
is_repeat = eqpSpotInsTemH.is_repeat.ToString(),
is_send = eqpSpotInsTemH.is_send,
spot_ins_tem_id = input.id,
equip_id = equipId,
remark = eqpSpotInsTemH.remark,
plan_run_notice_unit = eqpSpotInsTemH.plan_run_notice_unit,
plan_delay_unit = eqpSpotInsTemH.plan_delay_unit,
repeat_post_info_user_id = eqpSpotInsTemH.repeat_post_info_user_id,
send_post_info_user_id = eqpSpotInsTemH.send_post_info_user_id,
send_post_id = eqpSpotInsTemH.send_post_id,
org_id = eqpSpotInsTemH.org_id,
create_id = _userManager.UserId,
create_time = DateTime.Now,
};
insertEqpSpotInsTemEquipHs.Add(eqpSpotInsTemEquipH);
if (eqpSpotInsTemDs != null && eqpSpotInsTemDs.Count > 0)
{
foreach (var eqpSpotInsTem in eqpSpotInsTemDs)
{
EqpSpotInsTemEquipD eqpSpotInsTemEquipD = new EqpSpotInsTemEquipD()
{
id = SnowflakeIdHelper.NextId(),
spot_ins_item_id = eqpSpotInsTem.id,
spot_ins_tem_equip_id = id,
};
insertEqpSpotInsTemEquipDs.Add(eqpSpotInsTemEquipD);
}
}
}
if (insertEqpSpotInsTemEquipHs != null && insertEqpSpotInsTemEquipHs.Count > 0)
{
await db.Insertable(insertEqpSpotInsTemEquipHs).ExecuteCommandAsync();
}
if (insertEqpSpotInsTemEquipDs != null && insertEqpSpotInsTemEquipDs.Count > 0)
{
await db.Insertable(insertEqpSpotInsTemEquipDs).ExecuteCommandAsync();
}
}
});
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "发布成功" : result.ErrorMessage;
}
}
}

View File

@@ -0,0 +1,82 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Enums;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SqlSugar;
using Tnb.EquipMgr.Entities;
using Tnb.EquipMgr.Interfaces;
namespace Tnb.EquipMgr
{
/// <summary>
/// 点巡检执行管理
/// </summary>
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
[OverideVisualDev(ModuleId)]
public class EquSpotInsRecordService : IOverideVisualDevService, IEquSpotInsRecordService, IDynamicApiController, ITransient
{
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
private const string ModuleId = "26123080740885";
private readonly ISqlSugarRepository<EqpSpotInsRecordH> _repository;
private readonly IVisualDevService _visualDevService;
private readonly IRunService _runService;
private readonly IUserManager _userManager;
public EquSpotInsRecordService(ISqlSugarRepository<EqpSpotInsRecordH> repository,
IRunService runService,
IUserManager userManager,
IVisualDevService visualDevService)
{
_repository = repository;
_visualDevService = visualDevService;
_runService = runService;
_userManager = userManager;
OverideFuncs.UpdateAsync = ExecuteSpotIns;
}
public async Task<dynamic> ExecuteSpotIns(string id,[FromBody]VisualDevModelDataUpInput input)
{
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
{
//string attachment = JsonConvert.SerializeObject(input.data["attachment"]);
// _repository.UpdateAsync(x => new EqpSpotInsRecordH()
// {
// result = (int)input.data["result"],
// attachment = attachment,
// result_remark = input.data["result_remark"].ToString(),
// }, x => x.id == input.data["id"]);
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
await _runService.Update(id,templateEntity, input);
EqpSpotInsRecordH eqpSpotInsRecordH = _repository.GetSingle(x=>x.id==input.data["id"].ToString());
string status = "";
if (eqpSpotInsRecordH.is_repeat == "1")
{
status = SpotInsRecordExecutionStatus.TOBECHECK;
}
else
{
status = SpotInsRecordExecutionStatus.COMPLETED;
}
_repository.UpdateAsync(x => new EqpSpotInsRecordH()
{
status = status,
spot_record_date_time = DateTime.Now,
spot_record_user_id = _userManager.UserId
}, x => x.id == input.data["id"]);
});
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "执行成功" : result.ErrorMessage;
}
}
}

View File

@@ -21,42 +21,41 @@ namespace Tnb.EquipMgr
{
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
public class ToolMoldProductService : IToolMoldProductService, IDynamicApiController, ITransient
public class ToolMoldMaterialService : IToolMoldMaterialService, IDynamicApiController, ITransient
{
private readonly IUserManager _userManager;
private readonly ISqlSugarRepository<ToolMolds> _repository;
public ToolMoldProductService(IUserManager userManager, ISqlSugarRepository<ToolMolds> repository)
public ToolMoldMaterialService(IUserManager userManager, ISqlSugarRepository<ToolMolds> repository)
{
_userManager = userManager;
_repository = repository;
}
/// <summary>
/// 根据模具id获取产品集合
/// 根据模具id获取物料集合
/// </summary>
/// <param name="mold"></param>
/// <returns></returns>
[HttpPost]
public async Task<List<ProductListOutput>> GetProductLists(ToolMoldInput ToolMoldInput)
public async Task<List<MaterialListOutput>> GetMaterialLists(ToolMoldInput ToolMoldInput)
{
var db = _repository.AsSugarClient();
var list = await db.Queryable<BasProduct, ToolMoldsProduct>((a, b) => new object[]
var list = await db.Queryable<BasMaterial, ToolMoldsMaterial>((a, b) => new object[]
{
JoinType.Inner, a.id == b.product_id,
JoinType.Inner, a.id == b.material_id,
})
.Where((a, b) => b.mold_id == ToolMoldInput.mold)
.Select((a, b) => new ProductListOutput
.Select((a, b) => new MaterialListOutput
{
id = a.id,
product_code = a.product_code,
product_name = a.product_name,
product_standard = a.product_standard,
product_group=b.product_group,
code = a.code,
name = a.name,
material_group=b.material_group,
real_cavity_qty = b.real_cavity_qty.HasValue ? b.real_cavity_qty.Value : 0
}).ToListAsync();
return list;
}
/// <summary>
/// 增加模具产品绑定
/// 增加模具物料绑定
/// </summary>
/// <param name="mold"></param>
/// <param name="productid"></param>
@@ -67,21 +66,21 @@ namespace Tnb.EquipMgr
{
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
{
var ToolMoldsProduct= await _repository.AsSugarClient().Queryable<ToolMoldsProduct>().Where(p=>p.mold_id== ToolMoldInput.mold&&p.product_id== ToolMoldInput.productid).FirstAsync();
var ToolMoldsProduct= await _repository.AsSugarClient().Queryable<ToolMoldsMaterial>().Where(p=>p.mold_id== ToolMoldInput.mold&&p.material_id== ToolMoldInput.materialid).FirstAsync();
if (ToolMoldsProduct == null)
{
var entity = new ToolMoldsProduct();
var entity = new ToolMoldsMaterial();
entity.id = SnowflakeIdHelper.NextId();
entity.mold_id = ToolMoldInput.mold;
entity.product_id = ToolMoldInput.productid;
entity.material_id = ToolMoldInput.materialid;
entity.real_cavity_qty = ToolMoldInput.real_cavity_qty;
entity.create_time = DateTime.Now;
entity.create_id = _userManager.UserId;
await _repository.AsSugarClient().Insertable<ToolMoldsProduct>(entity).ExecuteCommandAsync();
await _repository.AsSugarClient().Insertable<ToolMoldsMaterial>(entity).ExecuteCommandAsync();
}
else {
ToolMoldsProduct.real_cavity_qty= ToolMoldInput.real_cavity_qty;
await _repository.AsSugarClient().Updateable<ToolMoldsProduct>(ToolMoldsProduct).ExecuteCommandAsync();
await _repository.AsSugarClient().Updateable<ToolMoldsMaterial>(ToolMoldsProduct).ExecuteCommandAsync();
}
@@ -92,7 +91,7 @@ namespace Tnb.EquipMgr
}
/// <summary>
/// 批量删除模具产品绑定
/// 批量删除模具物料绑定
/// </summary>
/// <param name="mold"></param>
/// <param name="productids"></param>
@@ -102,53 +101,53 @@ namespace Tnb.EquipMgr
{
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
{
var arr = _repository.AsSugarClient().Queryable<ToolMoldsProduct>().Where(x => x.mold_id == ToolMoldInput.mold && ToolMoldInput.productids.Contains(x.product_id)).ToList();
await _repository.AsSugarClient().Deleteable<ToolMoldsProduct>(arr).ExecuteCommandAsync();
var arr = _repository.AsSugarClient().Queryable<ToolMoldsMaterial>().Where(x => x.mold_id == ToolMoldInput.mold && ToolMoldInput.materialids.Contains(x.material_id)).ToList();
await _repository.AsSugarClient().Deleteable<ToolMoldsMaterial>(arr).ExecuteCommandAsync();
});
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
}
/// <summary>
/// 产品同组
/// 物料同组
/// </summary>
/// <param name="mold"></param>
/// <param name="productids"></param>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> SaveProductGroup(ToolMoldInput ToolMoldInput)
public async Task<dynamic> SaveMaterialGroup(ToolMoldInput ToolMoldInput)
{
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
{
var arr = _repository.AsSugarClient().Queryable<ToolMoldsProduct>().Where(x => x.mold_id == ToolMoldInput.mold && ToolMoldInput.productids.Contains(x.product_id)).ToList();
var arr = _repository.AsSugarClient().Queryable<ToolMoldsMaterial>().Where(x => x.mold_id == ToolMoldInput.mold && ToolMoldInput.materialids.Contains(x.material_id)).ToList();
var sign = SnowflakeIdHelper.NextId();
arr.ForEach(p => { p.product_group = sign; });
await _repository.AsSugarClient().Updateable<ToolMoldsProduct>(arr).ExecuteCommandAsync();
arr.ForEach(p => { p.material_group = sign; });
await _repository.AsSugarClient().Updateable<ToolMoldsMaterial>(arr).ExecuteCommandAsync();
});
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
}
/// <summary>
/// 取消产品同组
/// 取消物料同组
/// </summary>
/// <param name="mold"></param>
/// <param name="productids"></param>
/// <returns></returns>
public async Task<dynamic> CancelProductGroup(ToolMoldInput ToolMoldInput)
public async Task<dynamic> CancelMaterialGroup(ToolMoldInput ToolMoldInput)
{
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
{
var arr = _repository.AsSugarClient().Queryable<ToolMoldsProduct>().Where(x => x.mold_id == ToolMoldInput.mold && ToolMoldInput.productids.Contains(x.product_id)).ToList();
arr.ForEach(p => { p.product_group = string.Empty; });
await _repository.AsSugarClient().Updateable<ToolMoldsProduct>(arr).ExecuteCommandAsync();
var arr = _repository.AsSugarClient().Queryable<ToolMoldsMaterial>().Where(x => x.mold_id == ToolMoldInput.mold && ToolMoldInput.materialids.Contains(x.material_id)).ToList();
arr.ForEach(p => { p.material_group = string.Empty; });
await _repository.AsSugarClient().Updateable<ToolMoldsMaterial>(arr).ExecuteCommandAsync();
});
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
}
/// <summary>
/// 根据产品id获取模具集合
/// 根据物料id获取模具集合
/// </summary>
/// <param name="productid"></param>
/// <returns></returns>
@@ -156,11 +155,11 @@ namespace Tnb.EquipMgr
public async Task<List<MoldListOutput>> GetMoldLists(ToolMoldInput ToolMoldInput)
{
var db = _repository.AsSugarClient();
var list = await db.Queryable<ToolMolds, ToolMoldsProduct>((a, b) => new object[]
var list = await db.Queryable<ToolMolds, ToolMoldsMaterial>((a, b) => new object[]
{
JoinType.Inner, a.id == b.mold_id,
})
.Where((a, b) => b.product_id == ToolMoldInput.productid)
.Where((a, b) => b.material_id == ToolMoldInput.materialid)
.Select((a, b) => new MoldListOutput
{
id = a.id,
@@ -172,18 +171,18 @@ namespace Tnb.EquipMgr
return list;
}
/// <summary>
/// 批量删除产品模具绑定
/// 批量删除物料模具绑定
/// </summary>
/// <param name="molds"></param>
/// <param name="productid"></param>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> DetachProductData(ToolMoldInput ToolMoldInput)
public async Task<dynamic> DetachMaterialData(ToolMoldInput ToolMoldInput)
{
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
{
var arr = _repository.AsSugarClient().Queryable<ToolMoldsProduct>().Where(x => ToolMoldInput.molds.Contains(x.mold_id) && x.product_id == ToolMoldInput.productid).ToList();
await _repository.AsSugarClient().Deleteable<ToolMoldsProduct>(arr).ExecuteCommandAsync();
var arr = _repository.AsSugarClient().Queryable<ToolMoldsMaterial>().Where(x => ToolMoldInput.molds.Contains(x.mold_id) && x.material_id == ToolMoldInput.materialid).ToList();
await _repository.AsSugarClient().Deleteable<ToolMoldsMaterial>(arr).ExecuteCommandAsync();
});
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "操作成功" : result.ErrorMessage;

View File

@@ -68,9 +68,12 @@ namespace Tnb.EquipMgr
{
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
{
var his= await _repository.AsSugarClient().Queryable<ToolMoldsEquipment>().ToListAsync();
var list = new List<ToolMoldsEquipment>();
foreach (var equip in ToolMoldInput.equipid)
{
if (his.Where(p => p.mold_id == ToolMoldInput.mold && p.equipment_id == equip).ToList().Count > 0)
continue;
var entity = new ToolMoldsEquipment();
entity.id = SnowflakeIdHelper.NextId();
entity.mold_id = ToolMoldInput.mold;
@@ -83,8 +86,6 @@ namespace Tnb.EquipMgr
});
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
}
/// <summary>
/// 批量删除模具设备绑定