diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs index 2984eee7..2310c5af 100644 --- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs +++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs @@ -93,19 +93,47 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro //读取列表数据 try { - var list = stream.Query(sheetName: "Sheet1", startCell: "A3") - .Where(it => it.FinishedPartNumber != null) - .Where(it =>it.BlankNumber!=null&&!it.BlankNumber.Contains("圈数")) - .ToList(); - list.ForEach(it => - { - it.ToCreate(HttpContext); - it.Year = year; - it.Week = week; - it.Date = date; + var list = stream.Query(sheetName: "Sheet1", startCell: "A3").ToList(); ; - }); - string result = proWorkorderService.ImportExceldata(list); + + foreach (ProWorkorder_v2 item in list) + { + if (item.BlankNumber == null) + item.BlankNumber = ""; + if (item.FinishedPartNumber == null) + item.FinishedPartNumber = ""; + if (item.ProductDescription == null) + item.ProductDescription = ""; + if (item.Colour == null) + item.Colour = ""; + if (item.FinishedPartNumber == null) + item.FinishedPartNumber = ""; + if (item.ProductDescription == null) + item.ProductDescription = ""; + if (item.Colour == null) + item.Colour = ""; + if (item.Specifications == null) + item.Specifications = ""; + if (item.CylinderNumber == null) + item.CylinderNumber = ""; + if (item.Remark1 == null) + item.Remark1 = ""; + if (item.Remark2 == null) + item.Remark2 = ""; + if (item.Remark3 == null) + item.Remark3 = ""; + if (item.Remark4 == null) + item.Remark4 = ""; + if (item.ClientWorkorder == null) + item.ClientWorkorder = ""; + item.ToCreate(HttpContext); + item.Year = year; + item.Week = week; + item.Date = date; + } + var final_list = list.Where(it => !it.BlankNumber.Contains("圈数")).ToList(); + + string result = proWorkorderService.ImportExceldata(final_list); return SUCCESS(result); } catch (Exception ex) @@ -124,13 +152,13 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro /// [HttpGet("downloadWorkorder")] [Log(Title = "下载生产工单", BusinessType = BusinessType.EXPORT)] - public IActionResult UserExport(int? year, int? week,int? date) + public IActionResult UserExport(int? year, int? week, int? date) { - if (year == null || week == null || date==null) + if (year == null || week == null || date == null) { return SUCCESS(0); } - var result = proWorkorderService.ExportExceldata((int)year, (int)week,(int)date); + var result = proWorkorderService.ExportExceldata((int)year, (int)week, (int)date); return ExportExcel(result.Item2, result.Item1); @@ -147,7 +175,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro if (week != null && week > 0) { if (year != null && year > 0) - data = proWorkorderService.DeleteAllWorkorder((int)year, (int)week,(int)date); + data = proWorkorderService.DeleteAllWorkorder((int)year, (int)week, (int)date); } return ToResponse(new ApiResult(200, "success", data)); @@ -212,6 +240,74 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro } + /// + /// 删除本周所有计划 + /// + /// + /// + [HttpGet("updateSort")] + public IActionResult UpdateSort(string id, int? sort) + { + int data = 0; + if (!string.IsNullOrEmpty(id)) + { + + data = proWorkorderService.UpdateworkorderSort(id, (int)sort); + } + + return ToResponse(new ApiResult(200, "success", data)); + } + + + + /// + /// 工单开始上线 + /// + /// 工单ID + /// + [HttpGet("startOnline/{id}")] + public IActionResult StartOnline(string id) + { + int data = 0; + if (!string.IsNullOrEmpty(id)) + { + data = proWorkorderService.StartWorkOrder(id); + } + + return ToResponse(new ApiResult(200, "success", data)); + } + + + /// + /// 工单下线 + /// + /// 工单ID + /// + [HttpGet("cancelOnline/{id}")] + public IActionResult CancelOnline(string id) + { + int data = 0; + if (!string.IsNullOrEmpty(id)) + { + data = proWorkorderService.CancelWorkOrder(id); + } + + return ToResponse(new ApiResult(200, "success", data)); + } + + + /// + /// 生成工单号 + /// + /// + /// + [HttpGet("generateWorkorder")] + public IActionResult GenerateWorkorder(int? year, int? week, int? date) + { + int data = 0; + data = proWorkorderService.GenerateWorkorder((int)year, (int)week,(int)date); + 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 f32447a9..72f6f1fa 100644 --- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs +++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs @@ -133,7 +133,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro [AllowAnonymous] //不需要授权 就可以访问 public IActionResult ImportTemplateExcel() { - (string, string) result = DownloadImportTemplate("周生产计划模板");//返回文件名和路径 + (string, string) result = DownloadImportTemplate("周计划标准模板");//返回文件名和路径 return ExportExcel(result.Item2, result.Item1); } diff --git a/ZR.Admin.WebApi/wwwroot/ImportTemplate/日生产计划模板.xlsx b/ZR.Admin.WebApi/wwwroot/ImportTemplate/日生产计划模板.xlsx index 6f35b14c..e9d1d9ba 100644 Binary files a/ZR.Admin.WebApi/wwwroot/ImportTemplate/日生产计划模板.xlsx and b/ZR.Admin.WebApi/wwwroot/ImportTemplate/日生产计划模板.xlsx differ diff --git a/ZR.Admin.WebApi/wwwroot/workorder/2024012311144797e79fbae8a188e6a19d%bf.xlsx b/ZR.Admin.WebApi/wwwroot/workorder/2024012311144797e79fbae8a188e6a19d%bf.xlsx new file mode 100644 index 00000000..6f35b14c Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/workorder/2024012311144797e79fbae8a188e6a19d%bf.xlsx differ diff --git a/ZR.Admin.WebApi/wwwroot/workorder/2024012318564397e79fbae8a188e6a19d%bf.xlsx b/ZR.Admin.WebApi/wwwroot/workorder/2024012318564397e79fbae8a188e6a19d%bf.xlsx new file mode 100644 index 00000000..06c48fce Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/workorder/2024012318564397e79fbae8a188e6a19d%bf.xlsx differ diff --git a/ZR.Admin.WebApi/wwwroot/workorder/2024012318590497e79fbae8a188e6a19d%bf.xlsx b/ZR.Admin.WebApi/wwwroot/workorder/2024012318590497e79fbae8a188e6a19d%bf.xlsx new file mode 100644 index 00000000..06c48fce Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/workorder/2024012318590497e79fbae8a188e6a19d%bf.xlsx differ diff --git a/ZR.Admin.WebApi/wwwroot/workorder/2024012319060897e79fbae8a188e6a19d%bf.xlsx b/ZR.Admin.WebApi/wwwroot/workorder/2024012319060897e79fbae8a188e6a19d%bf.xlsx new file mode 100644 index 00000000..06c48fce Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/workorder/2024012319060897e79fbae8a188e6a19d%bf.xlsx differ diff --git a/ZR.Admin.WebApi/wwwroot/workorder/2024012319123497e79fbae8a188e6a19d%bf.xlsx b/ZR.Admin.WebApi/wwwroot/workorder/2024012319123497e79fbae8a188e6a19d%bf.xlsx new file mode 100644 index 00000000..06c48fce Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/workorder/2024012319123497e79fbae8a188e6a19d%bf.xlsx differ diff --git a/ZR.Admin.WebApi/wwwroot/workorder/2024012319485797e79fbae8a188e6a19d%bf.xlsx b/ZR.Admin.WebApi/wwwroot/workorder/2024012319485797e79fbae8a188e6a19d%bf.xlsx new file mode 100644 index 00000000..6f35b14c Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/workorder/2024012319485797e79fbae8a188e6a19d%bf.xlsx differ diff --git a/ZR.Admin.WebApi/wwwroot/workorder/2024012319543897e79fbae8a188e6a19d%bf.xlsx b/ZR.Admin.WebApi/wwwroot/workorder/2024012319543897e79fbae8a188e6a19d%bf.xlsx new file mode 100644 index 00000000..6f35b14c Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/workorder/2024012319543897e79fbae8a188e6a19d%bf.xlsx differ diff --git a/ZR.Admin.WebApi/wwwroot/workplan/2024012309515591e8a188e68787e6a19d%bf.xlsx b/ZR.Admin.WebApi/wwwroot/workplan/2024012309515591e8a188e68787e6a19d%bf.xlsx new file mode 100644 index 00000000..34be72e6 Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/workplan/2024012309515591e8a188e68787e6a19d%bf.xlsx differ diff --git a/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs b/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs index 24914cc3..953d8f4c 100644 --- a/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs +++ b/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.VisualBasic; using Model.DBModel; using System; @@ -34,8 +35,14 @@ namespace ZR.Service.mes.pro.IService public int UpdateWorkOrder(ProWorkorder_v2 workorder); + public int UpdateworkorderSort(string id ,int sort); + public int StartWorkOrder(string id); + public int CancelWorkOrder(string id); + + public int GenerateWorkorder(int year, int week, int date); + } } diff --git a/ZR.Service/mes/pro/ProWorkorderServiceV2.cs b/ZR.Service/mes/pro/ProWorkorderServiceV2.cs index 69cddb5a..a24ead8c 100644 --- a/ZR.Service/mes/pro/ProWorkorderServiceV2.cs +++ b/ZR.Service/mes/pro/ProWorkorderServiceV2.cs @@ -255,6 +255,7 @@ namespace ZR.Service.mes.pro } public int DeleteWorkOrder(string id) + { return Context.Deleteable().In(id).ExecuteCommand(); @@ -262,7 +263,99 @@ namespace ZR.Service.mes.pro public int UpdateWorkOrder(ProWorkorder_v2 workorder) { + workorder.Status = 0; + if (workorder.Remark2 == "批量") + { + workorder.Remark3 = "是"; + } return Context.Updateable(workorder).ExecuteCommand(); } + + /// + /// 更改工单顺序 + /// + /// + /// + /// + /// + public int UpdateworkorderSort(string id, int sort) + { + if(sort > 0) + { + int finalreuslt = 0; + + int max = Convert.ToInt32(sort.ToString().Substring(0, 6) + "999"); + int result = Context.Updateable().Where(it => it.Sort >= sort && it.Sort <= max).SetColumns(it => it.Sort == it.Sort + 1).ExecuteCommand(); + if (result > 0) + { + finalreuslt = Context.Updateable().Where(it => it.Id == id).SetColumns(it => it.Sort == sort).ExecuteCommand(); + } + return finalreuslt; + + } + + return 0; + } + + + /// + /// 工单开始 + /// + /// + /// + /// + public int StartWorkOrder(string id) + { + return Context.Updateable().Where(it => it.Id == id) + .SetColumns(it => it.Status == 1).ExecuteCommand(); + } + + + + /// + /// 工单上线取消 + /// + /// + /// + /// + public int CancelWorkOrder(string id) + { + + return Context.Updateable().Where(it => it.Id == id) + .SetColumns(it => it.Status == 0).ExecuteCommand(); + } + + + + /// + /// 生成工单号 + /// + /// + /// + /// + /// + + public int GenerateWorkorder(int year, int week, int date) + { + if (year > 0 && week > 0 && date >0) + { + string date_now = DateTime.Now.ToString("yyMMdd"); + + List workorderList= Context.Queryable().Where(it => it.Year == year && it.Week == week && it.Date == date).Where(it=>it.Remark3=="是").ToList(); + + foreach(ProWorkorder_v2 item in workorderList) { + int index = workorderList.IndexOf(item) + 1; + item.ClientWorkorder = date_now + index.ToString("000"); + } + + + + + + + return Context.Updateable(workorderList).ExecuteCommand(); + } + return 0; + } } }