😎新增获取记录ID、通过id和对象id获取物料编码、获取行号、生成guid、对比物料版本方法
This commit is contained in:
parent
1f2458c0ea
commit
525f78bfbf
@ -8,8 +8,10 @@ using Admin.NET.Core;
|
|||||||
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
|
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
|
||||||
using Furion.DependencyInjection;
|
using Furion.DependencyInjection;
|
||||||
using Furion.DynamicApiController;
|
using Furion.DynamicApiController;
|
||||||
|
using Microsoft.AspNetCore.Server.IISIntegration;
|
||||||
using NewLife;
|
using NewLife;
|
||||||
using RazorEngine;
|
using RazorEngine;
|
||||||
|
using RazorEngine.Compilation.ImpromptuInterface;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -30,6 +32,7 @@ public class DataValidationService : IDynamicApiController, ITransient
|
|||||||
public SqlSugarRepository<Obj122> _obj122Rep;
|
public SqlSugarRepository<Obj122> _obj122Rep;
|
||||||
public SqlSugarRepository<Obj137> _obj137Rep;
|
public SqlSugarRepository<Obj137> _obj137Rep;
|
||||||
public SqlSugarRepository<ObjectTypeCheckList> _objectTypeCheckListRep;
|
public SqlSugarRepository<ObjectTypeCheckList> _objectTypeCheckListRep;
|
||||||
|
public SqlSugarRepository<ConfigurationData> _configurationDataRep;
|
||||||
public DataValidationService(
|
public DataValidationService(
|
||||||
SqlSugarRepository<Obj110> obj110Rep,
|
SqlSugarRepository<Obj110> obj110Rep,
|
||||||
SqlSugarRepository<Obj109> obj109Rep,
|
SqlSugarRepository<Obj109> obj109Rep,
|
||||||
@ -37,7 +40,9 @@ public class DataValidationService : IDynamicApiController, ITransient
|
|||||||
SqlSugarRepository<Obj133> obj133Rep,
|
SqlSugarRepository<Obj133> obj133Rep,
|
||||||
SqlSugarRepository<Obj122> obj122Rep,
|
SqlSugarRepository<Obj122> obj122Rep,
|
||||||
SqlSugarRepository<Obj137> obj137Rep,
|
SqlSugarRepository<Obj137> obj137Rep,
|
||||||
SqlSugarRepository<ObjectTypeCheckList> objectTypeCheckList
|
SqlSugarRepository<ObjectTypeCheckList> objectTypeCheckList,
|
||||||
|
SqlSugarRepository<ConfigurationData> configurationDataRep
|
||||||
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_obj110Rep = obj110Rep;
|
_obj110Rep = obj110Rep;
|
||||||
@ -47,6 +52,7 @@ public class DataValidationService : IDynamicApiController, ITransient
|
|||||||
_obj122Rep = obj122Rep;
|
_obj122Rep = obj122Rep;
|
||||||
_obj137Rep = obj137Rep;
|
_obj137Rep = obj137Rep;
|
||||||
_objectTypeCheckListRep = objectTypeCheckList;
|
_objectTypeCheckListRep = objectTypeCheckList;
|
||||||
|
_configurationDataRep = configurationDataRep;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证物料是否存在
|
/// 验证物料是否存在
|
||||||
@ -179,4 +185,120 @@ public class DataValidationService : IDynamicApiController, ITransient
|
|||||||
}
|
}
|
||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取记录ID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="objId">对象id</param>
|
||||||
|
/// <param name="recordGuid">物料guid</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<long> GetRecordId(long objId, string recordGuid)
|
||||||
|
{
|
||||||
|
long idRecord = 0;
|
||||||
|
if (objId == 137)
|
||||||
|
{
|
||||||
|
var data = await _obj137Rep.AsQueryable().Where(x => x.RecordGuid == recordGuid && x.deleted == false).OrderByDescending(x => x.VersionIndex).FirstAsync();
|
||||||
|
idRecord = data.idRecord;
|
||||||
|
}
|
||||||
|
if (objId == 112)
|
||||||
|
{
|
||||||
|
var data = await _obj112Rep.AsQueryable().Where(x => x.RecordGuid == recordGuid && x.deleted == false).OrderByDescending(x => x.VersionIndex).FirstAsync();
|
||||||
|
idRecord = data.idRecord;
|
||||||
|
}
|
||||||
|
return idRecord;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过id和对象id获取物料编码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="objId">对象id</param>
|
||||||
|
/// <param name="id">物料guid</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<string> GetCoding(long objId, long id)
|
||||||
|
{
|
||||||
|
string coding = "编码不存在";
|
||||||
|
if (objId == 137)
|
||||||
|
{
|
||||||
|
var data = await _obj137Rep.AsQueryable().Where(x => x.idRecord == id).FirstAsync();
|
||||||
|
coding = data._System_objNBS;
|
||||||
|
}
|
||||||
|
if (objId == 112)
|
||||||
|
{
|
||||||
|
var data = await _obj112Rep.AsQueryable().Where(x => x.idRecord == id).FirstAsync();
|
||||||
|
coding = data._System_objNBS;
|
||||||
|
}
|
||||||
|
return coding;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取行号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="objId">对象id</param>
|
||||||
|
/// <param name="recordGuid">guid</param>
|
||||||
|
/// <param name="versionIndex">版本</param>
|
||||||
|
/// <param name="configId">配置id</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<int> GetLineNumber(long objId, string recordGuid, int versionIndex, int configId)
|
||||||
|
{
|
||||||
|
int lineNumber = 0;
|
||||||
|
|
||||||
|
if (objId==118)
|
||||||
|
{
|
||||||
|
lineNumber = await _configurationDataRep.AsQueryable().Where(x => x.ParentGuid == recordGuid && x.isDeleted == false && x.ParentVersion == versionIndex && x.ConfigId == configId && x.isSuppressed == false && x.inContext == false).CountAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
return lineNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成guid
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<string> GetGuid()
|
||||||
|
{
|
||||||
|
await Task.Delay(0);
|
||||||
|
// 生成一个新的Guid实例
|
||||||
|
Guid guid = Guid.NewGuid();
|
||||||
|
|
||||||
|
// 将Guid转换为字符串形式
|
||||||
|
string uuidString = guid.ToString();
|
||||||
|
|
||||||
|
return uuidString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 对比物料版本
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="objId"></param>
|
||||||
|
/// <param name="recordGuid"></param>
|
||||||
|
/// <param name="newVersion"></param>
|
||||||
|
/// <param name="olderVersion"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<string> ComparativeVersion(long objId, string recordGuid, int newVersion, int olderVersion)
|
||||||
|
{
|
||||||
|
string contrastResult ="";
|
||||||
|
|
||||||
|
if (objId == 137)
|
||||||
|
{
|
||||||
|
var contrastNewData = await _obj137Rep.AsQueryable().Where(x => x.RecordGuid == recordGuid && x.deleted == false && x.VersionIndex == newVersion).FirstAsync();
|
||||||
|
var contrastOlderData = await _obj137Rep.AsQueryable().Where(x => x.RecordGuid == recordGuid && x.deleted == false && x.VersionIndex == olderVersion).FirstAsync();
|
||||||
|
if (contrastNewData.revision == contrastOlderData.revision)
|
||||||
|
{
|
||||||
|
contrastResult = "是";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (objId == 112)
|
||||||
|
{
|
||||||
|
var contrastNewData = await _obj112Rep.AsQueryable().Where(x => x.RecordGuid == recordGuid && x.deleted == false && x.VersionIndex == newVersion).FirstAsync();
|
||||||
|
var contrastOlderData = await _obj112Rep.AsQueryable().Where(x => x.RecordGuid == recordGuid && x.deleted == false && x.VersionIndex == olderVersion).FirstAsync();
|
||||||
|
if (contrastNewData.revision == contrastOlderData.revision)
|
||||||
|
{
|
||||||
|
contrastResult = "是";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return contrastResult;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user