修改钣金功能

main
liulb@mesnac.com 10 months ago
parent 477909a205
commit 701bd266f2

2
.gitignore vendored

@ -34,5 +34,3 @@ bld/
/*/obj/
/*/*/obj/
/.vs/Admin.Core/v17/.futdcache.v2
/Admin.Core.Repository/Repository_New/SysUserInfoRepository.cs
/Aucma.Core.SheetMetal/ViewModels/IndexPageViewModel.cs

@ -137,7 +137,7 @@ WHERE E.PRODUCTLINE_CODE = '{stationCode}' AND E.IS_FLAG = 0 ) T ORDER BY T.EXE
sql = sql.Replace("\r", "");
sql = sql.Replace("\n", "");
sql = sql.Replace("\t", "");
Task.Delay(3000);
await Task.Delay(3000);
return await Db.CopyNew().SqlQueryable<SheetMetaSendPlanInfoView>(sql).ToListAsync();
}
catch { return null; }

@ -0,0 +1,137 @@
using Admin.Core.Model;
using Admin.Core.IRepository;
using System.Threading.Tasks;
using Admin.Core.Model.ViewModels;
using Admin.Core.Model.Model_New;
using System.Collections.Generic;
using System;
using Microsoft.IdentityModel.Logging;
using System.Linq;
using SqlSugar;
namespace Admin.Core.Repository
{
/// <summary>
/// SysUserInfoRepository
/// </summary>
public class SysUserInfoRepository : BaseRepository<SysUserInfo>, ISysUserInfoRepository
{
public SysUserInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
{
}
public async Task<List<ProductInfoView>> GetStationData(string code)
{
string sql = @$"SELECT BP.PLANT_CODE PLANT_CODE, BP.PARENT_ID PRODUCT_LINE_CODE, BPS.PROCESS_CODE, BP.PRODUCT_LINE_CODE STATION_CODE
FROM BASE_PRODUCTLINE BP
LEFT JOIN BASE_PROCESS_STATION BPS ON BPS.PARENT_ID LIKE '%' || BP.PRODUCT_LINE_CODE || '%'
WHERE BP.PRODUCT_LINE_CODE = '{code}'";
return await Db.CopyNew().Ado.SqlQueryAsync<ProductInfoView>(sql);
}
#region 获取班组数据
/// <summary>
/// 获取班组数据
/// </summary>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public async Task<List<CurrentTeamTimeView>> GetTeamData()
{
string sql = "SELECT * FROM VIEW_CURRENT_TEAM_TIME";
return await Db.CopyNew().Ado.SqlQueryAsync<CurrentTeamTimeView>(sql);
}
#endregion
#region 获取班组数据
/// <summary>
/// 获取班组数据
/// </summary>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public async Task<List<ProductLineInfoView>> GetProductLineInfo(string productLineCode)
{
if (GetConnectionState() == false) return null;
string sql = @$"SELECT BP.PLANT_CODE PLANT_CODE, BP.PARENT_ID PRODUCT_LINE_CODE, BPS.PROCESS_CODE, BP.PRODUCT_LINE_CODE STATION_CODE FROM BASE_PRODUCTLINE BP
LEFT JOIN BASE_PROCESS_STATION BPS ON BPS.PARENT_ID LIKE '%' || BP.PRODUCT_LINE_CODE || '%' WHERE BP.PRODUCT_LINE_CODE = '{productLineCode}'";
return await Db.CopyNew().Ado.SqlQueryAsync<ProductLineInfoView>(sql);
}
#endregion
#region 获取钣金型号统计数据
/// <summary>
/// 获取班组数据
/// </summary>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public async Task<List<SheetMetalTypeDataView>> GetSheetMetalTypeData(string productLineCode)
{
string sql = @$" WITH CTT AS (SELECT MIN(START_TIME) START_TIME, MAX(END_TIME) END_TIME
FROM VIEW_CURRENT_TEAM_TIME)
SELECT FB.MATERIAL_CODE as MATERUALNAME,
SUM(CASE WHEN FB.BOX_TYPE = 1 THEN FB.OUTPUT_AMOUNT ELSE 0 END) FRONTPLATE_AMOUNT,
SUM(CASE WHEN FB.BOX_TYPE = 2 THEN FB.OUTPUT_AMOUNT ELSE 0 END) REARPANEL_AMOUNT
FROM VIEW_RECORD_FRONT_BACK_COMP FB
CROSS JOIN CTT
WHERE FB.RECORD_TIME >= CTT.START_TIME
AND FB.RECORD_TIME < CTT.END_TIME
GROUP BY FB.MATERIAL_CODE";
return await Db.CopyNew().Ado.SqlQueryAsync<SheetMetalTypeDataView>(sql);
}
#endregion
#region 小时统计
/// <summary>
/// 小时统计
/// </summary>
/// <param name="productLineCode">工位</param>
/// <returns></returns>
public async Task<List<SheetMetaHourDataView>> GetSheetMetaHourData(string productLineCode)
{
string sql = @$"SELECT CTT.HOUR_TIME,
SUM(CASE WHEN FB.BOX_TYPE = 1 THEN FB.OUTPUT_AMOUNT ELSE 0 END) FRONTPLATE_AMOUNT,
SUM(CASE WHEN FB.BOX_TYPE = 2 THEN FB.OUTPUT_AMOUNT ELSE 0 END) REARPANEL_AMOUNT
FROM VIEW_CURRENT_TEAM_TIME CTT
LEFT JOIN VIEW_RECORD_FRONT_BACK_COMP FB
ON FB.RECORD_TIME >= CTT.START_TIME AND FB.RECORD_TIME < CTT.END_TIME
GROUP BY CTT.HOUR_TIME
ORDER BY CTT.HOUR_TIME";
return await Db.CopyNew().Ado.SqlQueryAsync<SheetMetaHourDataView>(sql);
}
#endregion
#region 当前订单执行第一次数据采集时候更新SAP计划
/// <summary>
/// 当前订单执行第一次数据采集时候更新SAP计划
/// </summary>
public int UpdateSapPlan(string sapCode)
{
var parameters = new SugarParameter[]
{
new SugarParameter("@SAP_PLAN_CODE", sapCode)
};
string sql = "UPDATE PRODUCT_CALENDAR_INFO SET IS_SCHEDULING = 0 WHERE SAP_PLAN_CODE = @SAP_PLAN_CODE";
int affectedRows = Db.CopyNew().Ado.ExecuteCommand(sql, parameters);
return affectedRows;
}
#endregion
#region 统计夹具型号状态
/// <summary>
/// 统计夹具型号状态
/// </summary>
public async Task<List<ModeStatusView>> StatisticalModelStatus()
{
string sql = "select * from table (scada_xk_fp_01('') )";
return await Db.CopyNew().Ado.SqlQueryAsync<ModeStatusView>(sql);
}
#endregion
}
}

