using Microsoft.AspNetCore.Mvc;
|
using System.Net;
|
using System.Net.Http.Headers;
|
using Microsoft.Extensions.Hosting.Internal;
|
using Microsoft.AspNetCore.Http.Extensions;
|
using IStation.Untity;
|
using Furion.DynamicApiController;
|
using System.ComponentModel.DataAnnotations;
|
using Mapster;
|
using Microsoft.AspNetCore.Http;
|
|
namespace IStation.Application
|
{
|
/// <summary>
|
/// InspectTemplate
|
/// </summary>
|
[Route("Inspect/Template/Mgr")]
|
[ApiDescriptionSettings("Inspect", Name = "巡检模板项(管理)", Order = 991)]
|
public class InspectTemplate_MgrController : IDynamicApiController
|
{
|
#region Query
|
/// <summary>
|
/// 通过 ProductType 获取
|
/// </summary>
|
[Route("GetItemsByProductType@V1.0")]
|
[HttpGet]
|
public Dto.InspectionTemplateBundle4MgrGetProductType GetItemsByProductType([FromQuery][Required] Dto.InspectionTemplateBundle4MgrGetProductType.Input input)
|
{
|
Service.ProductInspectionTemplateGrp the_grp_service = new Service.ProductInspectionTemplateGrp();
|
var list_grp_models = the_grp_service.GetByProductType(input.ProductType);
|
if (list_grp_models == null || list_grp_models.Count == 0)
|
return null;
|
|
Service.ProductInspectionTemplateItem the_item_service = new Service.ProductInspectionTemplateItem();
|
var list_item_models = the_item_service.GetByProductType(input.ProductType);
|
|
|
var vm = new Dto.InspectionTemplateBundle4MgrGetProductType();
|
vm.GrpList = list_grp_models.Select(x => x.Adapt<Model.ProductInspectionTemplateGrp, Dto.InspectionTemplateGrp4MgrGetProductType>()).ToList();
|
|
if (list_item_models != null && list_item_models.Count > 0)
|
vm.ItemList = list_item_models?.Select(x => x.Adapt<Model.ProductInspectionTemplateItem, Dto.InspectionTemplateItem4MgrGetProductType>()).ToList();
|
|
return vm;
|
}
|
|
/// <summary>
|
/// 通过 ItemID 获取 值
|
/// </summary>
|
[Route("GetValuesByItemID@V1.0")]
|
[HttpGet]
|
public List<Dto.InspectionTemplateValue4MgrGet> GetValuesByItemID([FromQuery][Required] Dto.InspectionTemplateValue4MgrGet.Input input)
|
{
|
Service.ProductInspectionTemplateValue the_grp_service = new Service.ProductInspectionTemplateValue();
|
var list_item_models = the_grp_service.GetByItemID(input.ItemID);
|
if (list_item_models == null || list_item_models.Count == 0)
|
return null;
|
|
return list_item_models .Select(x => x.Adapt<Model.ProductInspectionTemplateValue , Dto.InspectionTemplateValue4MgrGet>()).ToList();
|
}
|
|
#endregion
|
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
[Route("InsertGrp@V1.0")]
|
[HttpPost]
|
public long InsertGrp([Required] IStation.Dto.AddProductInspectionTemplateGrpInput input)
|
{
|
if (input == null)
|
return default;
|
var model = input.Adapt<IStation.Dto.AddProductInspectionTemplateGrpInput, Model.ProductInspectionTemplateGrp>();
|
model.UseStatus = Model.ProductInspectionContentGrp.eUseStatus.有效;
|
Service.ProductInspectionTemplateGrp the_service = new Service.ProductInspectionTemplateGrp();
|
var id = the_service.Insert(model);
|
return id;
|
}
|
|
/// <summary>
|
/// 插入多条
|
/// </summary>
|
[Route("InsertGrps@V1.0")]
|
[HttpPost]
|
public bool InsertGrps([Required] List<IStation.Dto.AddProductInspectionTemplateGrpInput> inputList)
|
{
|
if (inputList == null || inputList.Count < 1)
|
return false;
|
var list = inputList.Select(x => x.Adapt<IStation.Dto.AddProductInspectionTemplateGrpInput, Model.ProductInspectionTemplateGrp>()).ToList();
|
foreach (var item in list)
|
item.UseStatus = Model.ProductInspectionContentGrp.eUseStatus.有效;
|
Service.ProductInspectionTemplateGrp the_service = new Service.ProductInspectionTemplateGrp();
|
var bol = the_service.Inserts(list);
|
return bol;
|
}
|
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
[Route("InsertItem@V1.0")]
|
[HttpPost]
|
public long InsertItem([Required] IStation.Dto.AddProductInspectionTemplateItemInput input)
|
{
|
if (input == null)
|
return default;
|
var model_item = input.Adapt<IStation.Dto.AddProductInspectionTemplateItemInput, Model.ProductInspectionTemplateItem>();
|
model_item.UseStatus = Model.ProductInspectionContentItem.eUseStatus.有效;
|
model_item.ProductType = input.ProductType;
|
|
List<Model.ProductInspectionTemplateValue> list = null;
|
if (input.ValueList != null && input.ValueList.Count > 0)
|
{
|
list = input.ValueList.Select(x => x.Adapt<IStation.Dto.AddProductInspectionTemplateValueInput, Model.ProductInspectionTemplateValue>()).ToList();
|
foreach (var item in list)
|
{
|
item.UseStatus = Model.ProductInspectionContentValue.eUseStatus.有效;
|
item.CreateUserID = input.CreateUserID;
|
}
|
}
|
|
|
|
|
Service.ProductInspectionTemplateItem the_service = new Service.ProductInspectionTemplateItem();
|
var id = the_service.Insert(model_item, list);
|
return id;
|
}
|
|
|
|
|
|
#endregion
|
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
[Route("UpdateGrp@V1.0")]
|
[HttpPut]
|
public bool UpdateGrp([Required] IStation.Dto.UpdateProductInspectionTemplateGrpInput input)
|
{
|
if (input == null)
|
return false;
|
Service.ProductInspectionTemplateGrp the_service = new Service.ProductInspectionTemplateGrp();
|
var model = input.Adapt<IStation.Dto.UpdateProductInspectionTemplateGrpInput, Model.ProductInspectionTemplateGrp>();
|
var bol = the_service.Update(model);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新多条
|
/// </summary>
|
[Route("UpdateGrps@V1.0")]
|
[HttpPut]
|
public bool UpdateGrps([Required] List<IStation.Dto.UpdateProductInspectionTemplateGrpInput> inputList)
|
{
|
if (inputList == null || inputList.Count() < 1)
|
{
|
return false;
|
}
|
var corpIds = inputList.Select(x => x.CorpID).Distinct().ToList();
|
if (corpIds.Count > 1)
|
return false;
|
Service.ProductInspectionTemplateGrp the_service = new Service.ProductInspectionTemplateGrp();
|
|
List<Model.ProductInspectionTemplateGrp> model_list = new List<Model.ProductInspectionTemplateGrp>();
|
inputList.ForEach(input =>
|
{
|
var model = input.Adapt<IStation.Dto.UpdateProductInspectionTemplateGrpInput, Model.ProductInspectionTemplateGrp>();
|
model_list.Add(model);
|
});
|
|
var bol = the_service.Updates(model_list);
|
return bol;
|
}
|
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
[Route("UpdateItem@V1.0")]
|
[HttpPut]
|
public bool UpdateItem([Required] IStation.Dto.UpdateProductInspectionTemplateItemInput input)
|
{
|
if (input == null)
|
return false;
|
Service.ProductInspectionTemplateItem the_service = new Service.ProductInspectionTemplateItem();
|
var model = input.Adapt<IStation.Dto.UpdateProductInspectionTemplateItemInput, Model.ProductInspectionTemplateItem>();
|
if (model.ID <= 0)
|
return false;
|
|
List<Model.ProductInspectionTemplateValue> list = null;
|
if (input.ValueList != null && input.ValueList.Count > 0)
|
{
|
list = input.ValueList.Select(x => x.Adapt<IStation.Dto.UpdateProductInspectionTemplateValueInput, Model.ProductInspectionTemplateValue>()).ToList();
|
foreach (var vvv in list)
|
{
|
vvv.ItemID = model.ID;
|
if(vvv.ID <= 0)
|
{
|
vvv.CreateTime = DateTime.Now;
|
vvv.CreateUserID = input.UpdateUserID;
|
}
|
vvv.UpdateUserID = input.UpdateUserID;
|
}
|
}
|
|
|
var bol = the_service.Update(model, list);
|
return bol;
|
}
|
|
|
|
|
|
/// <summary>
|
/// 更新排序码
|
/// </summary>
|
[Route("UpdateGrpSortCode@V1.0")]
|
[HttpPut]
|
public bool UpdateGrpSortCode([Required] UpdateSortCodeUnderCorpInput input)
|
{
|
Service.ProductInspectionTemplateGrp the_service = new Service.ProductInspectionTemplateGrp();
|
var bol = the_service.UpdateSortCode(input.CorpID, input.ID, input.SortCode, UserManager.UserID );
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新排序码
|
/// </summary>
|
[Route("UpdateItemSortCode@V1.0")]
|
[HttpPut]
|
public bool UpdateItemSortCode([Required] UpdateSortCodeUnderCorpInput input)
|
{
|
Service.ProductInspectionTemplateItem the_service = new Service.ProductInspectionTemplateItem();
|
var bol = the_service.UpdateSortCode(input.CorpID, input.ID, input.SortCode, UserManager.UserID);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新排序码
|
/// </summary>
|
[Route("UpdateValueSortCode@V1.0")]
|
[HttpPut]
|
public bool UpdateValueSortCode([Required] UpdateSortCodeUnderCorpInput input)
|
{
|
Service.ProductInspectionTemplateValue the_service = new Service.ProductInspectionTemplateValue();
|
var bol = the_service.UpdateSortCode(input.CorpID, input.ID, input.SortCode, UserManager.UserID);
|
return bol;
|
}
|
/// <summary>
|
/// 更新排序
|
/// </summary>
|
[Route("UpdateGrpSorter@V1.0")]
|
[HttpPut]
|
public bool UpdateGrpSorter([Required] UpdateSorterUnderCorpInput input)
|
{
|
if (input.Sorters == null || input.Sorters.Count < 1)
|
return false;
|
var list = input.Sorters.Select(x => x.Adapt<UpdateSortCodeInput, Model.TraceSorter>()).ToList();
|
Service.ProductInspectionTemplateGrp the_service = new Service.ProductInspectionTemplateGrp();
|
var bol = the_service.UpdateSorter(input.CorpID, list);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新排序
|
/// </summary>
|
[Route("UpdateItemSorter@V1.0")]
|
[HttpPut]
|
public bool UpdateItemSorter([Required] UpdateSorterUnderCorpInput input)
|
{
|
if (input.Sorters == null || input.Sorters.Count < 1)
|
return false;
|
var list = input.Sorters.Select(x => x.Adapt<UpdateSortCodeInput, Model.TraceSorter>()).ToList();
|
Service.ProductInspectionTemplateItem the_service = new Service.ProductInspectionTemplateItem();
|
var bol = the_service.UpdateSorter(input.CorpID, list);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新排序
|
/// </summary>
|
[Route("UpdateValueSorter@V1.0")]
|
[HttpPut]
|
public bool UpdateValueSorter([Required] UpdateSorterUnderCorpInput input)
|
{
|
if (input.Sorters == null || input.Sorters.Count < 1)
|
return false;
|
var list = input.Sorters.Select(x => x.Adapt<UpdateSortCodeInput, Model.TraceSorter>()).ToList();
|
Service.ProductInspectionTemplateValue the_service = new Service.ProductInspectionTemplateValue();
|
var bol = the_service.UpdateSorter(input.CorpID, list);
|
return bol;
|
}
|
/// <summary>
|
/// 更新使用状态
|
/// </summary>
|
[Route("UpdateGrpUseStatus@V1.0")]
|
[HttpPut]
|
public bool UpdateGrpUseStatus([Required] UpdateUseStatusUnderCorpInput input)
|
{
|
Service.ProductInspectionTemplateGrp the_service = new Service.ProductInspectionTemplateGrp();
|
var bol = the_service.UpdateUseStatus(input.CorpID, input.ID, input.UseStatus, UserManager.UserID );
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新使用状态
|
/// </summary>
|
[Route("UpdateItemUseStatus@V1.0")]
|
[HttpPut]
|
public bool UpdateItemUseStatus([Required] UpdateUseStatusUnderCorpInput input)
|
{
|
Service.ProductInspectionTemplateItem the_service = new Service.ProductInspectionTemplateItem();
|
var bol = the_service.UpdateUseStatus(input.CorpID, input.ID, input.UseStatus, UserManager.UserID);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新使用状态
|
/// </summary>
|
[Route("UpdateValueUseStatus@V1.0")]
|
[HttpPut]
|
public bool UpdateValueUseStatus([Required] UpdateUseStatusUnderCorpInput input)
|
{
|
Service.ProductInspectionTemplateValue the_service = new Service.ProductInspectionTemplateValue();
|
var bol = the_service.UpdateUseStatus(input.CorpID, input.ID, input.UseStatus, UserManager.UserID);
|
return bol;
|
}
|
|
#endregion
|
|
|
#region Delete
|
|
/// <summary>
|
/// 删除
|
/// </summary>
|
[Route("DeleteGrpByID@V1.0")]
|
[HttpDelete]
|
public DeleteReasonOutput DeleteGrpByID([FromQuery][Required] IDUnderCorpInput input)
|
{
|
Service.ProductInspectionTemplateGrp the_service = new Service.ProductInspectionTemplateGrp();
|
var bol = the_service.DeleteByID(input.CorpID, input.ID, out string Msg);
|
return new DeleteReasonOutput() { Success = bol, Reason = Msg };
|
}
|
|
/// <summary>
|
/// 删除
|
/// </summary>
|
[Route("DeleteItemByID@V1.0")]
|
[HttpDelete]
|
public DeleteReasonOutput DeleteItemByID([FromQuery][Required] IDUnderCorpInput input)
|
{
|
Service.ProductInspectionTemplateItem the_service = new Service.ProductInspectionTemplateItem();
|
var bol = the_service.DeleteByID(input.CorpID, input.ID, out string Msg);
|
return new DeleteReasonOutput() { Success = bol, Reason = Msg };
|
}
|
|
/// <summary>
|
/// 删除
|
/// </summary>
|
[Route("DeleteValueByID@V1.0")]
|
[HttpDelete]
|
public DeleteReasonOutput DeleteValueByID([FromQuery][Required] IDUnderCorpInput input)
|
{
|
Service.ProductInspectionTemplateValue the_service = new Service.ProductInspectionTemplateValue();
|
var bol = the_service.DeleteByID(input.CorpID, input.ID, out string Msg);
|
return new DeleteReasonOutput() { Success = bol, Reason = Msg };
|
}
|
#endregion
|
}
|
}
|