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>
|
/// InspectContent
|
/// </summary>
|
[Route("Inspect/Content/Mgr")]
|
[ApiDescriptionSettings("Inspect", Name = "巡检内容项(管理)", Order = 991)]
|
public class InspectContent_MgrController : IDynamicApiController
|
{
|
#region Query
|
/// <summary>
|
/// 通过 ProductID 获取
|
/// </summary>
|
[Route("GetItemsByProductID@V1.0")]
|
[HttpGet]
|
public Dto.InspectionContentBundle4MgrGetProductID GetItemsByProductID([FromQuery][Required] Dto.InspectionContentBundle4MgrGetProductID.Input input)
|
{
|
Service.ProductInspectionContentGrp the_grp_service = new Service.ProductInspectionContentGrp();
|
var list_grp_models = the_grp_service.GetByProductID(input.ProductID);
|
if (list_grp_models == null || list_grp_models.Count == 0)
|
return null;
|
|
Service.ProductInspectionContentItem the_item_service = new Service.ProductInspectionContentItem();
|
var list_item_models = the_item_service.GetByProductID(input.ProductID);
|
|
|
var vm = new Dto.InspectionContentBundle4MgrGetProductID();
|
vm.GrpList = list_grp_models.Select(x => x.Adapt<Model.ProductInspectionContentGrp, Dto.InspectionContentGrp4MgrGetProductID>()).ToList();
|
|
if (list_item_models != null && list_item_models.Count > 0)
|
vm.ItemList = list_item_models?.Select(x => x.Adapt<Model.ProductInspectionContentItem, Dto.InspectionContentItem4MgrGetProductID>()).ToList();
|
|
return vm;
|
}
|
|
/// <summary>
|
/// 通过 ItemID 获取 值
|
/// </summary>
|
[Route("GetValuesByItemID@V1.0")]
|
[HttpGet]
|
public List<Dto.InspectionContentValue4MgrGet> GetValuesByItemID([FromQuery][Required] Dto.InspectionContentValue4MgrGet.Input input)
|
{
|
Service.ProductInspectionContentValue the_grp_service = new Service.ProductInspectionContentValue();
|
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.ProductInspectionContentValue , Dto.InspectionContentValue4MgrGet>()).ToList();
|
}
|
|
#endregion
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
[Route("InsertGrp@V1.0")]
|
[HttpPost]
|
public long InsertGrp([Required] IStation.Dto.AddProductInspectionContentGrpInput input)
|
{
|
if (input == null)
|
return default;
|
var model = input.Adapt<IStation.Dto.AddProductInspectionContentGrpInput, Model.ProductInspectionContentGrp>();
|
model.UseStatus = Model.ProductInspectionContentGrp.eUseStatus.有效;
|
Service.ProductInspectionContentGrp the_service = new Service.ProductInspectionContentGrp();
|
var id = the_service.Insert(model);
|
return id;
|
}
|
|
/// <summary>
|
/// 插入多条
|
/// </summary>
|
[Route("InsertGrps@V1.0")]
|
[HttpPost]
|
public bool InsertGrps([Required] List<IStation.Dto.AddProductInspectionContentGrpInput> inputList)
|
{
|
if (inputList == null || inputList.Count < 1)
|
return false;
|
var list = inputList.Select(x => x.Adapt<IStation.Dto.AddProductInspectionContentGrpInput, Model.ProductInspectionContentGrp>()).ToList();
|
foreach (var item in list)
|
item.UseStatus = Model.ProductInspectionContentGrp.eUseStatus.有效;
|
Service.ProductInspectionContentGrp the_service = new Service.ProductInspectionContentGrp();
|
var bol = the_service.Inserts(list);
|
return bol;
|
}
|
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
[Route("InsertItem@V1.0")]
|
[HttpPost]
|
public long InsertItem([Required] IStation.Dto.AddProductInspectionContentItemInput input)
|
{
|
if (input == null)
|
return default;
|
var model_item = input.Adapt<IStation.Dto.AddProductInspectionContentItemInput, Model.ProductInspectionContentItem>();
|
model_item.UseStatus = Model.ProductInspectionContentItem.eUseStatus.有效;
|
model_item.ProductID = input.ProductID;
|
|
List<Model.ProductInspectionContentValue> list = null;
|
if (input.ValueList != null && input.ValueList.Count > 0)
|
{
|
list = input.ValueList.Select(x => x.Adapt<IStation.Dto.AddProductInspectionContentValueInput, Model.ProductInspectionContentValue>()).ToList();
|
foreach (var item in list)
|
{
|
item.UseStatus = Model.ProductInspectionContentValue.eUseStatus.有效;
|
item.CreateUserID = input.CreateUserID;
|
}
|
}
|
|
|
|
|
Service.ProductInspectionContentItem the_service = new Service.ProductInspectionContentItem();
|
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.UpdateProductInspectionContentGrpInput input)
|
{
|
if (input == null)
|
return false;
|
Service.ProductInspectionContentGrp the_service = new Service.ProductInspectionContentGrp();
|
var model = input.Adapt<IStation.Dto.UpdateProductInspectionContentGrpInput, Model.ProductInspectionContentGrp>();
|
var bol = the_service.Update(model);
|
return bol;
|
}
|
|
/// <summary>
|
/// 更新多条
|
/// </summary>
|
[Route("UpdateGrps@V1.0")]
|
[HttpPut]
|
public bool UpdateGrps([Required] List<IStation.Dto.UpdateProductInspectionContentGrpInput> 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.ProductInspectionContentGrp the_service = new Service.ProductInspectionContentGrp();
|
|
List<Model.ProductInspectionContentGrp> model_list = new List<Model.ProductInspectionContentGrp>();
|
inputList.ForEach(input =>
|
{
|
var model = input.Adapt<IStation.Dto.UpdateProductInspectionContentGrpInput, Model.ProductInspectionContentGrp>();
|
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.UpdateProductInspectionContentItemInput input)
|
{
|
if (input == null)
|
return false;
|
Service.ProductInspectionContentItem the_service = new Service.ProductInspectionContentItem();
|
var model = input.Adapt<IStation.Dto.UpdateProductInspectionContentItemInput, Model.ProductInspectionContentItem>();
|
if (model.ID <= 0)
|
return false;
|
|
List<Model.ProductInspectionContentValue> list = null;
|
if (input.ValueList != null && input.ValueList.Count > 0)
|
{
|
list = input.ValueList.Select(x => x.Adapt<IStation.Dto.UpdateProductInspectionContentValueInput, Model.ProductInspectionContentValue>()).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.ProductInspectionContentGrp the_service = new Service.ProductInspectionContentGrp();
|
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.ProductInspectionContentItem the_service = new Service.ProductInspectionContentItem();
|
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.ProductInspectionContentValue the_service = new Service.ProductInspectionContentValue();
|
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.ProductInspectionContentGrp the_service = new Service.ProductInspectionContentGrp();
|
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.ProductInspectionContentItem the_service = new Service.ProductInspectionContentItem();
|
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.ProductInspectionContentValue the_service = new Service.ProductInspectionContentValue();
|
var bol = the_service.UpdateSorter(input.CorpID, list);
|
return bol;
|
}
|
/// <summary>
|
/// 更新使用状态
|
/// </summary>
|
[Route("UpdateGrpUseStatus@V1.0")]
|
[HttpPut]
|
public bool UpdateGrpUseStatus([Required] UpdateUseStatusUnderCorpInput input)
|
{
|
Service.ProductInspectionContentGrp the_service = new Service.ProductInspectionContentGrp();
|
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.ProductInspectionContentItem the_service = new Service.ProductInspectionContentItem();
|
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.ProductInspectionContentValue the_service = new Service.ProductInspectionContentValue();
|
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.ProductInspectionContentGrp the_service = new Service.ProductInspectionContentGrp();
|
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.ProductInspectionContentItem the_service = new Service.ProductInspectionContentItem();
|
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.ProductInspectionContentValue the_service = new Service.ProductInspectionContentValue();
|
var bol = the_service.DeleteByID(input.CorpID, input.ID, out string Msg);
|
return new DeleteReasonOutput() { Success = bol, Reason = Msg };
|
}
|
#endregion
|
}
|
}
|