合并代码

main
CaesarBao 1 month ago
commit 1495c20b1f

@ -90,7 +90,7 @@ public class MesDownLoadPlanList
/// <summary> /// <summary>
/// 反应釜编号 /// 反应釜编号
/// </summary> /// </summary>
public string MainId { get; set; } public string MainId { get; set; } = string.Empty;
} }

@ -46,7 +46,7 @@ namespace Admin.Core.Service
private readonly IXLPlan_weightRepository _XLPlan_weightRepository; private readonly IXLPlan_weightRepository _XLPlan_weightRepository;
public Hw_WarehouseServices(IBaseRepository<Hw_Warehouse> dal, IHw_WarehouseRepository wareHouse, public Hw_WarehouseServices(IBaseRepository<Hw_Warehouse> dal, IHw_WarehouseRepository wareHouse,
IHw_WareHouse_SubRepository wareHouse_Sub, IHw_FeedReportRepository feed, IHw_WareHouse_SubRepository wareHouse_Sub, IHw_FeedReportRepository feed,
IHw_BarrelRepository barrel, Ixl_materialRepository materialRepository, IHw_BarrelRepository barrel, Ixl_materialRepository materialRepository,
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) 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)
@ -107,7 +107,7 @@ namespace Admin.Core.Service
list.Add(childView); list.Add(childView);
} }
var kettle = await _dal.FirstAsync(d => d.BarCode.Equals(kettleBarCode)); var kettle = await _dal.FirstAsync(d => d.BarCode.Equals(kettleBarCode));
var subList = await _wareHouse_Sub.QueryAsync(d => d.MainId == kettle.ID && d.PId.Equals(planId) &&d.MaterialType.Contains("尾料")); var subList = await _wareHouse_Sub.QueryAsync(d => d.MainId == kettle.ID && d.PId.Equals(planId) && d.MaterialType.Contains("尾料"));
foreach (var check in list) foreach (var check in list)
{ {
MaterialView childView = new MaterialView(); MaterialView childView = new MaterialView();
@ -119,7 +119,7 @@ namespace Admin.Core.Service
if (pList == null) if (pList == null)
{ {
childView.MatchOrNot = 0; childView.MatchOrNot = 0;
materList.Add(childView); materList.Add(childView);
continue; continue;
} }
foreach (var item in pList) foreach (var item in pList)
@ -168,11 +168,11 @@ namespace Admin.Core.Service
/// <returns>返回可用的序号</returns> /// <returns>返回可用的序号</returns>
public int GetNextSerialNumAsync() public int GetNextSerialNumAsync()
{ {
string strSql = "SELECT MAX(Plan_Serial) FROM RT_plan"; string strSql = "SELECT MAX(Plan_Serial) FROM RT_plan";
Expression<Func<RT_plan, bool>> exp = s1 => true; Expression<Func<RT_plan, bool>> exp = s1 => true;
Expression<Func<RT_plan, object>> order = (x) => x.Plan_Serial; Expression<Func<RT_plan, object>> order = (x) => x.Plan_Serial;
var result = _rtplanRepository.Query(exp,order,false).First(); var result = _rtplanRepository.Query(exp, order, false).First();
if (result == null) if (result == null)
{ {
return 1; return 1;
@ -284,7 +284,7 @@ namespace Admin.Core.Service
list.ForEach((a) => list.ForEach((a) =>
{ {
Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub(); Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub();
sb.MainId = int.TryParse(a.MainId, out int value) ? value : throw new Exception("MainID格式错误请传入int类型的反应釜编号"); //sb.MainId = int.TryParse(a.MainId, out int value) ? value : throw new Exception("MainID格式错误请传入int类型的反应釜编号");
sb.PId = a.PId; sb.PId = a.PId;
sb.ProductName = a.ProductName; sb.ProductName = a.ProductName;
sb.MaterialID = a.Material_Code; sb.MaterialID = a.Material_Code;
@ -492,7 +492,7 @@ namespace Admin.Core.Service
list.ForEach((a) => list.ForEach((a) =>
{ {
Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub(); Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub();
sb.MainId = int.TryParse(a.MainId, out int value) ? value : throw new Exception("MainID格式错误请传入int类型的反应釜编号"); //sb.MainId = int.TryParse(a.MainId, out int value) ? value : throw new Exception("MainID格式错误请传入int类型的反应釜编号");
sb.PId = a.PId; sb.PId = a.PId;
sb.ProductName = a.ProductName; sb.ProductName = a.ProductName;
sb.MaterialID = a.Material_Code; sb.MaterialID = a.Material_Code;
@ -680,16 +680,16 @@ namespace Admin.Core.Service
try try
{ {
var list = MesDownLoadPlanList; var list = MesDownLoadPlanList;
List <Hw_WareHouse_Sub> subList = new List<Hw_WareHouse_Sub>(); List<Hw_WareHouse_Sub> subList = new List<Hw_WareHouse_Sub>();
List<xl_recipe> recipeList = new List<xl_recipe>(); List<xl_recipe> recipeList = new List<xl_recipe>();
list.ForEach((a) => list.ForEach((a) =>
{ {
Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub(); Hw_WareHouse_Sub sb = new Hw_WareHouse_Sub();
sb.MainId = int.TryParse(a.MainId, out int value) ? value : throw new Exception("MainID格式错误请传入int类型的反应釜编号"); //sb.MainId = int.TryParse(a.MainId, out int value) ? value : throw new Exception("MainID格式错误请传入int类型的反应釜编号");
sb.PId = a.PId; sb.PId = a.PId;
sb.ProductName = a.ProductName; sb.ProductName = a.ProductName;
sb.BinId = a.BinId == "" || a.BinId == null ? 0 : int.Parse(a.BinId); sb.BinId = a.BinId == "" || a.BinId == null ? 0 : int.Parse(a.BinId);
sb.MaterialID = a.Material_Code; sb.MaterialID = a.Material_Code;
sb.Material_Code = a.Material_Code; sb.Material_Code = a.Material_Code;
sb.MaterialName = a.MaterialName; sb.MaterialName = a.MaterialName;
@ -707,14 +707,14 @@ namespace Admin.Core.Service
//查询小料数据 //查询小料数据
var xlList = subList.Where(d => d.MaterialType.Contains("尾料")).ToList(); var xlList = subList.Where(d => d.MaterialType.Contains("尾料")).ToList();
var xt = (from d in xlList var xt = (from d in xlList
select new select new
{ {
d.PId, d.PId,
d.ProductName, d.ProductName,
d.MaterialType, d.MaterialType,
d.Recipe, d.Recipe,
}).Distinct(); }).Distinct();
foreach (var item in xt) foreach (var item in xt)
{ {
try try
@ -878,7 +878,7 @@ namespace Admin.Core.Service
/// <param name="plan"></param> /// <param name="plan"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public bool SaveRecipe(Pmt_recipe recipeList, List<Pmt_weigh> pmt_weighList, RT_plan plan, List<Hw_WareHouse_Sub> sub) public bool SaveRecipe(Pmt_recipe recipeList, List<Pmt_weigh> pmt_weighList, RT_plan plan, List<Hw_WareHouse_Sub> sub)
{ {
try try
{ {
@ -895,14 +895,14 @@ namespace Admin.Core.Service
var iflag2 = _pmtWeighRepository.Add(pmt_weighList); var iflag2 = _pmtWeighRepository.Add(pmt_weighList);
if (iflag2 < 1) if (iflag2 < 1)
throw new Exception("保存配方物料失败!"); throw new Exception("保存配方物料失败!");
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
{ {
return false; return false;
} }
} }
public bool SaveXLRecipe(xl_recipe recipeList, List<xl_weigh> pmt_weighList, xl_plan plan, List<Hw_WareHouse_Sub> sub) public bool SaveXLRecipe(xl_recipe recipeList, List<xl_weigh> pmt_weighList, xl_plan plan, List<Hw_WareHouse_Sub> sub)
{ {
@ -954,7 +954,7 @@ namespace Admin.Core.Service
{ {
Hw_Warehouse wh = await _wareHouse.FirstAsync(d => d.BarCode == code); Hw_Warehouse wh = await _wareHouse.FirstAsync(d => d.BarCode == code);
if (wh == null) return null; if (wh == null) return null;
var sub = await _wareHouse_Sub.QueryAsync(d => d.MainId == wh.ID&& d.PId== planId&&(d.MaterialType.Contains("整包")|| d.MaterialType.Contains("尾料"))); var sub = await _wareHouse_Sub.QueryAsync(d => d.MainId == wh.ID && d.PId == planId && (d.MaterialType.Contains("整包") || d.MaterialType.Contains("尾料")));
if (sub.Count == 0) return null; if (sub.Count == 0) return null;
sub.ForEach(sub => sub.ForEach(sub =>
{ {
@ -968,18 +968,18 @@ namespace Admin.Core.Service
view.MaterialName = sub.MaterialName; view.MaterialName = sub.MaterialName;
view.BinId = sub.BinId; view.BinId = sub.BinId;
view.MaterialType = sub.MaterialType; view.MaterialType = sub.MaterialType;
view.SetWeight = sub.SetWeight- sub.Tare;//设置重量减去皮重 view.SetWeight = sub.SetWeight - sub.Tare;//设置重量减去皮重
view.SetError = sub.SetError; view.SetError = sub.SetError;
view.Tare = sub.Tare; view.Tare = sub.Tare;
list.Add(view); list.Add(view);
}); });
WarehouseView warehouseView = new WarehouseView() WarehouseView warehouseView = new WarehouseView()
{ {
ID = wh.ID, ID = wh.ID,
Name = wh.Name, Name = wh.Name,
BarCode = wh.BarCode, BarCode = wh.BarCode,
Children = list Children = list
}; };
return warehouseView; return warehouseView;
} }
@ -1068,8 +1068,8 @@ namespace Admin.Core.Service
} }
else else
{ {
log.Error(result.Message+",读取失败!"); log.Error(result.Message + ",读取失败!");
return WeightNo+"称,读取失败!"; return WeightNo + "称,读取失败!";
} }
//return WeightInfo; //return WeightInfo;
@ -1259,7 +1259,7 @@ namespace Admin.Core.Service
try try
{ {
log.Info("开始投料"); log.Info("开始投料");
#region 记录数据 #region 记录数据
//同时记录该扫码到数据库中 //同时记录该扫码到数据库中
wh = await _wareHouse.FirstAsync(d => d.BarCode == view.KCode); wh = await _wareHouse.FirstAsync(d => d.BarCode == view.KCode);
@ -1306,13 +1306,13 @@ namespace Admin.Core.Service
return false; return false;
} }
var s7 = PlcConnect.Instance; var s7 = PlcConnect.Instance;
var result = s7.Write(name,short.Parse(view.State.ToString()));//反应釜点位 var result = s7.Write(name, short.Parse(view.State.ToString()));//反应釜点位
log.Error($"反应釜开启点位状态:{result.IsSuccess},返回信息:{result.Message}"); log.Error($"反应釜开启点位状态:{result.IsSuccess},返回信息:{result.Message}");
if (result.IsSuccess) if (result.IsSuccess)
{ {
if (view.State == 1) if (view.State == 1)
{ {
foreach (var item in view.Child.Where(d=>d.MatType== "散装")) foreach (var item in view.Child.Where(d => d.MatType == "散装"))
{ {
} }
@ -1342,11 +1342,11 @@ namespace Admin.Core.Service
public async Task<List<string>> GetWarehousePlan(string code) public async Task<List<string>> GetWarehousePlan(string code)
{ {
Hw_Warehouse wh = await _wareHouse.FirstAsync(d=>d.BarCode== code.Trim()); Hw_Warehouse wh = await _wareHouse.FirstAsync(d => d.BarCode == code.Trim());
if (wh==null) return null; if (wh == null) return null;
var list = await _wareHouse_Sub.QueryAsync(d=>d.MainId== wh.ID); var list = await _wareHouse_Sub.QueryAsync(d => d.MainId == wh.ID);
var planList = (from d in list var planList = (from d in list
select d.PId).Distinct(); select d.PId).Distinct();
return planList.ToList(); return planList.ToList();
} }
#endregion #endregion

Loading…
Cancel
Save