diff --git a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs
index 9bc26c82..d663d5ac 100644
--- a/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs
+++ b/ZR.Admin.WebApi/Controllers/mes/qc/FQC/FirstFQCController.cs
@@ -34,26 +34,45 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.IQC
///
- /// 获取 检测项 填充
+ /// 获取 检测项 填充 (首检)
///
///
- [HttpGet("getcheckItemTable")]
- public IActionResult GetcheckItemTable()
+ [HttpGet("getcheckItemTable__first")]
+ public IActionResult GetcheckItemTable__first(string workorderID)
{
- CheckItemTableDTO itemTableDTO = fQCService.GetCheckItemTable();
+ CheckItemTableDTO itemTableDTO = fQCService.GetCheckItemTable_first(workorderID);
+
+ return SUCCESS(itemTableDTO);
+ }
+
+ ///
+ /// 获取 检测项 填充 (二检)
+ ///
+ ///
+ [HttpGet("getcheckItemTable__again")]
+ public IActionResult GetcheckItemTable__again(string workorderID)
+ {
+
+ CheckItemTableDTO itemTableDTO = fQCService.GetCheckItemTable_again(workorderID);
+
+ return SUCCESS(itemTableDTO);
+ }
+
+ ///
+ /// 获取 检测项 填充 (三检)
+ ///
+ ///
+ [HttpGet("getcheckItemTable__thirty")]
+ public IActionResult GetcheckItemTable__thirty(string workorderID)
+ {
+
+ CheckItemTableDTO itemTableDTO = fQCService.GetCheckItemTable_thirty(workorderID);
return SUCCESS(itemTableDTO);
}
- [HttpGet("getcheckitemRecord")]
- public IActionResult GetcheckitemRecord()
- {
-
-
- return null;
- }
@@ -98,5 +117,82 @@ namespace ZR.Admin.WebApi.Controllers.mes.qc.IQC
return SUCCESS(workorder);
}
+ ///
+ /// 初检累加器
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("accumulator_query_first")]
+ public IActionResult Accumulator_first(string workorder_id,int checkid,int counter)
+ {
+
+ int result= fQCService.Accumulator_first(workorder_id, checkid, counter, HttpContext.GetName());
+
+ return SUCCESS(counter);
+ }
+ ///
+ /// 二检累加器
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("accumulator_query_again")]
+ public IActionResult Accumulator_again(string workorder_id, int checkid, int counter)
+ {
+
+ int result = fQCService.Accumulator_again(workorder_id, checkid, counter, HttpContext.GetName());
+
+ return SUCCESS(counter);
+ }
+
+ ///
+ /// 三检累加器
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("accumulator_query_thirty")]
+ public IActionResult Accumulator_thirty(string workorder_id, int checkid, int counter)
+ {
+
+ int result = fQCService.Accumulator_thirty(workorder_id, checkid, counter, HttpContext.GetName());
+
+ return SUCCESS(counter);
+ }
+
+
+ ///
+ /// 计算当前工单抛光总数
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("calculate_polish_total_number")]
+ public IActionResult CalculatePolishTotalNumber(string workorder_id)
+ {
+
+ int AllNumber = fQCService.CalculatePolishTotalNumber(workorder_id);
+
+ return SUCCESS(AllNumber);
+ }
+ ///
+ /// 计算当前工单下的包装投入数==一次合格+抛光合格
+ ///
+ ///
+ ///
+ [HttpGet("calculate_packagingInvestment")]
+ public IActionResult CalculatePackagingInvestment(string workorder_id)
+ {
+ int AllNumber = fQCService.CalculatePackagingInvestment(workorder_id);
+ return SUCCESS(AllNumber);
+
+ }
+
+
}
}
diff --git a/ZR.Admin.WebApi/Controllers/mes/qc/QcinspectionItemController.cs b/ZR.Admin.WebApi/Controllers/mes/qc/QcinspectionItemController.cs
index 33f11c79..8cbb5020 100644
--- a/ZR.Admin.WebApi/Controllers/mes/qc/QcinspectionItemController.cs
+++ b/ZR.Admin.WebApi/Controllers/mes/qc/QcinspectionItemController.cs
@@ -13,7 +13,9 @@ using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ZR.Admin.WebApi.Controllers.mes.qc
{
-
+ ///
+ /// 检测
+ ///
[Route("mes/qc/IQC")]
public class QcinspectionItemController : BaseController
{
diff --git a/ZR.Admin.WebApi/Hubs/MessageHub.cs b/ZR.Admin.WebApi/Hubs/MessageHub.cs
index e55b318a..e5725ec8 100644
--- a/ZR.Admin.WebApi/Hubs/MessageHub.cs
+++ b/ZR.Admin.WebApi/Hubs/MessageHub.cs
@@ -117,23 +117,24 @@ namespace ZR.Admin.WebApi.Hubs
///
public async Task SaveCacheInformation_v1(string workorderid, string Moudle, string checkid)
{
- checkid = checkid + "_v1";
+ //缓存key
+ string checkid_Key =checkid + "_" + workorderid + "_v1";
- if (CacheHelper.Exists(checkid))
+ if (CacheHelper.Exists(checkid_Key))
{
- int sum = Convert.ToInt32(CacheHelper.GetCache(checkid)) + 1;
- logger.Info($"当前保存工单号{workorderid},检测项{checkid},累加的数为{sum}");
- CacheHelper.SetCache(checkid, sum);
- //SaveinspectItem
- await firstFQCService.SaveinspectItem_v1(workorderid,Moudle, checkid,sum);
- await Clients.All.SendAsync("GetCache_v1", Moudle,checkid, sum);
+ int sum = Convert.ToInt32(CacheHelper.GetCache(checkid_Key)) + 1;
+ logger.Info($"当前保存工单号{workorderid},检测项{checkid_Key},累加的数为{sum}");
+ CacheHelper.SetCache(checkid_Key, sum);
+
+ await firstFQCService.SaveinspectItem_v1(workorderid,Moudle, checkid_Key, sum);
+ await Clients.All.SendAsync("GetCache_v1", Moudle, checkid_Key, sum);
}
else
{
- CacheHelper.SetCache(checkid, 1);
- logger.Info($"当前保存工单号{workorderid},检测项{checkid},累加的数为1");
- await firstFQCService.SaveinspectItem_v1(workorderid, Moudle, checkid, 1);
- await Clients.All.SendAsync("GetCache_v1", Moudle, checkid, 1);
+ CacheHelper.SetCache(checkid_Key, 1);
+ logger.Info($"当前保存工单号{workorderid},检测项{checkid_Key},累加的数为1");
+ await firstFQCService.SaveinspectItem_v1(workorderid, Moudle, checkid_Key, 1);
+ await Clients.All.SendAsync("GetCache_v1", Moudle, checkid_Key, 1);
}
}
diff --git a/ZR.Model/MES/qc/QcInspectionitem.cs b/ZR.Model/MES/qc/QcInspectionitem.cs
index a2a94cc0..35b13eb1 100644
--- a/ZR.Model/MES/qc/QcInspectionitem.cs
+++ b/ZR.Model/MES/qc/QcInspectionitem.cs
@@ -66,12 +66,17 @@ namespace ZR.Model.MES.qu
///
[SugarColumn(ColumnName = "UPDATED_BY")]
public string UpdatedBy { get; set; }
+
+
///
/// 更新时间
///
[SugarColumn(ColumnName = "UPDATED_TIME")]
public DateTime? UpdatedTime { get; set; }
+ ///
+ /// 检测数量
+ ///
[SugarColumn(IsIgnore =true)]
public int? Counter { get; set; }
}
diff --git a/ZR.Service/mes/pro/ProWorkorderServiceV2.cs b/ZR.Service/mes/pro/ProWorkorderServiceV2.cs
index 11972317..3dd2afe7 100644
--- a/ZR.Service/mes/pro/ProWorkorderServiceV2.cs
+++ b/ZR.Service/mes/pro/ProWorkorderServiceV2.cs
@@ -348,11 +348,7 @@ namespace ZR.Service.mes.pro
item.ClientWorkorder = date_now + index.ToString("000");
}
-
-
-
-
-
+
return Context.Updateable(workorderList).ExecuteCommand();
}
return 0;
diff --git a/ZR.Service/mes/qc/FirstFQCService.cs b/ZR.Service/mes/qc/FirstFQCService.cs
index b2ff53a7..73aa8d5f 100644
--- a/ZR.Service/mes/qc/FirstFQCService.cs
+++ b/ZR.Service/mes/qc/FirstFQCService.cs
@@ -1,4 +1,6 @@
-using Infrastructure.Attribute;
+using AutoMapper.Configuration.Conventions;
+using Infrastructure.Attribute;
+using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System;
@@ -9,6 +11,8 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using ZR.Common;
+using ZR.Model.mes.pro;
using ZR.Model.MES.pro;
using ZR.Model.MES.qc;
using ZR.Model.MES.qc.DTO;
@@ -23,21 +27,250 @@ namespace ZR.Service.mes.qc
[AppService(ServiceType = typeof(IFirstFQCService), ServiceLifetime = LifeTime.Transient)]
public class FirstFQCService : BaseService, IFirstFQCService
{
- public CheckItemTableDTO GetCheckItemTable()
+ ///
+ /// 获取检测项 (首检)
+ ///
+ ///
+ ///
+
+ public CheckItemTableDTO GetCheckItemTable_first(string workorderID)
{
CheckItemTableDTO checkItem = new CheckItemTableDTO();
checkItem.Paint = Queryable().Where(it => it.InspectionModule == "油漆").OrderBy(it => it.Id).ToList();
+ checkItem.Paint.ForEach(item =>
+ {
+
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == item.Id.ToString()).First();
+ if (record != null)
+ {
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
+ }
+
+
+
+ });
checkItem.device = Queryable().Where(it => it.InspectionModule == "设备").OrderBy(it => it.Id).ToList();
+ checkItem.device.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+
+ });
checkItem.Blank = Queryable().Where(it => it.InspectionModule == "毛坯").OrderBy(it => it.Id).ToList();
+ checkItem.Blank.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+
+ });
checkItem.program = Queryable().Where(it => it.InspectionModule == "程序").OrderBy(it => it.Id).ToList();
+ checkItem.program.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+ });
checkItem.Team = Queryable().Where(it => it.InspectionModule == "班组操作").OrderBy(it => it.Id).ToList();
+ checkItem.Team.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+ });
return checkItem;
}
+
+ ///
+ /// 获取检测项 (二检)
+ ///
+ ///
+ ///
+
+ public CheckItemTableDTO GetCheckItemTable_again(string workorderID)
+ {
+ CheckItemTableDTO checkItem = new CheckItemTableDTO();
+
+
+ checkItem.Paint = Queryable().Where(it => it.InspectionModule == "油漆").OrderBy(it => it.Id).ToList();
+ checkItem.Paint.ForEach(item =>
+ {
+
+ QcAgaininspectionRecord record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First();
+ if (record != null)
+ {
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
+ }
+
+
+
+ });
+ checkItem.device = Queryable().Where(it => it.InspectionModule == "设备").OrderBy(it => it.Id).ToList();
+ checkItem.device.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+
+ });
+ checkItem.Blank = Queryable().Where(it => it.InspectionModule == "毛坯").OrderBy(it => it.Id).ToList();
+ checkItem.Blank.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+
+ });
+ checkItem.program = Queryable().Where(it => it.InspectionModule == "程序").OrderBy(it => it.Id).ToList();
+ checkItem.program.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+ });
+ checkItem.Team = Queryable().Where(it => it.InspectionModule == "班组操作").OrderBy(it => it.Id).ToList();
+ checkItem.Team.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+ });
+
+ return checkItem;
+
+ }
+
+
+
+ ///
+ /// 获取检测项 (三检)
+ ///
+ ///
+ ///
+
+ public CheckItemTableDTO GetCheckItemTable_thirty(string workorderID)
+ {
+ CheckItemTableDTO checkItem = new CheckItemTableDTO();
+
+
+ checkItem.Paint = Queryable().Where(it => it.InspectionModule == "油漆").OrderBy(it => it.Id).ToList();
+ checkItem.Paint.ForEach(item =>
+ {
+
+ QcFinalinspectionRecord record = Context.Queryable()
+ .Where(it => it.FkWorkorderId == workorderID && it.FkInpectionId == item.Id.ToString()).First();
+ if (record != null)
+ {
+ item.Counter = record.Counter;
+ }
+ else
+ {
+ item.Counter = 0;
+ }
+
+
+
+ });
+ checkItem.device = Queryable().Where(it => it.InspectionModule == "设备").OrderBy(it => it.Id).ToList();
+ checkItem.device.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+
+ });
+ checkItem.Blank = Queryable().Where(it => it.InspectionModule == "毛坯").OrderBy(it => it.Id).ToList();
+ checkItem.Blank.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+
+ });
+ checkItem.program = Queryable().Where(it => it.InspectionModule == "程序").OrderBy(it => it.Id).ToList();
+ checkItem.program.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+ });
+ checkItem.Team = Queryable().Where(it => it.InspectionModule == "班组操作").OrderBy(it => it.Id).ToList();
+ checkItem.Team.ForEach(it =>
+ {
+ QcFirstinspectionRecord record = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
+ if (record != null)
+ {
+ it.Counter = record.Counter;
+ }
+ it.Counter = 0;
+ });
+
+ return checkItem;
+
+ }
+
+
///
/// 保存首次检测结果
///
@@ -48,6 +281,7 @@ namespace ZR.Service.mes.qc
///
public async Task SaveinspectItem_v1(string workorder_id, string InspectionModule, string checkid, int counter)
{
+
//更新实时记录表
QcFirstinspectionRecord record = new QcFirstinspectionRecord();
record.Id = DateTime.Now.ToString("YYMMddHHmmss");
@@ -163,7 +397,7 @@ namespace ZR.Service.mes.qc
.ToStorage();
x.AsInsertable.ExecuteCommandAsync(); //执行插入
- x.AsUpdateable.UpdateColumns(it => new { it.UpdatedBy,it.UpdatedTime,it.Counter }).ExecuteCommandAsync(); //执行更新
+ x.AsUpdateable.UpdateColumns(it => new { it.UpdatedBy, it.UpdatedTime, it.Counter }).ExecuteCommandAsync(); //执行更新
////更新初检报废表
//if (Convert.ToInt32(checkid) / 10 % 10==3)
@@ -354,12 +588,12 @@ namespace ZR.Service.mes.qc
///
///
///
- public List GetNow_producting_WorkorderList()
+ public List GetNow_producting_WorkorderList()
{
- List workorders= Context.Queryable().Where(it => it.Remark3 == "是").Where(it => it.Status == 1).OrderBy(it=>it.Sort).ToList();
-
- List qcCurrentList= new List();
- foreach(ProWorkorder_v2 item in workorders)
+ List workorders = Context.Queryable().Where(it => it.Remark3 == "是").Where(it => it.Status == 1).OrderBy(it => it.Sort).ToList();
+
+ List qcCurrentList = new List();
+ foreach (ProWorkorder_v2 item in workorders)
{
qcCurrentList.Add(new QcCurrentWorkorderDto()
{
@@ -369,15 +603,15 @@ namespace ZR.Service.mes.qc
Specifications = item.Specifications,
Colour = item.Colour,
Team = "",
- PreviousNumber=item.PreviousNumber,
- FirstPassNumber=0,
- FirstPassRate=0.0,
- PolisheNumber=0,
+ PreviousNumber = item.PreviousNumber,
+ FirstPassNumber = 0,
+ FirstPassRate = 0.0,
+ PolisheNumber = 0,
ScrapNumber = 0,
DefectNumber = 0
});
- ;
-
+ ;
+
}
return qcCurrentList;
@@ -392,14 +626,14 @@ namespace ZR.Service.mes.qc
public QcCurrentWorkorderDto GetcurrentWorkorder()
{
//获取状态为1的生产工单列表
- List Now_producting_WorkorderList= GetNow_producting_WorkorderList();
+ List Now_producting_WorkorderList = GetNow_producting_WorkorderList();
// 当前没有生产工单
- if (Now_producting_WorkorderList==null|| Now_producting_WorkorderList.Count<=0)
+ if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
{
Now_producting_Workorder = null;
return null;
}
- else if(Now_producting_Workorder==null)
+ else if (Now_producting_Workorder == null)
{
Now_producting_Workorder = Now_producting_WorkorderList[0];
return Now_producting_Workorder;
@@ -408,10 +642,10 @@ namespace ZR.Service.mes.qc
{
return Now_producting_Workorder;
}
-
+
}
-
+
///
/// 获取下一个生产工单
@@ -419,7 +653,49 @@ namespace ZR.Service.mes.qc
///
///
public QcCurrentWorkorderDto GetcurrentWorkorder_next()
- {
+ {
+
+ //#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的生产工单列表
List Now_producting_WorkorderList = GetNow_producting_WorkorderList();
// 当前没有生产工单
@@ -437,16 +713,18 @@ namespace ZR.Service.mes.qc
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.ClientWorkorder);
if (index < 0)
{
// 逻辑异常
Now_producting_Workorder = Now_producting_WorkorderList[0];
return null;
}
- if (index== Now_producting_WorkorderList.Count()-1)
+ if (index == Now_producting_WorkorderList.Count() - 1)
{
// 已经是最后一个了没有
+
+
return null;
}
@@ -455,9 +733,37 @@ namespace ZR.Service.mes.qc
Now_producting_Workorder = Now_producting_WorkorderList[index + 1];
return Now_producting_Workorder;
}
-
+
}
+ }
+ ///
+ /// 记录检测项结果
+ ///
+ /// 工单
+ /// 检测结果
+ private void Record_inspect_result(string workorder_id, List inspectionList, string createBy)
+ {
+ if (inspectionList != null && inspectionList.Count > 0)
+ {
+ foreach (var item in inspectionList)
+ {
+
+ QcFirstinspectionRecord record = new QcFirstinspectionRecord();
+ record.Id = DateTime.Now.ToString("yyMMddHHmmss") + inspectionList.IndexOf(item);
+ record.FKWorkorderId = workorder_id;
+ record.FKInpectionId = item.Id.ToString();
+ record.InspectionModule = item.InspectionModule;
+ record.Counter = item.Counter;
+ record.CreatedBy = createBy;
+
+
+ //Context.Storageable()
+ }
+
+ }
+
+
}
///
/// 获取上一个工单
@@ -499,15 +805,173 @@ namespace ZR.Service.mes.qc
}
else
{
- Now_producting_Workorder = Now_producting_WorkorderList[index -1];
+ Now_producting_Workorder = Now_producting_WorkorderList[index - 1];
return Now_producting_Workorder;
}
}
}
+ ///
+ /// 缺陷项目 累加 (首检)
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public int Accumulator_first(string workorder_id, int checkid, int counter, 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();//存在更新
-
+ return result;
+ }
+ ///
+ /// 缺陷项目 累加 (二检)
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public int Accumulator_again(string workorder_id, int checkid, int counter, 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();//存在更新
+
+
+
+ return result;
+ }
+ ///
+ /// 缺陷项目 累加 (三检)
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public int Accumulator_thirty(string workorder_id, int checkid, int counter, 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();//存在更新
+
+
+
+ return result;
+ }
+
+
+ ///
+ /// 计算当前工单下所有抛光总数
+ ///
+ ///
+ ///
+ public int CalculatePolishTotalNumber(string workorder_id)
+ {
+ var list = Context.Queryable()
+ .Where(it => it.FKWorkorderId == workorder_id)
+ .Where("fk_inpection_id like @fk_inpection_id", new { fk_inpection_id = "_" + 1 + "_" })
+ .GroupBy(it => it.FKWorkorderId)
+ .Select(it => new
+ {
+ sum = SqlFunc.AggregateSum(it.Counter ?? 0)
+ }).First();
+
+ return list.sum;
+
+ }
+ ///
+ /// 计算当前工单下的包装投入数==一次合格+抛光合格
+ ///
+ ///
+ ///
+ ///
+
+ public int CalculatePackagingInvestment(string workorder_id)
+ {
+
+ //TODO 一次合格数=计划数-所有缺陷数
+ int OnePassNumber = 0;
+ int polishPassNumber = 0;
+
+ UseTran(() =>
+ {
+ 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;
+
+ //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();
+
+
+ polishPassNumber = polishNumber - polish_defect_Number.sum;
+
+
+ });
+
+ return OnePassNumber + polishPassNumber;
+
+ }
}
}
diff --git a/ZR.Service/mes/qc/IService/IFirstFQCService.cs b/ZR.Service/mes/qc/IService/IFirstFQCService.cs
index 221a4d9f..5ed5e686 100644
--- a/ZR.Service/mes/qc/IService/IFirstFQCService.cs
+++ b/ZR.Service/mes/qc/IService/IFirstFQCService.cs
@@ -1,15 +1,20 @@
-using System;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http.HttpResults;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.MES.qc.DTO;
+using ZR.Model.MES.qu;
namespace ZR.Service.mes.qc.IService
{
public interface IFirstFQCService
{
- public CheckItemTableDTO GetCheckItemTable();
+ public CheckItemTableDTO GetCheckItemTable_first(string workorderID);
+ public CheckItemTableDTO GetCheckItemTable_again(string workorderID);
+ public CheckItemTableDTO GetCheckItemTable_thirty(string workorderID);
public Task SaveinspectItem_v1(string workorder_id, string InspectionModule, string checkid, int counter);
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);
@@ -17,5 +22,15 @@ namespace ZR.Service.mes.qc.IService
public QcCurrentWorkorderDto GetcurrentWorkorder();
public QcCurrentWorkorderDto GetcurrentWorkorder_next();
public QcCurrentWorkorderDto GetcurrentWorkorder_previous();
+
+ 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 int CalculatePolishTotalNumber(string workorder_id);
+
+ public int CalculatePackagingInvestment(string workorder_id);
+
+
}
}