diff --git a/DOAN.Admin.WebApi/Controllers/MES/dev/DevicePerformanceController.cs b/DOAN.Admin.WebApi/Controllers/MES/dev/DevicePerformanceController.cs index 524ab48..65ebf62 100644 --- a/DOAN.Admin.WebApi/Controllers/MES/dev/DevicePerformanceController.cs +++ b/DOAN.Admin.WebApi/Controllers/MES/dev/DevicePerformanceController.cs @@ -31,12 +31,12 @@ namespace DOAN.Admin.WebApi.Controllers /// /// /// - [HttpGet("list")] + [HttpPost("list")] [ActionPermissionFilter(Permission = "business:deviceperformance:list")] - public IActionResult QueryDevicePerformance([FromQuery] DevicePerformanceQueryDto parm) + public IActionResult QueryDevicePerformance([FromBody] DevicePerformanceQueryDto parm) { - parm.FillDate = DOANConvertDateTime.ConvertLocalDateTime(parm.FillDate.Value); - var response = _DevicePerformanceService.GetList(parm); + + var response = _DevicePerformanceService.GetList(parm); return SUCCESS(response); } @@ -68,8 +68,18 @@ namespace DOAN.Admin.WebApi.Controllers var modal = parm.Adapt().ToCreate(HttpContext); var response = _DevicePerformanceService.AddDevicePerformance(modal); + string data = ""; + if (response == -1) + { + data = "填写日期不能重复"; - return SUCCESS(response); + } + else + { + data = "成功"; + } + + return SUCCESS(data); } /// @@ -96,7 +106,7 @@ namespace DOAN.Admin.WebApi.Controllers [Log(Title = "设备运行绩效分析", BusinessType = BusinessType.DELETE)] public IActionResult DeleteDevicePerformance(string ids) { - int[] idsArr = Tools.SpitIntArrary(ids); + string [] idsArr = Tools.SpitStrArrary(ids); if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } var response = _DevicePerformanceService.Delete(idsArr); diff --git a/DOAN.Admin.WebApi/appsettings.Development.json b/DOAN.Admin.WebApi/appsettings.Development.json index 7327dae..5e8a047 100644 --- a/DOAN.Admin.WebApi/appsettings.Development.json +++ b/DOAN.Admin.WebApi/appsettings.Development.json @@ -8,9 +8,9 @@ }, "dbConfigs": [ { - "Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog=GXAssembly;Port=3308", + //"Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog=GXAssembly;Port=3308", // "Conn": "Data Source=192.168.0.58;User ID=root;Password=123456;Initial Catalog=GXAssembly;Port=3306;AllowLoadLocalInfile=true", - // "Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog=GXAssembly;Port=3306", + "Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog=GXAssembly;Port=3306", //"Conn": "Data Source=192.168.50.163;User ID=root;Password=123456;Initial Catalog=GXAssembly;Port=3306", "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 "ConfigId": "0", //多租户唯一标识 @@ -29,7 +29,7 @@ //代码生成数据库配置 "CodeGenDbConfig": { //代码生成连接字符串,注意{dbName}为固定格式,不要填写数据库名 - "Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog={dbName};Port=3308", + "Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog={dbName};Port=3306", "DbType": 0, "IsAutoCloseConnection": true, "DbName": "GXAssembly" //代码生成默认连接数据库,Oracle库是实例的名称 diff --git a/DOAN.Model/MES/dev/Dto/DevicePerformanceDto.cs b/DOAN.Model/MES/dev/Dto/DevicePerformanceDto.cs index 4bb74c1..a05421a 100644 --- a/DOAN.Model/MES/dev/Dto/DevicePerformanceDto.cs +++ b/DOAN.Model/MES/dev/Dto/DevicePerformanceDto.cs @@ -7,8 +7,8 @@ namespace DOAN.Model.MES.dev.Dto /// public class DevicePerformanceQueryDto : PagerInfo { - public DateTime? FillDate { get; set; } - } + public DateTime[] FillDateTime { get; set; } = new DateTime[2]; + } /// /// 设备运行绩效分析输入输出对象 diff --git a/DOAN.Service/MES/dev/DevicePerformanceService.cs b/DOAN.Service/MES/dev/DevicePerformanceService.cs index d009662..992e5d2 100644 --- a/DOAN.Service/MES/dev/DevicePerformanceService.cs +++ b/DOAN.Service/MES/dev/DevicePerformanceService.cs @@ -9,6 +9,8 @@ using DOAN.Model.MES.dev; using DOAN.Repository; using DOAN.Service.MES.dev.IService; using System.Linq; +using DOAN.Model.MES.product.Dto; +using DOAN.Model.MES.product; namespace DOAN.Service.MES.dev { @@ -25,13 +27,26 @@ namespace DOAN.Service.MES.dev /// public PagedInfo GetList(DevicePerformanceQueryDto parm) { - var predicate = Expressionable.Create() - .AndIF(parm.FillDate>DateTime.MinValue,it=>it.FillDate==parm.FillDate) - ; - var response = Queryable() - .Where(predicate.ToExpression()) - .ToPage(parm); - return response; + + var response = Queryable(); + + + if (parm.FillDateTime != null && parm.FillDateTime.Length == 2) + { + if (parm.FillDateTime[0] > DateTime.MinValue) + { + response = response.Where(it => it.FillDate >= parm.FillDateTime[0]); + } + + if (parm.FillDateTime[1] > DateTime.MinValue) + { + + response = response.Where(it => it.FillDate <= parm.FillDateTime[1]); + } + } + + return response.ToPage(parm); + } @@ -54,11 +69,19 @@ namespace DOAN.Service.MES.dev /// /// /// - public DevicePerformance AddDevicePerformance(DevicePerformance model) + public int AddDevicePerformance(DevicePerformance model) { - model.Id = XueHua; - AutoCalculation(ref model); - return Context.Insertable(model).ExecuteReturnEntity(); + if (Queryable().Where(x => x.FillDate.Value.ToString("yyyy-MM-dd") == model.FillDate.Value.ToString("yyyy-MM-dd")).Count() > 0) + { + return -1;//填写日期不能重复 + } + else + { + model.Id = XueHua; + AutoCalculation(ref model); + return Context.Insertable(model).ExecuteCommand(); + } + } /// @@ -99,6 +122,7 @@ namespace DOAN.Service.MES.dev private void AutoCalculation(ref DevicePerformance model) { + // 设备计划运行时间:(分钟)=设备可使用时间:(分钟)-节假日 model.PlanRuntime = model.Usabletime - model.Holiday??0; @@ -139,5 +163,6 @@ namespace DOAN.Service.MES.dev } - } + + } } \ No newline at end of file diff --git a/DOAN.Service/MES/dev/IService/IDevicePerformanceService.cs b/DOAN.Service/MES/dev/IService/IDevicePerformanceService.cs index a18d57f..47f426f 100644 --- a/DOAN.Service/MES/dev/IService/IDevicePerformanceService.cs +++ b/DOAN.Service/MES/dev/IService/IDevicePerformanceService.cs @@ -16,7 +16,7 @@ namespace DOAN.Service.MES.dev.IService DevicePerformance GetInfo(string Id); - DevicePerformance AddDevicePerformance(DevicePerformance parm); + int AddDevicePerformance(DevicePerformance parm); int UpdateDevicePerformance(DevicePerformance parm);