实现产线产品托盘配置管理功能,包括接口、模型和服务层 优化包装标签打印逻辑,支持根据托盘配置自动分段打印满箱和零头箱标签 新增多个辅助方法创建不同类型的标签DTO 修复当没有托盘配置时使用默认单个标签打印的逻辑
4266 lines
190 KiB
C#
4266 lines
190 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using Infrastructure.Attribute;
|
|
using Microsoft.Extensions.Logging;
|
|
using MQTTnet.Protocol;
|
|
using SqlSugar;
|
|
using ZR.Model.MES.pro;
|
|
using ZR.Model.MES.qc;
|
|
using ZR.Model.MES.qc.DTO;
|
|
using ZR.Model.MES.qu;
|
|
using ZR.Model.MES.wms;
|
|
using ZR.Service.Business;
|
|
using ZR.Service.mes.qc.IService;
|
|
using ZR.Service.mes.wms;
|
|
using ZR.Service.mqtt;
|
|
|
|
namespace ZR.Service.mes.qc
|
|
{
|
|
[AppService(ServiceType = typeof(IFirstFQCService), ServiceLifetime = LifeTime.Transient)]
|
|
public class FirstFQCService : BaseService<QcInspectionitem>, IFirstFQCService
|
|
{
|
|
private readonly MqttService _mqttService; // 注入MqttService
|
|
private readonly ILogger<QcQualityStatisticsFirst> _logger;
|
|
|
|
public FirstFQCService(MqttService mqttService, ILogger<QcQualityStatisticsFirst> logger)
|
|
{
|
|
_mqttService = mqttService;
|
|
_logger = logger;
|
|
}
|
|
|
|
/// <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(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.Blank = Queryable()
|
|
.Where(it => it.InspectionModule == "毛坯")
|
|
.OrderBy(it => it.Id)
|
|
.ToList();
|
|
checkItem.Blank.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.program = Queryable()
|
|
.Where(it => it.InspectionModule == "程序")
|
|
.OrderBy(it => it.Id)
|
|
.ToList();
|
|
checkItem.program.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.Team = Queryable()
|
|
.Where(it => it.InspectionModule == "班组操作")
|
|
.OrderBy(it => it.Id)
|
|
.ToList();
|
|
checkItem.Team.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;
|
|
}
|
|
});
|
|
|
|
return checkItem;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 首检写入时间流转表
|
|
/// </summary>
|
|
/// <param name="workorderID">工单id</param>
|
|
/// <param name="time">首检结束时间</param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
|
public int WriteProcessFlow_first(string workorderID, DateTime time)
|
|
{
|
|
ProWorkordertimeStep step = new ProWorkordertimeStep();
|
|
step.FirstInspectTime = time.ToLocalTime();
|
|
step.CreatedTime = DateTime.Now;
|
|
step.WorkoderId = workorderID;
|
|
|
|
var x = Context.Storageable(step).WhereColumns(it => it.WorkoderId).ToStorage();
|
|
x.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x.AsUpdateable.ExecuteCommand(); //存在更新
|
|
|
|
return 1;
|
|
}
|
|
|
|
/// <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(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.Blank = Queryable()
|
|
.Where(it => it.InspectionModule == "毛坯")
|
|
.OrderBy(it => it.Id)
|
|
.ToList();
|
|
checkItem.Blank.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.program = Queryable()
|
|
.Where(it => it.InspectionModule == "程序")
|
|
.OrderBy(it => it.Id)
|
|
.ToList();
|
|
checkItem.program.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.Team = Queryable()
|
|
.Where(it => it.InspectionModule == "班组操作")
|
|
.OrderBy(it => it.Id)
|
|
.ToList();
|
|
checkItem.Team.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;
|
|
}
|
|
});
|
|
|
|
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(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.Blank = Queryable()
|
|
.Where(it => it.InspectionModule == "毛坯")
|
|
.OrderBy(it => it.Id)
|
|
.ToList();
|
|
checkItem.Blank.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.program = Queryable()
|
|
.Where(it => it.InspectionModule == "程序")
|
|
.OrderBy(it => it.Id)
|
|
.ToList();
|
|
checkItem.program.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.Team = Queryable()
|
|
.Where(it => it.InspectionModule == "班组操作")
|
|
.OrderBy(it => it.Id)
|
|
.ToList();
|
|
checkItem.Team.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;
|
|
}
|
|
});
|
|
|
|
return checkItem;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存首次检测结果
|
|
/// </summary>
|
|
/// <param name="workorder_id">工单</param>
|
|
/// <param name="InspectionModule">模块</param>
|
|
/// <param name="inspectItem">检测项</param>
|
|
/// <param name="counter">数量</param>
|
|
/// <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");
|
|
record.InspectionModule = InspectionModule;
|
|
record.FKWorkorderId = workorder_id;
|
|
record.FKInpectionId = checkid.Substring(0, 3);
|
|
record.Counter = counter;
|
|
record.UpdatedTime = DateTime.Now;
|
|
var x = Context
|
|
.Storageable(record)
|
|
.WhereColumns(it => new
|
|
{
|
|
it.FKInpectionId,
|
|
it.FKWorkorderId,
|
|
it.InspectionModule
|
|
})
|
|
.ToStorage();
|
|
|
|
x.AsInsertable.ExecuteCommandAsync(); //执行插入
|
|
x.AsUpdateable.ExecuteCommandAsync(); //执行更新
|
|
|
|
////更新初检报废表
|
|
//if (Convert.ToInt32(checkid) / 10 % 10==3)
|
|
//{
|
|
// QcAgaininspectionUselessnum scrap =new QcAgaininspectionUselessnum();
|
|
// scrap.Id = "scrap" + DateTime.Now.ToString("MMddHHmmss");
|
|
// scrap.FkInspectionitemId = checkid;
|
|
// scrap.FkFqcId = "";
|
|
// scrap.ProductName = "";
|
|
// scrap.Number= 1;
|
|
|
|
|
|
|
|
//}
|
|
|
|
////更新初检xiazi表
|
|
//if (Convert.ToInt32(checkid) / 10 % 10 == 1)
|
|
//{
|
|
|
|
//}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存二次检测结果
|
|
/// </summary>
|
|
/// <param name="workorder_id">工单</param>
|
|
/// <param name="InspectionModule">模块</param>
|
|
/// <param name="inspectItem">检测项</param>
|
|
/// <param name="counter">数量</param>
|
|
/// <returns></returns>
|
|
public async Task SaveinspectItem_v2(
|
|
string workorder_id,
|
|
string InspectionModule,
|
|
string checkid,
|
|
int counter
|
|
)
|
|
{
|
|
//更新实时记录表
|
|
QcAgaininspectionRecord record = new QcAgaininspectionRecord();
|
|
record.Id = DateTime.Now.ToString("yyMMddHHmmss");
|
|
record.InspectionModule = InspectionModule;
|
|
record.FkWorkorderId = workorder_id;
|
|
record.FkInpectionId = checkid.Substring(0, 3);
|
|
record.Counter = counter;
|
|
record.UpdatedTime = DateTime.Now;
|
|
var x = Context
|
|
.Storageable(record)
|
|
.WhereColumns(it => new
|
|
{
|
|
it.FkInpectionId,
|
|
it.FkWorkorderId,
|
|
it.InspectionModule
|
|
})
|
|
.ToStorage();
|
|
|
|
x.AsInsertable.ExecuteCommandAsync(); //执行插入
|
|
x.AsUpdateable.ExecuteCommandAsync(); //执行更新
|
|
|
|
////更新初检报废表
|
|
//if (Convert.ToInt32(checkid) / 10 % 10==3)
|
|
//{
|
|
// QcAgaininspectionUselessnum scrap =new QcAgaininspectionUselessnum();
|
|
// scrap.Id = "scrap" + DateTime.Now.ToString("MMddHHmmss");
|
|
// scrap.FkInspectionitemId = checkid;
|
|
// scrap.FkFqcId = "";
|
|
// scrap.ProductName = "";
|
|
// scrap.Number= 1;
|
|
|
|
|
|
|
|
//}
|
|
|
|
////更新初检xiazi表
|
|
//if (Convert.ToInt32(checkid) / 10 % 10 == 1)
|
|
//{
|
|
|
|
//}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存最终检测结果
|
|
/// </summary>
|
|
/// <param name="workorder_id">工单</param>
|
|
/// <param name="InspectionModule">模块</param>
|
|
/// <param name="inspectItem">检测项</param>
|
|
/// <param name="counter">数量</param>
|
|
/// <returns></returns>
|
|
public async Task SaveinspectItem_v3(
|
|
string workorder_id,
|
|
string InspectionModule,
|
|
string checkid,
|
|
int counter
|
|
)
|
|
{
|
|
//更新实时记录表
|
|
QcFinalinspectionRecord record = new QcFinalinspectionRecord();
|
|
record.Id = DateTime.Now.ToString("yyMMddHHmmss");
|
|
record.InspectionModule = InspectionModule;
|
|
record.FkWorkorderId = workorder_id;
|
|
record.FkInpectionId = checkid.Substring(0, 3);
|
|
record.Counter = counter;
|
|
record.UpdatedTime = DateTime.Now;
|
|
var x = Context
|
|
.Storageable(record)
|
|
.WhereColumns(it => new
|
|
{
|
|
it.FkInpectionId,
|
|
it.FkWorkorderId,
|
|
it.InspectionModule
|
|
})
|
|
.ToStorage();
|
|
|
|
x.AsInsertable.ExecuteCommandAsync(); //执行插入
|
|
x.AsUpdateable.UpdateColumns(it => new
|
|
{
|
|
it.UpdatedBy,
|
|
it.UpdatedTime,
|
|
it.Counter
|
|
})
|
|
.ExecuteCommandAsync(); //执行更新
|
|
|
|
////更新初检报废表
|
|
//if (Convert.ToInt32(checkid) / 10 % 10==3)
|
|
//{
|
|
// QcAgaininspectionUselessnum scrap =new QcAgaininspectionUselessnum();
|
|
// scrap.Id = "scrap" + DateTime.Now.ToString("MMddHHmmss");
|
|
// scrap.FkInspectionitemId = checkid;
|
|
// scrap.FkFqcId = "";
|
|
// scrap.ProductName = "";
|
|
// scrap.Number= 1;
|
|
|
|
|
|
|
|
//}
|
|
|
|
////更新初检xiazi表
|
|
//if (Convert.ToInt32(checkid) / 10 % 10 == 1)
|
|
//{
|
|
|
|
//}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 当产品切换时,完成质量统计分析
|
|
/// </summary>
|
|
/// <param name="workorderid">工单</param>
|
|
/// <param name="productName">产品名称</param>
|
|
/// <param name="leftRight">左右</param>
|
|
/// <param name="color">颜色</param>
|
|
/// <param name="team">班组</param>
|
|
/// <param name="inputNum">投入数</param>
|
|
public void quailtyStatics(
|
|
string workorderid,
|
|
string productName,
|
|
string leftRight,
|
|
string color,
|
|
string team,
|
|
int inputNum
|
|
)
|
|
{
|
|
QcFqc record = new QcFqc();
|
|
record.Id = DateTime.Now.ToString("MMddHHmmss");
|
|
record.ProductName = productName;
|
|
record.LeftRight = leftRight;
|
|
record.Color = color;
|
|
record.Team = team;
|
|
|
|
//TODO 1. 处理首检
|
|
|
|
|
|
//1.1 首检合格数=投入数-抛光数-打磨数-报废数
|
|
List<QcFirstinspectionRecord> qcFirstinspections = Context
|
|
.Queryable<QcFirstinspectionRecord>()
|
|
.Where(it => it.FKWorkorderId == workorderid)
|
|
.ToList();
|
|
|
|
int NoQualifiedNum01 = 0;
|
|
qcFirstinspections.ForEach(it =>
|
|
{
|
|
NoQualifiedNum01 += (int)it.Counter;
|
|
});
|
|
record.QualifiedNum01 = inputNum - NoQualifiedNum01;
|
|
|
|
//1.2 首检抛光数
|
|
List<QcFirstinspectionRecord> defectNum01RecordList = Context
|
|
.Queryable<QcFirstinspectionRecord>()
|
|
.Where(it => it.FKWorkorderId == workorderid)
|
|
.Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 1 + "_" })
|
|
.ToList();
|
|
int defectNum01RecordSum = 0;
|
|
defectNum01RecordList.ForEach(it =>
|
|
{
|
|
defectNum01RecordSum += (int)it.Counter;
|
|
});
|
|
record.DefectNum01 = defectNum01RecordSum;
|
|
|
|
//1.3 首检打磨数
|
|
List<QcFirstinspectionRecord> polishNum01RecordList = Context
|
|
.Queryable<QcFirstinspectionRecord>()
|
|
.Where(it => it.FKWorkorderId == workorderid)
|
|
.Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 2 + "_" })
|
|
.ToList();
|
|
int polishNum01RecordSum = 0;
|
|
polishNum01RecordList.ForEach(it =>
|
|
{
|
|
polishNum01RecordSum += (int)it.Counter;
|
|
});
|
|
record.PolishNum01 = polishNum01RecordSum;
|
|
|
|
//1.4 首检报废数
|
|
List<QcFirstinspectionRecord> scrapNum01RecordList = Context
|
|
.Queryable<QcFirstinspectionRecord>()
|
|
.Where(it => it.FKWorkorderId == workorderid)
|
|
.Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 3 + "_" })
|
|
.ToList();
|
|
int scrapNum01RecordSum = 0;
|
|
scrapNum01RecordList.ForEach(it =>
|
|
{
|
|
scrapNum01RecordSum += (int)it.Counter;
|
|
});
|
|
record.PolishNum01 = scrapNum01RecordSum;
|
|
|
|
//TODO 2. 处理二检
|
|
|
|
//2.1 二检的合格数 = 首检的抛光数 - 二检打磨 - 二检报废
|
|
List<QcAgaininspectionRecord> qcAgaininspections = Context
|
|
.Queryable<QcAgaininspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderid)
|
|
.ToList();
|
|
|
|
int NoQualifiedNum02 = 0;
|
|
qcAgaininspections.ForEach(it =>
|
|
{
|
|
NoQualifiedNum02 += (int)it.Counter;
|
|
});
|
|
record.QualifiedNum02 = defectNum01RecordSum - NoQualifiedNum02;
|
|
|
|
//2.2 二检打磨数
|
|
List<QcAgaininspectionRecord> polishNum02RecordList = Context
|
|
.Queryable<QcAgaininspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderid)
|
|
.Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 2 + "_" })
|
|
.ToList();
|
|
int polishNum02RecordSum = 0;
|
|
|
|
polishNum02RecordList.ForEach(it =>
|
|
{
|
|
polishNum02RecordSum += (int)it.Counter;
|
|
});
|
|
record.PolishNum02 = polishNum02RecordSum;
|
|
|
|
//2.3 二检报废
|
|
List<QcAgaininspectionRecord> scrapNum02RecordList = Context
|
|
.Queryable<QcAgaininspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderid)
|
|
.Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 3 + "_" })
|
|
.ToList();
|
|
int scrapNum02RecordSum = 0;
|
|
scrapNum02RecordList.ForEach(it =>
|
|
{
|
|
scrapNum02RecordSum += (int)it.Counter;
|
|
});
|
|
record.ScrapNum02 = scrapNum02RecordSum;
|
|
|
|
//TODO 3. 处理三检
|
|
// 3.1 三检合格数=(一检合格数 + 二检合格数) - (三检打磨数+三检报废数)
|
|
|
|
List<QcFinalinspectionRecord> qcFinalinspections = Context
|
|
.Queryable<QcFinalinspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderid)
|
|
.ToList();
|
|
|
|
int NoQualifiedNum03 = 0;
|
|
qcAgaininspections.ForEach(it =>
|
|
{
|
|
NoQualifiedNum03 += (int)it.Counter;
|
|
});
|
|
|
|
record.QualifiedNum03 =
|
|
(record.QualifiedNum01 + record.QualifiedNum02) - NoQualifiedNum03;
|
|
|
|
//3.2 三检打磨数
|
|
List<QcFinalinspectionRecord> polishNum03RecordList = Context
|
|
.Queryable<QcFinalinspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderid)
|
|
.Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 2 + "_" })
|
|
.ToList();
|
|
int polishNum03RecordSum = 0;
|
|
|
|
polishNum03RecordList.ForEach(it =>
|
|
{
|
|
polishNum03RecordSum += (int)it.Counter;
|
|
});
|
|
record.PolishNum03 = polishNum03RecordSum;
|
|
|
|
//3.3 三检报废数
|
|
|
|
List<QcFinalinspectionRecord> scrapNum03RecordList = Context
|
|
.Queryable<QcFinalinspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderid)
|
|
.Where("FKInpectionId like @FKInpectionId", new { FKInpectionId = "_" + 3 + "_" })
|
|
.ToList();
|
|
int scrapNum03RecordSum = 0;
|
|
scrapNum03RecordList.ForEach(it =>
|
|
{
|
|
scrapNum03RecordSum += (int)it.Counter;
|
|
});
|
|
record.ScrapNum03 = scrapNum03RecordSum;
|
|
|
|
//TODO 4 统计分析
|
|
|
|
// 4.1 一次合格率
|
|
record.FirstgoodNum = record.QualifiedNum01;
|
|
record.FirstgoodRate = CalculatePercentage((int)record.FirstgoodNum, inputNum);
|
|
// 4.2 最终合格率
|
|
record.FinalgoodNum = record.QualifiedNum03 / inputNum;
|
|
record.FinalgoodRate = CalculatePercentage((int)record.FinalgoodNum, inputNum);
|
|
// 4.3 报废率
|
|
record.ScrapNum = record.ScrapNum01 + record.ScrapNum02 + record.ScrapNum03;
|
|
record.ScrapRate = CalculatePercentage((int)record.ScrapNum, inputNum);
|
|
|
|
record.CreatedTime = DateTime.Now;
|
|
Context.Insertable<QcFqc>(record).ExecuteCommand();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 计算百分比
|
|
/// </summary>
|
|
/// <param name="num1"></param>
|
|
/// <param name="num2"></param>
|
|
/// <returns></returns>
|
|
|
|
static double CalculatePercentage(int num1, int num2)
|
|
{
|
|
double percentage = ((double)num1 / num2) * 100;
|
|
return Math.Round(percentage, 2);
|
|
}
|
|
|
|
public static QcCurrentWorkorderDto Now_producting_Workorder_first = null; //当前生产工单 首检
|
|
public static QcCurrentWorkorderDto Now_producting_Workorder_again = null; //当前生产工单 二检
|
|
public static QcCurrentWorkorderDto Now_producting_Workorder_thirty = null; //当前生产工单 三检
|
|
|
|
/// <summary>
|
|
/// 获取当前_生产中_工单列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
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)
|
|
{
|
|
qcCurrentList.Add(
|
|
new QcCurrentWorkorderDto()
|
|
{
|
|
ClientWorkorder = item.ClientWorkorder,
|
|
ProductDescription = item.ProductDescription,
|
|
FinishedPartNumber = item.FinishedPartNumber,
|
|
Specifications = item.Specifications,
|
|
Colour = item.Colour,
|
|
Team = "A",
|
|
PreviousNumber = item.PreviousNumber,
|
|
FirstPassNumber = 0,
|
|
FirstPassRate = 0.0,
|
|
PolisheNumber = 0,
|
|
ScrapNumber = 0,
|
|
DefectNumber = 0
|
|
}
|
|
);
|
|
;
|
|
}
|
|
|
|
return qcCurrentList;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取当前生产工单 一检
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public QcCurrentWorkorderDto GetcurrentWorkorder_first()
|
|
{
|
|
//获取状态为1的生产工单列表
|
|
List<QcCurrentWorkorderDto> Now_producting_WorkorderList =
|
|
GetNow_producting_WorkorderList();
|
|
// 当前没有生产工单
|
|
if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
|
|
{
|
|
Now_producting_Workorder_first = null;
|
|
return null;
|
|
}
|
|
else if (Now_producting_Workorder_first == null)
|
|
{
|
|
Now_producting_Workorder_first = Now_producting_WorkorderList[0];
|
|
return Now_producting_Workorder_first;
|
|
}
|
|
else
|
|
{
|
|
return Now_producting_Workorder_first;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取当前生产工单 二检
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public QcCurrentWorkorderDto GetcurrentWorkorder_again()
|
|
{
|
|
//获取状态为1的生产工单列表
|
|
List<QcCurrentWorkorderDto> 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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取当前生产工单 三检
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public QcCurrentWorkorderDto GetcurrentWorkorder_thirty()
|
|
{
|
|
//获取状态为1的生产工单列表
|
|
List<QcCurrentWorkorderDto> 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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取下一个生产工单 一检
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public QcCurrentWorkorderDto GetcurrentWorkorder_next_first()
|
|
{
|
|
//获取状态为1的生产工单列表
|
|
List<QcCurrentWorkorderDto> Now_producting_WorkorderList =
|
|
GetNow_producting_WorkorderList();
|
|
// 当前没有生产工单
|
|
if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
|
|
{
|
|
Now_producting_Workorder_first = null;
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
// 当前没有生产工单
|
|
if (Now_producting_Workorder_first == null)
|
|
{
|
|
return null;
|
|
}
|
|
//获取上一个工单号 游标
|
|
int index = Now_producting_WorkorderList.FindIndex(x =>
|
|
x.ClientWorkorder == Now_producting_Workorder_first.ClientWorkorder
|
|
);
|
|
if (index < 0)
|
|
{
|
|
// 逻辑异常
|
|
Now_producting_Workorder_first = Now_producting_WorkorderList[0];
|
|
return null;
|
|
}
|
|
if (index == Now_producting_WorkorderList.Count() - 1)
|
|
{
|
|
// 已经是最后一个了没有
|
|
|
|
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
Now_producting_Workorder_first = Now_producting_WorkorderList[index + 1];
|
|
return Now_producting_Workorder_first;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取下一个生产工单 二检
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public QcCurrentWorkorderDto GetcurrentWorkorder_next_again()
|
|
{
|
|
//获取状态为1的生产工单列表
|
|
List<QcCurrentWorkorderDto> 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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取下一个生产工单 三检
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public QcCurrentWorkorderDto GetcurrentWorkorder_next_thirty()
|
|
{
|
|
//获取状态为1的生产工单列表
|
|
List<QcCurrentWorkorderDto> 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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <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>
|
|
/// 获取上一个工单 首检
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref=""></exception>
|
|
|
|
public QcCurrentWorkorderDto GetcurrentWorkorder_previous_first()
|
|
{
|
|
//获取状态为1的生产工单列表
|
|
List<QcCurrentWorkorderDto> Now_producting_WorkorderList =
|
|
GetNow_producting_WorkorderList();
|
|
// 当前没有生产工单
|
|
if (Now_producting_WorkorderList == null || Now_producting_WorkorderList.Count <= 0)
|
|
{
|
|
Now_producting_Workorder_first = null;
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
// 当前没有生产工单
|
|
if (Now_producting_Workorder_first == null)
|
|
{
|
|
return null;
|
|
}
|
|
//获取上一个工单号 游标
|
|
int index = Now_producting_WorkorderList.FindIndex(x =>
|
|
x.ClientWorkorder == Now_producting_Workorder_first.ClientWorkorder
|
|
);
|
|
if (index < 0)
|
|
{
|
|
// 逻辑异常
|
|
Now_producting_Workorder_first = Now_producting_WorkorderList[0];
|
|
return null;
|
|
}
|
|
if (index == 0)
|
|
{
|
|
// 已经是最后一个了没有
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
Now_producting_Workorder_first = Now_producting_WorkorderList[index - 1];
|
|
return Now_producting_Workorder_first;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取上一个工单 二检
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref=""></exception>
|
|
|
|
public QcCurrentWorkorderDto GetcurrentWorkorder_previous_again()
|
|
{
|
|
//获取状态为1的生产工单列表
|
|
List<QcCurrentWorkorderDto> 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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取上一个工单 三检
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref=""></exception>
|
|
|
|
public QcCurrentWorkorderDto GetcurrentWorkorder_previous_thirty()
|
|
{
|
|
//获取状态为1的生产工单列表
|
|
List<QcCurrentWorkorderDto> 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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 缺陷项目 累加 (首检)
|
|
/// </summary>
|
|
/// <param name="workorder_id">工单id</param>
|
|
/// <param name="checkid">缺陷项</param>
|
|
/// <param name="number">要累加的值</param>
|
|
/// <returns> 最终累加的值</returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public int Accumulator_first(
|
|
string workorder_id,
|
|
int checkid,
|
|
int number,
|
|
string InspectionModule,
|
|
string name
|
|
)
|
|
{
|
|
int result = 0;
|
|
//TODO 获取已知的的检测项 +1
|
|
QcFirstinspectionRecord exist_record = Context
|
|
.Queryable<QcFirstinspectionRecord>()
|
|
.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<QcFirstinspectionRecord>()
|
|
.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;
|
|
}
|
|
|
|
/// <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 number,
|
|
string InspectionModule,
|
|
string name
|
|
)
|
|
{
|
|
int result = 0;
|
|
//TODO 获取已知的的检测项 +1
|
|
QcAgaininspectionRecord exist_record = Context
|
|
.Queryable<QcAgaininspectionRecord>()
|
|
.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<QcAgaininspectionRecord>()
|
|
.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;
|
|
}
|
|
|
|
/// <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 number,
|
|
string InspectionModule,
|
|
string name
|
|
)
|
|
{
|
|
int result = 0;
|
|
//TODO 获取已知的的检测项 +1
|
|
QcFinalinspectionRecord exist_record = Context
|
|
.Queryable<QcFinalinspectionRecord>()
|
|
.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<QcFinalinspectionRecord>()
|
|
.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;
|
|
}
|
|
|
|
/// <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();
|
|
if (list != null)
|
|
return list.sum;
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 计算当前工单下的包装投入数==一次合格+抛光合格
|
|
/// </summary>
|
|
/// <param name="workorder_id"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
|
public int CalculatePackagingInvestment(string workorder_id)
|
|
{
|
|
int OnePassNumber = 0;
|
|
int polishPassNumber = 0;
|
|
|
|
UseTran(() =>
|
|
{
|
|
//TODO 一次合格数=计划数-所有缺陷数
|
|
var workorder = Context
|
|
.Queryable<ProWorkorder_v2>()
|
|
.Where(it => it.ClientWorkorder == workorder_id)
|
|
.First();
|
|
|
|
if (workorder != null)
|
|
{
|
|
var list = Context
|
|
.Queryable<QcFirstinspectionRecord>()
|
|
.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;
|
|
}
|
|
|
|
//TODO 计算抛光合格=首检的抛光-抛光缺陷项
|
|
int polishNumber = CalculatePolishTotalNumber(workorder_id);
|
|
var polish_defect_Number = Context
|
|
.Queryable<QcAgaininspectionRecord>()
|
|
.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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更改工单为完成态
|
|
/// </summary>
|
|
/// <param name="workorder_id"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public int UpdateWorkorderStatus(string workorder_id)
|
|
{
|
|
return Context
|
|
.Updateable<ProWorkorder_v2>()
|
|
.SetColumns(it => it.Status == 2)
|
|
.Where(it => it.ClientWorkorder == workorder_id)
|
|
.ExecuteCommand();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成质量统计表
|
|
/// </summary>
|
|
/// <param name="workorderID"></param>
|
|
/// <param name="team"></param>
|
|
/// <returns></returns>
|
|
public int GenerateQualityStatisticsTable(
|
|
string workorderID,
|
|
string team,
|
|
DateTime firstQuality_time
|
|
)
|
|
{
|
|
if (!string.IsNullOrEmpty(workorderID))
|
|
{
|
|
// 开始时间
|
|
ProWorkordertimeStep step = Context
|
|
.Queryable<ProWorkordertimeStep>()
|
|
.Where(it => it.WorkoderId == workorderID)
|
|
.First();
|
|
#region 首检
|
|
#region 抛光
|
|
QcQualityStatisticsFirst first = new QcQualityStatisticsFirst();
|
|
first.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
first.WorkorderId = workorderID;
|
|
|
|
ProWorkorder_v2 workorder_item = Context
|
|
.Queryable<ProWorkorder_v2>()
|
|
.Where(it => it.ClientWorkorder == workorderID)
|
|
.First();
|
|
if (workorder_item != null)
|
|
{
|
|
first.Color = workorder_item?.Colour;
|
|
first.FinishedPartNumber = workorder_item.FinishedPartNumber;
|
|
first.ProductDescription = workorder_item.ProductDescription;
|
|
first.RequireNumber = workorder_item.PreviousNumber;
|
|
if (step != null)
|
|
{
|
|
first.StartTime = step.FirstInspectTime; //这地方是不妥的
|
|
}
|
|
else
|
|
{
|
|
first.StartTime = null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("工单不存在!");
|
|
}
|
|
|
|
first.Team = team;
|
|
first.EndTime = DateTime.Now;
|
|
first.Remark = "抛光";
|
|
first.Remark2 = 1;
|
|
int paoguang_total = 0; //抛光总数
|
|
//XXX20240223:记录首检后的抛光数
|
|
int paoguang_by_first = 0;
|
|
List<QcFirstinspectionRecord> firstrecordList = Context
|
|
.Queryable<QcFirstinspectionRecord>()
|
|
.Where(it => it.FKWorkorderId == workorderID)
|
|
.Where(it => SqlFunc.Contains(it.FKInpectionId, "_1_"))
|
|
.ToList();
|
|
if (firstrecordList != null && firstrecordList.Count > 0)
|
|
{
|
|
for (int i = 0; i < firstrecordList.Count; i++)
|
|
{
|
|
if (firstrecordList[i].FKInpectionId == "111")
|
|
{
|
|
first.PaintSuokong = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList[i].FKInpectionId == "112")
|
|
{
|
|
first.PaintZhengkong = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList[i].FKInpectionId == "113")
|
|
{
|
|
first.PaintShiguang = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList[i].FKInpectionId == "114")
|
|
{
|
|
first.PaintSecha = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList[i].FKInpectionId == "115")
|
|
{
|
|
first.PaintDianzi = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList[i].FKInpectionId == "116")
|
|
{
|
|
first.PaintOther = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList[i].FKInpectionId == "211")
|
|
{
|
|
first.DeviceShuiban = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList[i].FKInpectionId == "212")
|
|
{
|
|
first.DeviceZandian = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "213")
|
|
{
|
|
first.DeviceBianxing = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList[i].FKInpectionId == "214")
|
|
{
|
|
first.DeviceYouzhu = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList[i].FKInpectionId == "215")
|
|
{
|
|
first.DeviceTuoluo = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "216")
|
|
{
|
|
first.DeviceZhuangshang = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "217")
|
|
{
|
|
first.DeviceOther = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList[i].FKInpectionId == "311")
|
|
{
|
|
first.BlankMaoci = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "312")
|
|
{
|
|
first.BlankSuoyin = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "313")
|
|
{
|
|
first.BlankCanshuang = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "314")
|
|
{
|
|
first.BlankShaying = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "315")
|
|
{
|
|
first.BlankZangdian = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "316")
|
|
{
|
|
first.BlankDamo = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "411")
|
|
{
|
|
first.ProgramLiuguang = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "412")
|
|
{
|
|
first.ProgramSeqiqueqi = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "413")
|
|
{
|
|
first.ProgramQingqiqueqi = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "414")
|
|
{
|
|
first.ProgramJupi = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "415")
|
|
{
|
|
first.ProgramOther = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "511")
|
|
{
|
|
first.TeamTuoluocanshuang = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "512")
|
|
{
|
|
first.TeamQingqiqikuai = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "513")
|
|
{
|
|
first.TeamSeqiqikuai = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "514")
|
|
{
|
|
first.TeamFahua = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "515")
|
|
{
|
|
first.TeamLiangbang = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
if (firstrecordList[i].FKInpectionId == "516")
|
|
{
|
|
first.TeamPenglou = firstrecordList[i].Counter;
|
|
paoguang_total = paoguang_total + (int)firstrecordList[i].Counter;
|
|
}
|
|
}
|
|
}
|
|
// XXX20240223: 记录首检时抛光数
|
|
paoguang_by_first = paoguang_total;
|
|
first.CreatedTime = DateTime.Now;
|
|
first.UpdatedTime = DateTime.Now;
|
|
#endregion
|
|
|
|
#region 打磨
|
|
QcQualityStatisticsFirst first2 = new QcQualityStatisticsFirst();
|
|
first2.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
first2.WorkorderId = workorderID;
|
|
|
|
ProWorkorder_v2 workorder_item2 = Context
|
|
.Queryable<ProWorkorder_v2>()
|
|
.Where(it => it.ClientWorkorder == workorderID)
|
|
.First();
|
|
if (workorder_item2 != null)
|
|
{
|
|
first2.Color = workorder_item2?.Colour;
|
|
first2.FinishedPartNumber = workorder_item2.FinishedPartNumber;
|
|
first2.ProductDescription = workorder_item2.ProductDescription;
|
|
first2.RequireNumber = workorder_item2.PreviousNumber;
|
|
|
|
if (step != null)
|
|
{
|
|
first2.StartTime = step.FirstInspectTime; //这地方是不妥的
|
|
}
|
|
else
|
|
{
|
|
first2.StartTime = null;
|
|
}
|
|
}
|
|
|
|
first2.Team = team;
|
|
|
|
first2.EndTime = DateTime.Now;
|
|
first2.Remark = "打磨";
|
|
first2.Remark2 = 2;
|
|
int damo_total = 0;
|
|
|
|
List<QcFirstinspectionRecord> firstrecordList2 = Context
|
|
.Queryable<QcFirstinspectionRecord>()
|
|
.Where(it => it.FKWorkorderId == workorderID)
|
|
.Where(it => SqlFunc.Contains(it.FKInpectionId, "_2_"))
|
|
.ToList();
|
|
if (firstrecordList2 != null && firstrecordList2.Count > 0)
|
|
{
|
|
for (int i = 0; i < firstrecordList2.Count; i++)
|
|
{
|
|
if (firstrecordList2[i].FKInpectionId == "121")
|
|
{
|
|
first2.PaintSuokong = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList2[i].FKInpectionId == "122")
|
|
{
|
|
first2.PaintZhengkong = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList2[i].FKInpectionId == "123")
|
|
{
|
|
first2.PaintShiguang = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList2[i].FKInpectionId == "124")
|
|
{
|
|
first2.PaintSecha = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList2[i].FKInpectionId == "125")
|
|
{
|
|
first2.PaintDianzi = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList2[i].FKInpectionId == "126")
|
|
{
|
|
first2.PaintOther = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList2[i].FKInpectionId == "221")
|
|
{
|
|
first2.DeviceShuiban = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList2[i].FKInpectionId == "222")
|
|
{
|
|
first2.DeviceZandian = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "223")
|
|
{
|
|
first2.DeviceBianxing = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList2[i].FKInpectionId == "224")
|
|
{
|
|
first2.DeviceYouzhu = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList2[i].FKInpectionId == "225")
|
|
{
|
|
first2.DeviceTuoluo = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "226")
|
|
{
|
|
first2.DeviceZhuangshang = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "227")
|
|
{
|
|
first2.DeviceOther = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList2[i].FKInpectionId == "321")
|
|
{
|
|
first2.BlankMaoci = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "322")
|
|
{
|
|
first2.BlankSuoyin = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "323")
|
|
{
|
|
first2.BlankCanshuang = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "324")
|
|
{
|
|
first2.BlankShaying = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "325")
|
|
{
|
|
first2.BlankZangdian = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "326")
|
|
{
|
|
first2.BlankDamo = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "421")
|
|
{
|
|
first2.ProgramLiuguang = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "422")
|
|
{
|
|
first2.ProgramSeqiqueqi = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "423")
|
|
{
|
|
first2.ProgramQingqiqueqi = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "424")
|
|
{
|
|
first2.ProgramJupi = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "425")
|
|
{
|
|
first2.ProgramOther = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "521")
|
|
{
|
|
first2.TeamTuoluocanshuang = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "522")
|
|
{
|
|
first2.TeamQingqiqikuai = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "523")
|
|
{
|
|
first2.TeamSeqiqikuai = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "524")
|
|
{
|
|
first2.TeamFahua = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "525")
|
|
{
|
|
first2.TeamLiangbang = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
if (firstrecordList2[i].FKInpectionId == "526")
|
|
{
|
|
first2.TeamPenglou = firstrecordList2[i].Counter;
|
|
damo_total = damo_total + (int)firstrecordList2[i].Counter;
|
|
}
|
|
}
|
|
}
|
|
first2.CreatedTime = DateTime.Now;
|
|
first2.UpdatedTime = DateTime.Now;
|
|
#endregion
|
|
|
|
#region 报废
|
|
QcQualityStatisticsFirst first3 = new QcQualityStatisticsFirst();
|
|
first3.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
first3.WorkorderId = workorderID;
|
|
|
|
ProWorkorder_v2 workorder3 = Context
|
|
.Queryable<ProWorkorder_v2>()
|
|
.Where(it => it.Id == first.WorkorderId)
|
|
.First();
|
|
|
|
ProWorkorder_v2 workorder_item3 = Context
|
|
.Queryable<ProWorkorder_v2>()
|
|
.Where(it => it.ClientWorkorder == workorderID)
|
|
.First();
|
|
if (workorder_item3 != null)
|
|
{
|
|
first3.Color = workorder_item3?.Colour;
|
|
first3.FinishedPartNumber = workorder_item3.FinishedPartNumber;
|
|
first3.ProductDescription = workorder_item3.ProductDescription;
|
|
first3.RequireNumber = workorder_item3.PreviousNumber;
|
|
if (step != null)
|
|
{
|
|
first3.StartTime = step.FirstInspectTime; //这地方是不妥的
|
|
}
|
|
else
|
|
{
|
|
first3.StartTime = null;
|
|
}
|
|
}
|
|
first3.Team = team;
|
|
first3.EndTime = DateTime.Now;
|
|
first3.Remark = "报废";
|
|
first3.Remark2 = 3;
|
|
int baofei_total = 0;
|
|
List<QcFirstinspectionRecord> firstrecordList3 = Context
|
|
.Queryable<QcFirstinspectionRecord>()
|
|
.Where(it => it.FKWorkorderId == workorderID)
|
|
.Where(it => SqlFunc.Contains(it.FKInpectionId, "_3_"))
|
|
.ToList();
|
|
if (firstrecordList3 != null && firstrecordList3.Count > 0)
|
|
{
|
|
for (int i = 0; i < firstrecordList3.Count; i++)
|
|
{
|
|
if (firstrecordList3[i].FKInpectionId == "131")
|
|
{
|
|
first3.PaintSuokong = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList3[i].FKInpectionId == "132")
|
|
{
|
|
first3.PaintZhengkong = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList3[i].FKInpectionId == "133")
|
|
{
|
|
first3.PaintShiguang = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList3[i].FKInpectionId == "134")
|
|
{
|
|
first3.PaintSecha = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList3[i].FKInpectionId == "135")
|
|
{
|
|
first3.PaintDianzi = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList3[i].FKInpectionId == "136")
|
|
{
|
|
first3.PaintOther = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList3[i].FKInpectionId == "231")
|
|
{
|
|
first3.DeviceShuiban = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList3[i].FKInpectionId == "232")
|
|
{
|
|
first3.DeviceZandian = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "233")
|
|
{
|
|
first3.DeviceBianxing = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList3[i].FKInpectionId == "234")
|
|
{
|
|
first3.DeviceYouzhu = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList3[i].FKInpectionId == "235")
|
|
{
|
|
first3.DeviceTuoluo = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "236")
|
|
{
|
|
first3.DeviceZhuangshang = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "237")
|
|
{
|
|
first3.DeviceOther = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
|
|
if (firstrecordList3[i].FKInpectionId == "331")
|
|
{
|
|
first3.BlankMaoci = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "332")
|
|
{
|
|
first3.BlankSuoyin = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "333")
|
|
{
|
|
first3.BlankCanshuang = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "334")
|
|
{
|
|
first3.BlankShaying = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "335")
|
|
{
|
|
first3.BlankZangdian = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "336")
|
|
{
|
|
first3.BlankDamo = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "431")
|
|
{
|
|
first3.ProgramLiuguang = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "432")
|
|
{
|
|
first3.ProgramSeqiqueqi = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "433")
|
|
{
|
|
first3.ProgramQingqiqueqi = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "434")
|
|
{
|
|
first3.ProgramJupi = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "435")
|
|
{
|
|
first3.ProgramOther = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "531")
|
|
{
|
|
first3.TeamTuoluocanshuang = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "532")
|
|
{
|
|
first3.TeamQingqiqikuai = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "533")
|
|
{
|
|
first3.TeamSeqiqikuai = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "534")
|
|
{
|
|
first3.TeamFahua = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "535")
|
|
{
|
|
first3.TeamLiangbang = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
if (firstrecordList3[i].FKInpectionId == "536")
|
|
{
|
|
first3.TeamPenglou = firstrecordList3[i].Counter;
|
|
baofei_total = baofei_total + (int)firstrecordList3[i].Counter;
|
|
}
|
|
}
|
|
}
|
|
|
|
first3.CreatedTime = DateTime.Now;
|
|
first3.UpdatedTime = DateTime.Now;
|
|
#endregion
|
|
|
|
#region 计算汇总
|
|
int qualifiedNumber_No_all = paoguang_total + damo_total + baofei_total;
|
|
|
|
first.QualifiedNumber = first.RequireNumber - qualifiedNumber_No_all;
|
|
if (first.RequireNumber == 0)
|
|
first.QualifiedRate = 0;
|
|
else
|
|
first.QualifiedRate = Math.Round(
|
|
((decimal)first.QualifiedNumber / (decimal)first.RequireNumber) * 100,
|
|
3
|
|
);
|
|
first.PaoguangTotal = paoguang_total;
|
|
first.DamoTotal = damo_total;
|
|
first.BaofeiTotal = baofei_total;
|
|
|
|
var x = Context
|
|
.Storageable(first)
|
|
.WhereColumns(it => new { it.WorkorderId, it.Remark2 })
|
|
.ToStorage();
|
|
x.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新
|
|
first2.QualifiedNumber = first2.RequireNumber - qualifiedNumber_No_all;
|
|
if (first2.RequireNumber == 0)
|
|
{
|
|
first2.QualifiedRate = 0;
|
|
}
|
|
else
|
|
{
|
|
first2.QualifiedRate = Math.Round(
|
|
((decimal)first2.QualifiedNumber / (decimal)first2.RequireNumber) * 100,
|
|
3
|
|
);
|
|
}
|
|
|
|
first2.PaoguangTotal = paoguang_total;
|
|
first2.DamoTotal = damo_total;
|
|
first2.BaofeiTotal = baofei_total;
|
|
|
|
var x2 = Context
|
|
.Storageable(first2)
|
|
.WhereColumns(it => new { it.WorkorderId, it.Remark2 })
|
|
.ToStorage();
|
|
x2.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新
|
|
|
|
first3.QualifiedNumber = first3.RequireNumber - qualifiedNumber_No_all;
|
|
if (first3.RequireNumber == 0)
|
|
{
|
|
first3.QualifiedRate = 0;
|
|
}
|
|
else
|
|
first3.QualifiedRate = Math.Round(
|
|
((decimal)first3.QualifiedNumber / (decimal)first3.RequireNumber) * 100,
|
|
3
|
|
);
|
|
first3.PaoguangTotal = paoguang_total;
|
|
first3.DamoTotal = damo_total;
|
|
first3.BaofeiTotal = baofei_total;
|
|
|
|
var x3 = Context
|
|
.Storageable(first3)
|
|
.WhereColumns(it => new { it.WorkorderId, it.Remark2 })
|
|
.ToStorage();
|
|
x3.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
#region 二检
|
|
#region 打磨
|
|
QcQualityStatisticsAgain again2 = new QcQualityStatisticsAgain();
|
|
again2.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
again2.WorkorderId = workorderID;
|
|
|
|
ProWorkorder_v2 workorder_again2 = Context
|
|
.Queryable<ProWorkorder_v2>()
|
|
.Where(it => it.ClientWorkorder == workorderID)
|
|
.First();
|
|
if (workorder_again2 != null)
|
|
{
|
|
again2.Color = workorder_again2?.Colour;
|
|
again2.FinishedPartNumber = workorder_again2.FinishedPartNumber;
|
|
again2.ProductDescription = workorder_again2.ProductDescription;
|
|
// XXX:二检入参修改为一检抛光记录值
|
|
//again2.RequireNumber = workorder_again2.PreviousNumber;
|
|
again2.RequireNumber = paoguang_total;
|
|
if (step != null)
|
|
{
|
|
again2.StartTime = step.FirstInspectTime; //这地方是不妥的
|
|
}
|
|
else
|
|
{
|
|
again2.StartTime = null;
|
|
}
|
|
}
|
|
|
|
again2.Team = team;
|
|
|
|
again2.EndTime = DateTime.Now;
|
|
again2.Remark = "打磨";
|
|
again2.Remark2 = 2;
|
|
int damo_total_again = 0;
|
|
|
|
List<QcAgaininspectionRecord> againrecordList2 = Context
|
|
.Queryable<QcAgaininspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderID)
|
|
.Where(it => SqlFunc.Contains(it.FkInpectionId, "_2_"))
|
|
.ToList();
|
|
if (againrecordList2 != null && againrecordList2.Count > 0)
|
|
{
|
|
for (int i = 0; i < againrecordList2.Count; i++)
|
|
{
|
|
if (againrecordList2[i].FkInpectionId == "121")
|
|
{
|
|
again2.PaintSuokong = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
|
|
if (againrecordList2[i].FkInpectionId == "122")
|
|
{
|
|
again2.PaintZhengkong = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
|
|
if (againrecordList2[i].FkInpectionId == "123")
|
|
{
|
|
again2.PaintShiguang = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
|
|
if (againrecordList2[i].FkInpectionId == "124")
|
|
{
|
|
again2.PaintSecha = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
|
|
if (againrecordList2[i].FkInpectionId == "125")
|
|
{
|
|
again2.PaintDianzi = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
|
|
if (againrecordList2[i].FkInpectionId == "126")
|
|
{
|
|
again2.PaintOther = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
|
|
if (againrecordList2[i].FkInpectionId == "221")
|
|
{
|
|
again2.DeviceShuiban = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
|
|
if (againrecordList2[i].FkInpectionId == "222")
|
|
{
|
|
again2.DeviceZandian = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "223")
|
|
{
|
|
first2.DeviceBianxing = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
|
|
if (againrecordList2[i].FkInpectionId == "224")
|
|
{
|
|
again2.DeviceYouzhu = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
|
|
if (againrecordList2[i].FkInpectionId == "225")
|
|
{
|
|
again2.DeviceTuoluo = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "226")
|
|
{
|
|
again2.DeviceZhuangshang = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "227")
|
|
{
|
|
again2.DeviceOther = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
|
|
if (againrecordList2[i].FkInpectionId == "321")
|
|
{
|
|
again2.BlankMaoci = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "322")
|
|
{
|
|
again2.BlankSuoyin = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "323")
|
|
{
|
|
again2.BlankCanshuang = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "324")
|
|
{
|
|
again2.BlankShaying = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "325")
|
|
{
|
|
again2.BlankZangdian = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "326")
|
|
{
|
|
again2.BlankDamo = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "421")
|
|
{
|
|
again2.ProgramLiuguang = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "422")
|
|
{
|
|
again2.ProgramSeqiqueqi = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "423")
|
|
{
|
|
again2.ProgramQingqiqueqi = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "424")
|
|
{
|
|
again2.ProgramJupi = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "425")
|
|
{
|
|
again2.ProgramOther = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "521")
|
|
{
|
|
again2.TeamTuoluocanshuang = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "522")
|
|
{
|
|
again2.TeamQingqiqikuai = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "523")
|
|
{
|
|
again2.TeamSeqiqikuai = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "524")
|
|
{
|
|
again2.TeamFahua = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "525")
|
|
{
|
|
again2.TeamLiangbang = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
if (againrecordList2[i].FkInpectionId == "526")
|
|
{
|
|
again2.TeamPenglou = againrecordList2[i].Counter;
|
|
damo_total_again = damo_total_again + (int)againrecordList2[i].Counter;
|
|
}
|
|
}
|
|
}
|
|
|
|
again2.CreatedTime = DateTime.Now;
|
|
again2.UpdatedTime = DateTime.Now;
|
|
|
|
#endregion
|
|
|
|
#region 报废
|
|
QcQualityStatisticsAgain again3 = new QcQualityStatisticsAgain();
|
|
again3.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
again3.WorkorderId = workorderID;
|
|
|
|
ProWorkorder_v2 workorder_again3 = Context
|
|
.Queryable<ProWorkorder_v2>()
|
|
.Where(it => it.ClientWorkorder == workorderID)
|
|
.First();
|
|
if (workorder_again3 != null)
|
|
{
|
|
again3.Color = workorder_again3.Colour;
|
|
again3.FinishedPartNumber = workorder_again3.FinishedPartNumber;
|
|
again3.ProductDescription = workorder_again3.ProductDescription;
|
|
// XXX:二检(抛光)报废分数据上件数为首检抛光数
|
|
again3.RequireNumber = paoguang_total;
|
|
// again3.RequireNumber = workorder_again3.PreviousNumber;
|
|
if (step != null)
|
|
{
|
|
again3.StartTime = step.FirstInspectTime; //这地方是不妥的
|
|
}
|
|
else
|
|
{
|
|
again3.StartTime = null;
|
|
}
|
|
}
|
|
|
|
again3.Team = team;
|
|
again3.EndTime = DateTime.Now;
|
|
again3.Remark = "报废";
|
|
again3.Remark2 = 3;
|
|
int baofei_total_again3 = 0;
|
|
|
|
List<QcAgaininspectionRecord> againrecordList3 = Context
|
|
.Queryable<QcAgaininspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderID)
|
|
.Where(it => SqlFunc.Contains(it.FkWorkorderId, "_3_"))
|
|
.ToList();
|
|
if (againrecordList3 != null && againrecordList3.Count > 0)
|
|
{
|
|
for (int i = 0; i < againrecordList3.Count; i++)
|
|
{
|
|
if (againrecordList3[i].FkInpectionId == "131")
|
|
{
|
|
again3.PaintSuokong = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
|
|
if (againrecordList3[i].FkInpectionId == "132")
|
|
{
|
|
again3.PaintZhengkong = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
|
|
if (againrecordList3[i].FkInpectionId == "133")
|
|
{
|
|
again3.PaintShiguang = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
|
|
if (againrecordList3[i].FkInpectionId == "134")
|
|
{
|
|
again3.PaintSecha = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
|
|
if (againrecordList3[i].FkInpectionId == "135")
|
|
{
|
|
again3.PaintDianzi = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
|
|
if (againrecordList3[i].FkInpectionId == "136")
|
|
{
|
|
again3.PaintOther = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
|
|
if (againrecordList3[i].FkInpectionId == "231")
|
|
{
|
|
again3.DeviceShuiban = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
|
|
if (againrecordList3[i].FkInpectionId == "232")
|
|
{
|
|
again3.DeviceZandian = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "233")
|
|
{
|
|
again3.DeviceBianxing = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
|
|
if (againrecordList3[i].FkInpectionId == "234")
|
|
{
|
|
again3.DeviceYouzhu = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
|
|
if (againrecordList3[i].FkInpectionId == "235")
|
|
{
|
|
again3.DeviceTuoluo = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "236")
|
|
{
|
|
again3.DeviceZhuangshang = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "237")
|
|
{
|
|
again3.DeviceOther = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
|
|
if (againrecordList3[i].FkInpectionId == "331")
|
|
{
|
|
again3.BlankMaoci = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "332")
|
|
{
|
|
again3.BlankSuoyin = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "333")
|
|
{
|
|
again3.BlankCanshuang = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "334")
|
|
{
|
|
again3.BlankShaying = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "335")
|
|
{
|
|
again3.BlankZangdian = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "336")
|
|
{
|
|
again3.BlankDamo = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "431")
|
|
{
|
|
again3.ProgramLiuguang = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "432")
|
|
{
|
|
again3.ProgramSeqiqueqi = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "433")
|
|
{
|
|
again3.ProgramQingqiqueqi = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "434")
|
|
{
|
|
again3.ProgramJupi = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "435")
|
|
{
|
|
again3.ProgramOther = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "531")
|
|
{
|
|
again3.TeamTuoluocanshuang = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "532")
|
|
{
|
|
again3.TeamQingqiqikuai = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "533")
|
|
{
|
|
again3.TeamSeqiqikuai = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "534")
|
|
{
|
|
again3.TeamFahua = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "535")
|
|
{
|
|
again3.TeamLiangbang = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
if (againrecordList3[i].FkInpectionId == "536")
|
|
{
|
|
again3.TeamPenglou = againrecordList3[i].Counter;
|
|
baofei_total_again3 =
|
|
baofei_total_again3 + (int)againrecordList3[i].Counter;
|
|
}
|
|
}
|
|
}
|
|
|
|
again3.CreatedTime = DateTime.Now;
|
|
again3.UpdatedTime = DateTime.Now;
|
|
|
|
#endregion
|
|
|
|
#region 计算汇总
|
|
int qualifiedNumber_No_all_again = damo_total_again + baofei_total_again3;
|
|
|
|
again2.QualifiedNumber = again2.RequireNumber - qualifiedNumber_No_all_again;
|
|
if (again2.RequireNumber == 0)
|
|
{
|
|
again2.QualifiedNumber = 0;
|
|
}
|
|
else
|
|
again2.QualifiedRate = Math.Round(
|
|
((decimal)again2.QualifiedNumber / (decimal)again2.RequireNumber) * 100,
|
|
3
|
|
);
|
|
|
|
again2.DamoTotal = damo_total_again;
|
|
again2.BaofeiTotal = baofei_total_again3;
|
|
|
|
var x_again_2 = Context
|
|
.Storageable(again2)
|
|
.WhereColumns(it => new { it.WorkorderId, it.Remark2 })
|
|
.ToStorage();
|
|
x_again_2.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x_again_2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新
|
|
|
|
again3.QualifiedNumber = again3.RequireNumber - qualifiedNumber_No_all_again;
|
|
if (again3.RequireNumber == 0)
|
|
{
|
|
again3.QualifiedRate = 0;
|
|
}
|
|
else
|
|
again3.QualifiedRate = Math.Round(
|
|
((decimal)again3.QualifiedNumber / (decimal)again3.RequireNumber) * 100,
|
|
3
|
|
);
|
|
|
|
again3.DamoTotal = damo_total_again;
|
|
again3.BaofeiTotal = baofei_total_again3;
|
|
|
|
var x_again_3 = Context
|
|
.Storageable(again3)
|
|
.WhereColumns(it => new { it.WorkorderId, it.Remark2 })
|
|
.ToStorage();
|
|
x_again_3.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x_again_3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 三检
|
|
#region 三捡-抛光
|
|
QcQualityStatisticsFinal final1 = new QcQualityStatisticsFinal();
|
|
final1.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
final1.WorkorderId = workorderID;
|
|
if (workorder_item != null)
|
|
{
|
|
final1.Color = workorder_item?.Colour;
|
|
final1.FinishedPartNumber = workorder_item.FinishedPartNumber;
|
|
final1.ProductDescription = workorder_item.ProductDescription;
|
|
final1.RequireNumber = first.QualifiedNumber + again2.QualifiedNumber;
|
|
if (step != null)
|
|
{
|
|
final1.StartTime = step.FirstInspectTime;
|
|
}
|
|
else
|
|
{
|
|
final1.StartTime = null;
|
|
}
|
|
}
|
|
|
|
final1.Team = team;
|
|
final1.EndTime = DateTime.Now;
|
|
final1.Remark = "抛光";
|
|
final1.Remark2 = 1;
|
|
// 三检抛光总数
|
|
int paoguang_final = 0;
|
|
List<QcFinalinspectionRecord> finalrecordList = Context
|
|
.Queryable<QcFinalinspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderID)
|
|
.Where(it => SqlFunc.Contains(it.FkInpectionId, "_1_"))
|
|
.ToList();
|
|
paoguang_final =
|
|
Context
|
|
.Queryable<QcFinalinspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderID)
|
|
.Where(it => SqlFunc.Contains(it.FkInpectionId, "_1_"))
|
|
.Sum(it => it.Counter) ?? 0;
|
|
|
|
if (finalrecordList != null && finalrecordList.Count > 0)
|
|
{
|
|
foreach (QcFinalinspectionRecord fianlRecord in finalrecordList)
|
|
{
|
|
if (fianlRecord.FkInpectionId == "111")
|
|
{
|
|
final1.PaintSuokong = fianlRecord.Counter;
|
|
}
|
|
|
|
if (fianlRecord.FkInpectionId == "112")
|
|
{
|
|
final1.PaintZhengkong = fianlRecord.Counter;
|
|
}
|
|
|
|
if (fianlRecord.FkInpectionId == "113")
|
|
{
|
|
final1.PaintShiguang = fianlRecord.Counter;
|
|
}
|
|
|
|
if (fianlRecord.FkInpectionId == "114")
|
|
{
|
|
final1.PaintSecha = fianlRecord.Counter;
|
|
}
|
|
|
|
if (fianlRecord.FkInpectionId == "115")
|
|
{
|
|
final1.PaintDianzi = fianlRecord.Counter;
|
|
}
|
|
|
|
if (fianlRecord.FkInpectionId == "116")
|
|
{
|
|
final1.PaintOther = fianlRecord.Counter;
|
|
}
|
|
|
|
if (fianlRecord.FkInpectionId == "211")
|
|
{
|
|
final1.DeviceShuiban = fianlRecord.Counter;
|
|
}
|
|
|
|
if (fianlRecord.FkInpectionId == "212")
|
|
{
|
|
final1.DeviceZandian = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "213")
|
|
{
|
|
final1.DeviceBianxing = fianlRecord.Counter;
|
|
}
|
|
|
|
if (fianlRecord.FkInpectionId == "214")
|
|
{
|
|
final1.DeviceYouzhu = fianlRecord.Counter;
|
|
}
|
|
|
|
if (fianlRecord.FkInpectionId == "215")
|
|
{
|
|
final1.DeviceTuoluo = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "216")
|
|
{
|
|
final1.DeviceZhuangshang = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "217")
|
|
{
|
|
final1.DeviceOther = fianlRecord.Counter;
|
|
}
|
|
|
|
if (fianlRecord.FkInpectionId == "311")
|
|
{
|
|
final1.BlankMaoci = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "312")
|
|
{
|
|
final1.BlankSuoyin = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "313")
|
|
{
|
|
final1.BlankCanshuang = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "314")
|
|
{
|
|
final1.BlankShaying = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "315")
|
|
{
|
|
final1.BlankZangdian = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "316")
|
|
{
|
|
final1.BlankDamo = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "411")
|
|
{
|
|
final1.ProgramLiuguang = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "412")
|
|
{
|
|
final1.ProgramSeqiqueqi = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "413")
|
|
{
|
|
final1.ProgramQingqiqueqi = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "414")
|
|
{
|
|
final1.ProgramJupi = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "415")
|
|
{
|
|
final1.ProgramOther = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "511")
|
|
{
|
|
final1.TeamTuoluocanshuang = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "512")
|
|
{
|
|
final1.TeamQingqiqikuai = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "513")
|
|
{
|
|
final1.TeamSeqiqikuai = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "514")
|
|
{
|
|
final1.TeamFahua = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "515")
|
|
{
|
|
final1.TeamLiangbang = fianlRecord.Counter;
|
|
}
|
|
if (fianlRecord.FkInpectionId == "516")
|
|
{
|
|
final1.TeamPenglou = fianlRecord.Counter;
|
|
}
|
|
}
|
|
}
|
|
final1.PaoguangTotal = paoguang_final;
|
|
final1.CreatedTime = DateTime.Now;
|
|
final1.UpdatedTime = DateTime.Now;
|
|
#endregion
|
|
|
|
#region 打磨
|
|
QcQualityStatisticsFinal final2 = new QcQualityStatisticsFinal();
|
|
final2.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
final2.WorkorderId = workorderID;
|
|
|
|
ProWorkorder_v2 workorder_final2 = Context
|
|
.Queryable<ProWorkorder_v2>()
|
|
.Where(it => it.ClientWorkorder == workorderID)
|
|
.First();
|
|
if (workorder_final2 != null)
|
|
{
|
|
final2.Color = workorder_final2.Colour;
|
|
final2.FinishedPartNumber = workorder_final2.FinishedPartNumber;
|
|
final2.ProductDescription = workorder_final2.ProductDescription;
|
|
|
|
// XXX:三检(包装),生产投入数为(首检合格数 + 抛光合格数)
|
|
final2.RequireNumber = first.QualifiedNumber + again2.QualifiedNumber;
|
|
if (step != null)
|
|
{
|
|
final2.StartTime = step.FirstInspectTime; //这地方是不妥的
|
|
}
|
|
else
|
|
{
|
|
final2.StartTime = null;
|
|
}
|
|
}
|
|
|
|
final2.Team = team;
|
|
|
|
final2.EndTime = DateTime.Now;
|
|
final2.Remark = "打磨";
|
|
final2.Remark2 = 2;
|
|
int damo_total_final = 0;
|
|
|
|
List<QcFinalinspectionRecord> finalrecordList2 = Context
|
|
.Queryable<QcFinalinspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderID)
|
|
.Where(it => SqlFunc.Contains(it.FkInpectionId, "_2_"))
|
|
.ToList();
|
|
if (finalrecordList2 != null && finalrecordList2.Count > 0)
|
|
{
|
|
for (int i = 0; i < finalrecordList2.Count; i++)
|
|
{
|
|
if (finalrecordList2[i].FkInpectionId == "121")
|
|
{
|
|
final2.PaintSuokong = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList2[i].FkInpectionId == "122")
|
|
{
|
|
final2.PaintZhengkong = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList2[i].FkInpectionId == "123")
|
|
{
|
|
final2.PaintShiguang = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList2[i].FkInpectionId == "124")
|
|
{
|
|
final2.PaintSecha = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList2[i].FkInpectionId == "125")
|
|
{
|
|
final2.PaintDianzi = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList2[i].FkInpectionId == "126")
|
|
{
|
|
final2.PaintOther = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList2[i].FkInpectionId == "221")
|
|
{
|
|
final2.DeviceShuiban = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList2[i].FkInpectionId == "222")
|
|
{
|
|
final2.DeviceZandian = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "223")
|
|
{
|
|
final2.DeviceBianxing = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList2[i].FkInpectionId == "224")
|
|
{
|
|
final2.DeviceYouzhu = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList2[i].FkInpectionId == "225")
|
|
{
|
|
final2.DeviceTuoluo = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "226")
|
|
{
|
|
final2.DeviceZhuangshang = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "227")
|
|
{
|
|
final2.DeviceOther = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList2[i].FkInpectionId == "321")
|
|
{
|
|
final2.BlankMaoci = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "322")
|
|
{
|
|
final2.BlankSuoyin = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "323")
|
|
{
|
|
final2.BlankCanshuang = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "324")
|
|
{
|
|
final2.BlankShaying = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "325")
|
|
{
|
|
final2.BlankZangdian = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "326")
|
|
{
|
|
final2.BlankDamo = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "421")
|
|
{
|
|
final2.ProgramLiuguang = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "422")
|
|
{
|
|
final2.ProgramSeqiqueqi = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "423")
|
|
{
|
|
final2.ProgramQingqiqueqi = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "424")
|
|
{
|
|
final2.ProgramJupi = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "425")
|
|
{
|
|
final2.ProgramOther = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "521")
|
|
{
|
|
final2.TeamTuoluocanshuang = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "522")
|
|
{
|
|
final2.TeamQingqiqikuai = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "523")
|
|
{
|
|
final2.TeamSeqiqikuai = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "524")
|
|
{
|
|
final2.TeamFahua = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "525")
|
|
{
|
|
final2.TeamLiangbang = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
if (finalrecordList2[i].FkInpectionId == "526")
|
|
{
|
|
final2.TeamPenglou = finalrecordList2[i].Counter;
|
|
damo_total_final = damo_total_final + (int)finalrecordList2[i].Counter;
|
|
}
|
|
}
|
|
}
|
|
|
|
final2.CreatedTime = DateTime.Now;
|
|
final2.UpdatedTime = DateTime.Now;
|
|
|
|
#endregion
|
|
|
|
#region 报废
|
|
QcQualityStatisticsFinal final3 = new QcQualityStatisticsFinal();
|
|
final3.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
final3.WorkorderId = workorderID;
|
|
|
|
ProWorkorder_v2 workorder_final3 = Context
|
|
.Queryable<ProWorkorder_v2>()
|
|
.Where(it => it.ClientWorkorder == workorderID)
|
|
.First();
|
|
if (workorder_again3 != null)
|
|
{
|
|
final3.Color = workorder_final3.Colour;
|
|
final3.FinishedPartNumber = workorder_final3.FinishedPartNumber;
|
|
final3.ProductDescription = workorder_final3.ProductDescription;
|
|
// XXX:三检(包装投入数)生产投入数为(首检合格数 + 抛光合格数)
|
|
final3.RequireNumber = first.QualifiedNumber + again2.QualifiedNumber;
|
|
//final3.RequireNumber = workorder_final3.PreviousNumber;
|
|
if (step != null)
|
|
{
|
|
final3.StartTime = step.FirstInspectTime; //这地方是不妥的
|
|
}
|
|
else
|
|
{
|
|
final3.StartTime = null;
|
|
}
|
|
}
|
|
|
|
final3.Team = team;
|
|
final3.EndTime = DateTime.Now;
|
|
final3.Remark = "报废";
|
|
final3.Remark2 = 3;
|
|
int baofei_total_final = 0;
|
|
List<QcFinalinspectionRecord> finalrecordList3 = Context
|
|
.Queryable<QcFinalinspectionRecord>()
|
|
.Where(it => it.FkWorkorderId == workorderID)
|
|
.Where(it => SqlFunc.Contains(it.FkInpectionId, "_3_"))
|
|
.ToList();
|
|
if (finalrecordList3 != null && finalrecordList3.Count > 0)
|
|
{
|
|
for (int i = 0; i < finalrecordList3.Count; i++)
|
|
{
|
|
if (finalrecordList3[i].FkInpectionId == "131")
|
|
{
|
|
final3.PaintSuokong = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList3[i].FkInpectionId == "132")
|
|
{
|
|
final3.PaintZhengkong = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList3[i].FkInpectionId == "133")
|
|
{
|
|
final3.PaintShiguang = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList3[i].FkInpectionId == "134")
|
|
{
|
|
final3.PaintSecha = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList3[i].FkInpectionId == "135")
|
|
{
|
|
final3.PaintDianzi = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList3[i].FkInpectionId == "136")
|
|
{
|
|
final3.PaintOther = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList3[i].FkInpectionId == "231")
|
|
{
|
|
final3.DeviceShuiban = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList3[i].FkInpectionId == "232")
|
|
{
|
|
final3.DeviceZandian = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "233")
|
|
{
|
|
final3.DeviceBianxing = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList3[i].FkInpectionId == "234")
|
|
{
|
|
final3.DeviceYouzhu = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList3[i].FkInpectionId == "235")
|
|
{
|
|
final3.DeviceTuoluo = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "236")
|
|
{
|
|
final3.DeviceZhuangshang = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "237")
|
|
{
|
|
final3.DeviceOther = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
|
|
if (finalrecordList3[i].FkInpectionId == "331")
|
|
{
|
|
final3.BlankMaoci = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "332")
|
|
{
|
|
final3.BlankSuoyin = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "333")
|
|
{
|
|
final3.BlankCanshuang = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "334")
|
|
{
|
|
final3.BlankShaying = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "335")
|
|
{
|
|
final3.BlankZangdian = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "336")
|
|
{
|
|
final3.BlankDamo = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "431")
|
|
{
|
|
final3.ProgramLiuguang = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "432")
|
|
{
|
|
final3.ProgramSeqiqueqi = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "433")
|
|
{
|
|
final3.ProgramQingqiqueqi = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "434")
|
|
{
|
|
final3.ProgramJupi = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "435")
|
|
{
|
|
final3.ProgramOther = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "531")
|
|
{
|
|
final3.TeamTuoluocanshuang = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "532")
|
|
{
|
|
final3.TeamQingqiqikuai = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "533")
|
|
{
|
|
final3.TeamSeqiqikuai = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "534")
|
|
{
|
|
final3.TeamFahua = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "535")
|
|
{
|
|
final3.TeamLiangbang = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
if (finalrecordList3[i].FkInpectionId == "536")
|
|
{
|
|
final3.TeamPenglou = finalrecordList3[i].Counter;
|
|
baofei_total_final =
|
|
baofei_total_final + (int)finalrecordList3[i].Counter;
|
|
}
|
|
}
|
|
}
|
|
|
|
final3.CreatedTime = DateTime.Now;
|
|
final3.UpdatedTime = DateTime.Now;
|
|
|
|
#endregion
|
|
|
|
#region 计算汇总
|
|
int qualifiedNumber_No_all_final = baofei_total_final + damo_total_final;
|
|
// 抛光表格插入
|
|
final1.QualifiedNumber = final1.RequireNumber - qualifiedNumber_No_all_final;
|
|
if (final1.RequireNumber == 0)
|
|
{
|
|
final1.QualifiedRate = 0;
|
|
}
|
|
else
|
|
{
|
|
final1.QualifiedRate = Math.Round(
|
|
((decimal)final1.QualifiedNumber / (decimal)final1.RequireNumber) * 100,
|
|
3
|
|
);
|
|
}
|
|
|
|
final1.PaoguangTotal = paoguang_final;
|
|
final1.DamoTotal = damo_total_final;
|
|
final1.BaofeiTotal = baofei_total_final;
|
|
|
|
var x_final_1 = Context
|
|
.Storageable(final1)
|
|
.WhereColumns(it => new { it.WorkorderId, it.Remark2 })
|
|
.ToStorage();
|
|
x_final_1.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x_final_1.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新
|
|
// 打磨表格插入
|
|
final2.QualifiedNumber = final3.RequireNumber - qualifiedNumber_No_all_final;
|
|
if (final2.RequireNumber == 0)
|
|
{
|
|
final2.QualifiedNumber = 0;
|
|
}
|
|
else
|
|
{
|
|
final2.QualifiedRate = Math.Round(
|
|
((decimal)final2.QualifiedNumber / (decimal)final2.RequireNumber) * 100,
|
|
3
|
|
);
|
|
}
|
|
|
|
final2.PaoguangTotal = paoguang_final;
|
|
final2.DamoTotal = damo_total_final;
|
|
final2.BaofeiTotal = baofei_total_final;
|
|
|
|
var x_final_2 = Context
|
|
.Storageable(final2)
|
|
.WhereColumns(it => new { it.WorkorderId, it.Remark2 })
|
|
.ToStorage();
|
|
x_final_2.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x_final_2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新
|
|
// 报废表格插入
|
|
final3.QualifiedNumber = final3.RequireNumber - qualifiedNumber_No_all_final;
|
|
if (final3.RequireNumber == 0)
|
|
{
|
|
final3.QualifiedNumber = 0;
|
|
}
|
|
else
|
|
{
|
|
final3.QualifiedRate = Math.Round(
|
|
((decimal)final3.QualifiedNumber / (decimal)final3.RequireNumber) * 100,
|
|
3
|
|
);
|
|
}
|
|
final3.PaoguangTotal = paoguang_final;
|
|
final3.DamoTotal = damo_total_final;
|
|
final3.BaofeiTotal = baofei_total_final;
|
|
|
|
var x_final_3 = Context
|
|
.Storageable(final3)
|
|
.WhereColumns(it => new { it.WorkorderId, it.Remark2 })
|
|
.ToStorage();
|
|
x_final_3.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x_final_3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新
|
|
#endregion
|
|
#endregion
|
|
#region 总报表
|
|
|
|
#region 抛光 将首检的抛光和包装三检的抛光合并
|
|
QcQualityStatisticsTotal total1 = new QcQualityStatisticsTotal();
|
|
total1.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
total1.WorkorderId = workorderID;
|
|
total1.FinishedPartNumber = workorder_item.FinishedPartNumber;
|
|
total1.ProductDescription = workorder_item.ProductDescription;
|
|
total1.Color = workorder_item.Colour;
|
|
//XXX:修改生产投入数为首检生产投入数 workorder_item
|
|
// total2.RequireNumber = again2.RequireNumber;
|
|
total1.RequireNumber = workorder_item.PreviousNumber;
|
|
if (step != null)
|
|
{
|
|
total1.StartTime = step.FirstInspectTime;
|
|
}
|
|
else
|
|
{
|
|
total1.StartTime = DateTime.Now;
|
|
}
|
|
total1.Team = team;
|
|
total1.EndTime = DateTime.Now;
|
|
total1.Remark = "抛光";
|
|
total1.Remark2 = 1;
|
|
total1.PaintSuokong = (final1.PaintSuokong ?? 0) + (first.PaintSuokong ?? 0);
|
|
total1.PaintZhengkong = (final1.PaintZhengkong ?? 0) + (first.PaintZhengkong ?? 0);
|
|
total1.PaintShiguang = (final1.PaintShiguang ?? 0) + (first.PaintShiguang ?? 0);
|
|
total1.PaintSecha = (final1.PaintSecha ?? 0) + (first.PaintSecha ?? 0);
|
|
total1.PaintDianzi = (final1.PaintDianzi ?? 0) + (first.PaintDianzi ?? 0);
|
|
total1.DeviceShuiban = (final1.DeviceShuiban ?? 0) + (first.DeviceShuiban ?? 0);
|
|
total1.PaintOther = (final1.PaintOther ?? 0) + (first.PaintOther ?? 0);
|
|
total1.DeviceZandian = (final1.DeviceZandian ?? 0) + (first.DeviceZandian ?? 0);
|
|
total1.DeviceBianxing = (final1.DeviceBianxing ?? 0) + (first.DeviceBianxing ?? 0);
|
|
total1.DeviceYouzhu = (final1.DeviceYouzhu ?? 0) + (first.DeviceYouzhu ?? 0);
|
|
total1.DeviceTuoluo = (final1.DeviceTuoluo ?? 0) + (first.DeviceTuoluo ?? 0);
|
|
total1.DeviceZhuangshang =
|
|
(final1.DeviceZhuangshang ?? 0) + (first.DeviceZhuangshang ?? 0);
|
|
total1.DeviceOther = final1.DeviceOther ?? 0 + first.DeviceOther ?? 0;
|
|
total1.BlankMaoci = (final1.BlankMaoci ?? 0) + (first.BlankMaoci ?? 0);
|
|
total1.BlankSuoyin = (final1.BlankSuoyin ?? 0) + (first.BlankSuoyin ?? 0);
|
|
total1.BlankCanshuang = (final1.BlankCanshuang ?? 0) + (first.BlankCanshuang ?? 0);
|
|
total1.BlankShaying = (final1.BlankShaying ?? 0) + (first.BlankShaying ?? 0);
|
|
total1.BlankZangdian = (final1.BlankZangdian ?? 0) + (first.BlankZangdian ?? 0);
|
|
total1.BlankDamo = (final1.BlankDamo ?? 0) + (first.BlankDamo ?? 0);
|
|
total1.ProgramLiuguang =
|
|
(final1.ProgramLiuguang ?? 0) + (first.ProgramLiuguang ?? 0);
|
|
total1.ProgramSeqiqueqi =
|
|
(final1.ProgramSeqiqueqi ?? 0) + (first.ProgramSeqiqueqi ?? 0);
|
|
total1.ProgramQingqiqueqi =
|
|
(final1.ProgramQingqiqueqi ?? 0) + (first.ProgramQingqiqueqi ?? 0);
|
|
total1.ProgramJupi = (final1.ProgramJupi ?? 0) + (first.ProgramJupi ?? 0);
|
|
total1.TeamTuoluocanshuang =
|
|
(final1.TeamTuoluocanshuang ?? 0) + (first.TeamTuoluocanshuang ?? 0);
|
|
total1.ProgramOther = (final1.ProgramOther ?? 0) + (first.ProgramOther ?? 0);
|
|
total1.TeamQingqiqikuai =
|
|
(final1.TeamQingqiqikuai ?? 0) + (first.TeamQingqiqikuai ?? 0);
|
|
total1.TeamSeqiqikuai = (final1.TeamSeqiqikuai ?? 0) + (first.TeamSeqiqikuai ?? 0);
|
|
total1.TeamFahua = (final1.TeamFahua ?? 0) + (first.TeamFahua ?? 0);
|
|
total1.TeamLiangbang = (final1.TeamLiangbang ?? 0) + (first.TeamLiangbang ?? 0);
|
|
total1.TeamPenglou = (final1.TeamPenglou ?? 0) + (first.TeamPenglou ?? 0);
|
|
|
|
total1.CreatedTime = DateTime.Now;
|
|
total1.UpdatedTime = DateTime.Now;
|
|
|
|
#endregion
|
|
|
|
#region 打磨 将二检的打磨和三检的打磨合并
|
|
QcQualityStatisticsTotal total2 = new QcQualityStatisticsTotal();
|
|
total2.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
total2.WorkorderId = workorderID;
|
|
total2.FinishedPartNumber = workorder_item.FinishedPartNumber;
|
|
total2.ProductDescription = workorder_item.ProductDescription;
|
|
total2.Color = workorder_item.Colour;
|
|
//XXX:修改生产投入数为首检生产投入数 workorder_item
|
|
// total2.RequireNumber = again2.RequireNumber;
|
|
total2.RequireNumber = workorder_item.PreviousNumber;
|
|
if (step != null)
|
|
{
|
|
total2.StartTime = step.FirstInspectTime; //这地方是不妥的
|
|
}
|
|
else
|
|
{
|
|
total2.StartTime = DateTime.Now;
|
|
}
|
|
|
|
total2.Team = team;
|
|
|
|
total2.EndTime = DateTime.Now;
|
|
total2.Remark = "打磨";
|
|
total2.Remark2 = 2;
|
|
total2.PaintSuokong =
|
|
(again2.PaintSuokong ?? 0)
|
|
+ (final2.PaintSuokong ?? 0)
|
|
+ (first2.PaintSuokong ?? 0);
|
|
total2.PaintZhengkong =
|
|
(again2.PaintZhengkong ?? 0)
|
|
+ (final2.PaintZhengkong ?? 0)
|
|
+ (first2.PaintZhengkong ?? 0);
|
|
total2.PaintShiguang =
|
|
(again2.PaintShiguang ?? 0)
|
|
+ (final2.PaintShiguang ?? 0)
|
|
+ (first2.PaintShiguang ?? 0);
|
|
total2.PaintSecha =
|
|
(again2.PaintSecha ?? 0) + (final2.PaintSecha ?? 0) + (first2.PaintSecha ?? 0);
|
|
total2.PaintDianzi =
|
|
(again2.PaintDianzi ?? 0)
|
|
+ (final2.PaintDianzi ?? 0)
|
|
+ (first2.PaintDianzi ?? 0);
|
|
total2.DeviceShuiban =
|
|
(again2.DeviceShuiban ?? 0)
|
|
+ (final2.DeviceShuiban ?? 0)
|
|
+ (first2.DeviceShuiban ?? 0);
|
|
total2.PaintOther =
|
|
(again2.PaintOther ?? 0) + (final2.PaintOther ?? 0) + (first2.PaintOther ?? 0);
|
|
total2.DeviceZandian =
|
|
(again2.DeviceZandian ?? 0)
|
|
+ (final2.DeviceZandian ?? 0)
|
|
+ (first2.DeviceZandian ?? 0);
|
|
total2.DeviceBianxing =
|
|
(again2.DeviceBianxing ?? 0)
|
|
+ (final2.DeviceBianxing ?? 0)
|
|
+ (first2.DeviceBianxing ?? 0);
|
|
total2.DeviceYouzhu =
|
|
(again2.DeviceYouzhu ?? 0)
|
|
+ (final2.DeviceYouzhu ?? 0)
|
|
+ (first2.DeviceYouzhu ?? 0);
|
|
total2.DeviceTuoluo =
|
|
(again2.DeviceTuoluo ?? 0)
|
|
+ (final2.DeviceTuoluo ?? 0)
|
|
+ (first2.DeviceTuoluo ?? 0);
|
|
total2.DeviceZhuangshang =
|
|
(again2.DeviceZhuangshang ?? 0)
|
|
+ (final2.DeviceZhuangshang ?? 0)
|
|
+ (first2.DeviceZhuangshang ?? 0);
|
|
total2.DeviceOther =
|
|
again2.DeviceOther ?? 0 + final2.DeviceOther ?? 0 + first2.DeviceOther ?? 0;
|
|
total2.BlankMaoci =
|
|
(again2.BlankMaoci ?? 0) + (final2.BlankMaoci ?? 0) + (first2.BlankMaoci ?? 0);
|
|
total2.BlankSuoyin =
|
|
(again2.BlankSuoyin ?? 0)
|
|
+ (final2.BlankSuoyin ?? 0)
|
|
+ (first2.BlankSuoyin ?? 0);
|
|
total2.BlankCanshuang =
|
|
(again2.BlankCanshuang ?? 0)
|
|
+ (final2.BlankCanshuang ?? 0)
|
|
+ (first2.BlankCanshuang ?? 0);
|
|
total2.BlankShaying =
|
|
(again2.BlankShaying ?? 0)
|
|
+ (final2.BlankShaying ?? 0)
|
|
+ (first2.BlankShaying ?? 0);
|
|
total2.BlankZangdian =
|
|
(again2.BlankZangdian ?? 0)
|
|
+ (final2.BlankZangdian ?? 0)
|
|
+ (first2.BlankZangdian ?? 0);
|
|
total2.BlankDamo =
|
|
(again2.BlankDamo ?? 0) + (final2.BlankDamo ?? 0) + (first2.BlankDamo ?? 0);
|
|
total2.ProgramLiuguang =
|
|
(again2.ProgramLiuguang ?? 0)
|
|
+ (final2.ProgramLiuguang ?? 0)
|
|
+ (first2.ProgramLiuguang ?? 0);
|
|
total2.ProgramSeqiqueqi =
|
|
(again2.ProgramSeqiqueqi ?? 0)
|
|
+ (final2.ProgramSeqiqueqi ?? 0)
|
|
+ (first2.ProgramSeqiqueqi ?? 0);
|
|
total2.ProgramQingqiqueqi =
|
|
(again2.ProgramQingqiqueqi ?? 0)
|
|
+ (final2.ProgramQingqiqueqi ?? 0)
|
|
+ (first2.ProgramQingqiqueqi ?? 0);
|
|
total2.ProgramJupi =
|
|
(again2.ProgramJupi ?? 0)
|
|
+ (final2.ProgramJupi ?? 0)
|
|
+ (first2.ProgramJupi ?? 0);
|
|
total2.TeamTuoluocanshuang =
|
|
(again2.TeamTuoluocanshuang ?? 0)
|
|
+ (final2.TeamTuoluocanshuang ?? 0)
|
|
+ (first2.TeamTuoluocanshuang ?? 0);
|
|
total2.ProgramOther =
|
|
(again2.ProgramOther ?? 0)
|
|
+ (final2.ProgramOther ?? 0)
|
|
+ (first2.ProgramOther ?? 0);
|
|
total2.TeamQingqiqikuai =
|
|
(again2.TeamQingqiqikuai ?? 0)
|
|
+ (final2.TeamQingqiqikuai ?? 0)
|
|
+ (first2.TeamQingqiqikuai ?? 0);
|
|
total2.TeamSeqiqikuai =
|
|
(again2.TeamSeqiqikuai ?? 0)
|
|
+ (final2.TeamSeqiqikuai ?? 0)
|
|
+ (first2.TeamSeqiqikuai ?? 0);
|
|
total2.TeamFahua =
|
|
(again2.TeamFahua ?? 0) + (final2.TeamFahua ?? 0) + (first2.TeamFahua ?? 0);
|
|
total2.TeamLiangbang =
|
|
(again2.TeamLiangbang ?? 0)
|
|
+ (final2.TeamLiangbang ?? 0)
|
|
+ (first2.TeamLiangbang ?? 0);
|
|
total2.TeamPenglou =
|
|
(again2.TeamPenglou ?? 0)
|
|
+ (final2.TeamPenglou ?? 0)
|
|
+ (first2.TeamPenglou ?? 0);
|
|
|
|
total2.CreatedTime = DateTime.Now;
|
|
total2.UpdatedTime = DateTime.Now;
|
|
|
|
#endregion
|
|
#region 报废 =二检报废+三检报废
|
|
QcQualityStatisticsTotal total3 = new QcQualityStatisticsTotal();
|
|
total3.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
total3.WorkorderId = workorderID;
|
|
total3.Color = again3.Color;
|
|
|
|
total3.FinishedPartNumber = again3.FinishedPartNumber;
|
|
total3.ProductDescription = again3.ProductDescription;
|
|
// XXX:修改生产投入数
|
|
// total3.RequireNumber = again3.RequireNumber;
|
|
total3.RequireNumber = workorder_item.PreviousNumber;
|
|
if (step != null)
|
|
{
|
|
total3.StartTime = step.FirstInspectTime; //这地方是不妥的
|
|
}
|
|
else
|
|
{
|
|
total3.StartTime = DateTime.Now;
|
|
}
|
|
|
|
total3.Team = team;
|
|
total3.EndTime = DateTime.Now;
|
|
total3.Remark = "报废";
|
|
total3.Remark2 = 3;
|
|
|
|
total3.PaintSuokong =
|
|
(again3.PaintSuokong ?? 0)
|
|
+ (final3.PaintSuokong ?? 0)
|
|
+ (first3.PaintSuokong ?? 0);
|
|
total3.PaintZhengkong =
|
|
(again3.PaintZhengkong ?? 0)
|
|
+ (final3.PaintZhengkong ?? 0)
|
|
+ (first3.PaintZhengkong ?? 00);
|
|
total3.PaintShiguang =
|
|
(again3.PaintShiguang ?? 0)
|
|
+ (final3.PaintShiguang ?? 0)
|
|
+ (first3.PaintShiguang ?? 0);
|
|
total3.PaintSecha =
|
|
(again3.PaintSecha ?? 0) + (final3.PaintSecha ?? 0) + (first3.PaintSecha ?? 0);
|
|
total3.PaintDianzi =
|
|
(again3.PaintDianzi ?? 0)
|
|
+ (final3.PaintDianzi ?? 0)
|
|
+ (first3.PaintDianzi ?? 0);
|
|
total3.DeviceShuiban =
|
|
(again3.DeviceShuiban ?? 0)
|
|
+ (final3.DeviceShuiban ?? 0)
|
|
+ (first3.DeviceShuiban ?? 0);
|
|
total3.PaintOther =
|
|
(again3.PaintOther ?? 0) + (final3.PaintOther ?? 0) + (first3.PaintOther ?? 0);
|
|
total3.DeviceZandian =
|
|
again3.DeviceZandian
|
|
?? 0 + final3.DeviceZandian
|
|
?? 0 + first3.DeviceZandian
|
|
?? 0;
|
|
total3.DeviceBianxing =
|
|
(again3.DeviceBianxing ?? 0)
|
|
+ (final3.DeviceBianxing ?? 0)
|
|
+ (first3.DeviceBianxing ?? 0);
|
|
total3.DeviceYouzhu =
|
|
(again3.DeviceYouzhu ?? 0)
|
|
+ (final3.DeviceYouzhu ?? 0)
|
|
+ (first3.DeviceYouzhu ?? 0);
|
|
total3.DeviceTuoluo =
|
|
(again3.DeviceTuoluo ?? 0)
|
|
+ (final3.DeviceTuoluo ?? 0)
|
|
+ (first3.DeviceTuoluo ?? 0);
|
|
total3.DeviceZhuangshang =
|
|
(again3.DeviceZhuangshang ?? 0)
|
|
+ (final3.DeviceZhuangshang ?? 0)
|
|
+ (first3.DeviceZhuangshang ?? 0);
|
|
total3.DeviceOther =
|
|
(again3.DeviceOther ?? 0)
|
|
+ (final3.DeviceOther ?? 0)
|
|
+ (first3.DeviceOther ?? 0);
|
|
total3.BlankMaoci =
|
|
(again3.BlankMaoci ?? 0) + (final3.BlankMaoci ?? 0) + (first3.BlankMaoci ?? 0);
|
|
total3.BlankSuoyin =
|
|
(again3.BlankSuoyin ?? 0) + (final3.BlankMaoci ?? 0) + (first3.BlankMaoci ?? 0);
|
|
total3.BlankCanshuang =
|
|
(again3.BlankCanshuang ?? 0)
|
|
+ (final3.BlankCanshuang ?? 0)
|
|
+ (first3.BlankCanshuang ?? 0);
|
|
total3.BlankShaying =
|
|
(again3.BlankShaying ?? 0)
|
|
+ (final3.BlankShaying ?? 0)
|
|
+ (first3.BlankShaying ?? 0);
|
|
total3.BlankZangdian =
|
|
(again3.BlankZangdian ?? 0)
|
|
+ (final3.BlankZangdian ?? 0)
|
|
+ (first3.BlankZangdian ?? 0);
|
|
total3.BlankDamo =
|
|
(again3.BlankDamo ?? 0) + (final3.BlankDamo ?? 0) + (first3.BlankDamo ?? 0);
|
|
total3.ProgramLiuguang =
|
|
(again3.ProgramLiuguang ?? 0)
|
|
+ (final3.ProgramLiuguang ?? 0)
|
|
+ (first3.ProgramLiuguang ?? 0);
|
|
total3.ProgramSeqiqueqi =
|
|
(again3.ProgramSeqiqueqi ?? 0)
|
|
+ (final3.ProgramSeqiqueqi ?? 0)
|
|
+ (first3.ProgramSeqiqueqi ?? 0);
|
|
total3.ProgramQingqiqueqi =
|
|
(again3.ProgramQingqiqueqi ?? 0)
|
|
+ (final3.ProgramQingqiqueqi ?? 0)
|
|
+ (first3.ProgramQingqiqueqi ?? 0);
|
|
total3.ProgramJupi =
|
|
(again3.ProgramJupi ?? 0)
|
|
+ (final3.ProgramJupi ?? 0)
|
|
+ (first3.ProgramJupi ?? 0);
|
|
total3.TeamTuoluocanshuang =
|
|
(again3.TeamTuoluocanshuang ?? 0)
|
|
+ (final3.TeamTuoluocanshuang ?? 0)
|
|
+ (first3.TeamTuoluocanshuang ?? 0);
|
|
total3.ProgramOther =
|
|
(again3.ProgramOther ?? 0)
|
|
+ (final3.ProgramOther ?? 0)
|
|
+ (first3.ProgramOther ?? 0);
|
|
total3.TeamQingqiqikuai =
|
|
again3.TeamQingqiqikuai
|
|
?? 0 + final3.TeamQingqiqikuai
|
|
?? 0 + first3.TeamQingqiqikuai
|
|
?? 0;
|
|
total3.TeamSeqiqikuai =
|
|
(again3.TeamSeqiqikuai ?? 0)
|
|
+ (final3.TeamSeqiqikuai ?? 0)
|
|
+ (first3.TeamSeqiqikuai ?? 0);
|
|
total3.TeamFahua =
|
|
(again3.TeamFahua ?? 0) + (final3.TeamFahua ?? 0) + (first3.TeamFahua ?? 0);
|
|
total3.TeamLiangbang =
|
|
(again3.TeamLiangbang ?? 0)
|
|
+ (final3.TeamLiangbang ?? 0)
|
|
+ (first3.TeamLiangbang ?? 0);
|
|
total3.TeamPenglou =
|
|
(again3.TeamPenglou ?? 0)
|
|
+ (final3.TeamPenglou ?? 0)
|
|
+ (first3.TeamPenglou ?? 0);
|
|
|
|
total3.CreatedTime = DateTime.Now;
|
|
total3.UpdatedTime = DateTime.Now;
|
|
|
|
#endregion
|
|
#region 计算汇总
|
|
int qualifiedNumber_No_all_total =
|
|
qualifiedNumber_No_all
|
|
+ qualifiedNumber_No_all_again
|
|
+ qualifiedNumber_No_all_final;
|
|
//XXX:修改合格数公式:包装数
|
|
// total2.QualifiedNumber = (again2.RequireNumber ?? 0) - qualifiedNumber_No_all_total;
|
|
|
|
|
|
// 总报表-抛光记录插入
|
|
total1.QualifiedNumber = final1.QualifiedNumber;
|
|
if (total1.RequireNumber == 0)
|
|
{
|
|
total1.QualifiedRate = 0;
|
|
}
|
|
else
|
|
total1.QualifiedRate = Math.Round(
|
|
((decimal)total1.QualifiedNumber / (decimal)total1.RequireNumber) * 100,
|
|
3
|
|
);
|
|
// XXX:修改总报表打磨,报废数计算公式
|
|
total1.PaoguangTotal = first.PaoguangTotal + final1.PaoguangTotal;
|
|
total1.DamoTotal = damo_total + damo_total_again + damo_total_final;
|
|
total1.BaofeiTotal = baofei_total + baofei_total_again3 + baofei_total_final;
|
|
var x_total_1 = Context
|
|
.Storageable(total1)
|
|
.WhereColumns(it => new { it.WorkorderId, it.Remark2 })
|
|
.ToStorage();
|
|
x_total_1.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x_total_1.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新
|
|
|
|
// 总报表-打磨记录插入
|
|
|
|
total2.QualifiedNumber = final2.QualifiedNumber;
|
|
if (total2.RequireNumber == 0)
|
|
{
|
|
total2.QualifiedRate = 0;
|
|
}
|
|
else
|
|
total2.QualifiedRate = Math.Round(
|
|
((decimal)total2.QualifiedNumber / (decimal)total2.RequireNumber) * 100,
|
|
3
|
|
);
|
|
// XXX:修改总报表打磨,报废数计算公式
|
|
total2.PaoguangTotal = first.PaoguangTotal + final1.PaoguangTotal;
|
|
total2.DamoTotal = damo_total + damo_total_again + damo_total_final;
|
|
total2.BaofeiTotal = baofei_total + baofei_total_again3 + baofei_total_final;
|
|
// total2.DamoTotal = damo_total_again + damo_total_final;
|
|
// total2.BaofeiTotal = baofei_total_again3 + baofei_total_final;
|
|
|
|
|
|
var x_total_2 = Context
|
|
.Storageable(total2)
|
|
.WhereColumns(it => new { it.WorkorderId, it.Remark2 })
|
|
.ToStorage();
|
|
x_total_2.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x_total_2.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新
|
|
|
|
// 总报表-报废记录插入
|
|
//XXX:修改合格数公式
|
|
// total3.QualifiedNumber = again3.RequireNumber ?? 0 - qualifiedNumber_No_all_total;
|
|
total3.QualifiedNumber = final2.QualifiedNumber;
|
|
if (total3.RequireNumber == 0)
|
|
{
|
|
total3.QualifiedRate = 0;
|
|
}
|
|
else
|
|
total3.QualifiedRate = Math.Round(
|
|
((decimal)total3.QualifiedNumber / (decimal)total3.RequireNumber) * 100,
|
|
3
|
|
);
|
|
// XXX:修改总报表打磨,报废数计算公式
|
|
total3.PaoguangTotal = first.PaoguangTotal + final1.PaoguangTotal;
|
|
total3.DamoTotal = damo_total + damo_total_again + damo_total_final;
|
|
total3.BaofeiTotal = baofei_total + baofei_total_again3 + baofei_total_final;
|
|
// total3.DamoTotal = damo_total_again + damo_total_final;
|
|
// total3.BaofeiTotal = baofei_total_again3 + baofei_total_final;
|
|
|
|
|
|
var x_total_3 = Context
|
|
.Storageable(total3)
|
|
.WhereColumns(it => new { it.WorkorderId, it.Remark2 })
|
|
.ToStorage();
|
|
x_total_3.AsInsertable.ExecuteCommand(); //不存在插入
|
|
x_total_3.AsUpdateable.IgnoreColumns(z => z.CreatedTime).ExecuteCommand(); //存在更新
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
//TODO 20241023 不再变动抛光盘点后的数据
|
|
|
|
try
|
|
{
|
|
// 合格,抛光,打磨数
|
|
int qualifiedNumber = first.QualifiedNumber.Value;
|
|
int paoguangTotal = first.PaoguangTotal.Value;
|
|
int damoTotal = first.DamoTotal.Value;
|
|
|
|
//TODO 20251021 包装完成工单后,发送送货单打印数据
|
|
string mqttTopic = $"shgg_mes/package_print_1/print/1站点";
|
|
string qualifiedLabelPath = "D:\\RIZO\\label\\合格送货单.btw";
|
|
string polishLabelPath = "D:\\RIZO\\label\\抛光送货单.btw";
|
|
string polishingLabelPath = "D:\\RIZO\\label\\打磨送货单.btw";
|
|
//TODO 20251027 检查是否存在产线产品托盘配置
|
|
WmMaterialPackage packageConfig = Context.Queryable<WmMaterialPackage>()
|
|
.Where(it => it.RecordType == "零件")
|
|
.Where(it => it.PartNumber == first.FinishedPartNumber)
|
|
.First();
|
|
//TODO 20251027 计算合格数是否超出合格托盘
|
|
if (packageConfig != null && packageConfig.PackageProductionQualifiedPalletNum != null)
|
|
{
|
|
// 合格数超额分段出标签
|
|
if (qualifiedNumber > packageConfig.PackageProductionQualifiedPalletNum)
|
|
{
|
|
// 分批次出多个合格品满箱标签和零头箱标签
|
|
int qualifiedPalletCapacity = packageConfig.PackageProductionQualifiedPalletNum.Value;
|
|
int fullPalletCount = qualifiedNumber / qualifiedPalletCapacity;
|
|
int remainderCount = qualifiedNumber % qualifiedPalletCapacity;
|
|
|
|
// 出满箱标签
|
|
for (int i = 1; i <= fullPalletCount; i++)
|
|
{
|
|
PrintDeliveryNoteDto qualifiedFullPalletDto = CreateQualifiedFullPalletLabelDto(first, qualifiedPalletCapacity, i);
|
|
SendMqttLabelMessage(mqttTopic, qualifiedFullPalletDto);
|
|
}
|
|
|
|
// 出零头箱标签
|
|
if (remainderCount > 0)
|
|
{
|
|
PrintDeliveryNoteDto qualifiedRemainderDto = CreateQualifiedRemainderLabelDto(first, remainderCount, fullPalletCount);
|
|
SendMqttLabelMessage(mqttTopic, qualifiedRemainderDto);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 正常出单个标签
|
|
PrintDeliveryNoteDto qualifiedSingleLabelDto = CreateQualifiedSingleLabelDto(first, first.QualifiedNumber.Value);
|
|
SendMqttLabelMessage(mqttTopic, qualifiedSingleLabelDto);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 没有配置时使用默认的单个标签打印
|
|
PrintDeliveryNoteDto qualifiedSingleLabelDto = CreateQualifiedSingleLabelDto(first, first.QualifiedNumber.Value);
|
|
SendMqttLabelMessage(mqttTopic, qualifiedSingleLabelDto);
|
|
}
|
|
|
|
if (packageConfig != null && packageConfig.PackageProductionPolishPalletNum != null)
|
|
{
|
|
// 抛光数超额分段
|
|
if (paoguangTotal > packageConfig.PackageProductionPolishPalletNum)
|
|
{
|
|
// 分批次出多个抛光品满箱标签和零头箱标签
|
|
int polishPalletCapacity = packageConfig.PackageProductionPolishPalletNum.Value;
|
|
int fullPalletCount = paoguangTotal / polishPalletCapacity;
|
|
int remainderCount = paoguangTotal % polishPalletCapacity;
|
|
|
|
// 出满箱标签
|
|
for (int i = 1; i <= fullPalletCount; i++)
|
|
{
|
|
PrintDeliveryNoteDto polishFullPalletDto = CreatePolishFullPalletLabelDto(first, polishPalletCapacity, i);
|
|
SendMqttLabelMessage(mqttTopic, polishFullPalletDto);
|
|
}
|
|
|
|
// 出零头箱标签
|
|
if (remainderCount > 0)
|
|
{
|
|
PrintDeliveryNoteDto polishRemainderDto = CreatePolishRemainderLabelDto(first, remainderCount, fullPalletCount);
|
|
SendMqttLabelMessage(mqttTopic, polishRemainderDto);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 正常出单个标签
|
|
PrintDeliveryNoteDto polishSingleLabelDto = CreatePolishSingleLabelDto(first, first.PaoguangTotal.Value);
|
|
SendMqttLabelMessage(mqttTopic, polishSingleLabelDto);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 没有配置时使用默认的单个标签打印
|
|
PrintDeliveryNoteDto polishSingleLabelDto = CreatePolishSingleLabelDto(first, first.PaoguangTotal.Value);
|
|
SendMqttLabelMessage(mqttTopic, polishSingleLabelDto);
|
|
}
|
|
|
|
|
|
// 使用辅助方法创建打磨标签
|
|
PrintDeliveryNoteDto polishingLabelDto = CreatePolishingLabelDto(first, first.DamoTotal.Value);
|
|
SendMqttLabelMessage(mqttTopic, polishingLabelDto);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
|
|
return 1;
|
|
// 以下代码暂时停用
|
|
// 产线报表生成后自动化操作
|
|
try
|
|
{
|
|
// 1.抛光品入库
|
|
WmPolishInventoryService wmPolishInventoryService = new();
|
|
WmPolishInventory warehousingInfo =
|
|
new()
|
|
{
|
|
Partnumber = workorder_item.FinishedPartNumber,
|
|
WorkOrder = workorder_item.ClientWorkorder,
|
|
Type = workorder_item.Remark1.Contains("返工") ? 2 : 1,
|
|
Quantity = paoguang_by_first + paoguang_final,
|
|
ActionTime = DateTime.Now.ToLocalTime(),
|
|
CreatedBy = "包装" + team + "组",
|
|
Remark = "产线抛光件,自动入库。来源工单号:[" + workorder_item.ClientWorkorder + "]"
|
|
};
|
|
wmPolishInventoryService.DoWmPolishWarehousing(warehousingInfo);
|
|
// 2.成品入一次合格品库
|
|
// 合格品检查是否是门把手或倒车雷达,是进入成品库(仅出库),不是进入一次合格品库
|
|
string[] checkStrArray =
|
|
{
|
|
"门把手",
|
|
"面盖",
|
|
"T22",
|
|
"T26",
|
|
"A58",
|
|
"A60",
|
|
"C01",
|
|
"B02",
|
|
"V71",
|
|
"T1EJ ",
|
|
"倒车雷达"
|
|
};
|
|
var isDoorknobCheck = Expressionable.Create<WmMaterial>();
|
|
foreach (string checkStr in checkStrArray)
|
|
{
|
|
isDoorknobCheck.Or(it => it.Description.Contains(checkStr));
|
|
}
|
|
isDoorknobCheck
|
|
.And(it => it.Partnumber == workorder_item.FinishedPartNumber)
|
|
.And(it => it.Type == 1)
|
|
.And(it => it.Status == 1);
|
|
bool isDoorknob = Context
|
|
.Queryable<WmMaterial>()
|
|
.Where(isDoorknobCheck.ToExpression())
|
|
.Any();
|
|
if (!isDoorknob)
|
|
{
|
|
WmOneTimeInventoryService oneTimeService = new();
|
|
WmOneTimeInventory wmOneTimeInventoryWarehousing =
|
|
new()
|
|
{
|
|
Partnumber = workorder_item.FinishedPartNumber,
|
|
WorkOrder = workorder_item.ClientWorkorder,
|
|
Type = workorder_item.Remark1.Contains("返工") ? 2 : 1,
|
|
Quantity = total3.QualifiedNumber,
|
|
CreatedBy = "包装" + team + "组",
|
|
ActionTime = DateTime.Now.ToLocalTime(),
|
|
Remark =
|
|
"包装合格品入库,合格数:"
|
|
+ total3.QualifiedNumber
|
|
+ "、工单号:"
|
|
+ workorder_item.ClientWorkorder
|
|
?? "未填写工单号" + "。记录时间:" + DateTime.Now.ToLocalTime().ToString()
|
|
};
|
|
oneTimeService.DoWmOneTimeWarehousing(wmOneTimeInventoryWarehousing);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发送MQTT标签打印消息
|
|
/// </summary>
|
|
private void SendMqttLabelMessage(string mqttTopic, PrintDeliveryNoteDto labelDto)
|
|
{
|
|
string labelJsonPayload = JsonSerializer.Serialize(labelDto);
|
|
_mqttService
|
|
.PublishAsync(
|
|
mqttTopic,
|
|
labelJsonPayload,
|
|
MqttQualityOfServiceLevel.AtLeastOnce,
|
|
retain: false
|
|
)
|
|
.Wait();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建合格品满箱标签DTO
|
|
/// </summary>
|
|
private PrintDeliveryNoteDto CreateQualifiedFullPalletLabelDto(QcQualityStatisticsFirst first, int qualifiedPalletNum, int batchIndex)
|
|
{
|
|
return new PrintDeliveryNoteDto
|
|
{
|
|
Path = "D:\\RIZO\\label\\合格送货单.btw",
|
|
SiteNo = "1站点",
|
|
Name = $"包装合格送货单标签打印(满箱)第{batchIndex}箱",
|
|
PartNumber = first.FinishedPartNumber,
|
|
Description = first.ProductDescription,
|
|
Color = first.Color,
|
|
Specification = "",
|
|
WorkOrder = first.WorkorderId,
|
|
PackageCode = $"{first.WorkorderId}_{batchIndex}",
|
|
Team = first.Team,
|
|
Sort = batchIndex,
|
|
ProductionTime = first.WorkorderId,
|
|
BatchCode = first.WorkorderId,
|
|
PackageNum = qualifiedPalletNum,
|
|
LabelCode = $"Type=DeNoHG^ItemNumber={first.FinishedPartNumber}^Order={first.WorkorderId}^Qty={qualifiedPalletNum}^Batch={batchIndex}",
|
|
LabelType = 1,
|
|
CreatedTime = DateTime.Now.ToString()
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建合格品零头箱标签DTO
|
|
/// </summary>
|
|
private PrintDeliveryNoteDto CreateQualifiedRemainderLabelDto(QcQualityStatisticsFirst first, int remainderCount, int fullPalletCount)
|
|
{
|
|
int remainderBatchIndex = fullPalletCount + 1;
|
|
return new PrintDeliveryNoteDto
|
|
{
|
|
Path = "D:\\RIZO\\label\\合格送货单.btw",
|
|
SiteNo = "1站点",
|
|
Name = "包装合格送货单标签打印(零头箱)",
|
|
PartNumber = first.FinishedPartNumber,
|
|
Description = first.ProductDescription,
|
|
Color = first.Color,
|
|
Specification = "",
|
|
WorkOrder = first.WorkorderId,
|
|
PackageCode = $"{first.WorkorderId}_{remainderBatchIndex}_remainder",
|
|
Team = first.Team,
|
|
Sort = remainderBatchIndex,
|
|
ProductionTime = first.WorkorderId,
|
|
BatchCode = first.WorkorderId,
|
|
PackageNum = remainderCount,
|
|
LabelCode = $"Type=DeNoHG^ItemNumber={first.FinishedPartNumber}^Order={first.WorkorderId}^Qty={remainderCount}^Batch={remainderBatchIndex}_remainder",
|
|
LabelType = 1,
|
|
CreatedTime = DateTime.Now.ToString()
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建合格品单个标签DTO
|
|
/// </summary>
|
|
private PrintDeliveryNoteDto CreateQualifiedSingleLabelDto(QcQualityStatisticsFirst first, int qualifiedNumber)
|
|
{
|
|
return new PrintDeliveryNoteDto
|
|
{
|
|
Path = "D:\\RIZO\\label\\合格送货单.btw",
|
|
SiteNo = "1站点",
|
|
Name = "包装合格送货单标签打印",
|
|
PartNumber = first.FinishedPartNumber,
|
|
Description = first.ProductDescription,
|
|
Color = first.Color,
|
|
Specification = "",
|
|
WorkOrder = first.WorkorderId,
|
|
PackageCode = first.WorkorderId,
|
|
Team = first.Team,
|
|
Sort = 1,
|
|
ProductionTime = first.WorkorderId,
|
|
BatchCode = first.WorkorderId,
|
|
PackageNum = qualifiedNumber,
|
|
LabelCode = $"Type=DeNoHG^ItemNumber={first.FinishedPartNumber}^Order={first.WorkorderId}^Qty={qualifiedNumber}",
|
|
LabelType = 1,
|
|
CreatedTime = DateTime.Now.ToString()
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建抛光品满箱标签DTO
|
|
/// </summary>
|
|
private PrintDeliveryNoteDto CreatePolishFullPalletLabelDto(QcQualityStatisticsFirst first, int polishPalletNum, int batchIndex)
|
|
{
|
|
return new PrintDeliveryNoteDto
|
|
{
|
|
Path = "D:\\RIZO\\label\\抛光送货单.btw",
|
|
SiteNo = "1站点",
|
|
Name = $"包装抛光送货单标签打印(满箱)第{batchIndex}箱",
|
|
PartNumber = first.FinishedPartNumber,
|
|
Description = first.ProductDescription,
|
|
Color = first.Color,
|
|
Specification = "",
|
|
WorkOrder = first.WorkorderId,
|
|
PackageCode = $"{first.WorkorderId}_PG_{batchIndex}",
|
|
Team = first.Team,
|
|
Sort = batchIndex,
|
|
ProductionTime = first.WorkorderId,
|
|
BatchCode = first.WorkorderId,
|
|
PackageNum = polishPalletNum,
|
|
LabelCode = $"Type=DeNoPG^ItemNumber={first.FinishedPartNumber}^Order={first.WorkorderId}^Qty={polishPalletNum}^Batch={batchIndex}",
|
|
LabelType = 1,
|
|
CreatedTime = DateTime.Now.ToString()
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建抛光品零头箱标签DTO
|
|
/// </summary>
|
|
private PrintDeliveryNoteDto CreatePolishRemainderLabelDto(QcQualityStatisticsFirst first, int remainderCount, int fullPalletCount)
|
|
{
|
|
int remainderBatchIndex = fullPalletCount + 1;
|
|
return new PrintDeliveryNoteDto
|
|
{
|
|
Path = "D:\\RIZO\\label\\抛光送货单.btw",
|
|
SiteNo = "1站点",
|
|
Name = "包装抛光送货单标签打印(零头箱)",
|
|
PartNumber = first.FinishedPartNumber,
|
|
Description = first.ProductDescription,
|
|
Color = first.Color,
|
|
Specification = "",
|
|
WorkOrder = first.WorkorderId,
|
|
PackageCode = $"{first.WorkorderId}_PG_{remainderBatchIndex}_remainder",
|
|
Team = first.Team,
|
|
Sort = remainderBatchIndex,
|
|
ProductionTime = first.WorkorderId,
|
|
BatchCode = first.WorkorderId,
|
|
PackageNum = remainderCount,
|
|
LabelCode = $"Type=DeNoPG^ItemNumber={first.FinishedPartNumber}^Order={first.WorkorderId}^Qty={remainderCount}^Batch={remainderBatchIndex}_remainder",
|
|
LabelType = 1,
|
|
CreatedTime = DateTime.Now.ToString()
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建抛光品单个标签DTO
|
|
/// </summary>
|
|
private PrintDeliveryNoteDto CreatePolishSingleLabelDto(QcQualityStatisticsFirst first, int polishTotal)
|
|
{
|
|
return new PrintDeliveryNoteDto
|
|
{
|
|
Path = "D:\\RIZO\\label\\抛光送货单.btw",
|
|
SiteNo = "1站点",
|
|
Name = "包装抛光送货单标签打印",
|
|
PartNumber = first.FinishedPartNumber,
|
|
Description = first.ProductDescription,
|
|
Color = first.Color,
|
|
Specification = "",
|
|
WorkOrder = first.WorkorderId,
|
|
PackageCode = first.WorkorderId,
|
|
Team = first.Team,
|
|
Sort = 1,
|
|
ProductionTime = first.WorkorderId,
|
|
BatchCode = first.WorkorderId,
|
|
PackageNum = polishTotal,
|
|
LabelCode = $"Type=DeNoPG^ItemNumber={first.FinishedPartNumber}^Order={first.WorkorderId}^Qty={polishTotal}",
|
|
LabelType = 1,
|
|
CreatedTime = DateTime.Now.ToString()
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建打磨品标签DTO
|
|
/// </summary>
|
|
private PrintDeliveryNoteDto CreatePolishingLabelDto(QcQualityStatisticsFirst first, int polishingTotal)
|
|
{
|
|
return new PrintDeliveryNoteDto
|
|
{
|
|
Path = "D:\\RIZO\\label\\打磨送货单.btw",
|
|
SiteNo = "1站点",
|
|
Name = "包装打磨送货单标签打印",
|
|
PartNumber = first.FinishedPartNumber,
|
|
Description = first.ProductDescription,
|
|
Color = first.Color,
|
|
Specification = "",
|
|
WorkOrder = first.WorkorderId,
|
|
PackageCode = first.WorkorderId,
|
|
Team = first.Team,
|
|
Sort = 1,
|
|
ProductionTime = first.WorkorderId,
|
|
BatchCode = first.WorkorderId,
|
|
PackageNum = polishingTotal,
|
|
LabelCode = $"Type=DeNoDM^ItemNumber={first.FinishedPartNumber}^Order={first.WorkorderId}^Qty={polishingTotal}",
|
|
LabelType = 1,
|
|
CreatedTime = DateTime.Now.ToString()
|
|
};
|
|
}
|
|
}
|
|
}
|