add - 添加接口,物料同步准备测试

dep_wangsr
SoulStar 2 weeks ago
parent f7a39845b1
commit ce44035e7f

@ -390,12 +390,24 @@
投料仓服务
</summary>
</member>
<member name="M:Admin.Core.Api.Controllers.Business.WarehouseController.#ctor(Admin.Core.IService.IHw_WarehouseServices,Admin.Core.IService.ISys.ISysUserService)">
<member name="F:Admin.Core.Api.Controllers.Business.WarehouseController._hw_BarrelService">
<summary>
料筒服务类
</summary>
</member>
<member name="F:Admin.Core.Api.Controllers.Business.WarehouseController._lr_weighService">
<summary>
称重服务类
</summary>
</member>
<member name="M:Admin.Core.Api.Controllers.Business.WarehouseController.#ctor(Admin.Core.IService.IHw_WarehouseServices,Admin.Core.IService.ISys.ISysUserService,Admin.Core.IService.IService_New.IHw_BarrelServices,Admin.Core.IService.ILR_weighServices)">
<summary>
构造方法
</summary>
<param name="hw_WarehouseServices"></param>
<param name="sysUserService"></param>
<param name="hwBarrelService"></param>
<param name="lrweighService"></param>
</member>
<member name="M:Admin.Core.Api.Controllers.Business.WarehouseController.GetByBarrelInfo(System.String,System.String,System.String)">
<summary>
@ -442,6 +454,13 @@
</summary>
<returns></returns>
</member>
<member name="M:Admin.Core.Api.Controllers.Business.WarehouseController.GetWeightInfoByBarrelID(System.String)">
<summary>
根据罐号查询称量列表
</summary>
<param name="barrelID"></param>
<returns></returns>
</member>
<member name="T:Admin.Core.Api.SeedController">
<summary>
Controller代码生成
@ -1718,6 +1737,66 @@
DeleteSubscriptionFiles
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomData.pageCount">
<summary>
总页数
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomData.pageIndex">
<summary>
页码
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomData.recordList">
<summary>
数据对象
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomData.recordCount">
<summary>
总记录数
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomData.pageSize">
<summary>
每页记录数
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomData.endPageIndex">
<summary>
尾页编号
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomData.beginPageIndex">
<summary>
起始页编号
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomRecordListItem.id">
<summary>
物料id
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomRecordListItem.name">
<summary>
物料名称
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomRecordListItem.status">
<summary>
物料状态0禁用 1启用
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomRecordListItem.code">
<summary>
物料编号
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.BomRecordListItem.createTime">
<summary>
物料创建时间
</summary>
</member>
<member name="P:Admin.Core.Api.PLTBusiness.Entity.MaterialData.pageCount">
<summary>
总页数
@ -1803,12 +1882,25 @@
Token失效时间
</summary>
</member>
<member name="M:Admin.Core.Api.PLTBusiness.HttpService.ExecuteAsync(System.Threading.CancellationToken)">
<summary>
循环执行的服务
</summary>
<param name="stoppingToken"></param>
<returns></returns>
</member>
<member name="M:Admin.Core.Api.PLTBusiness.HttpService.GetMaterialDataPageList">
<summary>
分页拉取所有Mes物料信息
</summary>
<returns></returns>
</member>
<member name="M:Admin.Core.Api.PLTBusiness.HttpService.GetRecipeDataPageList">
<summary>
分页拉取所有MesBom配方信息
</summary>
<returns></returns>
</member>
<member name="M:Admin.Core.Api.PLTBusiness.HttpService.GetToken">
<summary>
获取Token
@ -1848,6 +1940,13 @@
<param name="url"></param>
<returns></returns>
</member>
<member name="M:Admin.Core.Api.PLTBusiness.XlBusiness.InsertNewMaterialData(System.Collections.Generic.List{Admin.Core.Api.PLTBusiness.Entity.MaterialRecordListItem})">
<summary>
向物料数据库中动态同步mes数据没有就插入不同就修改
</summary>
<param name="list"></param>
<returns></returns>
</member>
<member name="T:Admin.Core.Api.Program">
<summary>
Program

@ -253,14 +253,17 @@ namespace Admin.Core.Api
var result = await _xl_materialService.xlInsertMaterial(Guid.NewGuid().ToString("N"), materialCode, materialName, isEnable, createDateTime);
if (result)
{
return Success(result);
return Success(result, "成功");
}
else
{
return Failed<bool>("执行失败!");
}
}
catch (Exception ex)
{
return Failed<bool>("执行失败!");
}
return Failed<bool>("执行失败!");
}
}
}