@ -21,14 +21,13 @@ namespace Aucma.Core.RunPlc
public async Task StartMelsecMcSeverAsync()
{
await StartMelsecMcPlcServer();
}
#region 心跳
public async Task StartMelsecPlcAsync()
{
await Task.Run(async () =>
{
System.Timers.Timer timer = new System.Timers.Timer(3000);
System.Timers.Timer timer = new System.Timers.Timer(5000);
timer.Elapsed += new System.Timers.ElapsedEventHandler(ExecMelsecMcHeartTask); //到达时间的时候执行事件;
timer.AutoReset = true;//设置是执行一次false还是一直执行(true)
timer.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它
@ -68,7 +67,7 @@ namespace Aucma.Core.RunPlc
var item = PlcHelper.melsecList.Where(c => c.Id == i).FirstOrDefault();
if (item == null) continue;
var test = item.plc.ReadInt16("D6050");
if (item.plc.Read("M100").Result)
if (item.plc.Read("D6050").Result)
{
item.IsConnect = true;
item.plc.IsConnected = true;
@ -80,8 +79,6 @@ namespace Aucma.Core.RunPlc
if (item.plc.IsConnected == false)
{
item.IsConnect = false;
//Console.WriteLine($"{item.EquipName}:PLC连接失败");
// System.GC.Collect();
bool r = item.plc.Connect(item.IP, item.Port);
if (r)
{
@ -95,6 +92,7 @@ namespace Aucma.Core.RunPlc
}
}
}
Thread.Sleep(5000);
}
await Task.CompletedTask;
}

@ -431,6 +431,7 @@ public class SheetMetalPlanTaskHandle
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}", "Red");
}
}
/// <summary>
/// 根据前板完成记录更新生产计划
/// </summary>

