From bd28d4f1076181279757eca10e376902b259b011 Mon Sep 17 00:00:00 2001
From: CaesarBao <445720029@qq.com>
Date: Thu, 31 Oct 2024 16:24:46 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9C=80=E6=96=B0=E6=BA=90?=
=?UTF-8?q?=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Admin.Core.Api/Admin.Core.Api.xml | 14 +-
Admin.Core.Api/Admin.Core.Model.xml | 24 +-
.../Business/MaterialController.cs | 18 +
.../Business/WarehouseController.cs | 60 +-
Admin.Core.Api/Program.cs | 3 +-
Admin.Core.Api/Properties/launchSettings.json | 2 +-
Admin.Core.Api/appsettings.Development.json | 4 +-
Admin.Core.Api/appsettings.json | 2 +-
.../IService_New/IHw_WarehouseServices.cs | 4 +-
.../IService_New/Ixl_materialServices.cs | 7 +
Admin.Core.Model/Model_New/Pmt_weigh.cs | 15 +
Admin.Core.Model/Model_New/RT_plan.cs | 4 +-
Admin.Core.Model/Model_New/xl_plan.cs | 2 -
Admin.Core.Model/Model_New/xl_recipe.cs | 4 +
.../ViewModels/MesDownLoadPlanList.cs | 25 +-
.../Repository_New/Pmt_materialRepository.cs | 1 +
Admin.Core.Service/Admin.Core.Service.csproj | 3 +-
.../Service_New/Hw_WarehouseServices.cs | 752 ++++++++++++++++--
.../Service_New/SolventServices.cs | 4 +-
.../Service_New/xl_materialServices.cs | 25 +
20 files changed, 887 insertions(+), 86 deletions(-)
diff --git a/Admin.Core.Api/Admin.Core.Api.xml b/Admin.Core.Api/Admin.Core.Api.xml
index 3ba0122..6c8e5d8 100644
--- a/Admin.Core.Api/Admin.Core.Api.xml
+++ b/Admin.Core.Api/Admin.Core.Api.xml
@@ -300,6 +300,11 @@
+
+
+ 查询料桶重量
+
+
检量称扫码绑定桶(新加)
@@ -421,6 +426,13 @@
json 对象
+
+
+ MES计划下发
+
+
+
+
投料口开/投料口关
@@ -431,7 +443,7 @@
- 查询称量重量
+ 查询称量信息
diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml
index 58d43b3..40d53b3 100644
--- a/Admin.Core.Api/Admin.Core.Model.xml
+++ b/Admin.Core.Api/Admin.Core.Model.xml
@@ -1949,6 +1949,21 @@
Nullable:True
+
+
+ 理论固含
+
+
+
+
+ 是否有固含
+
+
+
+
+ 固含量
+
+
生产计划
@@ -2660,6 +2675,11 @@
Nullable:True
+
+
+ 是否产前验证
+
+
配方信息
@@ -4582,12 +4602,12 @@
投料整包完整信息
-
+
配方编号
-
+
批次号
diff --git a/Admin.Core.Api/Controllers/Business/MaterialController.cs b/Admin.Core.Api/Controllers/Business/MaterialController.cs
index b936c58..b9450f5 100644
--- a/Admin.Core.Api/Controllers/Business/MaterialController.cs
+++ b/Admin.Core.Api/Controllers/Business/MaterialController.cs
@@ -150,6 +150,24 @@ namespace Admin.Core.Api
}
#endregion
+
+ ///
+ /// 查询料桶重量
+ ///
+ [HttpGet]
+ public async Task> GetBindBarrelWeight()
+ {
+ try
+ {
+ decimal result = await _xl_materialService.GetBindBarrelWeight();
+ return Success(result, "成功");
+ }
+ catch (Exception ex)
+ {
+ return Failed("执行失败!");
+ }
+ }
+
#region 检量称扫码绑定桶(新加)
///
/// 检量称扫码绑定桶(新加)
diff --git a/Admin.Core.Api/Controllers/Business/WarehouseController.cs b/Admin.Core.Api/Controllers/Business/WarehouseController.cs
index a7d1dee..81e26d0 100644
--- a/Admin.Core.Api/Controllers/Business/WarehouseController.cs
+++ b/Admin.Core.Api/Controllers/Business/WarehouseController.cs
@@ -15,6 +15,7 @@ using Admin.Core.Model.ViewModels;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using System.Collections;
using NPOI.SS.Formula.Functions;
+using TouchSocket.Core;
namespace Admin.Core.Api.Controllers.Business
{
@@ -125,50 +126,63 @@ namespace Admin.Core.Api.Controllers.Business
}
return Failed("执行失败!");
}
-
+ ///
+ /// MES计划下发
+ ///
+ ///
+ ///
[HttpPost]
public async Task> DownLoadplanInfo([FromBody] List MesDownLoadPlanList)
{
try
{
- int iFlag = 0;
if (MesDownLoadPlanList == null || MesDownLoadPlanList.Count == 0)
{
return Failed("传入参数为空!");
}
-
- foreach (var item in MesDownLoadPlanList)
- {
-
- if (item.RecipeID == "")
- {
- return Failed("传入参数为空!");
- }
- var result = await _hw_WarehouseService.InsertXLPlanInfo(DateTime.Now, item.RecipeID, item.Batch, item.ProductName);
- if (result)
- {
- iFlag = iFlag + 1;
+ string result1 = await _hw_WarehouseService.DownRJPlanAsync(MesDownLoadPlanList);
+ string result2 = await _hw_WarehouseService.DownZBPlanAsync(MesDownLoadPlanList);
+ string result3 = await _hw_WarehouseService.DownXLPlanAsync(MesDownLoadPlanList);
+
+
+ if (result1.Contains("成功"))
+ {
+ if (result2.Contains("成功"))
+ {
+ if (result3.Contains("成功"))
+ {
+ return Success(true);
+ }
+ else
+ {
+ return Failed(result3 + "执行失败!");
+ }
+ }
+ else
+ {
+ return Failed(result2 + "执行失败!");
}
+ }
+ else
+ {
+ return Failed(result1 + "执行失败!");
}
- if (iFlag == MesDownLoadPlanList.Count)
- {
- return Success(true);
- }
- ////配方名或配方编号
+
+ ////配方名或配方编号
//string ss1 = "a82d016e813c4ac3bca0244c519da591";
////批次号
//string ss2 = "2408090522";
////产品名称
//var ss3 = "D1-813";
-
+
}
catch (Exception ex)
{
-
+ return Failed(ex.Message + "执行失败!");
}
- return Failed("执行失败!");
+ return Failed("执行失败!");
}
@@ -193,7 +207,7 @@ namespace Admin.Core.Api.Controllers.Business
return Failed("执行失败!");
}
///
- /// 查询称量重量
+ /// 查询称量信息
///
///
///
diff --git a/Admin.Core.Api/Program.cs b/Admin.Core.Api/Program.cs
index 18820c6..ff3e6a6 100644
--- a/Admin.Core.Api/Program.cs
+++ b/Admin.Core.Api/Program.cs
@@ -42,7 +42,8 @@ namespace Admin.Core.Api
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
- webBuilder.UseIIS().UseStartup();
+ webBuilder.UseUrls("http://*:6062").UseIIS().UseStartup();
+ //webBuilder.UseIIS().UseStartup();
})
.ConfigureLogging((hostingContext, builder) =>
{
diff --git a/Admin.Core.Api/Properties/launchSettings.json b/Admin.Core.Api/Properties/launchSettings.json
index 692d901..66a8f2f 100644
--- a/Admin.Core.Api/Properties/launchSettings.json
+++ b/Admin.Core.Api/Properties/launchSettings.json
@@ -24,7 +24,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": "true",
- "applicationUrl": "http://localhost:5001;http://localhost:5000"
+ "applicationUrl": "http://119.45.202.115:5001;http://119.45.202.115:6061"
//"applicationUrl": "http://192.168.137.1:5001;http://192.168.137.1:5000"
}
diff --git a/Admin.Core.Api/appsettings.Development.json b/Admin.Core.Api/appsettings.Development.json
index dc08c8b..bc6167b 100644
--- a/Admin.Core.Api/appsettings.Development.json
+++ b/Admin.Core.Api/appsettings.Development.json
@@ -81,7 +81,7 @@
"Enabled": true,
"HitRate": 50,
//"Connection": "Data Source=192.168.10.50;Initial Catalog=cwss_xl;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
- "Connection": "Data Source=127.0.0.1;Initial Catalog=cwss_xl;User ID=sa;Password=123456;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+ "Connection": "Data Source=119.45.202.115;Initial Catalog=cwss_xl;User ID=sa;Password=haiwei@123;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
//"Connection": "Data Source=192.168.10.50;Initial Catalog=cwss_xl;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
"ProviderName": "System.Data.SqlClient"
@@ -171,7 +171,7 @@
{
"Id": 2,
"EquipName": "溶剂PLC",
- "IP": "127.0.0.1",
+ "IP": "127.0.0.2",
"Port": 102
}
],
diff --git a/Admin.Core.Api/appsettings.json b/Admin.Core.Api/appsettings.json
index 8c7a8d2..17eba45 100644
--- a/Admin.Core.Api/appsettings.json
+++ b/Admin.Core.Api/appsettings.json
@@ -80,7 +80,7 @@
"DBType": 1,
"Enabled": true,
"HitRate": 50,
- "Connection": "Data Source=127.0.0.1;Initial Catalog=cwss_xl;User ID=sa;Password=123456;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+ "Connection": "Data Source=127.0.0.1;Initial Catalog=cwss_xl;User ID=sa;Password=haiwei@123;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
//"Connection": "Data Source=192.168.10.50;Initial Catalog=cwss_xl;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
"ProviderName": "System.Data.SqlClient"
}
diff --git a/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs b/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs
index b33be7a..47e0f1b 100644
--- a/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs
+++ b/Admin.Core.IService/IService_New/IHw_WarehouseServices.cs
@@ -19,8 +19,10 @@ namespace Admin.Core.IService
Task RealWeightInfo(string WeightNo);
Task GetXlInfo(string kettleBarCode, string planId, string code);
Task> GetWarehousePlan(string code);
+ Task DownRJPlanAsync(List MesDownLoadPlanList);
+ Task DownZBPlanAsync(List MesDownLoadPlanList);
- Task InsertXLPlanInfo(DateTime planDate, string recipeGUID, string batch, string productName);
+ Task DownXLPlanAsync(List MesDownLoadPlanList);
Task> GetPlanWeightInfo();
}
diff --git a/Admin.Core.IService/IService_New/Ixl_materialServices.cs b/Admin.Core.IService/IService_New/Ixl_materialServices.cs
index 9c70dfc..ed7b2c1 100644
--- a/Admin.Core.IService/IService_New/Ixl_materialServices.cs
+++ b/Admin.Core.IService/IService_New/Ixl_materialServices.cs
@@ -29,6 +29,13 @@ namespace Admin.Core.IService
///
Task BindBarrel(string code);
+ ///
+ /// 查询料桶重量
+ /// add by CaesarBao,2024.10.14
+ ///
+ ///
+ Task GetBindBarrelWeight();
+
Task> MaterialVerification(string barCode);
Task xlInsertMaterial(string materialCode, string materialName);
diff --git a/Admin.Core.Model/Model_New/Pmt_weigh.cs b/Admin.Core.Model/Model_New/Pmt_weigh.cs
index 6996833..8c338d3 100644
--- a/Admin.Core.Model/Model_New/Pmt_weigh.cs
+++ b/Admin.Core.Model/Model_New/Pmt_weigh.cs
@@ -64,5 +64,20 @@ namespace Admin.Core.Model
/// Nullable:True
///
public decimal? Cpk_Error { get; set; }
+
+ ///
+ /// 理论固含
+ ///
+ public decimal TheoryRate { get; set; }
+ ///
+ /// 是否有固含
+ ///
+ public bool IsRate { get; set; }
+ ///
+ /// 固含量
+ ///
+ public double RateWeight { get; set; }
+
+
}
}
\ No newline at end of file
diff --git a/Admin.Core.Model/Model_New/RT_plan.cs b/Admin.Core.Model/Model_New/RT_plan.cs
index 568f178..d2873e5 100644
--- a/Admin.Core.Model/Model_New/RT_plan.cs
+++ b/Admin.Core.Model/Model_New/RT_plan.cs
@@ -20,7 +20,7 @@ namespace Admin.Core.Model
/// Default:
/// Nullable:False
///
- [SugarColumn(IsPrimaryKey = true)]
+ // [SugarColumn(IsPrimaryKey = true)]
public int Dosing_Id { get; set; }
///
/// Desc:
@@ -34,7 +34,7 @@ namespace Admin.Core.Model
/// Default:
/// Nullable:False
///
- [SugarColumn(IsPrimaryKey = true)]
+ // [SugarColumn(IsPrimaryKey = true)]
public string Equip_Code { get; set; }
///
/// Desc:
diff --git a/Admin.Core.Model/Model_New/xl_plan.cs b/Admin.Core.Model/Model_New/xl_plan.cs
index 6b060ef..0837334 100644
--- a/Admin.Core.Model/Model_New/xl_plan.cs
+++ b/Admin.Core.Model/Model_New/xl_plan.cs
@@ -20,7 +20,6 @@ namespace Admin.Core.Model
/// Default:
/// Nullable:False
///
- [SugarColumn(IsPrimaryKey = true)]
public int Dosing_Id { get; set; }
///
/// Desc:计划Id
@@ -34,7 +33,6 @@ namespace Admin.Core.Model
/// Default:
/// Nullable:False
///
- [SugarColumn(IsPrimaryKey = true)]
public string Equip_Code { get; set; }
///
/// Desc:排序字段
diff --git a/Admin.Core.Model/Model_New/xl_recipe.cs b/Admin.Core.Model/Model_New/xl_recipe.cs
index c877469..b1008cd 100644
--- a/Admin.Core.Model/Model_New/xl_recipe.cs
+++ b/Admin.Core.Model/Model_New/xl_recipe.cs
@@ -153,5 +153,9 @@ public string Creator { get; set; }
/// Nullable:True
///
public DateTime? CreateDateTime { get; set; }
+///
+/// 是否产前验证
+///
+public int IsCheck { get; set; }
}
}
\ No newline at end of file
diff --git a/Admin.Core.Model/ViewModels/MesDownLoadPlanList.cs b/Admin.Core.Model/ViewModels/MesDownLoadPlanList.cs
index aef3dff..c7a03df 100644
--- a/Admin.Core.Model/ViewModels/MesDownLoadPlanList.cs
+++ b/Admin.Core.Model/ViewModels/MesDownLoadPlanList.cs
@@ -5,15 +5,36 @@ public class MesDownLoadPlanList
///
/// 配方编号
///
- public string RecipeID { get; set; }
+ public string No { get; set; }
///
/// 批次号
///
- public string Batch { get; set; }
+ public string PId { get; set; }
///
/// 产品名称
///
public string ProductName { get; set; }
+
+ public string BinId { get; set; }
+
+ public string Material_Code { get; set; }
+ public string MaterialName { get; set; }
+ public string MaterialType { get; set; }
+ public string SetWeight { get; set; }
+ public string SetError { get; set; }
+ public string Difference { get; set; }
+ public string Fixed { get; set; }
+ public string FixedRatio { get; set; }
+ public string PumpCode { get; set; }
+ public string Weighbridge { get; set; }
+ public string Recipe { get; set; }
+ public string Remark { get; set; }
+
+ public string Tare { get; set; }
+
+ public string MainId { get; set; }
+
+
}
\ No newline at end of file
diff --git a/Admin.Core.Repository/Repository_New/Pmt_materialRepository.cs b/Admin.Core.Repository/Repository_New/Pmt_materialRepository.cs
index b38c111..b3241e0 100644
--- a/Admin.Core.Repository/Repository_New/Pmt_materialRepository.cs
+++ b/Admin.Core.Repository/Repository_New/Pmt_materialRepository.cs
@@ -10,6 +10,7 @@ namespace Admin.Core.Repository
{
public Pmt_materialRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
{
+
}
}
}
\ No newline at end of file
diff --git a/Admin.Core.Service/Admin.Core.Service.csproj b/Admin.Core.Service/Admin.Core.Service.csproj
index b332b8b..41064bc 100644
--- a/Admin.Core.Service/Admin.Core.Service.csproj
+++ b/Admin.Core.Service/Admin.Core.Service.csproj
@@ -1,4 +1,4 @@
-
+
net6.0
@@ -17,6 +17,7 @@
+
diff --git a/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs b/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs
index 6915a25..9da9f55 100644
--- a/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs
+++ b/Admin.Core.Service/Service_New/Hw_WarehouseServices.cs
@@ -15,6 +15,10 @@ using System.Numerics;
using System.Text;
using NPOI.POIFS.FileSystem;
using System.Linq.Expressions;
+using NPOI.SS.Formula.Functions;
+using Admin.Core.Repository;
+using Microsoft.AspNetCore.SignalR;
+using Admin.Core.Common;
namespace Admin.Core.Service
{
@@ -23,6 +27,7 @@ namespace Admin.Core.Service
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(Hw_WarehouseServices));
private readonly IBaseRepository _dal;
private readonly IHw_WarehouseRepository _wareHouse;
+ private readonly IPmt_materialRepository _material;
private readonly IHw_WareHouse_SubRepository _wareHouse_Sub;
private readonly IHw_FeedReportRepository _feed;
private readonly IHw_BarrelRepository _barrel;
@@ -30,13 +35,21 @@ namespace Admin.Core.Service
private readonly Ixl_recipeRepository _recipeRepository;
private readonly ILR_weighRepository _lrWeighRepository;
private readonly Ixl_planRepository _planRepository;//小料计划
+ private readonly IHw_PumpRepository _hwPumpRepository;
+ private readonly IRT_planRepository _rtplanRepository;
+ private readonly IPmt_weighRepository _pmtWeighRepository;
+ private readonly IPmt_BinRepository _binRepository;
+ private readonly IPmt_recipeRepository _pmtRecipeRepository;
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly Ixl_weighRepository _xlWeighRepository;
+
private readonly IXLPlan_weightRepository _XLPlan_weightRepository;
public Hw_WarehouseServices(IBaseRepository 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, IPmt_materialRepository PmtmaterialRepository, IHw_PumpRepository hwPumpRepository, IRT_planRepository rtplanRepository, IPmt_recipeRepository pmtRecipeRepository, IUnitOfWork unitOfWork, IPmt_weighRepository pmtWeighRepository, IPmt_BinRepository binRepository, Ixl_weighRepository xlWeighRepository)
{
this._dal = dal;
base.BaseDal = dal;
@@ -49,6 +62,14 @@ namespace Admin.Core.Service
_lrWeighRepository = lrWeighRepository;
_planRepository = planRepository;
_XLPlan_weightRepository = xLPlan_weightRepository;
+ _material = PmtmaterialRepository;
+ _hwPumpRepository = hwPumpRepository;
+ _rtplanRepository = rtplanRepository;
+ _pmtRecipeRepository = pmtRecipeRepository;
+ _unitOfWork = unitOfWork;
+ _pmtWeighRepository = pmtWeighRepository;
+ _binRepository = binRepository;
+ _xlWeighRepository = xlWeighRepository;
}
#region 扫描桶二维码,获取绑定的小料配方物料
@@ -137,6 +158,8 @@ namespace Admin.Core.Service
}
}
#endregion
+
+
#region GetNextSerialNum 获取下一个可用的序号SerialNum 规则:同机台、同日期、同班次 计划号最后2位的最大值加1
///
/// 获取下一个可用的序号
@@ -146,10 +169,26 @@ namespace Admin.Core.Service
public int GetNextSerialNumAsync()
{
+ string strSql = "SELECT MAX(Plan_Serial) FROM RT_plan";
+ Expression> exp = s1 => true;
+ Expression> order = (x) => x.Plan_Serial;
+ var result = _rtplanRepository.Query(exp,order,false).First();
+ if (result == null)
+ {
+ return 1;
+ }
+ else
+ {
+ return Convert.ToInt32(result.Plan_Serial) + 1;
+ }
+ }
+ public int GetXLNextSerialNumAsync()
+ {
+
string strSql = "SELECT MAX(Plan_Serial) FROM xl_plan";
Expression> exp = s1 => true;
Expression> order = (x) => x.Plan_Serial;
- var result = _planRepository.Query(exp,order,false).First();
+ var result = _planRepository.Query(exp, order, false).First();
if (result == null)
{
return 1;
@@ -160,6 +199,24 @@ namespace Admin.Core.Service
}
}
public int GetNextSerialNumFromLRPlan(DateTime planDate)
+ {
+ string strSql = "SELECT MAX(RIGHT(Plan_Id,2)) FROM Hw_plan WHERE LEFT(Plan_Id,8) = @PlanDate";
+ string ss = String.Format("{0:yyyyMMdd}", planDate);
+ SugarParameter[] parameters = new SugarParameter[]
+ {
+ new SugarParameter($"@PlanDate", String.Format("{0:yyyyMMdd}", planDate))
+ };
+ var result = _planRepository.ExecSql(strSql, parameters);
+ if (result == null)
+ {
+ return 1;
+ }
+ else
+ {
+ return Convert.ToInt32(result) + 1;
+ }
+ }
+ public int GetXLNextSerialNumFromLRPlan(DateTime planDate)
{
string strSql = "SELECT MAX(RIGHT(Plan_Id,2)) FROM LR_plan WHERE LEFT(Plan_Id,8) = @PlanDate";
string ss = String.Format("{0:yyyyMMdd}", planDate);
@@ -177,7 +234,6 @@ namespace Admin.Core.Service
return Convert.ToInt32(result) + 1;
}
}
-
#endregion
///
/// 获取下一个可用的计划号 (6位日期、2位机台、1位班次、1位网络/本机、2位流水)
@@ -217,66 +273,672 @@ namespace Admin.Core.Service
}
#endregion
- public async Task InsertXLPlanInfo(DateTime planDate, string recipeGUID, string batch, string productName)
+
+ public async Task DownRJPlanAsync(List MesDownLoadPlanList)
{
try
{
- int shiftID = 1;
- //根据配方编号查询
- var recipe = await _recipeRepository.FirstAsync(d => d.Recipe_Verify == 1 && d.ID == recipeGUID);
- if (recipe == null)
+ var list = MesDownLoadPlanList;
+ List subList = new List();
+ List recipeList = new List();
+ list.ForEach((a) =>
{
- recipe.ID = recipeGUID;
- recipe.Recipe_Name = recipeGUID;
- recipe.Version = "1";
+ Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub();
+ sb.MainId = int.Parse(a.MainId);
+ sb.PId = a.PId;
+ sb.ProductName = a.ProductName;
+ sb.MaterialID = a.Material_Code;
+ sb.Material_Code = a.Material_Code;
+ sb.MaterialName = a.MaterialName;
+ sb.MaterialType = a.MaterialType;
+ sb.SetWeight = Convert.ToDecimal(a.SetWeight);
+ sb.SetError = Convert.ToDecimal(a.SetError);
+ sb.Difference = a.Difference;
+ sb.Fixed = a.Fixed == "" || a.Fixed == null ? false : true;
+ sb.FixedRatio = a.FixedRatio == "" || a.FixedRatio == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(a.FixedRatio);
+ sb.Weighbridge = a.Weighbridge;
+ sb.PumpCode = a.PumpCode;
+ sb.Recipe = a.Recipe;
+ sb.Remark = a.Remark;
+ sb.CreateTime = DateTime.Now;
+ sb.Tare = Convert.ToDecimal(a.Tare);
+ subList.Add(sb);
+ });
+ //查询溶剂数据
+ var xlList = subList.Where(d => d.MaterialType.Contains("溶剂")).ToList();
+ var xt = (from d in xlList
+ select new
+ {
+ d.PId,
+ d.ProductName,
+ d.MaterialType,
+ d.Recipe,
+ d.Weighbridge,
+ d.PumpCode
+
+ }).Distinct().ToList();
+ if (xt.Count == 0)
+ {
+ return "成功";
}
-
- int rtPlanSNum = GetNextSerialNumAsync(); //xl_plan序号
- //int lrPlanSNum = GetNextSerialNumFromLRPlan(planDate); //LR_Plan序号
- string planID = GenerateNextPlanIDNew(planDate, shiftID, rtPlanSNum); //计划号hlcs0929
+ foreach (var item in xt)
+ {
+ try
+ {
+ #region 配方
+ string recipeCode = Guid.NewGuid().ToString("N");
+ string recipeID = Guid.NewGuid().ToString("N");
+ Pmt_recipe recipe = new Pmt_recipe();
+ recipe.ID = recipeID;
+ recipe.Equip_Code = "01";
+ recipe.Recipe_Code = recipeCode;
+ recipe.Version = "1";
+ recipe.Recipe_Name = item.Recipe;
+ recipe.Recipe_Verify = 1;
+ recipe.Total_Weight = 0;
+ recipe.Total_Error = 0;
+ recipe.CreateDateTime = DateTime.Now;
+
+ #endregion
+
+ #region 物料
+ var repiceList = xlList.Where(d => item.PId.Equals(d.PId) && item.ProductName.Equals(d.ProductName) && item.Recipe.Equals(d.Recipe)).ToList();
+ int i = 1;
+ List weighList = new List();
+ foreach (var sub in repiceList)
+ {
+ Pmt_weigh material = new Pmt_weigh();
+ material.ID = Guid.NewGuid().ToString("N");
+ material.Equip_Code = "01";
+ material.Recipe_ID = recipeID;
+
+ material.Weight_Id = i;
+ if (sub.Material_Code == null | sub.Material_Code == "")
+ {
+ throw new Exception("未查询到物料!");
+ }
+ var obj = await _material.FirstAsync(d => d.Material_code == sub.Material_Code);
+ if (obj == null)
+ {
+ throw new Exception("未查询到当前物料!");
+ }
+ material.Material_ID = obj.ID.ToString();
+ material.Set_Weight = Convert.ToDecimal(sub.SetWeight);
+ material.Set_Error = Convert.ToDecimal(sub.SetError);
+ recipe.Total_Weight = recipe.Total_Weight + material.Set_Weight;
+ recipe.Total_Error = recipe.Total_Error + material.Set_Error;
+ if (sub.Fixed)
+ {
+ material.IsRate = true;
+ material.TheoryRate = Convert.ToDecimal(sub.FixedRatio);
+ }
+ else
+ {
+ material.IsRate = false;
+ material.TheoryRate = 0;
+ }
+ weighList.Add(material);
+ i++;
+ }
+ #endregion
- xl_plan xl_plan = new xl_plan()
+ #region 计划
+ RT_plan plan = new RT_plan();
+ plan.Dosing_Id = 0;
+ plan.Equip_Code = "01";
+ plan.Batch = item.PId;
+ plan.ProductName = item.ProductName;
+ int serialNum = 0;
+ int rtPlanSNum = GetNextSerialNumAsync(); //xl_plan序号
+ int lrPlanSNum = GetNextSerialNumFromLRPlan(DateTime.Now); //Hw_Plan序号
+ if (rtPlanSNum >= lrPlanSNum)
+ {
+ serialNum = rtPlanSNum;
+ }
+ else
+ {
+ serialNum = lrPlanSNum;
+ }
+ string planID = GenerateNextPlanIDNew(DateTime.Now, 1, serialNum); //计划号
+
+ plan.Plan_Id = planID;
+ plan.Plan_Serial = serialNum;
+ plan.Recipe_ID = recipeID;
+ plan.Recipe_Code = recipeCode;
+ plan.Recipe_Name = item.Recipe;
+ plan.Version = "1";
+ plan.Mixer_Line = null;
+ plan.Recipe_Type = 0;
+ plan.Shift_Id = "1";
+ plan.Shift_Class = "";
+ plan.Plan_Num = 1;
+ plan.Real_Num = 0;
+ plan.Duration_Time = 0;
+ plan.End_Date = null;
+ plan.Weight_Man = null;
+ plan.Stock_Man = null;
+ plan.Plan_Batch = null;
+ plan.Plan_State = 5;
+ plan.Plan_StateText = "未启动";
+ plan.Plan_Date = String.Format("{0:yyyy-MM-dd}", DateTime.Now);
+ plan.IF_FLAG = 1;
+ if (string.IsNullOrEmpty(item.Weighbridge))
+ {
+ throw new Exception("地磅不可为空!");
+ }
+ plan.Weighbridge = item.Weighbridge;
+ plan.PumpBarCode = item.PumpCode;
+ if (item.PumpCode == null || item.PumpCode == "")
+ {
+ throw new Exception("投料泵为空!");
+ }
+ var pumpList = _hwPumpRepository.Query();
+ var pump = pumpList.FirstOrDefault(d => d.BarCode == item.PumpCode);
+ plan.PumpName = pump.Name;
+ #endregion
+
+ if (recipe == null)
+ {
+ throw new Exception("配方数据不可为空!");
+ }
+ if (weighList == null)
+ {
+ throw new Exception("配方物料数据不可为空!");
+ }
+ if (plan == null)
+ {
+ throw new Exception("计划数据不可为空!");
+ }
+ if (repiceList == null)
+ {
+ throw new Exception("反应釜计划数据不可为空!");
+ }
+ bool r = SaveRecipe(recipe, weighList, plan, repiceList.ToList());
+ if (r == false)
+ {
+ string msg = $"批次[{plan.Batch}];配方[{item.Recipe}],导入数据失败!";
+ return msg;
+ Console.WriteLine($"批次[{plan.Batch}];配方[{item.Recipe}],导入数据失败!");
+ }
+
+ return "成功";
+ //Console.WriteLine($"{item.PId}——{item.ProductName}——{item.Recipe};状态:{r}");
+ }
+ catch (Exception ex)
+ {
+ string msg = $"配方[{item.Recipe}] 导入失败!异常信息:{ex.Message}";
+ return msg;
+
+ }
+
+ }
+
+ }
+ catch (Exception ex)
+ {
+ return ex.Message;
+ }
+
+ return "执行失败";
+ }
+
+ public async Task DownZBPlanAsync(List MesDownLoadPlanList)
+ {
+ try
+ {
+ var list = MesDownLoadPlanList;
+ List subList = new List();
+ List recipeList = new List();
+ list.ForEach((a) =>
{
- Equip_Code = "01",
- Dosing_Id = 0,
- Plan_Id = planID,
- Batch = batch,
- ProductName= productName,
- Plan_Serial = rtPlanSNum,
- Recipe_ID = recipe.ID,
- Recipe_Code = recipe.ID,
- Recipe_Name = recipe.Recipe_Name,
- Version = recipe.Version,
- Mixer_Line = "0",
- Recipe_Type = 0,
- Shift_Id = "1",
- Shift_Class = "0",
- Plan_Num = 1,
- Real_Num = 0,
- Duration_Time = 0,
- Plan_State = 5,
- Plan_StateText = "未启动",
- Plan_Date = DateTime.Now.ToString("yyyy-mm-dd"),
- IF_FLAG = 1,
-
- };
- var result = await _planRepository.Add(xl_plan);
- if (result == 1)
+ Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub();
+ sb.MainId = int.Parse(a.MainId);
+ sb.PId = a.PId;
+ sb.ProductName = a.ProductName;
+ sb.MaterialID = a.Material_Code;
+ sb.Material_Code = a.Material_Code;
+ sb.MaterialName = a.MaterialName;
+ sb.MaterialType = a.MaterialType;
+ sb.SetWeight = Convert.ToDecimal(a.SetWeight);
+ sb.SetError = Convert.ToDecimal(a.SetError);
+ sb.Difference = a.Difference;
+ sb.PumpCode = a.PumpCode;
+ sb.Weighbridge = a.Weighbridge;
+ sb.Recipe = a.Recipe;
+ sb.Remark = a.Remark;
+ sb.CreateTime = DateTime.Now;
+ sb.Tare = Convert.ToDecimal(a.Tare);
+ subList.Add(sb);
+ });
+
+ //查询数据
+ var xlList = subList.Where(d => d.MaterialType.Contains("整包")).ToList();
+ var xt = from d in xlList
+ group d by new { PId = d.PId, ProductName = d.ProductName, Material_Code = d.Material_Code, MaterialType = d.MaterialType, Recipe = d.Recipe, SetWeight = d.Recipe, SetError = d.SetError, Weighbridge = d.Weighbridge } into g
+ select new
+ {
+ g.Key.PId,
+ g.Key.ProductName,
+ g.Key.Material_Code,
+ g.Key.MaterialType,
+ g.Key.Recipe,
+ SetWeight = g.Sum(m => m.SetWeight),
+ SetError = g.Sum(m => m.SetError),
+ g.Key.Weighbridge
+ };
+
+ if (xt.ToList().Count == 0)
{
- return true;
+ return "成功";
}
- else
+ foreach (var item in xt)
{
- return false;
+ try
+ {
+ #region 配方
+ string recipeID = Guid.NewGuid().ToString("N");
+ string recipeCode = Guid.NewGuid().ToString("N");
+
+ Pmt_recipe recipe = new Pmt_recipe();
+
+ {
+ recipe.ID = recipeID;
+ recipe.Equip_Code = "01";
+ recipe.Recipe_Code = recipeCode;
+ recipe.Version = "1";
+ recipe.Recipe_Name = item.Recipe;
+ recipe.Recipe_Verify = 1;
+ recipe.Total_Weight = 0;
+ recipe.Total_Error = 0;
+ recipe.CreateDateTime = DateTime.Now;
+ }
+
+ #endregion
+
+ #region 物料
+
+
+ List weighList = new List();
+
+ {
+ Pmt_weigh material = new Pmt_weigh();
+ material.ID = Guid.NewGuid().ToString("N");
+ material.Equip_Code = "01";
+ material.Recipe_ID = recipe.ID;
+ material.Weight_Id = 1;
+ if (item.Material_Code == null | item.Material_Code == "")
+ {
+ throw new Exception("未查询到物料!");
+ }
+ var obj = await _material.FirstAsync(d => d.Material_code == item.Material_Code);
+ if (obj == null)
+ {
+ throw new Exception("未查询到当前物料!");
+ }
+ material.Material_ID = obj.ID;
+ material.Set_Weight = Convert.ToDecimal(item.SetWeight);
+ material.Set_Error = Convert.ToDecimal(item.SetError);
+ recipe.Total_Weight = Convert.ToDecimal(item.SetWeight);
+ recipe.Total_Error = Convert.ToDecimal(item.SetError);
+ weighList.Add(material);
+ }
+ #endregion
+
+ #region 计划
+ RT_plan plan = new RT_plan();
+ plan.Dosing_Id = 0;
+ plan.Equip_Code = "01";
+ plan.Batch = item.PId;
+ plan.ProductName = item.ProductName;
+ int serialNum = 0;
+ int rtPlanSNum = GetNextSerialNumAsync(); //xl_plan序号
+ int lrPlanSNum = GetNextSerialNumFromLRPlan(DateTime.Now); //Hw_Plan序号
+ if (rtPlanSNum >= lrPlanSNum)
+ {
+ serialNum = rtPlanSNum;
+ }
+ else
+ {
+ serialNum = lrPlanSNum;
+ }
+ string planID = GenerateNextPlanIDNew(DateTime.Now, 1, serialNum); //计划号
+
+ plan.Plan_Id = planID;
+ plan.Plan_Serial = serialNum;
+ plan.Recipe_ID = recipe.ID;
+ plan.Recipe_Code = recipeCode;
+ plan.Recipe_Name = item.Recipe;
+ plan.Version = "1";
+ plan.Mixer_Line = null;
+ plan.Recipe_Type = 0;
+ plan.Shift_Id = "1";
+ plan.Shift_Class = "";
+ plan.Plan_Num = 1;
+ plan.Real_Num = 0;
+ plan.Duration_Time = 0;
+ plan.End_Date = null;
+ plan.Weight_Man = null;
+ plan.Stock_Man = null;
+ plan.Plan_Batch = null;
+ plan.Plan_State = 5;
+ plan.Plan_StateText = "未启动";
+ plan.Plan_Date = String.Format("{0:yyyy-MM-dd}", DateTime.Now);
+ plan.IF_FLAG = 1;
+ if (string.IsNullOrEmpty(item.Weighbridge))
+ {
+ throw new Exception("地磅不可为空!");
+ }
+ plan.Weighbridge = item.Weighbridge;
+ #endregion
+
+ if (recipe == null)
+ {
+ throw new Exception("配方数据不可为空!");
+ }
+ if (weighList == null)
+ {
+ throw new Exception("配方物料数据不可为空!");
+ }
+ if (plan == null)
+ {
+ throw new Exception("计划数据不可为空!");
+ }
+ var repiceList = xlList.Where(d => item.PId.Equals(d.PId) && item.ProductName.Equals(d.ProductName) && item.Recipe.Equals(d.Recipe)).ToList();
+ if (repiceList == null)
+ {
+ throw new Exception("反应釜计划数据不可为空!");
+ }
+ bool r = SaveRecipe(recipe, weighList, plan, repiceList.ToList());
+ if (r == false)
+ {
+ string msg = $"批次[{plan.Batch}];配方[{item.Recipe}],导入数据失败!";
+ return msg;
+ //Console.WriteLine($"批次[{plan.Batch}];配方[{item.Recipe}],导入数据失败!");
+ }
+ //Console.WriteLine($"{item.PId}——{item.ProductName}——{item.Recipe};状态:{r}");
+ return "成功";
+ }
+ catch (Exception ex)
+ {
+ string msg = $"配方[{item.Recipe}] 导入失败!异常信息:{ex.Message}";
+ return msg;
+ //Console.WriteLine($"配方[{item.Recipe}] 导入失败!异常信息:{ex.Message}");
+ }
}
}
catch (Exception ex)
+ {
+ return ex.Message;
+ }
+
+ return "执行失败";
+ }
+
+
+ public async Task DownXLPlanAsync(List MesDownLoadPlanList)
+ {
+ try
+ {
+ var list = MesDownLoadPlanList;
+ List subList = new List();
+ List recipeList = new List();
+ list.ForEach((a) =>
+ {
+ Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub();
+ sb.MainId = int.Parse(a.MainId);
+ sb.PId = a.PId;
+ sb.ProductName = a.ProductName;
+ sb.BinId = a.BinId == "" || a.BinId == null ? 0 : int.Parse(a.BinId);
+
+ sb.MaterialID = a.Material_Code;
+ sb.Material_Code = a.Material_Code;
+ sb.MaterialName = a.MaterialName;
+ sb.MaterialType = a.MaterialType;
+ sb.SetWeight = Convert.ToDecimal(a.SetWeight);
+ sb.SetError = Convert.ToDecimal(a.SetError);
+ sb.Difference = a.Difference;
+ sb.Fixed = a.Fixed == "" || a.Fixed == null ? false : true;
+ sb.FixedRatio = a.FixedRatio == a.FixedRatio ? Convert.ToDecimal(0.00) : Convert.ToDecimal(a.FixedRatio);
+ sb.Recipe = a.Recipe;
+ sb.Remark = a.Remark;
+ subList.Add(sb);
+ });
+
+ //查询小料数据
+ var xlList = subList.Where(d => d.MaterialType.Contains("尾料")).ToList();
+ var xt = (from d in xlList
+ select new
+ {
+ d.PId,
+ d.ProductName,
+ d.MaterialType,
+ d.Recipe,
+
+ }).Distinct();
+ foreach (var item in xt)
+ {
+ try
+ {
+ string recipeID = Guid.NewGuid().ToString("N");
+ string recipeCode = Guid.NewGuid().ToString("N");
+
+ #region 配方
+ xl_recipe recipe = new xl_recipe();
+ recipe.ID = recipeID;
+ recipe.Equip_Code = "01";
+ recipe.Recipe_Code = recipeCode;
+ recipe.Version = "1";
+ recipe.Recipe_Name = item.Recipe;
+ recipe.Recipe_Verify = 1;
+ recipe.Total_Weight = 0;
+ recipe.Total_Error = 0;
+ recipe.CreateDateTime = DateTime.Now;
+ recipe.IsCheck = 0;
+
+ #endregion
+
+ #region 物料
+ var repiceList = xlList.Where(d => item.PId.Equals(d.PId) && item.ProductName.Equals(d.ProductName) && item.Recipe.Equals(d.Recipe)).ToList();
+ int i = 1;
+ List weighList = new List();
+ foreach (var sub in repiceList)
+ {
+ xl_weigh material = new xl_weigh();
+ material.Equip_Code = "01";
+ material.Recipe_ID = recipe.ID;
+
+ material.Weight_Id = i;
+ if (sub.Material_Code == null | sub.Material_Code == "")
+ {
+ throw new Exception("未查询到物料!");
+ }
+ var obj = await _materialRepository.FirstAsync(d => d.Material_code == sub.Material_Code);
+ if (obj == null)
+ {
+ throw new Exception("未查询到当前物料!");
+ }
+ material.Material_ID = obj.ID;
+ if (sub.BinId == 0)
+ {
+ throw new Exception("未查询到对应料仓!");
+ }
+
+ var binInfo = await _binRepository.FirstAsync(d => d.Bin_Serial == sub.BinId && d.Material_ID == obj.ID);
+ if (binInfo == null)
+ {
+ throw new Exception("未查询到对应料仓!");
+ }
+ material.Bin_Serial = sub.BinId;
+ material.Set_Weight = Convert.ToDecimal(sub.SetWeight);
+ material.Set_Error = Convert.ToDecimal(sub.SetError);
+ recipe.Total_Weight = recipe.Total_Weight + material.Set_Weight;
+ recipe.Total_Error = recipe.Total_Error + material.Set_Error;
+ weighList.Add(material);
+ i++;
+ }
+ #endregion
+
+ #region 计划
+ xl_plan plan = new xl_plan();
+ plan.Dosing_Id = 0;
+
+ plan.Equip_Code = "01";
+ plan.Batch = item.PId;
+ plan.ProductName = item.ProductName;
+ int serialNum = 0;
+ int rtPlanSNum = GetXLNextSerialNumAsync(); //xl_plan序号
+ int lrPlanSNum = GetXLNextSerialNumFromLRPlan(DateTime.Now); //LR_Plan序号
+ if (rtPlanSNum >= lrPlanSNum)
+ {
+ serialNum = rtPlanSNum;
+ }
+ else
+ {
+ serialNum = lrPlanSNum;
+ }
+ string planID = GenerateNextPlanIDNew(DateTime.Now, 1, serialNum); //计划号
+
+ plan.Plan_Id = planID;
+ plan.Plan_Serial = serialNum;
+ plan.Recipe_ID = recipe.ID;
+ plan.Recipe_Code = recipeID;
+ plan.Recipe_Name = item.Recipe;
+ plan.Version = "1";
+ plan.Recipe_Type = 0;
+ plan.Shift_Id = "1";
+ plan.Shift_Class = "";
+ plan.Plan_Num = 1;
+ plan.Real_Num = 0;
+ plan.Duration_Time = 0;
+ plan.Mixer_Line = "0";
+ plan.End_Date = null;
+ plan.Weight_Man = null;
+ plan.Stock_Man = null;
+ plan.Plan_Batch = null;
+ plan.Plan_State = 5;
+ plan.Plan_StateText = "未启动";
+ plan.Plan_Date = String.Format("{0:yyyy-MM-dd}", DateTime.Now);
+ plan.IF_FLAG = 1;
+ #endregion
+
+ if (recipe == null)
+ {
+ throw new Exception("配方数据不可为空!");
+ }
+ if (weighList == null)
+ {
+ throw new Exception("配方物料数据不可为空!");
+ }
+ if (plan == null)
+ {
+ throw new Exception("计划数据不可为空!");
+ }
+ if (repiceList == null)
+ {
+ throw new Exception("反应釜计划数据不可为空!");
+ }
+ bool r = SaveXLRecipe(recipe, weighList, plan, repiceList.ToList());
+ if (r == false)
+ {
+ string msg = $"批次[{plan.Batch}];配方[{item.Recipe}],导入数据失败!";
+ return msg;
+ //Console.WriteLine($"批次[{plan.Batch}];配方[{item.Recipe}],导入数据失败!");
+ }
+ else
+ {
+ return "成功";
+ }
+ //Console.WriteLine($"{item.PId}——{item.ProductName}——{item.Recipe};状态:{r}");
+ }
+ catch (Exception ex)
+ {
+ string msg = $"配方[{item.Recipe}] 导入失败!异常信息:{ex.Message}";
+ return msg;
+ //Console.WriteLine($"配方[{item.Recipe}] 导入失败!异常信息:{ex.Message}");
+ }
+
+ }
+
+
+ }
+ catch (Exception ex)
+ {
+ return ex.Message;
+ }
+
+ return "执行失败";
+ }
+
+ #region 保存配方、计划物料信息
+ ///
+ /// 保存配方、计划物料信息
+ ///
+ /// 配方、物料
+ ///
+ ///
+ ///
+ ///
+ public bool SaveRecipe(Pmt_recipe recipeList, List pmt_weighList, RT_plan plan, List sub)
+ {
+ try
+ {
+ var iflag3 = _rtplanRepository.Add(plan);
+ if (iflag3.Result < 1)
+ throw new Exception("保存计划失败!");
+ var iflag4 = _wareHouse_Sub.Add(sub);
+ if (iflag4 < 1)
+ throw new Exception("保存反应釜计划失败!");
+
+ var iflag1 = _pmtRecipeRepository.Add(recipeList);
+ if (iflag1.Result < 1)
+ throw new Exception("保存溶剂配方失败!");
+ var iflag2 = _pmtWeighRepository.Add(pmt_weighList);
+ if (iflag2 < 1)
+ throw new Exception("保存配方物料失败!");
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+
+ }
+ public bool SaveXLRecipe(xl_recipe recipeList, List pmt_weighList, xl_plan plan, List sub)
+ {
+ try
+ {
+ var iflag3 = _planRepository.Add(plan);
+ if (iflag3.Result < 1)
+ throw new Exception("保存计划失败!");
+ var iflag4 = _wareHouse_Sub.Add(sub);
+ if (iflag4 < 1)
+ throw new Exception("保存反应釜计划失败!");
+
+ var iflag1 = _recipeRepository.Add(recipeList);
+ if (iflag1.Result < 1)
+ throw new Exception("保存溶剂配方失败!");
+ var iflag2 = _xlWeighRepository.Add(pmt_weighList);
+ if (iflag2 < 1)
+ throw new Exception("保存配方物料失败!");
+
+ return true;
+ }
+ catch (Exception ex)
{
return false;
}
- return false;
+
+ }
+ #endregion
+ #region 根据二维码获取物料
+ public async Task GetMaterialAsync(string barCode)
+ {
+ Pmt_material sub = await _material.FirstAsync(d => d.Material_code == barCode);
+ return sub;
}
+ #endregion
#region 根据传入的二维码、计划Id 查询反应釜下所有的物料
///
diff --git a/Admin.Core.Service/Service_New/SolventServices.cs b/Admin.Core.Service/Service_New/SolventServices.cs
index 466ff12..701771d 100644
--- a/Admin.Core.Service/Service_New/SolventServices.cs
+++ b/Admin.Core.Service/Service_New/SolventServices.cs
@@ -522,13 +522,13 @@ namespace Admin.Core.Service
else
{
var s7 = PlcConnect.Instance;
- int planNum = s7.ReadInt16("DB110.DBW2.0").Content;//执行批次
+ int planNum = s7.ReadInt16("DB111.DBW2.0").Content;//执行批次
if (plan.Plan_Num > planNum)
{
var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3);
var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == plan.Plan_Id);
execNum = rtPlan.Exec_Num;
- int materialNo = s7.ReadInt16("DB110.DBW1758").Content;//当前执行物料
+ int materialNo = s7.ReadInt16("DB111.DBW1758").Content;//当前执行物料
var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == materialNo);
if (hwWeigh == null) return null;
diff --git a/Admin.Core.Service/Service_New/xl_materialServices.cs b/Admin.Core.Service/Service_New/xl_materialServices.cs
index 86f4626..75082d0 100644
--- a/Admin.Core.Service/Service_New/xl_materialServices.cs
+++ b/Admin.Core.Service/Service_New/xl_materialServices.cs
@@ -307,6 +307,31 @@ namespace Admin.Core.Service
#endregion
#region 扫码料桶,绑定物料、重量批次信息
+
+ public async Task GetBindBarrelWeight()
+ {
+ try
+ {
+ var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("小料PLC"));
+ if (plcList.plc.IsConnected) // 000533
+ {
+ decimal tcheckWeight = Convert.ToDecimal(plcList.plc.ReadInt16("DB104.DBW164")) / 1000;//检量秤重量
+ log.Info($"重量:{tcheckWeight}");
+ return tcheckWeight;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ catch (Exception ex)
+ {
+ log.Error(ex.Message);
+ return 0;//异常报错
+ }
+ }
+
+
///
/// 扫码料桶,绑定物料、重量批次信息
///