From 835025afe9bc7c2b72a3d4c0aafcabaa08e6b6df Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Mon, 22 Jan 2024 15:22:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E4=BD=93=E5=B7=A5=E7=A8=8B=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/pro/ProWorkorderV2Controller.cs | 59 ++++++++++++++++++- .../mes/pro/ProWorkplanV2Controller.cs | 12 ---- .../pro/IService/IProWorkorderServiceV2.cs | 12 +++- .../mes/pro/IService/IProWorkplanServiceV2.cs | 3 +- ZR.Service/mes/pro/ProWorkorderServiceV2.cs | 49 ++++++++++++--- ZR.Service/mes/pro/ProWorkplanServiceV2.cs | 9 +-- 6 files changed, 116 insertions(+), 28 deletions(-) diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs index 55095723..2984eee7 100644 --- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs +++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs @@ -10,7 +10,7 @@ using SqlSugar; using System.Text.Json; using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; -using ZR.Model.mes.pro; + using ZR.Model.MES.pro; using ZR.Service.mes.pro; using ZR.Service.mes.pro.IService; @@ -155,6 +155,63 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro + /// + /// 新增生产工单 + /// + /// 生产工单对象 + /// + [HttpPost("addworkorder")] + public IActionResult AddWorkOrder([FromBody] ProWorkorder_v2 proWorkorder) + { + int data = 0; + if (proWorkorder != null) + { + proWorkorder.ToCreate(HttpContext); + data = proWorkorderService.AddWorkOrder(proWorkorder); + } + + return ToResponse(new ApiResult(200, "success", data)); + } + + + /// + /// 删除生产工单 + /// + /// 工单ID + /// + [HttpGet("deleteitem/{id}")] + public IActionResult DeleteItem(string id) + { + int data = 0; + if (!string.IsNullOrEmpty(id)) + { + data = proWorkorderService.DeleteWorkOrder(id); + } + + return ToResponse(new ApiResult(200, "success", data)); + } + + + /// + /// 更新生产计划 + /// + /// 生产计划对象 + /// + [HttpPost("updateworkorder")] + public IActionResult UpdateWorkOrder([FromBody] ProWorkorder_v2 proWorkorder) + { + int data = 0; + if (proWorkorder != null) + { + proWorkorder.ToUpdate(HttpContext); + data = proWorkorderService.UpdateWorkOrder(proWorkorder); + + } + + return ToResponse(new ApiResult(200, "success", data)); + } + + diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs index 1173ba2e..f32447a9 100644 --- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs +++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs @@ -212,19 +212,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro { return ToResponse(ResultCode.GLOBAL_ERROR,"模板内容错误,请仔细检测格式,并联系管理员"+ex.Message); } - - - - - - - - - } - - - return SUCCESS(null); } diff --git a/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs b/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs index 665ec5ac..24914cc3 100644 --- a/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs +++ b/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs @@ -7,7 +7,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; -using ZR.Model.mes.pro; + using ZR.Model.MES.op.DTO; using ZR.Model.MES.pro; using ZR.Model.MES.pro.DTO; @@ -27,5 +27,15 @@ namespace ZR.Service.mes.pro.IService public int DeleteAllWorkorder(int year, int week, int date); + + public int AddWorkOrder(ProWorkorder_v2 workorder); + + public int DeleteWorkOrder(string id); + + public int UpdateWorkOrder(ProWorkorder_v2 workorder); + + + + } } diff --git a/ZR.Service/mes/pro/IService/IProWorkplanServiceV2.cs b/ZR.Service/mes/pro/IService/IProWorkplanServiceV2.cs index d26d9d57..97cfa4fa 100644 --- a/ZR.Service/mes/pro/IService/IProWorkplanServiceV2.cs +++ b/ZR.Service/mes/pro/IService/IProWorkplanServiceV2.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using ZR.Model.mes.pro; using ZR.Model.MES.op.DTO; using ZR.Model.MES.pro.DTO; +using ZR.Model.mes.pro; namespace ZR.Service.mes.pro.IService { @@ -22,7 +23,7 @@ namespace ZR.Service.mes.pro.IService /// /// /// - public List GetProWorkplanById(string id); + public List GetProWorkplanById(string id); public int AddWorkPlan(ProWorklplan_v2 proWorkplan); diff --git a/ZR.Service/mes/pro/ProWorkorderServiceV2.cs b/ZR.Service/mes/pro/ProWorkorderServiceV2.cs index 9991f58a..9f228153 100644 --- a/ZR.Service/mes/pro/ProWorkorderServiceV2.cs +++ b/ZR.Service/mes/pro/ProWorkorderServiceV2.cs @@ -10,13 +10,9 @@ using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; using ZR.Common; -using ZR.Model.mes.md; -using ZR.Model.mes.pro; -using ZR.Model.MES.wm; using ZR.Service.mes.pro.IService; using ZR.Service.MES.md.IService; using static System.Net.WebRequestMethods; - using JinianNet.JNTemplate; using static Aliyun.OSS.Model.LiveChannelStat; using ZR.Model.MES.pro.DTO; @@ -28,6 +24,7 @@ using Microsoft.AspNetCore.Hosting; using MiniExcelLibs; using System.IO; using SqlSugar.Extensions; +using ZR.Model.mes.pro; namespace ZR.Service.mes.pro { @@ -100,7 +97,7 @@ namespace ZR.Service.mes.pro } - + UseTran(() => { // 删除之前的工单 @@ -165,7 +162,7 @@ namespace ZR.Service.mes.pro { year = year, week = week, - date=date, + date = date, title = $"{year}年车镜实业涂装事业{week}周{date}生产滚动表", workorder = list @@ -177,7 +174,7 @@ namespace ZR.Service.mes.pro - // MiniExcel.SaveAs(fullPath, list); + // MiniExcel.SaveAs(fullPath, list); //3.0 返回路径和文件名 @@ -198,7 +195,45 @@ namespace ZR.Service.mes.pro { return Context.Deleteable().Where(it => it.Year == year && it.Week == week && it.Date == date).ExecuteCommand(); } + /// + /// 获取生产计划id + /// + /// + private int Getworkorderid_max() + { + + ProWorkorder_v2 max_workorder = Context.Queryable().OrderBy(it => it.Id, OrderByType.Desc).First(); + if (max_workorder != null && !string.IsNullOrEmpty(max_workorder.Id) && max_workorder.Id.Substring(2, 8) == DateTime.Now.ToString("yyyyMMdd")) + { + int num = Convert.ToInt32(max_workorder.Id.Substring(10)) + 1; + return num; + } + else + { + return 0; + } + } + + public int AddWorkOrder(ProWorkorder_v2 workorder) + { + + + workorder.Id = "WO" + DateTime.Now.ToString("yyyyMMdd") + Getworkorderid_max().ToString("000"); + + return Context.Insertable(workorder).ExecuteCommand(); + } + + public int DeleteWorkOrder(string id) + { + return Context.Deleteable().In(id).ExecuteCommand(); + + } + + public int UpdateWorkOrder(ProWorkorder_v2 workorder) + { + return Context.Updateable(workorder).ExecuteCommand(); + } } } diff --git a/ZR.Service/mes/pro/ProWorkplanServiceV2.cs b/ZR.Service/mes/pro/ProWorkplanServiceV2.cs index 1d6ce36c..79bcda9d 100644 --- a/ZR.Service/mes/pro/ProWorkplanServiceV2.cs +++ b/ZR.Service/mes/pro/ProWorkplanServiceV2.cs @@ -14,7 +14,6 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; -using ZR.Model.mes.md; using ZR.Model.mes.pro; using ZR.Model.MES.pro.DTO; using ZR.Service.mes.pro.IService; @@ -41,9 +40,9 @@ namespace ZR.Service.mes.pro } - public List GetProWorkplanById(string id) + public List GetProWorkplanById(string id) { - return Context.Queryable().Where(it => it.Id == id).ToList(); + return Context.Queryable().Where(it => it.Id == id).ToList(); } @@ -245,8 +244,6 @@ namespace ZR.Service.mes.pro return Context.Deleteable().Where(it => it.Year == year && it.Week == week).ExecuteCommand(); } - - - + } }