303 lines
10 KiB
C#
303 lines
10 KiB
C#
using BLL;
|
||
using Model;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Linq;
|
||
using System.Threading.Tasks;
|
||
using System.Web.Http;
|
||
|
||
namespace WebAPI.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 五环IDP平台
|
||
/// </summary>
|
||
public class IDPController : ApiController
|
||
{
|
||
#region IDP系统项目设计图纸数据
|
||
|
||
/// <summary>
|
||
/// 每天夜间同步获取IDP系统项目设计图纸数据
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SynIDPDesignDrawingData()
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
var lst = DesignDrawingService.GetIDPDesignDrawingFile();
|
||
if (lst.Any())
|
||
{
|
||
List<string> dates = new List<string>();
|
||
dates.Add(DateTime.Now.ToString("yyyy-MM-dd"));
|
||
dates.Add(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"));
|
||
dates.Add(DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd"));
|
||
//string date = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
|
||
|
||
foreach (var date in dates)
|
||
{
|
||
IDPDataService.GetIDPProjectDesignDrawingData("", date);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
IDPDataService.GetIDPProjectDesignDrawingData();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.ToString();
|
||
}
|
||
return responeData;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取指定日期的IDP系统项目设计图纸数据【调试数据用】
|
||
/// </summary>
|
||
/// <param name="dates"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SynIDPDesignDrawingDataByDate([FromBody] List<string> dates)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
foreach (var date in dates)
|
||
{
|
||
if (!string.IsNullOrWhiteSpace(date))
|
||
{
|
||
//string date = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
|
||
IDPDataService.GetIDPProjectDesignDrawingData("", date);
|
||
}
|
||
else
|
||
{
|
||
IDPDataService.GetIDPProjectDesignDrawingData();
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.ToString();
|
||
}
|
||
return responeData;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 每天夜间获取OA系统项目设计图纸数据
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SynIDPOADesignDrawingData()
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.message = IDPDataService.GetIDPOADesignDrawingData();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.ToString();
|
||
}
|
||
return responeData;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 每天夜间接收OA系统项目设计图纸数据【2025.11.24弃用】
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SynOADesignDrawingData([FromBody] List<OADesignDrawingDataItem> items)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.message = IDPDataService.SaveDesignDrawingData(items);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.ToString();
|
||
}
|
||
return responeData;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 每天夜间同步获取OA系统项目设计图纸数据蓝图寄出信息
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SynOADesignDrawingDataBlueprintInfo()
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.message = IDPDataService.GetDesignDrawingDataBlueprintInfo();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.ToString();
|
||
}
|
||
return responeData;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 每天夜间同步获取OA系统项目设计图纸数据蓝图打印信息
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ResponeData SynOADesignDrawingDataPrintInfo()
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.message = IDPDataService.GetDesignDrawingDataPrintInfo();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.ToString();
|
||
}
|
||
return responeData;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region IDP系统项目开车数据
|
||
|
||
/// <summary>
|
||
/// 获取IDP系统项目开车数据【测试用,接口不上线】
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ReturnData SynIDPPreRunData()
|
||
{
|
||
var responeData = new Model.ReturnData();
|
||
responeData.time = DateTime.Now.ToString();
|
||
try
|
||
{
|
||
var session = IDPDataService.GetAuthenticationSession();
|
||
//ErrLogInfo.WriteLog($"Session——name:{session.name};value:{session.value}");
|
||
|
||
string pipingMsg = IDPDataService.GetIDPProjectPreRunDataPiping(session, "32d0bca0-7693-4bd6-813d-6ee174ba29d3");
|
||
string equipmentMsg = IDPDataService.GetIDPProjectPreRunDataEquipment(session, "32d0bca0-7693-4bd6-813d-6ee174ba29d3");
|
||
string instrumentationMsg = IDPDataService.GetIDPProjectPreRunDataInstrumentation(session, "32d0bca0-7693-4bd6-813d-6ee174ba29d3");
|
||
responeData.message = $"管道一览表:{pipingMsg};设备一览表:{equipmentMsg};索引表:{instrumentationMsg}";
|
||
//responeData.message = $"管道一览表:{pipingMsg};设备一览表:{equipmentMsg};";
|
||
//responeData.message = $"索引表:{instrumentationMsg}";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.ToString();
|
||
}
|
||
return responeData;
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
|
||
#region 统计考勤人员考勤数据
|
||
|
||
/// <summary>
|
||
/// 统计考勤人员考勤数据
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Model.ReturnData SynSitePersonCheckingStatistics()
|
||
{
|
||
var responeData = new Model.ReturnData();
|
||
responeData.time = DateTime.Now.ToString();
|
||
using (SqlConnection Connection = new SqlConnection(Funs.ConnString))
|
||
{
|
||
try
|
||
{
|
||
string sql = @"
|
||
TRUNCATE TABLE dbo.SitePerson_Checking_Statistics;
|
||
|
||
INSERT INTO dbo.SitePerson_Checking_Statistics (
|
||
ProjectId,
|
||
UnitId,
|
||
UnitName,
|
||
WorkAreaId,
|
||
WorkAreaName,
|
||
WorkPostId,
|
||
WorkPostName,
|
||
IntoOutTime,
|
||
num
|
||
)
|
||
SELECT
|
||
a.ProjectId,
|
||
b.UnitId,
|
||
b.UnitName,
|
||
b.WorkAreaId,
|
||
b.WorkAreaName,
|
||
p.WorkPostId,
|
||
w.WorkPostName,
|
||
CAST(b.IntoOutTime AS DATE) AS IntoOutTime,
|
||
COUNT(1) AS num
|
||
FROM (
|
||
SELECT
|
||
PersonId,
|
||
CAST(IntoOutTime AS DATE) AS IntoOutTime,
|
||
MAX(CheckingId) AS MaxCheckingId,
|
||
ProjectId
|
||
FROM SitePerson_Checking
|
||
GROUP BY PersonId, CAST(IntoOutTime AS DATE), ProjectId
|
||
) a
|
||
JOIN SitePerson_Checking b ON a.MaxCheckingId = b.CheckingId
|
||
LEFT JOIN SitePerson_Person p ON a.PersonId = p.PersonId
|
||
LEFT JOIN Base_WorkPost w ON p.WorkPostId = w.WorkPostId
|
||
LEFT JOIN Base_Project bp ON a.ProjectId = bp.ProjectId
|
||
where bp.ProjectState='1'
|
||
GROUP BY
|
||
a.ProjectId,
|
||
b.UnitId,
|
||
b.UnitName,
|
||
b.WorkAreaId,
|
||
b.WorkAreaName,
|
||
p.WorkPostId,
|
||
w.WorkPostName,
|
||
CAST(b.IntoOutTime AS DATE);";
|
||
|
||
Connection.Open();
|
||
SqlCommand command = new SqlCommand(sql, Connection)
|
||
{
|
||
CommandTimeout = 0,
|
||
CommandType = CommandType.Text
|
||
};
|
||
int result = command.ExecuteNonQuery();
|
||
responeData.message = $"执行成功,共插入 {result} 条记录";
|
||
}
|
||
catch (SqlException sqlEx)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = $"数据库操作失败: {sqlEx.Message}";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = $"执行失败: {ex.Message}";
|
||
}
|
||
finally
|
||
{
|
||
Connection.Close();
|
||
}
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
}
|
||
} |