@ -15,6 +15,8 @@ using Admin.Core.Model.ViewModels;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using System.Collections;
using NPOI.SS.Formula.Functions;
using System.Numerics;
using Admin.Core.IService.IService_New;
namespace Admin.Core.Api.Controllers.Business
{
@ -38,16 +40,30 @@ namespace Admin.Core.Api.Controllers.Business
/// </summary>
private readonly IHw_WarehouseServices _hw_WarehouseService;
/// <summary>
/// 料筒服务类
/// </summary>
private readonly IHw_BarrelServices _hw_BarrelService;
/// <summary>
/// 称重服务类
/// </summary>
private readonly ILR_weighServices _lr_weighService;
#region 构造方法
/// <summary>
/// 构造方法
/// </summary>
/// <param name="hw_WarehouseServices"></param>
/// <param name="sysUserService"></param>
public WarehouseController(IHw_WarehouseServices hw_WarehouseServices, ISysUserService sysUserService) : base(sysUserService)
/// <param name="hwBarrelService"></param>
/// <param name="lrweighService"></param>
public WarehouseController(IHw_WarehouseServices hw_WarehouseServices, ISysUserService sysUserService, IHw_BarrelServices hwBarrelService, ILR_weighServices lrweighService) : base(sysUserService)
{
_sysUserService = sysUserService;
_hw_WarehouseService = hw_WarehouseServices;
_hw_BarrelService = hwBarrelService;
_lr_weighService = lrweighService;
}
#endregion
@ -61,13 +77,13 @@ namespace Admin.Core.Api.Controllers.Business
/// <param name="code">料桶Id</param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<BarrelView>> GetByBarrelInfo(string kettleBarCode, string planId,string code)
public async Task<MessageModel<BarrelView>> GetByBarrelInfo(string kettleBarCode, string planId, string code)
{
if (!code.IsNotEmptyOrNull())
{
return Failed<BarrelView>("传入参数为空!");
}
var query = await _hw_WarehouseService.GetXlInfo(kettleBarCode.Trim(),planId.Trim(),code.Trim());
var query = await _hw_WarehouseService.GetXlInfo(kettleBarCode.Trim(), planId.Trim(), code.Trim());
if (query == null)
{
return Failed<BarrelView>("查询失败!");
@ -84,7 +100,7 @@ namespace Admin.Core.Api.Controllers.Business
/// <param name="planId">计划Id</param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<WarehouseView>> GetByCode(string code,string planId)
public async Task<MessageModel<WarehouseView>> GetByCode(string code, string planId)
{
if (!code.IsNotEmptyOrNull())
@ -96,11 +112,11 @@ namespace Admin.Core.Api.Controllers.Business
return Failed<WarehouseView>("传入计划ID参数为空");
}
var query = await _hw_WarehouseService.QueryByCode(code.Trim(), planId);
if (query==null)
if (query == null)
{
return Failed<WarehouseView>("查询失败!");
}
}
return Success(query);
}
#endregion
@ -121,7 +137,7 @@ namespace Admin.Core.Api.Controllers.Business
var result = await _hw_WarehouseService.UpdatePlcState(view);
if (result)
{
return Success(result);
return Success(result);
}
return Failed<bool>("执行失败!");
}
@ -162,7 +178,7 @@ namespace Admin.Core.Api.Controllers.Business
////产品名称
//var ss3 = "D1-813";
}
catch (Exception ex)
{
@ -179,13 +195,13 @@ namespace Admin.Core.Api.Controllers.Business
/// <param name="state"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<bool>> ExecPlcState(string code,int state)
public async Task<MessageModel<bool>> ExecPlcState(string code, int state)
{
if (!code.IsNotEmptyOrNull() || !state.IsNotEmptyOrNull())
{
return Failed<bool>("传入参数为空!");
}
var result = await _hw_WarehouseService.UpdatePlcState(code,state);
var result = await _hw_WarehouseService.UpdatePlcState(code, state);
if (result)
{
return Success(result);
@ -208,7 +224,7 @@ namespace Admin.Core.Api.Controllers.Business
var result = await _hw_WarehouseService.GetPlanWeightInfo();
if (result != null)
{
return Success(result,"成功");
return Success(result, "成功");
}
return Failed<List<XLPlanWeightView>>("执行失败!");
}
@ -234,7 +250,34 @@ namespace Admin.Core.Api.Controllers.Business
messageModel.success = true;
messageModel.data = list;
return Success(list);
}
}
#endregion
/// <summary>
/// 根据罐号查询称量列表
/// </summary>
/// <param name="barrelID"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<LR_weigh>>> GetWeightInfoByBarrelID(string barrelBarcode)
{
if (!barrelBarcode.IsNotEmptyOrNull())
{
return Failed<List<LR_weigh>>("传入参数为空!");
}
MessageModel<List<LR_weigh>> messageModel = new MessageModel<List<LR_weigh>>();
string planID = _hw_BarrelService.GetPlanIdByBarrelID(barrelBarcode.Trim());
if (string.IsNullOrEmpty(planID))
{
return Failed<List<LR_weigh>>("查询不到罐号对应的计划ID!");
}
List<LR_weigh> list = _lr_weighService.GetRecentWeightList(planID);
if (list != null)
{
return Success(list);
}
return Failed<List<LR_weigh>>("执行失败!");
}
}
}

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SqlSugar;
namespace Admin.Core.Api.PLTBusiness.Entity
{
public class BomData
{
/// <summary>
/// 总页数
/// </summary>
public int pageCount { get; set; }
/// <summary>
/// 页码
/// </summary>
public int pageIndex { get; set; }
/// <summary>
/// 数据对象
/// </summary>
public List<BomRecordListItem> recordList { get; set; }
/// <summary>
/// 总记录数
/// </summary>
public int recordCount { get; set; }
/// <summary>
/// 每页记录数
/// </summary>
public int pageSize { get; set; }
/// <summary>
/// 尾页编号
/// </summary>
public int endPageIndex { get; set; }
/// <summary>
/// 起始页编号
/// </summary>
public int beginPageIndex { get; set; }
}
public class BomRecordListItem
{
/// <summary>
/// 物料id
/// </summary>
public int id { get; set; }
/// <summary>
/// 物料名称
/// </summary>
public string name { get; set; }
/// <summary>
/// 物料状态0禁用 1启用
/// </summary>
public int status { get; set; }
/// <summary>
/// 物料编号
/// </summary>
public string code { get; set; }
/// <summary>
/// 物料创建时间
/// </summary>
public string createTime { get; set; }
}
}

