From 69634a9fb78d742acfc587c2754d324259da9b89 Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Wed, 22 Nov 2023 18:10:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/pro/ProWorkorderController.cs | 15 ++++-------- ZR.Admin.WebApi/appsettings.json | 1 + ZR.Service/mes/pro/ProWorkorderService.cs | 24 ++++++++++++++++--- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs index f03faaf9..18dc8724 100644 --- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderController.cs @@ -69,18 +69,11 @@ namespace ZR.Admin.WebApi.Controllers.MES.pro /// 预计结束时间 /// [HttpGet("setschedule")] - public IActionResult SetSchedule(string id, string arrange_starttime, string arrange_endtime) + public IActionResult SetSchedule(string id, DateTime arrange_starttime, DateTime arrange_endtime) { - DateTime bgDateTime = DateTime.Now; - DateTime edDateTime = DateTime.Now; - try - { - bgDateTime = Convert.ToDateTime(arrange_starttime); - edDateTime = Convert.ToDateTime(arrange_endtime); - } - catch { } - int data = proWorkorderService.SetWorkorderSechedule(id, bgDateTime, edDateTime); + + int data = proWorkorderService.SetWorkorderSechedule(id, arrange_starttime, arrange_endtime); return ToResponse(new ApiResult(200, "success", data)); } @@ -90,7 +83,7 @@ namespace ZR.Admin.WebApi.Controllers.MES.pro /// /// 工单ID /// - [HttpGet("resetschedule")] + [HttpGet("resetschedule/{id}")] public IActionResult ResetSchedule(string id) { diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json index 112bd893..937cd4c6 100644 --- a/ZR.Admin.WebApi/appsettings.json +++ b/ZR.Admin.WebApi/appsettings.json @@ -10,6 +10,7 @@ "dbConfigs": [ { "Conn": "Data Source=192.168.0.36;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", + // "Conn": "Data Source=127.0.0.1;User ID=sa;Password=123456;Initial Catalog=ZrAdmin;", "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 "ConfigId": "0", //多租户唯一标识 "IsAutoCloseConnection": true diff --git a/ZR.Service/mes/pro/ProWorkorderService.cs b/ZR.Service/mes/pro/ProWorkorderService.cs index df50854f..17dd08d3 100644 --- a/ZR.Service/mes/pro/ProWorkorderService.cs +++ b/ZR.Service/mes/pro/ProWorkorderService.cs @@ -7,6 +7,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; +using ZR.Common; using ZR.Model.mes.md; using ZR.Model.mes.pro; using ZR.Service.mes.pro.IService; @@ -20,23 +21,39 @@ namespace ZR.Service.mes.pro public (List, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, string isSchedule) { + var predicate = Expressionable.Create() .AndIF(year > 0, it => it.Year == year) .AndIF(week > 0, it => it.Week == week) .AndIF(date > 0, it => it.Date == date) - .AndIF(date > 0, it => it.Isarrange.Equals(isSchedule)) + .And(it => it.Isarrange.Equals(isSchedule)) .ToExpression(); int totalCount = 0; - List proWorkorderList = Context.Queryable().Where(predicate).ToPageList(pageNum, pageSize, ref totalCount); + List proWorkorderList = Context.Queryable().Where(predicate).OrderBy(it=>it.Order).ToPageList(pageNum, pageSize, ref totalCount); return (proWorkorderList, totalCount); } public int SetWorkorderSechedule(string id, DateTime arrange_starttime, DateTime arrange_endtime) { + //获取排序最大值 + if(CacheHelper.GetCache("workorder_id_max")==null) + { + int? workorder_id_max = Context.Queryable().OrderBy(it => it.Order, OrderByType.Desc).First().Order; + //初次 + if(workorder_id_max==null|| workorder_id_max==0) + { + workorder_id_max = 1; + } + CacheHelper.SetCache("workorder_id_max", workorder_id_max); + } + CacheHelper.SetCache("workorder_id_max", (int)CacheHelper.GetCache("workorder_id_max")+1); + + + TimeSpan productionTime = arrange_endtime - arrange_starttime; return Context.Updateable() - .SetColumns(it => new ProWorkorder() { ArrangeStarttime = arrange_starttime, ArrangeEndtime = arrange_endtime, Isarrange = "1" }) + .SetColumns(it => new ProWorkorder() { ArrangeStarttime = arrange_starttime, ArrangeEndtime = arrange_endtime, Isarrange = "1", ProductionTime = (decimal)productionTime.TotalMinutes,Order=(int) CacheHelper.GetCache("workorder_id_max") }) .Where(it => it.Id.Equals(id)) .ExecuteCommand(); } @@ -45,6 +62,7 @@ namespace ZR.Service.mes.pro { return Context.Updateable() .SetColumns(it => it.Isarrange == "0") + .SetColumns(it => it.Order == 0) .Where(it => it.Id.Equals(id)) .ExecuteCommand(); }