CNCEC_SUBQHSE_WUHUAN/SGGL/WebAPI/Controllers/HSSE/TowerCraneController.cs

106 lines
4.5 KiB
C#
Raw Normal View History

2025-06-04 09:11:41 +08:00
using BLL;
using Model;
using Model.APIItem.HSSE;
using System;
2025-07-23 10:26:51 +08:00
using System.Collections.Generic;
using System.Data;
2025-06-04 09:11:41 +08:00
using System.Linq;
using System.Web.Http;
namespace WebAPI.Controllers
{
/// <summary>
/// 塔吊分信息
/// </summary>
public class TowerCraneController : ApiController
{
#region
/// <summary>
/// 根据类型获取图型数据
/// </summary>
/// <returns></returns>
[HttpPost]
public Model.ResponeData saveTowerCraneRecord([FromBody] TowerCraneRecordItem recordItem)
{
var responeData = new Model.ResponeData();
try
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var towerCrane = db.HSSE_TowerCrane.FirstOrDefault(x => x.TowerCraneCode == recordItem.Id);
if (towerCrane != null)
{
HSSE_TowerCraneRecord record = new HSSE_TowerCraneRecord();
record.TowerCraneRecordId = Guid.NewGuid().ToString();
record.TowerCraneId = towerCrane.TowerCraneId;
record.AlarmType = recordItem.AlarmType;
record.AmountHoist = recordItem.AmountHoist;
record.Camber = recordItem.Camber;
record.Height = recordItem.Height;
record.Hoist = recordItem.Hoist;
record.Moment = recordItem.Moment;
record.Range = recordItem.Range;
record.RotationAngle = recordItem.RotationAngle;
record.WindSpeed = recordItem.WindSpeed;
2025-07-23 10:26:51 +08:00
record.Hoist = recordItem.Hoist;
record.Date = DateTime.Now;
db.HSSE_TowerCraneRecord.InsertOnSubmit(record);
db.SubmitChanges();
2025-06-04 09:11:41 +08:00
2025-07-23 10:26:51 +08:00
if (!string.IsNullOrEmpty(record.AlarmType))
{
try
{
Dictionary<string, string> alarmMap = new Dictionary<string, string>();
2025-06-04 09:11:41 +08:00
2025-07-23 10:26:51 +08:00
alarmMap.Add("111", "重量预警");
alarmMap.Add("112", "重量报警");
alarmMap.Add("121", "风速预警");
alarmMap.Add("122", "风速报警");
alarmMap.Add("131", "内限位报警");
alarmMap.Add("132", "内限位预警");
alarmMap.Add("133", "外限位预警");
alarmMap.Add("134", "外限位报警");
alarmMap.Add("141", "倾角预警");
alarmMap.Add("142", "倾角报警");
alarmMap.Add("151", "上限位预警");
alarmMap.Add("152", "上限位报警");
alarmMap.Add("201", "障碍物碰撞报警");
alarmMap.Add("202", "塔机群碰撞报警");
2025-06-04 09:11:41 +08:00
2025-07-23 10:26:51 +08:00
var alarms = record.AlarmType.Replace("[", "").Replace("]", "").Split(',');
string res = "";
foreach (string alarm in alarms)
{
if (alarmMap.ContainsKey(alarm))
{
res += alarmMap[alarm] + ",";
}
}
res = res.TrimEnd(',');
var user = db.Project_ProjectUser.FirstOrDefault(x => x.ProjectId == towerCrane.ProjectId && x.UnitId == Const.UnitId_CWCEC && x.RoleName == "安全总监");
APICommonService.SendSubscribeMessage(user.UserId, "塔吊预警", towerCrane.TowerCraneName + ":" + res, string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
}
catch (Exception e)
{
}
}
2025-06-04 09:11:41 +08:00
}
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
}
}