@ -0,0 +1,24 @@
using System;
namespace Admin.Core.Api.PLTBusiness.Entity
{
public class LRWeighData
{
public string BinSerial { get; set; }
public string SetWeight { get; set; }
public string RealWeight { get; set; }
public string MainID { get; set; }
public DateTime EndTime { get; set; }
}
}

@ -29,18 +29,26 @@ namespace Admin.Core.Api.PLTBusiness
private readonly IHttpClientFactory _httpClientFactory;
private readonly string _host;
private readonly Ixl_recipeServices _xlrecipeServices;
private readonly string _host = "http://192.168.111.141:8090";
private string _token;
private int _tokenExpirationTime = 0;
public HttpService(IHttpClientFactory httpClientFactory, IServiceScopeFactory scopeFactory)
public HttpService(IHttpClientFactory httpClientFactory, IServiceScopeFactory scopeFactory, Ixl_recipeServices xlrecipeServices)
{
_httpClientFactory = httpClientFactory;
_scopeFactory = scopeFactory;
_xlrecipeServices = xlrecipeServices;
}
/// <summary>
/// 循环执行的服务
/// </summary>
/// <param name="stoppingToken"></param>
/// <returns></returns>
protected async override Task ExecuteAsync(CancellationToken stoppingToken)
{
int second = 1000 * 10;
@ -76,9 +84,11 @@ namespace Admin.Core.Api.PLTBusiness
try
{
//物料信息同步
if (_token.IsNotEmptyOrNull())
{
await xlBusiness.InsertNewMaterialData(await GetMaterialDataPageList());
//await _xlrecipeServices.xlUpdateOrAdd();
}
else
{
@ -149,6 +159,58 @@ namespace Admin.Core.Api.PLTBusiness
return allMaterials;
}
/// <summary>
/// 分页拉取所有MesBom配方信息
/// </summary>
/// <returns></returns>
private async Task<List<BomRecordListItem>> GetRecipeDataPageList()
{
int pageSize = 200;
int pageIndex = 0;
int pageCount = 1;
string orgCode = "Mesnac";
List<BomRecordListItem> allBoms = new List<BomRecordListItem>();
Dictionary<string, object> _pageInfo = new Dictionary<string, object>()
{
{"pageIndex", 200},
{"pageSize", 0},
{"orgCode", "Mesnac"},
};
try
{
do
{
string body = JsonSerializer.Serialize(_pageInfo);
string bomJson = await PostAsync(_host + "/qtn/api/q7/com/bom/page",
body, "application/json", "application/json",
new Dictionary<string, string> { { "token", _token } }, 10);
ResponseRoot<BomData> responseRoot = JsonSerializer.Deserialize<ResponseRoot<BomData>>(bomJson);
if (responseRoot == null)
{
log.Error("Bom信息拉取失败");
return null;
}
if (responseRoot.code != 200)
{
log.Error("ERROR 状态码:" + responseRoot.code);
return null;
}
pageCount = responseRoot.Data.pageCount;
pageIndex = responseRoot.Data.pageIndex;
allBoms.AddRange(responseRoot.Data.recordList);
pageIndex = pageIndex + 1;
}
while (pageIndex < pageSize);
}
catch (Exception ex)
{
log.Error("MesBom信息拉取失败 Error: " + ex);
return null;
}
return allBoms;
}
#endregion
#region Token获取

@ -42,7 +42,7 @@ namespace Admin.Core.Api
{
Configuration = configuration;
Env = env;
}
/// <summary>
@ -112,8 +112,8 @@ namespace Admin.Core.Api
//Ìí¼ÓPLC
services.AddPlcSetup();
//Ìí¼Ó·þÎñ
services.AddHostedService<PLTBusiness.HttpService>();
services.AddScoped<PLTBusiness.XlBusiness>();
//services.AddHostedService<PLTBusiness.HttpService>();
//services.AddScoped<PLTBusiness.XlBusiness>();
//Redis»º´æ
//services.AddRedisCacheSetup();

@ -0,0 +1,22 @@
using Admin.Core.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.IService.IService_New
{
/// <summary>
/// 料筒服务类
/// </summary>
public interface IHw_BarrelServices : IBaseServices<Hw_Barrel>
{
/// <summary>
/// 根据罐号获取料罐ID
/// </summary>
/// <param name="barrelID"></param>
/// <returns></returns>
string GetPlanIdByBarrelID(string barrelBarcode);
}
}

@ -1,5 +1,6 @@
using Admin.Core.IService;
using Admin.Core.Model;
using System.Collections.Generic;
namespace Admin.Core.IService
{
@ -8,5 +9,10 @@ namespace Admin.Core.IService
/// </summary>
public interface ILR_weighServices :IBaseServices<LR_weigh>
{
}
/// <summary>
/// 通过计划号获取最近一次的称量列表
/// </summary>
/// <returns></returns>
List<LR_weigh> GetRecentWeightList(string planCode);
}
}

@ -1,5 +1,7 @@
using Admin.Core.IService;
using Admin.Core.Model;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Admin.Core.IService
{
@ -8,5 +10,31 @@ namespace Admin.Core.IService
/// </summary>
public interface Ixl_recipeServices :IBaseServices<xl_recipe>
{
/// <summary>
/// 新增配方信息
/// </summary>
/// <param name="recipe"></param>
/// <returns></returns>
Task<bool> xlInsertRecipe(xl_recipe recipe);
/// <summary>
/// 更新配方信息
/// </summary>
/// <param name="recipe"></param>
/// <returns></returns>
Task<bool> xlUpdateRecipe(xl_recipe recipe);
/// <summary>
/// 获取配方列表
/// </summary>
/// <returns></returns>
Task<List<xl_recipe>> xlGetAllRecipes();
/// <summary>
/// 如果有记录就更新,没有记录就新增
/// </summary>
/// <param name="recipe"></param>
/// <returns></returns>
Task<bool> xlUpdateOrAdd(xl_recipe recipe);
}
}

@ -9,149 +9,149 @@ namespace Admin.Core.Model
///<summary>
///配方信息
///</summary>
[SugarTable( "xl_recipe", "cwss_xl")]
[SugarTable("xl_recipe", "cwss_xl")]
public class xl_recipe
{
public xl_recipe()
{
}
/// <summary>
/// Desc:
/// Default:
/// Nullable:False
/// </summary>
public string ID { get; set; }
/// <summary>
/// Desc:机台号
/// Default:
/// Nullable:True
/// </summary>
public string Equip_Code { get; set; }
/// <summary>
/// Desc:配方编码
/// Default:
/// Nullable:True
/// </summary>
public string Recipe_Code { get; set; }
/// <summary>
/// Desc:配方版本号
/// Default:
/// Nullable:True
/// </summary>
public string Version { get; set; }
/// <summary>
/// Desc:配方别名
/// Default:
/// Nullable:True
/// </summary>
public string Recipe_Name { get; set; }
/// <summary>
/// Desc:配方版本号
/// Default:
/// Nullable:True
/// </summary>
public string Mixer_line { get; set; }
/// <summary>
/// Desc:配方类型
/// Default:
/// Nullable:True
/// </summary>
public int? Recipe_type { get; set; }
/// <summary>
/// Desc:配方习惯
/// Default:
/// Nullable:True
/// </summary>
public int? Recipe_Used { get; set; }
/// <summary>
/// Desc:配方验证
/// Default:0
/// Nullable:True
/// </summary>
public int? Recipe_Verify { get; set; }
/// <summary>
/// Desc:总计重量
/// Default:
/// Nullable:True
/// </summary>
public decimal? Total_Weight { get; set; }
/// <summary>
/// Desc:总计误差
/// Default:
/// Nullable:True
/// </summary>
public decimal? Total_Error { get; set; }
/// <summary>
/// Desc:结束时间
/// Default:
/// Nullable:True
/// </summary>
public string End_datetime { get; set; }
/// <summary>
/// Desc:备注
/// Default:
/// Nullable:True
/// </summary>
public string Remark { get; set; }
/// <summary>
/// Desc:附件用户
/// Default:
/// Nullable:True
/// </summary>
public int? Attach_User { get; set; }
/// <summary>
/// Desc:分组袋
/// Default:
/// Nullable:True
/// </summary>
public int? GroupBags { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public int? IF_FLAG { get; set; }
/// <summary>
/// Desc:有效性
/// Default:
/// Nullable:True
/// </summary>
public int? Validity { get; set; }
/// <summary>
/// Desc:有效天数
/// Default:
/// Nullable:True
/// </summary>
public int? ValidDays { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public string UpdateByID { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public string UpdateBy { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public string CreatorID { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public string Creator { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public DateTime? CreateDateTime { get; set; }
public xl_recipe()
{
}
/// <summary>
/// Desc:
/// Default:
/// Nullable:False
/// </summary>
public string ID { get; set; }
/// <summary>
/// Desc:机台号
/// Default:
/// Nullable:True
/// </summary>
public string Equip_Code { get; set; }
/// <summary>
/// Desc:配方编码
/// Default:
/// Nullable:True
/// </summary>
public string Recipe_Code { get; set; }
/// <summary>
/// Desc:配方版本号
/// Default:
/// Nullable:True
/// </summary>
public string Version { get; set; }
/// <summary>
/// Desc:配方别名
/// Default:
/// Nullable:True
/// </summary>
public string Recipe_Name { get; set; }
/// <summary>
/// Desc:配方版本号
/// Default:
/// Nullable:True
/// </summary>
public string Mixer_line { get; set; }
/// <summary>
/// Desc:配方类型
/// Default:
/// Nullable:True
/// </summary>
public int? Recipe_type { get; set; }
/// <summary>
/// Desc:配方习惯
/// Default:
/// Nullable:True
/// </summary>
public int? Recipe_Used { get; set; }
/// <summary>
/// Desc:配方验证
/// Default:0
/// Nullable:True
/// </summary>
public int? Recipe_Verify { get; set; }
/// <summary>
/// Desc:总计重量
/// Default:
/// Nullable:True
/// </summary>
public decimal? Total_Weight { get; set; }
/// <summary>
/// Desc:总计误差
/// Default:
/// Nullable:True
/// </summary>
public decimal? Total_Error { get; set; }
/// <summary>
/// Desc:结束时间
/// Default:
/// Nullable:True
/// </summary>
public string End_datetime { get; set; }
/// <summary>
/// Desc:备注
/// Default:
/// Nullable:True
/// </summary>
public string Remark { get; set; }
/// <summary>
/// Desc:附件用户
/// Default:
/// Nullable:True
/// </summary>
public int? Attach_User { get; set; }
/// <summary>
/// Desc:分组袋
/// Default:
/// Nullable:True
/// </summary>
public int? GroupBags { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public int? IF_FLAG { get; set; }
/// <summary>
/// Desc:有效性
/// Default:
/// Nullable:True
/// </summary>
public int? Validity { get; set; }
/// <summary>
/// Desc:有效天数
/// Default:
/// Nullable:True
/// </summary>
public int? ValidDays { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public string UpdateByID { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public string UpdateBy { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public string CreatorID { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public string Creator { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public DateTime? CreateDateTime { get; set; }
}
}

@ -0,0 +1,36 @@
using Admin.Core.IRepository;
using Admin.Core.IService;
using Admin.Core.IService.IService_New;
using Admin.Core.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Service.Service_New
{
public class Hw_BarrelServices : BaseServices<Hw_Barrel>, IHw_BarrelServices
{
private readonly IBaseRepository<Hw_Barrel> _dal;
public Hw_BarrelServices(IBaseRepository<Hw_Barrel> dal)
{
this._dal = dal;
base.BaseDal = dal;
}
public string GetPlanIdByBarrelID(string barrelBarcode)
{
try
{
string planId = _dal.Query(x => x.BarCode == barrelBarcode).FirstOrDefault().PlanId.ToString();
return planId;
}
catch
{
throw;
}
}
}
}

@ -36,7 +36,9 @@ namespace Admin.Core.Service
public Hw_WarehouseServices(IBaseRepository<Hw_Warehouse> dal, IHw_WarehouseRepository wareHouse,
IHw_WareHouse_SubRepository wareHouse_Sub, IHw_FeedReportRepository feed,
IHw_BarrelRepository barrel, Ixl_materialRepository materialRepository,
Ixl_recipeRepository recipeRepository, ILR_weighRepository lrWeighRepository, Ixl_planRepository planRepository, IXLPlan_weightRepository IXLPlan_weightRepository, IXLPlan_weightRepository xLPlan_weightRepository)
Ixl_recipeRepository recipeRepository, ILR_weighRepository lrWeighRepository,
Ixl_planRepository planRepository, IXLPlan_weightRepository IXLPlan_weightRepository,
IXLPlan_weightRepository xLPlan_weightRepository)
{
this._dal = dal;
base.BaseDal = dal;

@ -2,6 +2,9 @@
using Admin.Core.Service;
using Admin.Core.IService;
using Admin.Core.Model;
using System.Collections.Generic;
using System.Linq;
using System;
namespace Admin.Core.Service
{
@ -13,5 +16,20 @@ namespace Admin.Core.Service
this._dal = dal;
base.BaseDal = dal;
}
public List<LR_weigh> GetRecentWeightList(string planCode)
{
try
{
List<LR_weigh> list = _dal.Query(x => x.Plan_ID == planCode).ToList();
int maxMainID = list.Max(x => x.MainId);
List<LR_weigh> groupList = list.Where(x => x.MainId == maxMainID).ToList();
return groupList;
}
catch
{
throw;
}
}
}
}

@ -2,6 +2,13 @@
using Admin.Core.Service;
using Admin.Core.IService;
using Admin.Core.Model;
using System.Threading.Tasks;
using System.Collections.Generic;
using System;
using Serilog;
using NPOI.SS.Formula.Functions;
using System.Linq;
using Microsoft.Extensions.Logging;
namespace Admin.Core.Service
{
@ -13,5 +20,69 @@ namespace Admin.Core.Service
this._dal = dal;
base.BaseDal = dal;
}
public async Task<List<xl_recipe>> xlGetAllRecipes()
{
try
{
return await _dal.QueryAsync();
}
catch(Exception ex)
{
throw;
}
}
public async Task<bool> xlInsertRecipe(xl_recipe recipe)
{
try
{
if(await _dal.AddAsync(recipe) == 1)
{
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
throw;
}
}
public async Task<bool> xlUpdateRecipe(xl_recipe recipe)
{
try
{
return await _dal.UpdateAsync(recipe);
}
catch(Exception ex)
{
throw;
}
}
public async Task<bool> xlUpdateOrAdd(xl_recipe recipe)
{
try
{
var record = await _dal.QueryAsync(x => x.Recipe_Code == recipe.Recipe_Code);
if(record == null || record.Count == 0)
{
recipe.ID = record[0].ID;
return await xlUpdateRecipe(recipe);
}
else
{
return await xlInsertRecipe(recipe);
}
}
catch (Exception ex)
{
throw;
}
}
}
}
Loading…
Cancel
Save