@ -27,6 +27,7 @@ namespace Aucma.Core.SheetMetal.Business
_smSyncModelServices = App.ServiceProvider.GetService<ISmSyncModelServices>();
}
#region 获取所有设置的钣金前板型号
/// <summary>
/// 获取所有设置的钣金前板型号
/// </summary>
@ -57,7 +58,11 @@ namespace Aucma.Core.SheetMetal.Business
{
//设置型号
mode = Encoding.ASCII.GetString(info.Skip(i * 10).Take(10).ToArray()).Replace("\0", "").Trim();
if (string.IsNullOrEmpty(mode)) return;
if (string.IsNullOrEmpty(mode))
{
j++;
continue;
}
if (smSyncModelList.Count == 0 || smSyncModelList == null)
{
SmSyncModel sm = new SmSyncModel();
@ -70,7 +75,7 @@ namespace Aucma.Core.SheetMetal.Business
}
else
{
var obj = smSyncModelList.First(d => d.SmProductId == j.ToString()&& d.Category=="0" );
var obj = smSyncModelList.First(d => d.SmProductId == j.ToString() && d.Category == "0");
if (obj == null)
{
SmSyncModel sm = new SmSyncModel();
@ -81,10 +86,14 @@ namespace Aucma.Core.SheetMetal.Business
addList.Add(sm);
}
if (string.IsNullOrEmpty(obj.SmModel) && string.IsNullOrEmpty(mode.Trim())) continue;
if (obj.SmModel.Equals(mode)) continue;
if (obj.SmModel.Equals(mode))
{
j++;
continue;
}
else
{
if (obj.SmModel.Equals(mode))
if (string.IsNullOrEmpty(obj.SmModel) || !obj.SmModel.Equals(mode))
{
obj.SmProductId = j.ToString();
obj.SmModel = mode;
@ -96,16 +105,20 @@ namespace Aucma.Core.SheetMetal.Business
}
Console.WriteLine($"型号{j}{mode}");
j++;
}
}
if (addList != null || addList.Count > 0) await _smSyncModelServices.AddAsync(addList);
if (updateList != null || updateList.Count > 0) await _smSyncModelServices.UpdateAsync(updateList);
if (addList != null && addList.Count > 0) await _smSyncModelServices.AddAsync(addList);
if (updateList != null && updateList.Count > 0) await _smSyncModelServices.UpdateAsync(updateList);
Console.WriteLine("===============采集结束===============");
}
}
#endregion
#region 获取所有设置的钣金后板型号
/// <summary>
/// 获取所有设置的钣金后板型号
/// </summary>
@ -135,7 +148,7 @@ namespace Aucma.Core.SheetMetal.Business
if (i % 2 == 0)
{
//设置型号
mode = Encoding.ASCII.GetString(info.Skip(i * 10).Take(10).ToArray()).Replace("\0","").Trim();
mode = Encoding.ASCII.GetString(info.Skip(i * 10).Take(10).ToArray()).Replace("\0", "").Trim();
if (smSyncModelList.Count == 0 || smSyncModelList == null)
{
@ -156,16 +169,12 @@ namespace Aucma.Core.SheetMetal.Business
sm.SmProductId = j.ToString();
sm.SmModel = mode.Trim();
sm.SyncTime = DateTime.Now;
sm.Category ="1";
sm.Category = "1";
addList.Add(sm);
}
else
{
if (string.IsNullOrEmpty(obj.SmModel))
{
obj.SmModel = mode;
}
if (string.IsNullOrEmpty(obj.SmModel) || !obj.SmModel.Equals(mode))
{
obj.SmProductId = j.ToString();
obj.SmModel = mode.Trim();
@ -187,6 +196,7 @@ namespace Aucma.Core.SheetMetal.Business
}
}
#endregion
}
}

File diff suppressed because it is too large Load Diff

@ -37,20 +37,6 @@ namespace Aucma.Core.SheetMetal.ViewModels
{
await RefreshTeamTime();//班组时间
});
//Task.Run(() =>
//{
// //_taskHandle.InitSendPlan();
// _taskHandle.InitSendBackPanelPlan();
//});
//Task.Run(() =>
//{
// _taskHandle.InitSendSidePanelPlan();
//});
//Task.Run( () =>
//{
// _taskHandle.UpdateComplatePlan();//更新计划数
//});
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 1); //间隔1秒

@ -189,10 +189,11 @@ namespace Aucma.Core.SheetMetal.ViewModels
try
{
List<int> tempList = new List<int>();
mesId = mesId.Substring(0, 6);
var list = _executePlanInfoServices.QueryAsync(d => d.TaskCode.Contains(mesId)).Result;
if (list.Count() == 0)
{
return mesId + "0001";
return mesId.Substring(0,6) + "0000000001";
}
foreach (var item in list)
{
@ -201,7 +202,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
tempList.Add(num);
}
string maxStr = (tempList.Max() + 1).ToString();
string taskCode = mesId+ maxStr.PadLeft(6, '0');
string taskCode = mesId+ maxStr.PadLeft(10, '0');
return taskCode;
}
catch

@ -110,7 +110,7 @@
"Enabled": false
},
"ScannerGun": {
"Enabled": true
"Enabled": false
},
"Plc": {
"Enabled": true
@ -133,7 +133,7 @@
"EquipName": "SidePanelPlc",
"PlcType": "Melsec",
"Enabled": true,
"IP": "127.0.0.1",//"10.10.91.1",
"IP": "10.10.91.1",
"Port": 5552
},
{
@ -141,7 +141,7 @@
"EquipName": "BackPanelPLC",
"PlcType": "Melsec",
"Enabled": true,
"IP": "127.0.0.1", //"10.10.91.6",
"IP": "10.10.91.1",
"Port": 5553
}
]

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save