diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs
index 6f9742f3..512ac6f8 100644
--- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs
+++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs
@@ -42,7 +42,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
return ToResponse(new ApiResult(200, "success", data));
}
- //
+
[HttpGet("getWorkoderList_piliang")]
@@ -66,6 +66,9 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
return ExportExcel(result.Item2, result.Item1);
}
+
+
+
///
/// 导入
///
@@ -82,10 +85,10 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
int year = 0;
int week = 0;
int date = 0;
- if (!Directory.Exists(target))
+ if (!Directory.Exists(Path.Combine(webHostEnvironment.WebRootPath, "workorder")))
{
// 如果目录不存在就创建
- Directory.CreateDirectory(target);
+ Directory.CreateDirectory(Path.Combine(webHostEnvironment.WebRootPath, "workorder"));
}
using (var stream = formFile.OpenReadStream())
@@ -100,8 +103,6 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
}
-
-
//读取列表数据
try
{
@@ -236,7 +237,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
///
- /// 更新生产计划
+ /// 更新生产计划
///
/// 生产计划对象
///
@@ -256,7 +257,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
///
- /// 删除本周所有计划
+ /// 根据工单顺序 排序
///
///
///
@@ -268,6 +269,8 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
{
data = proWorkorderService.UpdateworkorderSort(id, (int)sort);
+
+
}
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 002bbfa7..4bd07683 100644
--- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs
+++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs
@@ -169,9 +169,9 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
string sFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + formFile.FileName;
string target = Path.Combine(webHostEnvironment.WebRootPath, "workplan", sFileName);
- if (!Directory.Exists(target))
+ if (!Directory.Exists(Path.Combine(webHostEnvironment.WebRootPath, "workplan")))
{
- Directory.CreateDirectory(target);
+ Directory.CreateDirectory(Path.Combine(webHostEnvironment.WebRootPath, "workplan"));
}
int year = 0;
int week = 0;
@@ -196,7 +196,6 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
//读取第一行 解析 年和月
var row = stream.Query().Take(1).First();
year = Convert.ToInt32(row.A);
-
week = Convert.ToInt32(row.B);
var list = stream.Query(sheetName: "Sheet1", startCell: "B3")
.Where(it => it.Partnumber != null)
diff --git a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs
index d663d5ac..0a514d12 100644
--- a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs
+++ b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs
@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.SignalR;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
+using Org.BouncyCastle.Asn1.X509;
using System.Text.Json;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Hubs;
@@ -77,42 +78,118 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.IQC
///
- /// 获取当前工单
+ /// 获取当前工单 一检
///
///
- [HttpGet("getcurrentWorkorder")]
- public IActionResult GetcurrentWorkorder()
+ [HttpGet("getcurrentWorkorder_first")]
+ public IActionResult GetcurrentWorkorder_first()
{
- QcCurrentWorkorderDto workorder= fQCService.GetcurrentWorkorder();
+ QcCurrentWorkorderDto workorder= fQCService.GetcurrentWorkorder_first();
return SUCCESS(workorder);
}
-
-
///
- /// 获取下一个工单
+ /// 获取当前工单 二检
///
///
- [HttpGet("getcurrentWorkorder_next")]
- public IActionResult GetcurrentWorkorder_next()
+ [HttpGet("getcurrentWorkorder_again")]
+ public IActionResult GetcurrentWorkorder_again()
{
- QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_next();
+ QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_again();
+
+ return SUCCESS(workorder);
+ }
+
+
+
+ ///
+ /// 获取当前工单 三检
+ ///
+ ///
+ [HttpGet("getcurrentWorkorder_thirty")]
+ public IActionResult GetcurrentWorkorder_thirty()
+ {
+
+ QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_thirty();
return SUCCESS(workorder);
}
///
- /// 获取上一个工单
+ /// 获取下一个工单 一检
///
///
- [HttpGet("getcurrentWorkorder_previous")]
- public IActionResult GetcurrentWorkorder_previous()
+ [HttpGet("getcurrentWorkorder_next_first")]
+ public IActionResult GetcurrentWorkorder_next_first()
{
- QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_previous();
+ QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_next_first();
+
+ return SUCCESS(workorder);
+ }
+ ///
+ /// 获取下一个工单 二检
+ ///
+ ///
+ [HttpGet("getcurrentWorkorder_next_again")]
+ public IActionResult GetcurrentWorkorder_next_again()
+ {
+
+ QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_next_again();
+
+ return SUCCESS(workorder);
+ }
+ ///
+ /// 获取下一个工单 三检
+ ///
+ ///
+ [HttpGet("getcurrentWorkorder_next_thirty")]
+ public IActionResult GetcurrentWorkorder_next_thirty()
+ {
+
+ QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_next_thirty();
+
+ return SUCCESS(workorder);
+ }
+
+ ///
+ /// 获取上一个工单 一检
+ ///
+ ///
+ [HttpGet("getcurrentWorkorder_previous_first")]
+ public IActionResult GetcurrentWorkorder_previous_first()
+ {
+
+ QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_previous_first();
+
+ return SUCCESS(workorder);
+ }
+
+ ///
+ /// 获取上一个工单 二检
+ ///
+ ///
+ [HttpGet("getcurrentWorkorder_previous_again")]
+ public IActionResult GetcurrentWorkorder_previous_again()
+ {
+
+ QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_previous_again();
+
+ return SUCCESS(workorder);
+ }
+
+ ///
+ /// 获取上一个工单 三检
+ ///
+ ///
+ [HttpGet("getcurrentWorkorder_previous_thirty")]
+ public IActionResult GetcurrentWorkorder_previous_thirty()
+ {
+
+ QcCurrentWorkorderDto workorder = fQCService.GetcurrentWorkorder_previous_thirty();
return SUCCESS(workorder);
}
@@ -122,16 +199,18 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.IQC
///
///
///
- ///
+ /// 要累加的值
///
[HttpGet("accumulator_query_first")]
- public IActionResult Accumulator_first(string workorder_id,int checkid,int counter)
+ public IActionResult Accumulator_first(string workorder_id,int checkid,int number, string inspectionModule)
{
- int result= fQCService.Accumulator_first(workorder_id, checkid, counter, HttpContext.GetName());
+ int result= fQCService.Accumulator_first(workorder_id, checkid, number, inspectionModule, HttpContext.GetName());
- return SUCCESS(counter);
+ return SUCCESS(result);
}
+
+
///
/// 二检累加器
///
@@ -140,12 +219,12 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.IQC
///
///
[HttpGet("accumulator_query_again")]
- public IActionResult Accumulator_again(string workorder_id, int checkid, int counter)
+ public IActionResult Accumulator_again(string workorder_id, int checkid, int number, string inspectionModule)
{
- int result = fQCService.Accumulator_again(workorder_id, checkid, counter, HttpContext.GetName());
+ int result = fQCService.Accumulator_again(workorder_id, checkid, number, inspectionModule, HttpContext.GetName());
- return SUCCESS(counter);
+ return SUCCESS(result);
}
///
@@ -156,12 +235,12 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.IQC
///
///
[HttpGet("accumulator_query_thirty")]
- public IActionResult Accumulator_thirty(string workorder_id, int checkid, int counter)
+ public IActionResult Accumulator_thirty(string workorder_id, int checkid, int number, string inspectionModule)
{
- int result = fQCService.Accumulator_thirty(workorder_id, checkid, counter, HttpContext.GetName());
+ int result = fQCService.Accumulator_thirty(workorder_id, checkid, number, inspectionModule, HttpContext.GetName());
- return SUCCESS(counter);
+ return SUCCESS(result);
}
@@ -180,6 +259,8 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.IQC
return SUCCESS(AllNumber);
}
+
+
///
/// 计算当前工单下的包装投入数==一次合格+抛光合格
///
@@ -194,5 +275,14 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.IQC
}
+ // 更改工单状态为完成态
+ [HttpGet("update_workorder_status")]
+ public IActionResult UpdateWorkorderStatus(string workorderID)
+ {
+ int result= fQCService.UpdateWorkorderStatus(workorderID);
+ return SUCCESS(result);
+ }
+
+
}
}
diff --git a/ZR.Admin.WebApi/wwwroot/workorder/2024012614503797e79fbae8a188e6a19d%bf.xlsx b/ZR.Admin.WebApi/wwwroot/workorder/2024012614503797e79fbae8a188e6a19d%bf.xlsx
deleted file mode 100644
index 6f35b14c..00000000
Binary files a/ZR.Admin.WebApi/wwwroot/workorder/2024012614503797e79fbae8a188e6a19d%bf.xlsx and /dev/null differ
diff --git a/ZR.Admin.WebApi/wwwroot/workorder/20240130160521周2生产计划.xlsx b/ZR.Admin.WebApi/wwwroot/workorder/20240130160521周2生产计划.xlsx
new file mode 100644
index 00000000..748da8f7
Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/workorder/20240130160521周2生产计划.xlsx differ
diff --git a/ZR.Service/mes/op/OperationService.cs b/ZR.Service/mes/op/OperationService.cs
index a85d89ac..42766764 100644
--- a/ZR.Service/mes/op/OperationService.cs
+++ b/ZR.Service/mes/op/OperationService.cs
@@ -21,6 +21,7 @@ using System.Drawing;
using Newtonsoft.Json;
using ZR.Model.MES.qu;
using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
+using ZR.Model.MES.pro;
namespace ZR.Service.MES.op
{
@@ -99,7 +100,7 @@ namespace ZR.Service.MES.op
int totalCount = 0;
var query5 = Context.Queryable()
- .LeftJoin((q, p) => q.FkWorkorderId == p.Id)
+ .LeftJoin((q, p) => q.FkWorkorderId == p.Id)
.Where(predicate2)
.Select((q, p) => new QcFqcDTO {
Year = p.Year,
diff --git a/ZR.Service/mes/pro/ProWorkorderServiceV2.cs b/ZR.Service/mes/pro/ProWorkorderServiceV2.cs
index 3dd2afe7..d1845c05 100644
--- a/ZR.Service/mes/pro/ProWorkorderServiceV2.cs
+++ b/ZR.Service/mes/pro/ProWorkorderServiceV2.cs
@@ -1,7 +1,7 @@
using Infrastructure.Attribute;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using SqlSugar;
+
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -25,6 +25,7 @@ using MiniExcelLibs;
using System.IO;
using SqlSugar.Extensions;
using ZR.Model.mes.pro;
+using SqlSugar;
namespace ZR.Service.mes.pro
{
@@ -95,7 +96,7 @@ namespace ZR.Service.mes.pro
{
item.Id = "WO" + DateTime.Now.ToString("yyyyMMdd") + max_id.ToString("000");
item.Remark4 = "Excel导入";
- // 添加属性
+ // 添加属性 ------》 排序规则是 年周日+序列号(000)
item.Sort = Convert.ToInt32(item.Year.ToString("0000").Substring(2) + item.Week.ToString("00") + item.Date.ToString("00") + workorderList.IndexOf(item).ToString("000"));
if (item.Remark2 == "批量")
@@ -274,8 +275,8 @@ namespace ZR.Service.mes.pro
///
/// 更改工单顺序
///
- ///
- ///
+ /// 工单id
+ /// 新位置占据的排序值
///
///
public int UpdateworkorderSort(string id, int sort)
@@ -285,7 +286,9 @@ namespace ZR.Service.mes.pro
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();
@@ -339,8 +342,12 @@ namespace ZR.Service.mes.pro
{
if (year > 0 && week > 0 && date >0)
{
- string date_now = DateTime.Now.ToString("yyMMdd");
+ DateTime week_first = GetWeekStartTime(year, week);
+
+ string date_now = week_first.AddDays(date-1).ToString("yyMMdd");
+ Console.ForegroundColor = ConsoleColor.Green;
+ Console.WriteLine($"生成工单号前缀{date_now}");
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) {
@@ -353,5 +360,42 @@ namespace ZR.Service.mes.pro
}
return 0;
}
+
+ ///
+ /// 它接受年份和一年中的周数和星期几作为输入,并返回对应的日期。
+ ///
+ ///
+ ///
+ ///
+ ///
+ static DateTime GetDateFromWeek(int year, int weekNumber, DayOfWeek dayOfWeek)
+ {
+ DateTime jan1 = new DateTime(year, 1, 1);
+ int daysOffset = (int)dayOfWeek- (int)jan1.DayOfWeek;
+
+ DateTime firstDayOfWeek = jan1.AddDays(7 * (weekNumber - 1) - daysOffset+2);
+ return firstDayOfWeek;
+ }
+
+ ///
+ /// 当前周的第一天(星期一)
+ ///
+ /// 周数,格式:yyyywww
+ ///
+ private DateTime GetWeekStartTime(int year,int weekNum)
+ {
+
+ //本年1月1日
+ DateTime firstOfYear = new DateTime(year, 1, 1);
+ //周数
+
+ //本年1月1日与本周星期一相差的天数
+ int dayDiff = (firstOfYear.DayOfWeek == DayOfWeek.Sunday ? 7 : Convert.ToInt32(firstOfYear.DayOfWeek)) - 1;
+ //第一周的星期一
+ DateTime firstDayOfFirstWeek = firstOfYear.AddDays(-dayDiff);
+ //当前周的星期一
+ DateTime firstDayOfThisWeek = firstDayOfFirstWeek.AddDays((weekNum - 1) * 7);
+ return firstDayOfThisWeek;
+ }
}
}
diff --git a/ZR.Service/mes/qc/FirstFQCService.cs b/ZR.Service/mes/qc/FirstFQCService.cs
index 73aa8d5f..29f5e3ee 100644
--- a/ZR.Service/mes/qc/FirstFQCService.cs
+++ b/ZR.Service/mes/qc/FirstFQCService.cs
@@ -20,6 +20,7 @@ using ZR.Model.MES.qu;
using ZR.Service.mes.qc.IService;
using ZR.Service.mes.qu.IService;
using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
+using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ZR.Service.mes.qc
{
@@ -57,50 +58,62 @@ namespace ZR.Service.mes.qc
});
checkItem.device = Queryable().Where(it => it.InspectionModule == "设备").OrderBy(it => it.Id).ToList();
- checkItem.device.ForEach(it =>
+ checkItem.device.ForEach(item =>
{
QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
checkItem.Blank = Queryable().Where(it => it.InspectionModule == "毛坯").OrderBy(it => it.Id).ToList();
- checkItem.Blank.ForEach(it =>
+ checkItem.Blank.ForEach(item =>
{
QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
checkItem.program = Queryable().Where(it => it.InspectionModule == "程序").OrderBy(it => it.Id).ToList();
- checkItem.program.ForEach(it =>
+ checkItem.program.ForEach(item =>
{
QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
checkItem.Team = Queryable().Where(it => it.InspectionModule == "班组操作").OrderBy(it => it.Id).ToList();
- checkItem.Team.ForEach(it =>
+ checkItem.Team.ForEach(item =>
{
QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
return checkItem;
@@ -138,50 +151,62 @@ namespace ZR.Service.mes.qc
});
checkItem.device = Queryable().Where(it => it.InspectionModule == "设备").OrderBy(it => it.Id).ToList();
- checkItem.device.ForEach(it =>
+ checkItem.device.ForEach(item =>
{
- QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ QcAgaininspectionRecord record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
checkItem.Blank = Queryable().Where(it => it.InspectionModule == "毛坯").OrderBy(it => it.Id).ToList();
- checkItem.Blank.ForEach(it =>
+ checkItem.Blank.ForEach(item =>
{
- QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ QcAgaininspectionRecord record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
checkItem.program = Queryable().Where(it => it.InspectionModule == "程序").OrderBy(it => it.Id).ToList();
- checkItem.program.ForEach(it =>
+ checkItem.program.ForEach(item =>
{
- QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ QcAgaininspectionRecord record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
checkItem.Team = Queryable().Where(it => it.InspectionModule == "班组操作").OrderBy(it => it.Id).ToList();
- checkItem.Team.ForEach(it =>
+ checkItem.Team.ForEach(item =>
{
- QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ QcAgaininspectionRecord record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
return checkItem;
@@ -220,50 +245,62 @@ namespace ZR.Service.mes.qc
});
checkItem.device = Queryable().Where(it => it.InspectionModule == "设备").OrderBy(it => it.Id).ToList();
- checkItem.device.ForEach(it =>
+ checkItem.device.ForEach(item =>
{
- QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ QcFinalinspectionRecord record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
checkItem.Blank = Queryable().Where(it => it.InspectionModule == "毛坯").OrderBy(it => it.Id).ToList();
- checkItem.Blank.ForEach(it =>
+ checkItem.Blank.ForEach(item =>
{
- QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ QcFinalinspectionRecord record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
checkItem.program = Queryable().Where(it => it.InspectionModule == "程序").OrderBy(it => it.Id).ToList();
- checkItem.program.ForEach(it =>
+ checkItem.program.ForEach(item =>
{
- QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ QcFinalinspectionRecord record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
checkItem.Team = Queryable().Where(it => it.InspectionModule == "班组操作").OrderBy(it => it.Id).ToList();
- checkItem.Team.ForEach(it =>
+ checkItem.Team.ForEach(item =>
{
- QcFirstinspectionRecord record = Context.Queryable()
- .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ QcFinalinspectionRecord record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First();
if (record != null)
{
- it.Counter = record.Counter;
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
}
- it.Counter = 0;
});
return checkItem;
@@ -582,7 +619,11 @@ namespace ZR.Service.mes.qc
return Math.Round(percentage, 2);
}
- public static QcCurrentWorkorderDto Now_producting_Workorder = null; //当前生产工单
+ public static QcCurrentWorkorderDto Now_producting_Workorder_first = null; //当前生产工单 首检
+ public static QcCurrentWorkorderDto Now_producting_Workorder_again = null; //当前生产工单 二检
+ public static QcCurrentWorkorderDto Now_producting_Workorder_thirty = null; //当前生产工单 三检
+
+
///
/// 获取当前_生产中_工单列表
///
@@ -619,28 +660,56 @@ namespace ZR.Service.mes.qc
///
- /// 获取当前生产工单
+ /// 获取当前生产工单 一检
///
///
///
- public QcCurrentWorkorderDto GetcurrentWorkorder()
+ public QcCurrentWorkorderDto GetcurrentWorkorder_first()
{
//获取状态为1的生产工单列表
List Now_producting_WorkorderList = GetNow_producting_WorkorderList();
// 当前没有生产工单
if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
{
- Now_producting_Workorder = null;
+ Now_producting_Workorder_first = null;
return null;
}
- else if (Now_producting_Workorder == null)
+ else if (Now_producting_Workorder_first == null)
{
- Now_producting_Workorder = Now_producting_WorkorderList[0];
- return Now_producting_Workorder;
+ Now_producting_Workorder_first = Now_producting_WorkorderList[0];
+ return Now_producting_Workorder_first;
}
else
{
- return Now_producting_Workorder;
+ return Now_producting_Workorder_first;
+ }
+
+ }
+
+
+ ///
+ /// 获取当前生产工单 二检
+ ///
+ ///
+ ///
+ public QcCurrentWorkorderDto GetcurrentWorkorder_again()
+ {
+ //获取状态为1的生产工单列表
+ List Now_producting_WorkorderList = GetNow_producting_WorkorderList();
+ // 当前没有生产工单
+ if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
+ {
+ Now_producting_Workorder_again = null;
+ return null;
+ }
+ else if (Now_producting_Workorder_again == null)
+ {
+ Now_producting_Workorder_again = Now_producting_WorkorderList[0];
+ return Now_producting_Workorder_again;
+ }
+ else
+ {
+ return Now_producting_Workorder_again;
}
}
@@ -648,52 +717,43 @@ namespace ZR.Service.mes.qc
///
- /// 获取下一个生产工单
+ /// 获取当前生产工单 三检
///
///
///
- public QcCurrentWorkorderDto GetcurrentWorkorder_next()
+ public QcCurrentWorkorderDto GetcurrentWorkorder_thirty()
+ {
+ //获取状态为1的生产工单列表
+ List Now_producting_WorkorderList = GetNow_producting_WorkorderList();
+ // 当前没有生产工单
+ if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
+ {
+ Now_producting_Workorder_thirty = null;
+ return null;
+ }
+ else if (Now_producting_Workorder_thirty == null)
+ {
+ Now_producting_Workorder_thirty = Now_producting_WorkorderList[0];
+ return Now_producting_Workorder_thirty;
+ }
+ else
+ {
+ return Now_producting_Workorder_thirty;
+ }
+
+ }
+
+
+
+ ///
+ /// 获取下一个生产工单 一检
+ ///
+ ///
+ ///
+ public QcCurrentWorkorderDto GetcurrentWorkorder_next_first()
{
- //#region 清空已经完成工单的缓存
- //// 获取状态为2的工单列表,然后清空缓存
- //List workorders = Context.Queryable().Where(it => it.Remark3 == "是").Where(it => it.Status >1).OrderBy(it => it.Sort).ToList();
- //if(workorders!=null&&workorders.Count>0)
- //{
- // foreach(ProWorkorder_v2 workorder_item in workorders)
- // {
- // // key值规则 workorderid + "_"+ checkid + "_v1";
- // StringBuilder string_Key =new StringBuilder();
- // string_Key.Append(workorder_item.ClientWorkorder);
- // // 获取所有检测项
- // List qcInspectionitems=Context.Queryable().ToList();
- // foreach(QcInspectionitem qc in qcInspectionitems)
- // {
- // string_Key.Append(qc.Id);
- // string_Key.Append("_v1");
- // if (CacheHelper.Exists(string_Key.ToString()))
- // {
- // CacheHelper.Remove(string_Key.ToString());
- // }
- // string_Key.Append("_v2");
- // if (CacheHelper.Exists(string_Key.ToString()))
- // {
- // CacheHelper.Remove(string_Key.ToString());
- // }
- // string_Key.Append("_v3");
- // if (CacheHelper.Exists(string_Key.ToString()))
- // {
- // CacheHelper.Remove(string_Key.ToString());
- // }
-
- // }
-
- // }
- //}
-
-
-
- //#endregion
+
//获取状态为1的生产工单列表
@@ -701,23 +761,23 @@ namespace ZR.Service.mes.qc
// 当前没有生产工单
if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
{
- Now_producting_Workorder = null;
+ Now_producting_Workorder_first = null;
return null;
}
else
{
// 当前没有生产工单
- if (Now_producting_Workorder == null)
+ if (Now_producting_Workorder_first == null)
{
return null;
}
//获取上一个工单号 游标
- int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder.ClientWorkorder);
+ int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_first.ClientWorkorder);
if (index < 0)
{
// 逻辑异常
- Now_producting_Workorder = Now_producting_WorkorderList[0];
+ Now_producting_Workorder_first = Now_producting_WorkorderList[0];
return null;
}
if (index == Now_producting_WorkorderList.Count() - 1)
@@ -730,13 +790,117 @@ namespace ZR.Service.mes.qc
}
else
{
- Now_producting_Workorder = Now_producting_WorkorderList[index + 1];
- return Now_producting_Workorder;
+ Now_producting_Workorder_first = Now_producting_WorkorderList[index + 1];
+ return Now_producting_Workorder_first;
}
}
}
+
+ ///
+ /// 获取下一个生产工单 二检
+ ///
+ ///
+ ///
+ public QcCurrentWorkorderDto GetcurrentWorkorder_next_again()
+ {
+
+ //获取状态为1的生产工单列表
+ List Now_producting_WorkorderList = GetNow_producting_WorkorderList();
+ // 当前没有生产工单
+ if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
+ {
+ Now_producting_Workorder_again = null;
+ return null;
+ }
+ else
+ {
+
+ // 当前没有生产工单
+ if (Now_producting_Workorder_again == null)
+ {
+ return null;
+ }
+ //获取上一个工单号 游标
+ int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_again.ClientWorkorder);
+ if (index < 0)
+ {
+ // 逻辑异常
+ Now_producting_Workorder_again = Now_producting_WorkorderList[0];
+ return null;
+ }
+ if (index == Now_producting_WorkorderList.Count() - 1)
+ {
+ // 已经是最后一个了没有
+
+
+ return null;
+
+ }
+ else
+ {
+ Now_producting_Workorder_again = Now_producting_WorkorderList[index + 1];
+ return Now_producting_Workorder_again;
+ }
+
+ }
+
+ }
+
+ ///
+ /// 获取下一个生产工单 三检
+ ///
+ ///
+ ///
+ public QcCurrentWorkorderDto GetcurrentWorkorder_next_thirty()
+ {
+ //获取状态为1的生产工单列表
+ List Now_producting_WorkorderList = GetNow_producting_WorkorderList();
+ // 当前没有生产工单
+ if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
+ {
+ Now_producting_Workorder_thirty = null;
+ return null;
+ }
+ else
+ {
+
+ // 当前没有生产工单
+ if (Now_producting_Workorder_thirty == null)
+ {
+ return null;
+ }
+ //获取上一个工单号 游标
+ int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_thirty.ClientWorkorder);
+ if (index < 0)
+ {
+ // 逻辑异常
+ Now_producting_Workorder_thirty = Now_producting_WorkorderList[0];
+ return null;
+ }
+ if (index == Now_producting_WorkorderList.Count() - 1)
+ {
+ // 已经是最后一个了没有
+
+
+ return null;
+
+ }
+ else
+ {
+ Now_producting_Workorder_thirty = Now_producting_WorkorderList[index + 1];
+ return Now_producting_Workorder_thirty;
+ }
+
+ }
+
+ }
+
+
+
+
+
///
/// 记录检测项结果
///
@@ -765,36 +929,38 @@ namespace ZR.Service.mes.qc
}
+
+
///
- /// 获取上一个工单
+ /// 获取上一个工单 首检
///
///
- ///
+ ///
- public QcCurrentWorkorderDto GetcurrentWorkorder_previous()
+ public QcCurrentWorkorderDto GetcurrentWorkorder_previous_first()
{
//获取状态为1的生产工单列表
List Now_producting_WorkorderList = GetNow_producting_WorkorderList();
// 当前没有生产工单
if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
{
- Now_producting_Workorder = null;
+ Now_producting_Workorder_first = null;
return null;
}
else
{
// 当前没有生产工单
- if (Now_producting_Workorder == null)
+ if (Now_producting_Workorder_first == null)
{
return null;
}
//获取上一个工单号 游标
- int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder.ClientWorkorder);
+ int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_first.ClientWorkorder);
if (index < 0)
{
// 逻辑异常
- Now_producting_Workorder = Now_producting_WorkorderList[0];
+ Now_producting_Workorder_first = Now_producting_WorkorderList[0];
return null;
}
if (index == 0)
@@ -805,40 +971,168 @@ namespace ZR.Service.mes.qc
}
else
{
- Now_producting_Workorder = Now_producting_WorkorderList[index - 1];
- return Now_producting_Workorder;
+ Now_producting_Workorder_first = Now_producting_WorkorderList[index - 1];
+ return Now_producting_Workorder_first;
}
}
}
+
+
+
+
+ ///
+ /// 获取上一个工单 二检
+ ///
+ ///
+ ///
+
+ public QcCurrentWorkorderDto GetcurrentWorkorder_previous_again()
+ {
+ //获取状态为1的生产工单列表
+ List Now_producting_WorkorderList = GetNow_producting_WorkorderList();
+ // 当前没有生产工单
+ if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
+ {
+ Now_producting_Workorder_again = null;
+ return null;
+ }
+ else
+ {
+
+ // 当前没有生产工单
+ if (Now_producting_Workorder_again == null)
+ {
+ return null;
+ }
+ //获取上一个工单号 游标
+ int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_again.ClientWorkorder);
+ if (index < 0)
+ {
+ // 逻辑异常
+ Now_producting_Workorder_again = Now_producting_WorkorderList[0];
+ return null;
+ }
+ if (index == 0)
+ {
+ // 已经是最后一个了没有
+ return null;
+
+ }
+ else
+ {
+ Now_producting_Workorder_again = Now_producting_WorkorderList[index - 1];
+ return Now_producting_Workorder_again;
+ }
+
+ }
+ }
+
+
+
+
+ ///
+ /// 获取上一个工单 三检
+ ///
+ ///
+ ///
+
+ public QcCurrentWorkorderDto GetcurrentWorkorder_previous_thirty()
+ {
+ //获取状态为1的生产工单列表
+ List Now_producting_WorkorderList = GetNow_producting_WorkorderList();
+ // 当前没有生产工单
+ if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
+ {
+ Now_producting_Workorder_thirty = null;
+ return null;
+ }
+ else
+ {
+
+ // 当前没有生产工单
+ if (Now_producting_Workorder_thirty == null)
+ {
+ return null;
+ }
+ //获取上一个工单号 游标
+ int index = Now_producting_WorkorderList.FindIndex(x => x.ClientWorkorder == Now_producting_Workorder_thirty.ClientWorkorder);
+ if (index < 0)
+ {
+ // 逻辑异常
+ Now_producting_Workorder_thirty = Now_producting_WorkorderList[0];
+ return null;
+ }
+ if (index == 0)
+ {
+ // 已经是最后一个了没有
+ return null;
+
+ }
+ else
+ {
+ Now_producting_Workorder_thirty = Now_producting_WorkorderList[index - 1];
+ return Now_producting_Workorder_thirty;
+ }
+
+ }
+ }
+
+
+
+
///
/// 缺陷项目 累加 (首检)
///
- ///
- ///
- ///
- ///
+ /// 工单id
+ /// 缺陷项
+ /// 要累加的值
+ /// 最终累加的值
///
- public int Accumulator_first(string workorder_id, int checkid, int counter, string name)
+ public int Accumulator_first(string workorder_id, int checkid, int number, string InspectionModule, string name)
{
-
- QcFirstinspectionRecord record = new QcFirstinspectionRecord();
- record.Id = SnowFlakeSingle.Instance.NextId().ToString();
- record.FKWorkorderId = workorder_id;
- record.FKInpectionId = checkid.ToString();
- record.InspectionModule = "paint";
- record.Counter = counter;
- record.CreatedTime = DateTime.Now;
- record.UpdatedTime = DateTime.Now;
- record.CreatedBy = name;
- record.UpdatedBy = name;
-
- var x = Context.Storageable(record)
- .WhereColumns(it => new { it.FKWorkorderId, it.FKInpectionId }).ToStorage();
int result = 0;
- result += x.AsInsertable.ExecuteCommand();//不存在插入
- result += x.AsUpdateable.UpdateColumns(it => new { it.Counter, it.UpdatedBy, it.UpdatedTime }).ExecuteCommand();//存在更新
+ //TODO 获取已知的的检测项 +1
+ QcFirstinspectionRecord exist_record= Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorder_id && it.FKInpectionId == checkid.ToString())
+ .First();
+ if (exist_record == null)
+ {
+ QcFirstinspectionRecord record = new QcFirstinspectionRecord();
+
+ record.Id = SnowFlakeSingle.Instance.NextId().ToString();
+ record.FKWorkorderId = workorder_id;
+ record.FKInpectionId = checkid.ToString();
+ record.InspectionModule = InspectionModule;
+
+ record.Counter = number;
+ record.CreatedTime = DateTime.Now;
+ record.UpdatedTime = DateTime.Now;
+ record.CreatedBy = name;
+ record.UpdatedBy = name;
+ Context.Insertable(record).ExecuteCommand();
+
+ result = 1;
+
+ }
+ else
+ {
+ result= Context.Updateable()
+ .SetColumns(it=>it.Counter==(exist_record.Counter+ number))
+ .SetColumns(it=>it.UpdatedTime== DateTime.Now)
+ .SetColumns(it=>it.UpdatedBy == name)
+ .Where(it=>it.FKInpectionId==checkid.ToString()&&it.FKWorkorderId==workorder_id)
+ .ExecuteCommand();
+
+ result = (int)exist_record.Counter + number;
+
+ }
+
+
+
+
+
return result;
@@ -851,27 +1145,47 @@ namespace ZR.Service.mes.qc
///
///
///
- public int Accumulator_again(string workorder_id, int checkid, int counter, string name)
+ public int Accumulator_again(string workorder_id, int checkid, int number, string InspectionModule, string name)
{
- QcAgaininspectionRecord record = new QcAgaininspectionRecord();
- record.Id = SnowFlakeSingle.Instance.NextId().ToString();
- record.FkWorkorderId = workorder_id;
- record.FkInpectionId = checkid.ToString();
- record.InspectionModule = "paint";
- record.Counter = counter;
- record.CreatedTime = DateTime.Now;
- record.UpdatedTime = DateTime.Now;
- record.CreatedBy = name;
- record.UpdatedBy = name;
-
- var x = Context.Storageable(record)
- .WhereColumns(it => new { it.FkWorkorderId, it.FkInpectionId }).ToStorage();
+
int result = 0;
- result += x.AsInsertable.ExecuteCommand();//不存在插入
- result += x.AsUpdateable.UpdateColumns(it => new { it.Counter, it.UpdatedBy, it.UpdatedTime }).ExecuteCommand();//存在更新
+ //TODO 获取已知的的检测项 +1
+ QcAgaininspectionRecord exist_record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorder_id && it.FkInpectionId == checkid.ToString())
+ .First();
+ if (exist_record == null)
+ {
+ QcAgaininspectionRecord record = new QcAgaininspectionRecord();
+ record.Id = SnowFlakeSingle.Instance.NextId().ToString();
+ record.FkWorkorderId = workorder_id;
+ record.FkInpectionId = checkid.ToString();
+ record.InspectionModule = InspectionModule;
+
+ record.Counter = number;
+ record.CreatedTime = DateTime.Now;
+ record.UpdatedTime = DateTime.Now;
+ record.CreatedBy = name;
+ record.UpdatedBy = name;
+ Context.Insertable(record).ExecuteCommand();
+
+ result = 1;
+
+ }
+ else
+ {
+ result = Context.Updateable()
+ .SetColumns(it => it.Counter == (exist_record.Counter + number))
+ .SetColumns(it => it.UpdatedTime == DateTime.Now)
+ .SetColumns(it => it.UpdatedBy == name)
+ .Where(it => it.FkInpectionId == checkid.ToString() && it.FkWorkorderId == workorder_id)
+ .ExecuteCommand();
+
+ result = (int)exist_record.Counter + number;
+
+ }
return result;
}
@@ -883,25 +1197,51 @@ namespace ZR.Service.mes.qc
///
///
///
- public int Accumulator_thirty(string workorder_id, int checkid, int counter, string name)
+ public int Accumulator_thirty(string workorder_id, int checkid, int number, string InspectionModule, string name)
{
- QcFinalinspectionRecord record = new QcFinalinspectionRecord();
- record.Id = SnowFlakeSingle.Instance.NextId().ToString();
- record.FkWorkorderId = workorder_id;
- record.FkInpectionId = checkid.ToString();
- record.InspectionModule = "paint";
- record.Counter = counter;
- record.CreatedTime = DateTime.Now;
- record.UpdatedTime = DateTime.Now;
- record.CreatedBy = name;
- record.UpdatedBy = name;
- var x = Context.Storageable(record)
- .WhereColumns(it => new { it.FkWorkorderId, it.FkInpectionId }).ToStorage();
int result = 0;
- result += x.AsInsertable.ExecuteCommand();//不存在插入
- result += x.AsUpdateable.UpdateColumns(it => new { it.Counter, it.UpdatedBy, it.UpdatedTime }).ExecuteCommand();//存在更新
+ //TODO 获取已知的的检测项 +1
+ QcFinalinspectionRecord exist_record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorder_id && it.FkInpectionId == checkid.ToString())
+ .First();
+
+ if (exist_record == null)
+ {
+ QcFinalinspectionRecord record = new QcFinalinspectionRecord();
+
+ record.Id = SnowFlakeSingle.Instance.NextId().ToString();
+ record.FkWorkorderId = workorder_id;
+ record.FkInpectionId = checkid.ToString();
+ record.InspectionModule = InspectionModule;
+
+ record.Counter = number;
+ record.CreatedTime = DateTime.Now;
+ record.UpdatedTime = DateTime.Now;
+ record.CreatedBy = name;
+ record.UpdatedBy = name;
+ Context.Insertable(record).ExecuteCommand();
+
+ result = 1;
+
+ }
+ else
+ {
+ result = Context.Updateable()
+ .SetColumns(it => it.Counter == (exist_record.Counter + number))
+ .SetColumns(it => it.UpdatedTime == DateTime.Now)
+ .SetColumns(it => it.UpdatedBy == name)
+ .Where(it => it.FkInpectionId == checkid.ToString() && it.FkWorkorderId == workorder_id)
+ .ExecuteCommand();
+
+ result = (int)exist_record.Counter + number;
+
+ }
+
+
+
+
@@ -924,8 +1264,9 @@ namespace ZR.Service.mes.qc
{
sum = SqlFunc.AggregateSum(it.Counter ?? 0)
}).First();
-
- return list.sum;
+ if (list != null)
+ return list.sum;
+ else return 0;
}
///
@@ -938,40 +1279,84 @@ namespace ZR.Service.mes.qc
public int CalculatePackagingInvestment(string workorder_id)
{
- //TODO 一次合格数=计划数-所有缺陷数
+
int OnePassNumber = 0;
int polishPassNumber = 0;
UseTran(() =>
{
+ //TODO 一次合格数=计划数-所有缺陷数
var workorder = Context.Queryable().Where(it => it.ClientWorkorder == workorder_id).First();
- var list = Context.Queryable()
- .Where(it => it.Equals(workorder_id))
- .GroupBy(it => it.FKWorkorderId)
- .Select(it => new
- {
- sum = SqlFunc.AggregateSum(it.Counter ?? 0)
- }).First();
- OnePassNumber = workorder.PreviousNumber - list.sum;
+
+ if(workorder != null)
+ {
- //TODO 计算抛光合格=首检的抛光-抛光缺陷项
- int polishNumber = CalculatePolishTotalNumber(workorder_id);
- var polish_defect_Number = Context.Queryable()
- .Where(it => it.Equals(workorder_id))
- .GroupBy(it => it.FkWorkorderId)
- .Select(it => new
- {
- sum = SqlFunc.AggregateSum(it.Counter ?? 0)
- }).First();
+ var list = Context.Queryable()
+ .Where(it => it.FKWorkorderId.Equals(workorder_id))
+ .GroupBy(it => it.FKWorkorderId)
+ .Select(it => new
+ {
+ sum = SqlFunc.AggregateSum(it.Counter ?? 0)
+ }).First();
+ if (list != null)
+ {
+ OnePassNumber = workorder.PreviousNumber - list.sum;
+ }
+ else
+ {
+ OnePassNumber = workorder.PreviousNumber - 0;
+ }
- polishPassNumber = polishNumber - polish_defect_Number.sum;
+ //TODO 计算抛光合格=首检的抛光-抛光缺陷项
+ int polishNumber = CalculatePolishTotalNumber(workorder_id);
+ var polish_defect_Number = Context.Queryable()
+ .Where(it => it.FkWorkorderId.Equals(workorder_id))
+ .GroupBy(it => it.FkWorkorderId)
+ .Select(it => new
+ {
+ sum = SqlFunc.AggregateSum(it.Counter ?? 0)
+ }).First();
+ if (polish_defect_Number != null)
+ {
+ polishPassNumber = polishNumber - polish_defect_Number.sum;
+ }
+ else
+ {
+ polishPassNumber = polishNumber - 0;
+ }
+
+ Console.ForegroundColor = ConsoleColor.Green;
+ Console.WriteLine($"打印工单{workorder_id} 一次合格数{OnePassNumber}=计划数{workorder.PreviousNumber}-----所有缺陷数{list?.sum} ");
+ Console.ForegroundColor = ConsoleColor.Green;
+ Console.WriteLine($"打印工单{workorder_id} 计算抛光合格{polishPassNumber}=首检的抛光{polishNumber}-----抛光缺陷项{polish_defect_Number?.sum}");
+ Console.ForegroundColor = ConsoleColor.Green;
+ Console.WriteLine($"打印工单{workorder_id} 包装投入数{OnePassNumber + polishPassNumber}");
+
+
+
+
+ }
});
-
+
return OnePassNumber + polishPassNumber;
}
+ ///
+ /// 更改工单为完成态
+ ///
+ ///
+ ///
+ ///
+ public int UpdateWorkorderStatus(string workorder_id)
+ {
+
+ return Context.Updateable()
+ .SetColumns(it => it.Status == 2)
+ .Where(it => it.ClientWorkorder == workorder_id)
+ .ExecuteCommand();
+ }
}
}
diff --git a/ZR.Service/mes/qc/IService/IFirstFQCService.cs b/ZR.Service/mes/qc/IService/IFirstFQCService.cs
index 5ed5e686..736b3ca7 100644
--- a/ZR.Service/mes/qc/IService/IFirstFQCService.cs
+++ b/ZR.Service/mes/qc/IService/IFirstFQCService.cs
@@ -19,18 +19,29 @@ namespace ZR.Service.mes.qc.IService
public Task SaveinspectItem_v2(string workorder_id, string InspectionModule, string checkid, int counter);
public Task SaveinspectItem_v3(string workorder_id, string InspectionModule, string checkid, int counter);
- public QcCurrentWorkorderDto GetcurrentWorkorder();
- public QcCurrentWorkorderDto GetcurrentWorkorder_next();
- public QcCurrentWorkorderDto GetcurrentWorkorder_previous();
+ public QcCurrentWorkorderDto GetcurrentWorkorder_first();
+ public QcCurrentWorkorderDto GetcurrentWorkorder_next_first();
+ public QcCurrentWorkorderDto GetcurrentWorkorder_previous_first();
- public int Accumulator_first(string workorder_id, int checkid, int counter,string name);
- public int Accumulator_again(string workorder_id, int checkid, int counter,string name);
- public int Accumulator_thirty(string workorder_id, int checkid, int counter,string name);
+ public QcCurrentWorkorderDto GetcurrentWorkorder_again();
+ public QcCurrentWorkorderDto GetcurrentWorkorder_next_again();
+ public QcCurrentWorkorderDto GetcurrentWorkorder_previous_again();
+
+ public QcCurrentWorkorderDto GetcurrentWorkorder_thirty();
+ public QcCurrentWorkorderDto GetcurrentWorkorder_next_thirty();
+ public QcCurrentWorkorderDto GetcurrentWorkorder_previous_thirty();
+
+ public int Accumulator_first(string workorder_id, int checkid, int number, string InspectionModule, string name);
+ public int Accumulator_again(string workorder_id, int checkid, int number, string InspectionModule, string name);
+ public int Accumulator_thirty(string workorder_id, int checkid, int number, string InspectionModule, string name);
public int CalculatePolishTotalNumber(string workorder_id);
public int CalculatePackagingInvestment(string workorder_id);
+ public int UpdateWorkorderStatus(string workorder_id);
+
+
}
}