diff --git a/DOAN.Admin.WebApi/Controllers/huate_group/CloudMonitor/ZiyuanDevice01Controller.cs b/DOAN.Admin.WebApi/Controllers/huate_group/CloudMonitor/ZiyuanDevice01Controller.cs new file mode 100644 index 0000000..9e0c0ab --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/huate_group/CloudMonitor/ZiyuanDevice01Controller.cs @@ -0,0 +1,105 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Model.huate_group.CloudMonitor; +using DOAN.Model.huate_group.CloudMonitor.Dto; + +using DOAN.Service.huate_group.CloudMonitor; +using DOAN.Service.huate_group.CloudMonitor.IService; +using DOAN.Admin.WebApi.Filters; + +//创建时间:2024-08-21 +namespace DOAN.Admin.WebApi.Controllers.Business +{ + /// + /// 小房间热熔焊接 + /// + [Verify] + [Route("huate_group/cloudMonitor/")] + public class ZiyuanDevice01Controller : BaseController + { + /// + /// 小房间热熔焊接接口 + /// + private readonly IZiyuanDevice01Service _ZiyuanDevice01Service; + + public ZiyuanDevice01Controller(IZiyuanDevice01Service ZiyuanDevice01Service) + { + _ZiyuanDevice01Service = ZiyuanDevice01Service; + } + + /// + /// 查询小房间热熔焊接列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "ziyuandevice01:list")] + public IActionResult QueryZiyuanDevice01([FromQuery] ZiyuanDevice01QueryDto parm) + { + if (parm.ReflexAccount_id == 0) { throw new ArgumentException($"{parm.ReflexAccount_id}不存在"); }; + var response = _ZiyuanDevice01Service.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询小房间热熔焊接详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "ziyuandevice01:query")] + public IActionResult GetZiyuanDevice01(int Id) + { + var response = _ZiyuanDevice01Service.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加小房间热熔焊接 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "ziyuandevice01:add")] + [Log(Title = "小房间热熔焊接", BusinessType = BusinessType.INSERT)] + public IActionResult AddZiyuanDevice01([FromBody] ZiyuanDevice01Dto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _ZiyuanDevice01Service.AddZiyuanDevice01(modal); + + return SUCCESS(response); + } + + /// + /// 更新小房间热熔焊接 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "ziyuandevice01:edit")] + [Log(Title = "小房间热熔焊接", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateZiyuanDevice01([FromBody] ZiyuanDevice01Dto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _ZiyuanDevice01Service.UpdateZiyuanDevice01(modal); + + return ToResponse(response); + } + + /// + /// 删除小房间热熔焊接 + /// + /// + [HttpPost("delete/{ids}")] + [ActionPermissionFilter(Permission = "ziyuandevice01:delete")] + [Log(Title = "小房间热熔焊接", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteZiyuanDevice01([FromRoute]string ids) + { + var idArr = Tools.SplitAndConvert(ids); + + return ToResponse(_ZiyuanDevice01Service.Delete(idArr)); + } + + } +} \ No newline at end of file diff --git a/DOAN.Model/ReflexAccount.cs b/DOAN.Model/ReflexAccount.cs new file mode 100644 index 0000000..fb602f2 --- /dev/null +++ b/DOAN.Model/ReflexAccount.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model +{ + + /// + /// 设备表含义 + /// + [SugarTable("reflex_account")] + public class ReflexAccount + { + /// + /// Id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// FkTenantId + /// + [SugarColumn(ColumnName = "fk_tenant_id")] + public int? FkTenantId { get; set; } + + /// + /// 表名 + /// + [SugarColumn(ColumnName = "table_code")] + public string TableCode { get; set; } + + /// + /// 设备名称 + /// + [SugarColumn(ColumnName = "table_name")] + public string TableName { get; set; } + + /// + /// Status + /// + public int? Status { get; set; } + + } + +} diff --git a/DOAN.Model/huate_group/CloudMonitor/Dto/ZiyuanDevice01Dto.cs b/DOAN.Model/huate_group/CloudMonitor/Dto/ZiyuanDevice01Dto.cs new file mode 100644 index 0000000..cc24784 --- /dev/null +++ b/DOAN.Model/huate_group/CloudMonitor/Dto/ZiyuanDevice01Dto.cs @@ -0,0 +1,87 @@ +namespace DOAN.Model.huate_group.CloudMonitor.Dto +{ + /// + /// 小房间热熔焊接查询对象 + /// + public class ZiyuanDevice01QueryDto : PagerInfo + { + public int ReflexAccount_id { get; set; } + + public string Factory { get; set; } + + public string Workshop { get; set; } + + public string SupplierCode { get; set; } + + public string SupplierName { get; set; } + + public string Vehiclemodel { get; set; } + + public string Partnumber { get; set; } + + public string Partname { get; set; } + + public string Configuration { get; set; } + + public string Workstation { get; set; } + + public string Paramter { get; set; } + + public int? IsUpload { get; set; } + + } + + /// + /// 小房间热熔焊接输入输出对象 + /// + public class ZiyuanDevice01Dto + { + [Required(ErrorMessage = "Id不能为空")] + public int Id { get; set; } + + public string Localtion { get; set; } + + public string Factory { get; set; } + + public string Workshop { get; set; } + + public string SupplierCode { get; set; } + + public string SupplierName { get; set; } + + public string Vehiclemodel { get; set; } + + public string Partnumber { get; set; } + + public string Partname { get; set; } + + public string Configuration { get; set; } + + public string Workstation { get; set; } + + public string Paramter { get; set; } + + public decimal Value { get; set; } + + public decimal MiddleValue { get; set; } + + public decimal LowValue { get; set; } + + public decimal UpValue { get; set; } + + public DateTime? MeasureTime { get; set; } + + public int? IsUpload { get; set; } + + public string CreatedBy { get; set; } + + public DateTime? CreatedTime { get; set; } + + public string UpdatedBy { get; set; } + + + + [ExcelColumn(Name = "是否上传")] + public string IsUploadLabel { get; set; } + } +} \ No newline at end of file diff --git a/DOAN.Model/huate_group/CloudMonitor/ZiyuanDevice01.cs b/DOAN.Model/huate_group/CloudMonitor/ZiyuanDevice01.cs new file mode 100644 index 0000000..89802d9 --- /dev/null +++ b/DOAN.Model/huate_group/CloudMonitor/ZiyuanDevice01.cs @@ -0,0 +1,126 @@ +namespace DOAN.Model.huate_group.CloudMonitor +{ + /// + /// 小房间热熔焊接 + /// + [Tenant(2)] + [SugarTable("ziyuan_device_01")] + public class ZiyuanDevice01 + { + /// + /// Id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 地点 + /// + public string Localtion { get; set; } + + /// + /// 工厂 + /// + public string Factory { get; set; } + + /// + /// 车间 + /// + public string Workshop { get; set; } + + /// + /// 供应商代码 + /// + [SugarColumn(ColumnName = "supplier_code")] + public string SupplierCode { get; set; } + + /// + /// 供应商名称 + /// + [SugarColumn(ColumnName = "supplier_name")] + public string SupplierName { get; set; } + + /// + /// 车型 + /// + public string Vehiclemodel { get; set; } + + /// + /// 零件名称 + /// + public string Partnumber { get; set; } + + /// + /// 零件号 + /// + public string Partname { get; set; } + + /// + /// 配置 + /// + public string Configuration { get; set; } + + /// + /// 工位 + /// + public string Workstation { get; set; } + + /// + /// 参数 + /// + public string Paramter { get; set; } + + /// + /// 值 + /// + public decimal Value { get; set; } + + /// + /// 中值 + /// + [SugarColumn(ColumnName = "middle_value")] + public decimal MiddleValue { get; set; } + + /// + /// 下公差 + /// + [SugarColumn(ColumnName = "low_value")] + public decimal LowValue { get; set; } + + /// + /// 上公差 + /// + [SugarColumn(ColumnName = "up_value")] + public decimal UpValue { get; set; } + + /// + /// 测试时间 + /// + [SugarColumn(ColumnName = "measure_time")] + public DateTime? MeasureTime { get; set; } + + /// + /// 是否上传 + /// + public int? IsUpload { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "cREATED_BY")] + public string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "cREATED_TIME")] + public DateTime? CreatedTime { get; set; } + + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "uPDATED_BY")] + public string UpdatedBy { get; set; } + + } +} \ No newline at end of file diff --git a/DOAN.Service/huate_group/CloudMonitor/IServcie/IZiyuanDevice01Service.cs b/DOAN.Service/huate_group/CloudMonitor/IServcie/IZiyuanDevice01Service.cs new file mode 100644 index 0000000..e0f6890 --- /dev/null +++ b/DOAN.Service/huate_group/CloudMonitor/IServcie/IZiyuanDevice01Service.cs @@ -0,0 +1,21 @@ +using DOAN.Model.huate_group.CloudMonitor; +using DOAN.Model.huate_group.CloudMonitor.Dto; + +namespace DOAN.Service.huate_group.CloudMonitor.IService +{ + /// + /// 小房间热熔焊接service接口 + /// + public interface IZiyuanDevice01Service : IBaseService + { + PagedInfo GetList(ZiyuanDevice01QueryDto parm); + + ZiyuanDevice01 GetInfo(int Id); + + + ZiyuanDevice01 AddZiyuanDevice01(ZiyuanDevice01 parm); + int UpdateZiyuanDevice01(ZiyuanDevice01 parm); + + + } +} diff --git a/DOAN.Service/huate_group/CloudMonitor/ZiyuanDevice01Service.cs b/DOAN.Service/huate_group/CloudMonitor/ZiyuanDevice01Service.cs new file mode 100644 index 0000000..0380b0a --- /dev/null +++ b/DOAN.Service/huate_group/CloudMonitor/ZiyuanDevice01Service.cs @@ -0,0 +1,126 @@ +using Infrastructure.Attribute; +using Infrastructure.Extensions; + +using DOAN.Repository; +using DOAN.Model.huate_group.CloudMonitor; +using IP2Region.Ex.Models; +using DOAN.Model.huate_group.CloudMonitor.Dto; +using DOAN.Service.huate_group.CloudMonitor.IService; + +namespace DOAN.Service.huate_group.CloudMonitor +{ + /// + /// 小房间热熔焊接Service业务层处理 + /// + [AppService(ServiceType = typeof(IZiyuanDevice01Service), ServiceLifetime = LifeTime.Transient)] + public class ZiyuanDevice01Service : BaseService, IZiyuanDevice01Service + { + /// + /// 查询小房间热熔焊接列表 + /// + /// + /// + public PagedInfo GetList(ZiyuanDevice01QueryDto parm) + { + PagedInfo result = null; + //TODO 查询对应的表 + ReflexAccount reflex = Context.Queryable().Where(it => it.Id == parm.ReflexAccount_id).First(); + if (reflex == null) { + throw new ArgumentException($"这个表找不到{parm.ReflexAccount_id}"); + } + Type type = null; + try + { + type = Type.GetType($"DOAN.Model.huate_group.CloudMonitor.{reflex.TableCode}, DOAN.Model"); // 替换 "Namespace" 和 "AssemblyName" + if (type == null) + { + throw new ArgumentException($"Type '{reflex.TableCode}' not found."); + } + } + catch (Exception ex) + { + Console.WriteLine($"Error: {ex.Message}"); + } + switch (type) + { + + case Type t when t == typeof(ZiyuanDevice01): + result= QuerySubClass(parm); + break; + default: throw new ArgumentException("匹配不到表"); break; + } + + + return result; + } + + + /// + /// 获取详情 + /// + /// + /// + public ZiyuanDevice01 GetInfo(int Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加小房间热熔焊接 + /// + /// + /// + public ZiyuanDevice01 AddZiyuanDevice01(ZiyuanDevice01 model) + { + return Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改小房间热熔焊接 + /// + /// + /// + public int UpdateZiyuanDevice01(ZiyuanDevice01 model) + { + return Update(model, true); + } + + /// + /// 查询导出表达式 + /// + /// + /// + private static Expressionable QueryExp(ZiyuanDevice01QueryDto parm) + { + var predicate = Expressionable.Create(); + + return predicate; + } + + + private PagedInfo QuerySubClass(ZiyuanDevice01QueryDto parm) where T : ZiyuanDevice01, new() + { + var predicate = Expressionable.Create() + .AndIF(parm != null && !string.IsNullOrEmpty(parm.Factory), it => it.Factory.Contains(parm.Factory)) + .AndIF(parm != null && !string.IsNullOrEmpty(parm.Workshop), it => it.Workshop.Contains(parm.Workshop)) + .AndIF(parm != null && !string.IsNullOrEmpty(parm.SupplierCode), it => it.SupplierCode.Contains(parm.SupplierCode)) + .AndIF(parm != null && !string.IsNullOrEmpty(parm.SupplierName), it => it.SupplierName.Contains(parm.SupplierName)) + .AndIF(parm != null && !string.IsNullOrEmpty(parm.Vehiclemodel), it => it.Vehiclemodel.Contains(parm.Vehiclemodel)) + .AndIF(parm != null && !string.IsNullOrEmpty(parm.Partnumber), it => it.Partnumber.Contains(parm.Partnumber)) + .AndIF(parm != null && !string.IsNullOrEmpty(parm.Partname), it => it.Partname.Contains(parm.Partname)) + .AndIF(parm != null && !string.IsNullOrEmpty(parm.Configuration), it => it.Configuration.Contains(parm.Configuration)) + .AndIF(parm != null && !string.IsNullOrEmpty(parm.Workstation), it => it.Workstation.Contains(parm.Workstation)) + .AndIF(parm != null && !string.IsNullOrEmpty(parm.Paramter), it => it.Paramter.Contains(parm.Paramter)) + .AndIF(parm != null && parm.IsUpload > 0, it => it.IsUpload == parm.IsUpload) + ; + + + return Context.Queryable().Where(predicate.ToExpression()).ToPage(parm); + } + + } +} \ No newline at end of file