检验完成
This commit is contained in:
@@ -348,11 +348,7 @@ namespace ZR.Service.mes.pro
|
||||
item.ClientWorkorder = date_now + index.ToString("000");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return Context.Updateable(workorderList).ExecuteCommand();
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -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<QcInspectionitem>, IFirstFQCService
|
||||
{
|
||||
public CheckItemTableDTO GetCheckItemTable()
|
||||
/// <summary>
|
||||
/// 获取检测项 (首检)
|
||||
/// </summary>
|
||||
/// <param name="workorderID"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
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<QcFirstinspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
|
||||
if (record != null)
|
||||
{
|
||||
it.Counter = record.Counter;
|
||||
}
|
||||
it.Counter = 0;
|
||||
});
|
||||
|
||||
return checkItem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取检测项 (二检)
|
||||
/// </summary>
|
||||
/// <param name="workorderID"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
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<QcAgaininspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
|
||||
if (record != null)
|
||||
{
|
||||
it.Counter = record.Counter;
|
||||
}
|
||||
it.Counter = 0;
|
||||
});
|
||||
|
||||
return checkItem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取检测项 (三检)
|
||||
/// </summary>
|
||||
/// <param name="workorderID"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
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<QcFinalinspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.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<QcFirstinspectionRecord>()
|
||||
.Where(it => it.FKWorkorderId == workorderID && it.FKInpectionId == it.Id).First();
|
||||
if (record != null)
|
||||
{
|
||||
it.Counter = record.Counter;
|
||||
}
|
||||
it.Counter = 0;
|
||||
});
|
||||
|
||||
return checkItem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存首次检测结果
|
||||
/// </summary>
|
||||
@@ -48,6 +281,7 @@ namespace ZR.Service.mes.qc
|
||||
/// <returns></returns>
|
||||
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
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public List<QcCurrentWorkorderDto> GetNow_producting_WorkorderList()
|
||||
public List<QcCurrentWorkorderDto> GetNow_producting_WorkorderList()
|
||||
{
|
||||
List<ProWorkorder_v2> workorders= Context.Queryable<ProWorkorder_v2>().Where(it => it.Remark3 == "是").Where(it => it.Status == 1).OrderBy(it=>it.Sort).ToList();
|
||||
|
||||
List<QcCurrentWorkorderDto> qcCurrentList= new List<QcCurrentWorkorderDto>();
|
||||
foreach(ProWorkorder_v2 item in workorders)
|
||||
List<ProWorkorder_v2> workorders = Context.Queryable<ProWorkorder_v2>().Where(it => it.Remark3 == "是").Where(it => it.Status == 1).OrderBy(it => it.Sort).ToList();
|
||||
|
||||
List<QcCurrentWorkorderDto> qcCurrentList = new List<QcCurrentWorkorderDto>();
|
||||
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<QcCurrentWorkorderDto> Now_producting_WorkorderList= GetNow_producting_WorkorderList();
|
||||
List<QcCurrentWorkorderDto> 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取下一个生产工单
|
||||
@@ -419,7 +653,49 @@ namespace ZR.Service.mes.qc
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public QcCurrentWorkorderDto GetcurrentWorkorder_next()
|
||||
{
|
||||
{
|
||||
|
||||
//#region 清空已经完成工单的缓存
|
||||
//// 获取状态为2的工单列表,然后清空缓存
|
||||
//List<ProWorkorder_v2> workorders = Context.Queryable<ProWorkorder_v2>().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<QcInspectionitem> qcInspectionitems=Context.Queryable<QcInspectionitem>().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<QcCurrentWorkorderDto> 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 记录检测项结果
|
||||
/// </summary>
|
||||
/// <param name="workorder_id">工单</param>
|
||||
/// <param name="inspectionList">检测结果</param>
|
||||
private void Record_inspect_result(string workorder_id, List<QcInspectionitem> 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<QcInspectionitem>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取上一个工单
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 缺陷项目 累加 (首检)
|
||||
/// </summary>
|
||||
/// <param name="workorder_id"></param>
|
||||
/// <param name="checkid"></param>
|
||||
/// <param name="counter"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// 缺陷项目 累加 (二检)
|
||||
/// </summary>
|
||||
/// <param name="workorder_id"></param>
|
||||
/// <param name="checkid"></param>
|
||||
/// <param name="counter"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// 缺陷项目 累加 (三检)
|
||||
/// </summary>
|
||||
/// <param name="workorder_id"></param>
|
||||
/// <param name="checkid"></param>
|
||||
/// <param name="counter"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 计算当前工单下所有抛光总数
|
||||
/// </summary>
|
||||
/// <param name="workorder_id"></param>
|
||||
/// <returns></returns>
|
||||
public int CalculatePolishTotalNumber(string workorder_id)
|
||||
{
|
||||
var list = Context.Queryable<QcFirstinspectionRecord>()
|
||||
.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;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 计算当前工单下的包装投入数==一次合格+抛光合格
|
||||
/// </summary>
|
||||
/// <param name="workorder_id"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
|
||||
public int CalculatePackagingInvestment(string workorder_id)
|
||||
{
|
||||
|
||||
//TODO 一次合格数=计划数-所有缺陷数
|
||||
int OnePassNumber = 0;
|
||||
int polishPassNumber = 0;
|
||||
|
||||
UseTran(() =>
|
||||
{
|
||||
var workorder = Context.Queryable<ProWorkorder_v2>().Where(it => it.ClientWorkorder == workorder_id).First();
|
||||
var list = Context.Queryable<QcFirstinspectionRecord>()
|
||||
.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<QcAgaininspectionRecord>()
|
||||
.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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user