111 lines
4.1 KiB
C#
111 lines
4.1 KiB
C#
|
|
using System;
|
||
|
|
using SqlSugar;
|
||
|
|
using Infrastructure.Attribute;
|
||
|
|
using Infrastructure.Extensions;
|
||
|
|
using ZR.Model;
|
||
|
|
using ZR.Model.Dto;
|
||
|
|
using ZR.Model.Business;
|
||
|
|
using ZR.Repository;
|
||
|
|
using ZR.Service.Business.IBusinessService;
|
||
|
|
using System.Linq;
|
||
|
|
using Aliyun.OSS;
|
||
|
|
using System.Text.RegularExpressions;
|
||
|
|
|
||
|
|
namespace ZR.Service.Business
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 质量GP12工单业务模块Service业务层处理
|
||
|
|
/// </summary>
|
||
|
|
[AppService(ServiceType = typeof(IQcGp12Service), ServiceLifetime = LifeTime.Transient)]
|
||
|
|
public class QcGp12Service : BaseService<QcGp12ServiceWorkorder>, IQcGp12Service
|
||
|
|
{
|
||
|
|
public QcGp12LabelAnalysisDto AnalyzeLabelToDto(string label, int type)
|
||
|
|
{
|
||
|
|
QcGp12LabelAnalysisDto labelAnalysisDto = new();
|
||
|
|
labelAnalysisDto.IsOk = true;
|
||
|
|
labelAnalysisDto.Msg = "解析成功!";
|
||
|
|
// 零件号抓取
|
||
|
|
var predicate = Expressionable.Create<QcGp12BaseLabelAnalysis>()
|
||
|
|
.And(it => it.Code == "PartNumber")
|
||
|
|
.And(it => it.Status == "1");
|
||
|
|
List<QcGp12BaseLabelAnalysis> analysisList = Context.Queryable<QcGp12BaseLabelAnalysis>()
|
||
|
|
.Where(predicate.ToExpression())
|
||
|
|
.ToList();
|
||
|
|
foreach (QcGp12BaseLabelAnalysis analysis in analysisList)
|
||
|
|
{
|
||
|
|
if(string.IsNullOrEmpty(analysis.Expression))
|
||
|
|
{
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
// 零件号正则表达式
|
||
|
|
Regex pattern = new Regex(@analysis.Expression);
|
||
|
|
Match match = pattern.Match(label);
|
||
|
|
if (match.Success && match.Groups.Count > 1)
|
||
|
|
{
|
||
|
|
labelAnalysisDto.Partnumber = match.Groups[1].Value;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (string.IsNullOrEmpty(labelAnalysisDto.Partnumber))
|
||
|
|
{
|
||
|
|
labelAnalysisDto.IsOk = false;
|
||
|
|
labelAnalysisDto.Msg = "零件号标签解析异常!";
|
||
|
|
}
|
||
|
|
return labelAnalysisDto;
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<QcGp12AlterationDefectDto> GetDefectInitOptions()
|
||
|
|
{
|
||
|
|
List<QcGp12AlterationDefectDto> defectList = new();
|
||
|
|
var predicate = Expressionable.Create<QcGp12BaseDefect>()
|
||
|
|
.And(it => it.Status == "1");
|
||
|
|
List<string> groupList = Context.Queryable<QcGp12BaseDefect>()
|
||
|
|
.Where(predicate.ToExpression())
|
||
|
|
.GroupBy(it=>it.Group)
|
||
|
|
.Select(it => it.Group)
|
||
|
|
.ToList();
|
||
|
|
foreach (string group in groupList)
|
||
|
|
{
|
||
|
|
QcGp12AlterationDefectDto defectDto = new();
|
||
|
|
defectDto.GroupName = group;
|
||
|
|
List<QcGp12ChildrenDefectDto> children = Context.Queryable<QcGp12BaseDefect>()
|
||
|
|
.Where(it=>it.Group == group)
|
||
|
|
.Where(predicate.ToExpression())
|
||
|
|
.Select(it=> new QcGp12ChildrenDefectDto
|
||
|
|
{
|
||
|
|
Name = it.Name,
|
||
|
|
Code = it.Code,
|
||
|
|
Type = it.Type
|
||
|
|
})
|
||
|
|
.ToList();
|
||
|
|
defectDto.Children = children;
|
||
|
|
defectList.Add(defectDto);
|
||
|
|
}
|
||
|
|
return defectList;
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<QcGp12BaseGroupDto> GetGroupOptions()
|
||
|
|
{
|
||
|
|
var predicate = Expressionable.Create<QcGp12BaseGroup>()
|
||
|
|
.And(it=>it.Status == "1");
|
||
|
|
|
||
|
|
var response = Context.Queryable<QcGp12BaseGroup>()
|
||
|
|
.Where(predicate.ToExpression())
|
||
|
|
.Select(it=> new QcGp12BaseGroupDto())
|
||
|
|
.ToList();
|
||
|
|
return response;
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<QcGp12BaseSiteDto> GetStieOptions()
|
||
|
|
{
|
||
|
|
var predicate = Expressionable.Create<QcGp12BaseSite>()
|
||
|
|
.And(it => it.Status == "1");
|
||
|
|
|
||
|
|
var response = Context.Queryable<QcGp12BaseSite>()
|
||
|
|
.Where(predicate.ToExpression())
|
||
|
|
.Select(it => new QcGp12BaseSiteDto())
|
||
|
|
.ToList();
|
||
|
|
return response;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|