将指定文件压缩为Zip文件,将指定目录压缩为Zip文件
Dictionary<string, List<string>> m_entityDataList = new Dictionary<string, List<string>>();
private string m_className = MethodBase.GetCurrentMethod().DeclaringType.Name;
public static string orgid = "08dac781-f3a0-42c9-8675-a3fc4cc9fa23";
#region 将指定文件压缩为Zip文件,将指定目录压缩为Zip文件
/// <summary>
/// 将指定文件压缩为Zip文件
/// </summary>
/// <param name="filePath">文件地址 D:/1.txt </param>
/// <param name="zipPath">zip地址 D:/1.zip </param>
public static void CompressFileZip(string filePath, string zipPath)
{
try
{
FileInfo fileInfo = new FileInfo(filePath);
string dirPath = fileInfo.DirectoryName?.Replace("\\", "/") + "/";
string tempPath = dirPath + Guid.NewGuid() + "_temp/";
if (!Directory.Exists(tempPath))
{
Directory.CreateDirectory(tempPath);
}
fileInfo.CopyTo(tempPath + fileInfo.Name);
CompressDirectoryZip(tempPath, zipPath);
DirectoryInfo directory = new DirectoryInfo(zipPath);
if (directory.Exists)
{
//将文件夹属性设置为普通,如:只读文件夹设置为普通
directory.Attributes = FileAttributes.Normal;
directory.Delete(true);
}
}
catch (Exception ex)
{
throw;
}
}
/// <summary>
/// 将指定目录压缩为Zip文件
/// </summary>
/// <param name="folderPath">文件夹地址 D:/1/ </param>
/// <param name="zipPath">zip地址 D:/1.zip </param>
public static void CompressDirectoryZip(string folderPath, string zipPath)
{
try
{
DirectoryInfo directoryInfo = new DirectoryInfo((zipPath));
if (directoryInfo.Parent != null)
{
directoryInfo = directoryInfo.Parent;
}
if (!directoryInfo.Exists)
{
directoryInfo.Create();
}
ZipFile.CreateFromDirectory(folderPath, zipPath, CompressionLevel.Optimal, false);
DirectoryInfo directoryInfo1 = new DirectoryInfo((folderPath));
directoryInfo1.Delete(true);
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region 巡检任务执行过程.
/// <summary>
/// 巡检任务执行过程.
/// </summary>
[HttpGet("GetXunJianTask")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetXunJianTask()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
string logPath1 = @"C:\Zip_json\XunJianTask\";
string remotePath = "/520170011";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = 0;
EntityConverter m_tolist = new EntityConverter();
string sql = @"SELECT
h.RECORD_ID as ID,
CAST(h.org_code as char) as COMPANY_CODE,
a.CHECKTASK_ID as TASK_ID,
h.delete_mark as IS_DELETED,
m.F_RealName as CREATED_BY,
n.F_RealName as MODIFIED_BY ,
h.CREATE_TIME as CREATED_DATE ,
h.UPDATE_TIME as MODIFIED_DATE,
c.RISK_UNIT_ID
FROM Hidden_ScreenRecord h
left JOIN Hidden_ScreenTaskInfor a on a.CHECKTASK_ID=h.CHECK_TASK_ID
left JOIN Security_Measures b on a.RISK_MEASURE_ID=b.RISKMEASURE_ID
left JOIN Safety_RiskEvent c on b.RISK_EVENT_ID=c.RISKEVENT_ID
left join base_user m on h.create_by = m.F_Id
left join base_user n on h.update_by = n.F_Id
WHERE h.OrganizeId='" + orgid + "' ";
var dt = _sqlSugarClient.Ado.GetDataTable(sql);
List<XunJianTaskModel> list = m_tolist.ConvertToList<XunJianTaskModel>(dt);
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
foreach (var item in list)
{
item.TASK_OPERATION = "0";
item.OPERATION_TIME = item.CREATED_DATE.ToString("yyyy-MM-dd HH:mm:ss");
item.EXECUTOR = item.CREATED_BY;
item.MODIFIED_BY= item.MODIFIED_BY == null ? item.CREATED_BY: item.MODIFIED_BY;
item.MODIFIED_DATE = item.MODIFIED_DATE == null ? DateTime.Now : item.MODIFIED_DATE;
}
var obj = new
{
datas = list
};
var n1 = obj.datas;
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath1))
Directory.CreateDirectory(logPath1);
////将采集数据写入JSON文件
string jsonfile = logPath1 + COMPANY_CODE + "_XJRWZXGC_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath1 + COMPANY_CODE + "_XJRWZXGC_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_XJRWZXGC_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
public class XunJianTaskModel
{
public string ID { get; set; }
public string COMPANY_CODE { get; set; }
public string TASK_ID { get; set; }
public string RISK_UNIT_ID { get; set; }
public string TASK_OPERATION { get; set; }
public string OPERATION_TIME { get; set; }
public string EXECUTOR { get; set; }
public string OPERATION_REASON { get; set; }
public string IS_DELETED { get; set; }
public string CREATED_BY { get; set; }
public DateTime CREATED_DATE { get; set; }
public string MODIFIED_BY { get; set; }
public DateTime? MODIFIED_DATE { get; set; }
}
#endregion
#region 巡检管控记录.
/// <summary>
/// 巡检管控记录.
/// </summary>
/// <returns></returns>
[HttpGet("GetXunJianRecord")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetXunJianRecord()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
string logPath1 = @"C:\Zip_json\XunJianRecord\";
string remotePath = "/520170011";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = 0;
// var lists = _sqlSugarClient.Queryable<HiddenScreenrecordEntity>()
//.LeftJoin<HiddenScreentaskinforEntity>((a, it) => a.CheckTaskId == it.ChecktaskId)
//.LeftJoin<SecurityMeasuresEntity>((a, it, cus) => it.RiskMeasureId == cus.RiskmeasureId)
//.LeftJoin<SafetyRiskeventEntity>((a, it, cus, saft) => cus.RiskEventId == saft.RiskeventId)
//.LeftJoin<SecurityUnitEntity>((a, it, cus, saft, secu) => saft.RiskUnitId == secu.RiskunitId)
//.Where(a => a.OrganizeId.Equals(orgid))
//.Select((a, it, cus, saft, secu) => new XunJianRecordModel
//{
// ID = a.RecordId,
// COMPANY_CODE = it.OrgCode.ToString(),
// PATROL_RISK_UNIT_ID = secu.RiskunitId,
// CONTROL_MEASURES_ID = it.RiskMeasureId,
// ACTUAL_START_TIME = it.InvestigationDate.Value.ToString("yyyy-MM-dd HH:mm:ss"),
// CHECK_CONTENT = it.TroubleshootContent,
// RESULT = it.CheckStatus,
// IS_DELETED = a.DeleteMark.ToString(),
// CREATED_BY = SqlFunc.Subqueryable<UserEntity>().Where(a => a.Id.Equals(it.CreateBy)).Select(a => a.RealName),
// CREATED_DATE = a.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
// MODIFIED_BY = a.UpdateBy,
// MODIFIED_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
//}).ToSqlString();
// var n3 = lists;
var list = _sqlSugarClient.Queryable<HiddenScreenrecordEntity>()
.LeftJoin<HiddenScreentaskinforEntity>((a, it) => a.CheckTaskId == it.ChecktaskId)
.LeftJoin<SecurityMeasuresEntity>((a, it, cus) => it.RiskMeasureId == cus.RiskmeasureId)
.LeftJoin<SafetyRiskeventEntity>((a, it, cus, saft) => cus.RiskEventId == saft.RiskeventId)
.LeftJoin<SecurityUnitEntity>((a, it, cus, saft, secu) => saft.RiskUnitId == secu.RiskunitId)
.Where(a => a.OrganizeId.Equals(orgid))
.Select((a, it, cus, saft, secu) => new XunJianRecordModel
{
ID = a.RecordId,
COMPANY_CODE = it.OrgCode.ToString(),
PATROL_RISK_UNIT_ID = a.RecordId,
CONTROL_MEASURES_ID = it.RiskMeasureId,
ACTUAL_START_TIME = it.InvestigationDate.Value.ToString("yyyy-MM-dd HH:mm:ss"),
CHECK_CONTENT = it.TroubleshootContent,
RESULT = it.CheckStatus,
IS_DELETED = a.DeleteMark.ToString(),
CREATED_BY = SqlFunc.Subqueryable<UserEntity>().Where(a => a.Id.Equals(it.CreateBy)).Select(a => a.RealName),
CREATED_DATE = a.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
MODIFIED_BY = a.UpdateBy,
MODIFIED_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
}).ToList();
await _sqlSugarClient.ThenMapperAsync(list, async item =>
{
if (string.IsNullOrWhiteSpace(item.MODIFIED_BY))
{
item.MODIFIED_BY = item.CREATED_BY;
}
else
{
item.MODIFIED_BY = _sqlSugarClient.Queryable<UserEntity>().Where(it => item.MODIFIED_BY.Equals(it.Id)).Select(a => a.RealName).First();
}
});
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
var obj = new
{
datas = list
};
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath1))
Directory.CreateDirectory(logPath1);
////将采集数据写入JSON文件
string jsonfile = logPath1 + COMPANY_CODE + "_XJGKJL_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath1 + COMPANY_CODE + "_XJGKJL_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_XJGKJL_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
/// <summary>
/// 巡检管控记录.
/// </summary>
public class XunJianRecordModel
{
public string ID { get; set; }
public string COMPANY_CODE { get; set; }
public string PATROL_RISK_UNIT_ID { get; set; }
public string CONTROL_MEASURES_ID { get; set; }
public string ACTUAL_START_TIME { get; set; }
public string CHECK_CONTENT { get; set; }
public string RESULT { get; set; }
public string IS_DELETED { get; set; }
public string CREATED_BY { get; set; }
public string CREATED_DATE { get; set; }
public string MODIFIED_BY { get; set; }
public string MODIFIED_DATE { get; set; }
}
#endregion
#region 安全风险分析单元+安全风险分析对象数据接口
/// <summary>
/// 安全风险分析单元+对象数据接口.
/// </summary>
[HttpGet("GetFxUnitAndFxdx")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetFxUnitAndFxdx()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = -1;
EntityConverter m_tolist = new EntityConverter();
//=============风险对象
string sql = @"SELECT
h.RISKUNIT_ID as ID,
CONVERT(h.org_code,CHAR) as COMPANY_CODE,
h.HAZARD_CODE as RISK_OBJECT_CODE ,
h.Unit_objectName as RISK_OBJECT_NAME,
h.HAZARD_ISIMPORTANT as IS_MAJOR_HAZARD,
h.RISK_CLASS as RANK,
c.F_FullName as RESPONSIBLE_DEPARTMENT,
b.F_RealName as RESPONSIBLE_PERSON,
h.DELETE_MARK as IS_DELETED,
d.F_RealName as CREATED_BY,
h.create_time as CREATED_DATE,
e.F_RealName as MODIFIED_BY,
h.update_time as MODIFIED_DATE
FROM security_unit as h left
join base_user b on h.HAZARD_LIABLE_PERSON = b.F_Id left
join base_user d on h.create_by = d.F_Id left
join base_user e on h.update_by = e.F_Id left
join base_organize c on h.HAZARD_DEP = c.F_Id
WHERE h.company='" + orgid + "' ";
string logPath1 = @"C:\Zip_json\Security_object\";
string remotePath = "/520170011";
DataTable dt = _sqlSugarClient.Ado.GetDataTable(sql);
List<Security_object> list = m_tolist.ConvertToList<Security_object>(dt);
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
foreach (var item in list)
{
item.RISK_OBJECT_TYPE = "02";
item.REMARK = "";
item.CREATED_DATE = Convert.ToDateTime(item.CREATED_DATE.ToString("yyyy-MM-dd HH:mm:ss"));
item.MODIFIED_DATE = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
var obj = new
{
datas = list
};
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath1))
Directory.CreateDirectory(logPath1);
////将采集数据写入JSON文件
string jsonfile = logPath1 + COMPANY_CODE + "_FXDX_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath1 + COMPANY_CODE + "_FXDX_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_FXDX_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
//======================风险单元
string sql2 = @"SELECT
h.RISKUNIT_ID as ID,
CONVERT(h.org_code,CHAR) as COMPANY_CODE,
h.HAZARD_CODE as RISK_OBJECT_CODE,
h.RISK_UNIT_NAME as RISK_UNIT_NAME,
c.F_FullName as RESPONSIBLE_DEPARTMENT,
b.F_RealName as RESPONSIBLE_PERSON,
h.RISK_CLASS as RISK_LEVEL,
h.DELETE_MARK as IS_DELETED,
d.F_RealName as CREATED_BY,
h.create_time as CREATED_DATE,
e.F_RealName as MODIFIED_BY,
h.update_time as MODIFIED_DATE
FROM security_unit as h left
join base_user b on h.HAZARD_LIABLE_PERSON = b.F_Id left
join base_user d on h.create_by = d.F_Id left
join base_user e on h.update_by = e.F_Id left
join base_organize c on h.HAZARD_DEP = c.F_Id
WHERE h.company='" + orgid + "'";
string logPath2 = @"C:\Zip_json\Security_unit\";
string remotePath1 = "/520170011";
DataTable dt1 = _sqlSugarClient.Ado.GetDataTable(sql2);
List<Security_Unit> list1 = m_tolist.ConvertToList<Security_Unit>(dt1);
if (list1.Count == 0)
return state;
string strDate1 = DateTime.Now.ToString("yyyyMMddHHmmss");
foreach (var item in list1)
{
item.RISK_UNIT_TYPE = "01";
item.HIERARCHICAL_MODEL = "001";
item.CREATED_DATE = Convert.ToDateTime(item.CREATED_DATE.ToString("yyyy-MM-dd HH:mm:ss"));
item.MODIFIED_DATE = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
if(item.RISK_LEVEL =="1" )
{
item.RISK_LEVEL = "004";
}
if (item.RISK_LEVEL == "2")
{
item.RISK_LEVEL = "003";
}
if (item.RISK_LEVEL == "3")
{
item.RISK_LEVEL = "002";
}
if (item.RISK_LEVEL == "4")
{
item.RISK_LEVEL = "001";
}
if (item.RISK_LEVEL == "5")
{
item.RISK_LEVEL = "001";
}
}
var obj1 = new
{
datas = list1
};
//IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson1 = JsonConvert.SerializeObject(obj1, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath2))
Directory.CreateDirectory(logPath2);
////将采集数据写入JSON文件
string jsonfile = logPath2 + COMPANY_CODE + "_FXDY_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson1);
sw.Dispose();
fs.Close();
string zippath = logPath2 + COMPANY_CODE + "_FXDY_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath1 = remotePath1 + "/" + COMPANY_CODE + "_FXDY_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath1);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
public class Security_object
{
public string ID { get; set; }
public string RISK_OBJECT_CODE { get; set; }
public string RESPONSIBLE_DEPARTMENT { get; set; }
public string RESPONSIBLE_PERSON { get; set; }
public string RISK_OBJECT_NAME { get; set; }
public string RISK_OBJECT_TYPE { get; set; }
public string MODIFIED_BY { get; set; }
public DateTime MODIFIED_DATE { get; set; }
public DateTime CREATED_DATE { get; set; }
public string CREATED_BY { get; set; }
public string COMPANY_CODE { get; set; }
public string IS_DELETED { get; set; }
public string IS_MAJOR_HAZARD { get; set; }
public string RANK { get; set; }
public string REMARK { get; set; }
}
public class Security_Unit
{
public string ID { get; set; }
public string RISK_OBJECT_CODE { get; set; }
public string RESPONSIBLE_DEPARTMENT { get; set; }
public string RESPONSIBLE_PERSON { get; set; }
public string RISK_UNIT_NAME { get; set; }
public string RISK_UNIT_TYPE { get; set; }
public string MODIFIED_BY { get; set; }
public DateTime MODIFIED_DATE { get; set; }
public DateTime CREATED_DATE { get; set; }
public string CREATED_BY { get; set; }
public string COMPANY_CODE { get; set; }
public string IS_DELETED { get; set; }
public string RISK_LEVEL { get; set; }
public string HIERARCHICAL_MODEL { get; set; }
}
#endregion
#region 企业安全风险空间分布图数据接口
/// <summary>
/// 企业安全风险空间分布图数据接口.
/// </summary>
/// <returns></returns>
[HttpGet("GetSecurity_RiskM")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetSecurity_RiskM()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
string remotePath = "/520170011";
string logPath = @"C:\Zip_json\Security_RiskM\";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = -1;
EntityConverter m_tolist = new EntityConverter();
string sql = @"select ID, IMG, CONVERT(org_code,CHAR) COMPANY_CODE,
delete_mark IS_DELETED,
b.F_RealName CREATED_BY,
c.F_RealName MODIFIED_BY,
create_time CREATED_DATE,
update_time MODIFIED_DATE
from Security_Risk h left
join base_user b on h.create_by = b.F_Id left
join base_user c on h.update_by = c.F_Id
WHERE h.COMPANY_CODE ='" + orgid+"' ";
DataTable dt = _sqlSugarClient.Ado.GetDataTable(sql);
List<Security_Risk> list = m_tolist.ConvertToList<Security_Risk>(dt);
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
foreach (var item in list)
{
item.COMPANY_CODE = COMPANY_CODE;
item.MODIFIED_DATE = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
var obj = new
{
datas = list
};
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath))
Directory.CreateDirectory(logPath);
////将采集数据写入JSON文件
string jsonfile = logPath + COMPANY_CODE + "_FXFBT_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath + COMPANY_CODE + "_FXFBT_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_FXFBT_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
public class Security_Risk
{
public string ID { get; set; }
public string IMG { get; set; }
public DateTime CREATED_DATE{ get; set; }
public string CREATED_BY { get; set; }
public DateTime MODIFIED_DATE { get; set; }
public string MODIFIED_BY { get; set; }
public string IS_DELETED { get; set; }
public string COMPANY_CODE { get; set; }
}
#endregion
#region 安全风险管控措施数据接口
/// <summary>
/// 安全风险管控措施数据接口.
/// </summary>
/// <returns></returns>
[HttpGet("GetAqFxgkchushi")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetAqFxgkchushi()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
string logPath1 = @"C:\Zip_json\Security_MeasuresM\";
string remotePath = "/520170011";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = -1;
EntityConverter m_tolist = new EntityConverter();
string sql = @"select
h.RISKMEASURE_ID as ID,
CAST(h.org_code as char) as COMPANY_CODE,
h.RISK_EVENT_ID ,
d.RISK_EVENT_NAME as RISK_HARM,
h.DATA_SRC,
h.RISK_MEASURE_DESC as CONTROL_MEASURES,
h.CLASSIFY1,
h.CLASSIFY2,
h.CLASSIFY3,
h.TROUBLESHOOT_CONTENT as DANGER_CHECK_CONTENT,
h.delete_mark as IS_DELETED,
b.F_RealName as CREATED_BY,
c.F_RealName as MODIFIED_BY,
h.CREATE_TIME as CREATED_DATE,
h.UPDATE_TIME as MODIFIED_DATE
from Security_Measures h left
join base_user b on h.create_by = b.F_Id left
join base_user c on h.update_by = c.F_Id left
join safety_riskevent d on h.RISK_EVENT_ID=d.RISKEVENT_ID
WHERE h.COMPANY_CODE='08dac781-f3a0-42c9-8675-a3fc4cc9fa23' ";
DataTable dt = _sqlSugarClient.Ado.GetDataTable(sql);
List<Security_Measures> list = m_tolist.ConvertToList<Security_Measures>(dt);
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
foreach (var item in list)
{
item.IDENTIFY_RANGE = "001";
item.CREATED_DATE= Convert.ToDateTime(item.CREATED_DATE.ToString("yyyy-MM-dd HH:mm:ss"));
item.MODIFIED_DATE = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
var obj = new
{
datas = list
};
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath1))
Directory.CreateDirectory(logPath1);
////将采集数据写入JSON文件
string jsonfile = logPath1 + COMPANY_CODE + "_FXGKCS_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath1 + COMPANY_CODE + "_FXGKCS_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_FXGKCS_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
public class Security_Measures
{
public string ID { get; set; }
public string RISK_EVENT_ID { get; set; }
public string COMPANY_CODE { get; set; }
public string CLASSIFY1 { get; set; }
public string CLASSIFY2 { get; set; }
public string CLASSIFY3 { get; set; }
public string DANGER_CHECK_CONTENT { get; set; }
public string RISK_HARM { get; set; }
public string CONTROL_MEASURES { get; set; }
public string DATA_SRC { get; set; }
public string IS_DELETED { get; set; }
public string IDENTIFY_RANGE { get; set; }
public string CREATED_BY { get; set; }
public string MODIFIED_BY { get; set; }
public DateTime CREATED_DATE { get; set; }
public DateTime MODIFIED_DATE { get; set; }
}
#endregion
#region 安全风险事件数据接口.
/// <summary>
/// 安全风险事件数据接口.
/// </summary>
/// <returns></returns>
[HttpGet("GetAqFxsj")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetAqFxsj()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
string logPath1 = @"C:\Zip_json\Safety_RiskEventM\";
string remotePath = "/520170011";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = 0;
EntityConverter m_tolist = new EntityConverter();
string sql = @"SELECT
h.RISKEVENT_ID as ID,
CONVERT(h.org_code,CHAR) COMPANY_CODE,
h.RISK_UNIT_ID ,
h.RISK_EVENT_NAME ,
h.delete_mark as IS_DELETED,
b.F_RealName as CREATED_BY,
c.F_RealName as MODIFIED_BY,
h.CREATE_TIME as CREATED_DATE ,
h.UPDATE_TIME as MODIFIED_DATE
FROM Safety_RiskEvent h left
join base_user b on h.create_by = b.F_Id left
join base_user c on h.update_by = c.F_Id
WHERE h.OrganizeId='08dac781-f3a0-42c9-8675-a3fc4cc9fa23' ";
DataTable dt = _sqlSugarClient.Ado.GetDataTable(sql);
List<Safety_RiskEvent> list = m_tolist.ConvertToList<Safety_RiskEvent>(dt);
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
foreach (var item in list)
{
item.RISK_EVENT_CODE = "005,008,009";
item.CREATED_DATE = Convert.ToDateTime(item.CREATED_DATE.ToString("yyyy-MM-dd HH:mm:ss"));
item.MODIFIED_DATE = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
var obj = new
{
datas = list
};
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath1))
Directory.CreateDirectory(logPath1);
////将采集数据写入JSON文件
string jsonfile = logPath1 + COMPANY_CODE + "_FXSJ_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate,FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath1 + COMPANY_CODE + "_FXSJ_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_FXSJ_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
public class Safety_RiskEvent
{
public string ID { get; set; }
public string RISK_UNIT_ID { get; set; }
public string RISK_EVENT_NAME { get; set; }
public string IS_DELETED { get; set; }
public string COMPANY_CODE { get; set; }
public string RISK_EVENT_CODE { get; set; }
public string CREATED_BY { get; set; }
public string MODIFIED_BY { get; set; }
public DateTime CREATED_DATE { get; set; }
public DateTime MODIFIED_DATE { get; set; }
}
#endregion
#region 巡检任务、巡检分析单元信息.
/// <summary>
/// 巡检任务、巡检分析单元信息.
/// </summary>
/// <returns></returns>
[HttpGet("GetXjTaskAndXjfxdy")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetXjTaskAndXjfxdy()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
string remotePath = "/520170011";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = -1;
EntityConverter m_tolist = new EntityConverter();
///////////////==========================================================巡检任务===========================================
string sql = @"select
h.RECORD_ID as ID,
CONVERT(h.org_code,CHAR) as COMPANY_CODE,
i.TROUBLESHOOT_CONTENT as TASK_NAME,
h.CHECK_CYCLE as PATROL_CYCLE,
h.CHECK_CYCLE_UNIT as PATROL_CYCLE_UNIT,
h.TaskStartTime as PLAN_START_TIME,
h.TaskEndTime as PLAN_END_TIME,
j.F_RealName as EXECUTOR,
h.TaskStartTime as ACTUAL_START_TIME,
h.TaskEndTime as ACTUAL_END_TIME,
h.CHECK_STATUS as TASK_STATUS,
h.DELETE_MARK as IS_DELETED,
h.CREATE_TIME as CREATED_DATE ,
k.F_RealName as CREATED_BY,
h.UPDATE_TIME as MODIFIED_DATE,
l.F_RealName as MODIFIED_BY
from hidden_screenrecord h left
join hidden_screentaskinfor i on h.CHECK_TASK_ID=i.CHECKTASK_ID left
join base_user j on h.CheckBy = j.F_Id left
join base_user k on h.CREATE_BY = k.F_Id left
join base_user l on h.UPDATE_BY = l.F_Id
WHERE h.OrganizeId='08dac781-f3a0-42c9-8675-a3fc4cc9fa23' and h.CHECK_CYCLE_UNIT !='年'";
string logPath1 = @"C:\Zip_json\Hidden_ScreenTaskInforM\";
DataTable dt = _sqlSugarClient.Ado.GetDataTable(sql);
List<Hidden_ScreenTaskInfor> list = m_tolist.ConvertToList<Hidden_ScreenTaskInfor>(dt);
var n1 = list;
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
foreach (var item in list)
{
item.EXECUTOR = item.CREATED_BY;
item.TASK_STATUS = "2";
item.NO_ADVANCE = 0;
item.NO_ADVANCE_UNIT = "分钟";
item.NO_POSTPONE = 0;
item.NO_POSTPONE_UNIT = "分钟";
item.IS_CQ = "0";
item.CREATED_DATE = Convert.ToDateTime(item.CREATED_DATE.ToString("yyyy-MM-dd HH:mm:ss"));
item.MODIFIED_BY = item.CREATED_BY;
item.MODIFIED_DATE = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
var obj = new
{
datas = list
};
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath1))
Directory.CreateDirectory(logPath1);
////将采集数据写入JSON文件
string jsonfile = logPath1 + COMPANY_CODE + "_XJRW_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath1 + COMPANY_CODE + "_XJRW_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_XJRW_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
///////////////==========================================================巡检分析单元信息===========================================
string sql1 = @"select
h.RECORD_ID as ID,
CONVERT(h.org_code,CHAR) as COMPANY_CODE,
d.RISKUNIT_ID as RISK_UNIT_ID,
d.RISK_UNIT_NAME as RISK_UNIT_NAME,
h.TaskStartTime as PLAN_START_TIME,
h.TaskEndTime as PLAN_END_TIME,
h.DELETE_MARK as IS_DELETED,
h.CREATE_TIME as CREATED_DATE,
k.F_RealName as CREATED_BY ,
h.UPDATE_TIME as MODIFIED_DATE,
l.F_RealName as MODIFIED_BY
from hidden_screenrecord h left
join hidden_screentaskinfor i on h.CHECK_TASK_ID=i.CHECKTASK_ID left
join security_measures b on i.RISK_MEASURE_ID=b.RISKMEASURE_ID left
join safety_riskevent c on b.RISK_EVENT_ID=c.RISKEVENT_ID left
join security_unit d on c.RISK_UNIT_ID=d.RISKUNIT_ID left
join base_user j on h.CheckBy = j.F_Id left
join base_user k on h.CREATE_BY = k.F_Id left
join base_user l on h.UPDATE_BY = l.F_Id
WHERE h.OrganizeId='08dac781-f3a0-42c9-8675-a3fc4cc9fa23' ";
string logPath2 = @"C:\Zip_json\Hidden_ScreenTaskInforM\";
DataTable dt1 = _sqlSugarClient.Ado.GetDataTable(sql1);
List<Hidden_XJFXDY> list1 = m_tolist.ConvertToList<Hidden_XJFXDY>(dt1);
if (list1.Count == 0)
return state;
string strDate1 = DateTime.Now.ToString("yyyyMMddHHmmss");
int i = 0;
foreach (var item in list1)
{
item.MODIFIED_BY = item.CREATED_BY;
item.MODIFIED_DATE = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
i++;
item.TASK_ID = item.ID;
item.INSPECT_ORDER = i;
}
var obj1 = new
{
datas = list1
};
string menjson1 = JsonConvert.SerializeObject(obj1, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath2))
Directory.CreateDirectory(logPath2);
////将采集数据写入JSON文件
string jsonfile = logPath2 + COMPANY_CODE + "_XJFXDY_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson1);
sw.Dispose();
fs.Close();
string zippath = logPath2 + COMPANY_CODE + "_XJFXDY_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = "/520170011/" + COMPANY_CODE + "_XJFXDY_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
public class Hidden_ScreenTaskInfor
{
public string ID { get; set; }
public string COMPANY_CODE { get; set; }
public string TASK_NAME { get; set; }
public string PATROL_CYCLE { get; set; }
public string PATROL_CYCLE_UNIT { get; set; }
public DateTime PLAN_START_TIME { get; set; }
public string EXECUTOR { get; set; }
public DateTime PLAN_END_TIME { get; set; }
public DateTime ACTUAL_START_TIME { get; set; }
public DateTime ACTUAL_END_TIME { get; set; }
public string TASK_STATUS { get; set; }
public string IS_DELETED { get; set; }
public DateTime CREATED_DATE { get; set; }
public string CREATED_BY { get; set; }
public DateTime MODIFIED_DATE { get; set; }
public string MODIFIED_BY { get; set; }
public int NO_ADVANCE { get; set; }
public string NO_ADVANCE_UNIT { get; set; }
public int NO_POSTPONE { get; set; }
public string NO_POSTPONE_UNIT { get; set; }
public string IS_CQ { get; set; }
}
public class Hidden_XJFXDY
{
public string ID { get; set; }
public string COMPANY_CODE { get; set; }
public string TASK_ID { get; set; }
public string RISK_UNIT_ID { get; set; }
public string RISK_UNIT_NAME { get; set; }
public DateTime PLAN_START_TIME { get; set; }
public DateTime PLAN_END_TIME { get; set; }
public string IS_DELETED { get; set; }
public DateTime CREATED_DATE { get; set; }
public string CREATED_BY { get; set; }
public DateTime MODIFIED_DATE { get; set; }
public string MODIFIED_BY { get; set; }
public int INSPECT_ORDER { get; set; }
}
#endregion
#region 隐患排查信息
/// <summary>
/// 隐患排查信息.
/// </summary>
/// <returns></returns>
[HttpGet("GetYhPaicha")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetYhPaicha()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
string logPath1 = @"C:\Zip_json\YhPaicha\";
string remotePath = "/520170011";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = 0;
var list = _sqlSugarClient.Queryable<HiddenManageinforEntity>()
.InnerJoin<HiddenScreenrecordEntity>((a, it) => a.RecordId == it.RecordId)
.InnerJoin<SecurityMeasuresEntity>((a, it, cus) => a.RiskMeasureId == cus.RiskmeasureId)
.Where(a => a.OrganizeId.Equals(orgid))
.Select((a, it, cus) => new Hidden_ManageInfor
{
ID = a.DangerId,
COMPANY_CODE = a.CompanyCode.ToString(),
RISK_OBJECT_CODE = a.HazardCode,
CONTROL_MEASURES_ID = a.RiskMeasureId,
TASK_ITEM_ID = a.RecordId,
CHECK_CONTENT = cus.TroubleshootContent,
REGISTRANT = a.Registrant,
REGIST_TIME = a.RegistTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
DANGER_DESCRIPTION = a.DangerDesc.ToString(),
DANGER_LOCATION = a.HiddenPosition.ToString(),
DANGER_POSITION ="",
DANGER_LEVEL = a.DangerLevel.ToString(),
DANGER_CLASSIFICATION = a.HazardDangerType.ToString(),
DANGER_PICS =a.Attachments2,
RECTIFICATION_TYPE = a.DangerManageType.ToString(),
IS_XC = "1",
RECTIFICATION_PERIOD = a.DangerManageDeadline.Value.ToString("yyyy-MM-dd HH:mm:ss"),
RECTIFICATION_DEPARTMENT = SqlFunc.Subqueryable<OrganizeEntity>().Where(u => u.Id.Equals(a.OrganizeId)).Select(u => u.FullName),
RECTIFICATION_EXECUTOR = a.LiablePerson,
INSPECTED_DEPARTMENT = SqlFunc.Subqueryable<OrganizeEntity>().Where(u => u.Id.Equals(a.OrganizeId)).Select(u => u.FullName),
INSPECTED_PERSON = a.CheckAcceptPerson,
DANGER_STATUS = "3",
IS_DELETED = a.DeleteMark.ToString(),
CREATED_BY = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id.Equals(a.CreateBy)).Select(u => u.RealName),
CREATED_DATE = a.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
MODIFIED_BY = a.UpdateBy,
MODIFIED_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
}).ToList();
await _sqlSugarClient.ThenMapperAsync(list, async item =>
{
if (!string.IsNullOrWhiteSpace(item.DANGER_PICS))
{
var imglist = item.DANGER_PICS.ToObject<List<FileControlsModel>>();
foreach (var i in imglist)
{
item.DANGER_PICS = "SystemFile/" + i.fileId;
}
}
if (!string.IsNullOrWhiteSpace(item.RECTIFICATION_EXECUTOR))
{
var cjryUserSelect = item.RECTIFICATION_EXECUTOR.ToObject<List<string>>();
item.RECTIFICATION_EXECUTOR = string.Join(",", await _sqlSugarClient.Queryable<UserEntity>().Where(a => cjryUserSelect.Contains(a.Id)).Select(a => a.RealName).ToListAsync());
}
else
{
item.RECTIFICATION_EXECUTOR = _sqlSugarClient.Queryable<UserEntity>().Where(u => u.Id.Equals(item.CREATED_BY)).Select(u => u.RealName).First();
}
if (string.IsNullOrWhiteSpace(item.INSPECTED_PERSON))
{
var cjryUserSelect = item.INSPECTED_PERSON.ToObject<List<string>>();
item.INSPECTED_PERSON = string.Join(",", await _sqlSugarClient.Queryable<UserEntity>().Where(a => cjryUserSelect.Contains(a.Id)).Select(a => a.RealName).ToListAsync());
}
else
{
item.INSPECTED_PERSON = _sqlSugarClient.Queryable<UserEntity>().Where(u => u.Id.Equals(item.CREATED_BY)).Select(u => u.RealName).First();
}
if (item.DANGER_LEVEL == "0")
{
item.DANGER_LEVEL = "1";
}
else
{
item.DANGER_LEVEL = "2";
}
if (item.RECTIFICATION_TYPE == "0")
{
item.RECTIFICATION_TYPE = "2";
}
//if (item.DANGER_STATUS == "2")
//{
// item.DANGER_STATUS = "1";
//}
//if (item.DANGER_STATUS == "9")
//{
// item.DANGER_STATUS = "3";
//}
if (string.IsNullOrWhiteSpace(item.MODIFIED_BY))
{
item.MODIFIED_BY = item.CREATED_BY;
}
else
{
item.MODIFIED_BY = _sqlSugarClient.Queryable<UserEntity>().Where(it => item.MODIFIED_BY.Equals(it.Id)).Select(a => a.RealName).First();
}
});
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
var obj = new
{
datas = list
};
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath1))
Directory.CreateDirectory(logPath1);
////将采集数据写入JSON文件
string jsonfile = logPath1 + COMPANY_CODE + "_YHPCXX_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath1 + COMPANY_CODE + "_YHPCXX_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_YHPCXX_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
public class Hidden_ManageInfor
{
public string ID { get; set; }
public string COMPANY_CODE { get; set; }
public string RISK_OBJECT_CODE { get; set; }
/// <summary>
/// 管控措施ID.
/// </summary>
public string CONTROL_MEASURES_ID { get; set; }
/// <summary>
/// 管控记录ID.
/// </summary>
public string TASK_ITEM_ID { get; set; }
public string CHECK_CONTENT { get; set; }
public string REGISTRANT { get; set; }
public string REGIST_TIME
{ get; set; }
public string DANGER_DESCRIPTION
{ get; set; }
public string DANGER_LOCATION
{ get; set; }
public string DANGER_POSITION
{ get; set; }
public string DANGER_LEVEL
{ get; set; }
public string DANGER_CLASSIFICATION
{ get; set; }
public string DANGER_PICS
{ get; set; }
public string RECTIFICATION_TYPE
{ get; set; }
public string IS_XC
{ get; set; }
public string RECTIFICATION_PERIOD
{ get; set; }
public string RECTIFICATION_DEPARTMENT
{ get; set; }
public string RECTIFICATION_EXECUTOR
{ get; set; }
public string INSPECTED_DEPARTMENT
{ get; set; }
public string INSPECTED_PERSON
{ get; set; }
public string DANGER_STATUS
{ get; set; }
public string IS_DELETED
{ get; set; }
public string CREATED_BY
{ get; set; }
public string CREATED_DATE
{ get; set; }
public string MODIFIED_BY
{ get; set; }
public string MODIFIED_DATE
{ get; set; }
}
#endregion
#region 隐患整改
/// <summary>
/// 隐患整改.
/// </summary>
/// <returns></returns>
[HttpGet("GetYhZg")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetYhZg()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
string logPath1 = @"C:\Zip_json\YhZg\";
string remotePath = "/520170011";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = 0;
var list = _sqlSugarClient.Queryable<HiddenManageinforEntity>()
.InnerJoin<HiddenScreenrecordEntity>((a, it) => a.RecordId == it.RecordId)
.Where(a => a.DangerState == 0)
.Where(a => a.OrganizeId.Equals(orgid))
.Where(a => a.IfUpload == 1)
.Select((a, it) => new Hidden_ManageZg
{
ID = a.DangerId,
COMPANY_CODE = a.CompanyCode.ToString(),
DANGER_ID = a.DangerId,
RECTIFICATION_TIME = it.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
RECTIFICATION_DEPARTMENT = SqlFunc.Subqueryable<OrganizeEntity>().Where(u => u.Id.Equals(a.OrganizeId)).Select(u => u.FullName),
RECTIFICATION_EXECUTOR = a.LiablePerson,
RECTIFICATION_RESULT = "0",
RECTIFICATION_MEASURES = "99",
OTHER_MEASURES="",
RECTIFICATION_PICS=a.Attachments2,
IS_DELETED = a.DeleteMark.ToString(),
CREATED_BY = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id.Equals(a.CreateBy)).Select(u => u.RealName),
CREATED_DATE = a.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
MODIFIED_BY = a.UpdateBy,
MODIFIED_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
}).ToList();
await _sqlSugarClient.ThenMapperAsync(list, async item =>
{
if (!string.IsNullOrWhiteSpace(item.RECTIFICATION_EXECUTOR))
{
var cjryUserSelect = item.RECTIFICATION_EXECUTOR.ToObject<List<string>>();
item.RECTIFICATION_EXECUTOR = string.Join(",", await _sqlSugarClient.Queryable<UserEntity>().Where(a => cjryUserSelect.Contains(a.Id)).Select(a => a.RealName).ToListAsync());
}
else
{
item.RECTIFICATION_EXECUTOR = _sqlSugarClient.Queryable<UserEntity>().Where(u => u.Id.Equals(item.CREATED_BY)).Select(u => u.RealName).First();
}
if (!string.IsNullOrWhiteSpace(item.RECTIFICATION_PICS))
{
var imglist = item.RECTIFICATION_PICS.ToObject<List<FileControlsModel>>();
foreach (var i in imglist)
{
item.RECTIFICATION_PICS = "SystemFile/" + i.fileId;
}
}
if (string.IsNullOrWhiteSpace(item.MODIFIED_BY))
{
item.MODIFIED_BY = item.CREATED_BY;
}
else
{
item.MODIFIED_BY = _sqlSugarClient.Queryable<UserEntity>().Where(it => item.MODIFIED_BY.Equals(it.Id)).Select(a => a.RealName).First();
}
});
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
var obj = new
{
datas = list
};
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath1))
Directory.CreateDirectory(logPath1);
////将采集数据写入JSON文件
string jsonfile = logPath1 + COMPANY_CODE + "_YHZGXX_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath1 + COMPANY_CODE + "_YHZGXX_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_YHZGXX_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
/// <summary>
/// 隐患整改.
/// </summary>
public class Hidden_ManageZg
{
public string ID { get; set; }
public string COMPANY_CODE { get; set; }
public string DANGER_ID { get; set; }
public string RECTIFICATION_TIME { get; set; }
public string RECTIFICATION_DEPARTMENT { get; set; }
public string RECTIFICATION_EXECUTOR { get; set; }
public string RECTIFICATION_RESULT { get; set; }
public string RECTIFICATION_MEASURES { get; set; }
public string IS_DELETED { get; set; }
public string CREATED_BY { get; set; }
public string CREATED_DATE { get; set; }
public string MODIFIED_BY { get; set; }
public string MODIFIED_DATE { get; set; }
public string OTHER_MEASURES { get; set; }
public string RECTIFICATION_PICS { get; set; }
}
#endregion
#region 隐患复查
/// <summary>
/// 隐患复查.
/// </summary>
/// <returns></returns>
[HttpGet("GetYhFucha")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetYhFucha()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
string logPath1 = @"C:\Zip_json\YhFucha\";
string remotePath = "/520170011";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = 0;
var list = _sqlSugarClient.Queryable<HiddenManageinforEntity>()
.InnerJoin<HiddenScreenrecordEntity>((a, it) => a.RecordId == it.RecordId)
.Where(a => a.OrganizeId.Equals(orgid))
.Where(a => a.DangerState == 9)
.Where(a => a.IfUpload == 1)
.Select((a, it) => new Hidden_ManageFc
{
ID = a.DangerId,
COMPANY_CODE = a.CompanyCode.ToString(),
DANGER_ID = a.RecordId,
REVIEW_TIME = a.CheckAcceptTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
REVIEW_DEPARTMENT = SqlFunc.Subqueryable<OrganizeEntity>().Where(u => u.Id.Equals(a.OrganizeId)).Select(u => u.FullName),
REVIEW_EXECUTOR = a.CheckAcceptPerson,
REVIEW_RESULT = "0",
REVIEW_OPINION = a.CheckAcceptComment.ToString(),
REVIEW_PICS=a.Attachments2,
IS_DELETED = a.DeleteMark.ToString(),
CREATED_BY = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id.Equals(a.CreateBy)).Select(u => u.RealName),
CREATED_DATE = a.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
MODIFIED_BY = a.UpdateBy,
MODIFIED_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
}).ToList();
await _sqlSugarClient.ThenMapperAsync(list, async item =>
{
if (!string.IsNullOrWhiteSpace(item.REVIEW_EXECUTOR))
{
var cjryUserSelect = item.REVIEW_EXECUTOR.ToObject<List<string>>();
item.REVIEW_EXECUTOR = string.Join(",", await _sqlSugarClient.Queryable<UserEntity>().Where(a => cjryUserSelect.Contains(a.Id)).Select(a => a.RealName).ToListAsync());
}
else
{
item.REVIEW_EXECUTOR = _sqlSugarClient.Queryable<UserEntity>().Where(u => u.Id.Equals(item.CREATED_BY)).Select(u => u.RealName).First();
}
if (!string.IsNullOrWhiteSpace(item.REVIEW_PICS))
{
var imglist = item.REVIEW_PICS.ToObject<List<FileControlsModel>>();
foreach (var i in imglist)
{
item.REVIEW_PICS = "SystemFile/" + i.fileId;
}
}
if (string.IsNullOrWhiteSpace(item.MODIFIED_BY))
{
item.MODIFIED_BY = item.CREATED_BY;
}
else
{
item.MODIFIED_BY = _sqlSugarClient.Queryable<UserEntity>().Where(it => item.MODIFIED_BY.Equals(it.Id)).Select(a => a.RealName).First();
}
});
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
var obj = new
{
datas = list
};
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath1))
Directory.CreateDirectory(logPath1);
////将采集数据写入JSON文件
string jsonfile = logPath1 + COMPANY_CODE + "_YHFCXX_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath1 + COMPANY_CODE + "_YHFCXX_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_YHFCXX_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
/// <summary>
/// 隐患复查.
/// </summary>
public class Hidden_ManageFc
{
public string ID { get; set; }
public string COMPANY_CODE { get; set; }
/// <summary>
/// 隐患ID.
/// </summary>
public string DANGER_ID { get; set; }
/// <summary>
/// 复查时间.
/// </summary>
public string REVIEW_TIME { get; set; }
/// <summary>
/// 复查部门.
/// </summary>
public string REVIEW_DEPARTMENT { get; set; }
/// <summary>
/// 复查人员.
/// </summary>
public string REVIEW_EXECUTOR { get; set; }
/// <summary>
/// 复查结果.
/// </summary>
public string REVIEW_RESULT { get; set; }
/// <summary>
/// 复查意见.
/// </summary>
public string REVIEW_OPINION { get; set; }
/// <summary>
/// 隐患复查照片.
/// </summary>
public string REVIEW_PICS { get; set; }
public string IS_DELETED { get; set; }
public string CREATED_BY { get; set; }
public string CREATED_DATE { get; set; }
public string MODIFIED_BY { get; set; }
public string MODIFIED_DATE { get; set; }
}
#endregion
#region 隐患验收
/// <summary>
/// 隐患验收.
/// </summary>
/// <returns></returns>
[HttpGet("GetYhYanshou")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetYhYanshou()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
string logPath1 = @"C:\Zip_json\YhYanshou\";
string remotePath = "/520170011";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = 0;
var list = _sqlSugarClient.Queryable<HiddenManageinforEntity>()
.InnerJoin<HiddenScreenrecordEntity>((a, it) => a.RecordId == it.RecordId)
.Where(a => a.OrganizeId.Equals(orgid))
.Where(a => a.DangerState == 9)
.Where(a => a.IfUpload == 1)
.Select((a, it) => new Hidden_ManageYs
{
ID = a.DangerId,
COMPANY_CODE = a.CompanyCode.ToString(),
DANGER_ID = a.RecordId,
CHECK_ACCEPT_TIME = a.CheckAcceptTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
CHECK_ACCEPT_DEPARTMENT = SqlFunc.Subqueryable<OrganizeEntity>().Where(u => u.Id.Equals(a.OrganizeId)).Select(u => u.FullName),
CHECK_ACCEPT_EXECUTOR =a.CheckAcceptPerson,
CHECK_ACCEPT_RESULT = "0",
SIGN_PICS=a.Attachments2,
IS_DELETED = a.DeleteMark.ToString(),
CREATED_BY = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id.Equals(a.CreateBy)).Select(u => u.RealName),
CREATED_DATE = a.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
MODIFIED_BY = a.UpdateBy,
MODIFIED_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
}).ToList();
await _sqlSugarClient.ThenMapperAsync(list, async item =>
{
if (!string.IsNullOrWhiteSpace(item.CHECK_ACCEPT_EXECUTOR))
{
var cjryUserSelect = item.CHECK_ACCEPT_EXECUTOR.ToObject<List<string>>();
item.CHECK_ACCEPT_EXECUTOR = string.Join(",", await _sqlSugarClient.Queryable<UserEntity>().Where(a => cjryUserSelect.Contains(a.Id)).Select(a => a.RealName).ToListAsync());
}
else
{
item.CHECK_ACCEPT_EXECUTOR = _sqlSugarClient.Queryable<UserEntity>().Where(u => u.Id.Equals(item.CREATED_BY)).Select(u => u.RealName).First();
}
if (!string.IsNullOrWhiteSpace(item.SIGN_PICS))
{
var imglist= item.SIGN_PICS.ToObject<List<FileControlsModel>>();
foreach (var i in imglist)
{
item.SIGN_PICS = "SystemFile/" + i.fileId;
}
}
if (string.IsNullOrWhiteSpace(item.MODIFIED_BY))
{
item.MODIFIED_BY = item.CREATED_BY;
}
else
{
item.MODIFIED_BY = _sqlSugarClient.Queryable<UserEntity>().Where(it => item.MODIFIED_BY.Equals(it.Id)).Select(a => a.RealName).First();
}
});
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
var obj = new
{
datas = list
};
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath1))
Directory.CreateDirectory(logPath1);
////将采集数据写入JSON文件
string jsonfile = logPath1 + COMPANY_CODE + "_YHYSXX_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath1 + COMPANY_CODE + "_YHYSXX_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_YHYSXX_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
/// <summary>
/// 隐患验收.
/// </summary>
public class Hidden_ManageYs
{
public string ID { get; set; }
public string COMPANY_CODE { get; set; }
public string DANGER_ID { get; set; }
public string CHECK_ACCEPT_TIME { get; set; }
public string CHECK_ACCEPT_DEPARTMENT { get; set; }
public string CHECK_ACCEPT_EXECUTOR { get; set; }
public string CHECK_ACCEPT_RESULT { get; set; }
/// <summary>
/// 图片.
/// </summary>
public string SIGN_PICS { get; set; }
public string IS_DELETED { get; set; }
public string CREATED_BY { get; set; }
public string CREATED_DATE { get; set; }
public string MODIFIED_BY { get; set; }
public string MODIFIED_DATE { get; set; }
}
#endregion
#region 隐患排查治理过程信息
/// <summary>
/// 隐患排查治理过程信息.
/// </summary>
/// <returns></returns>
[HttpGet("GetYhpaZlgc")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> GetYhpaZlgc()
{
string IP = "39.104.15.82";
string USER = "node";
string PWD = "17tw@2022";
string COMPANY_CODE = "520170011";
string logPath1 = @"C:\Zip_json\GetYhpaZlgc\";
string remotePath = "/520170011";
var dbLink = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(it => it.Id.Equals("08dae333-158b-4fa1-832f-7d9876592a9e"));
_sqlSugarClient = _dataBaseManager.ChangeDataBase(dbLink);
int state = 0;
var list = _sqlSugarClient.Queryable<HiddenManageinforEntity>()
.InnerJoin<HiddenScreenrecordEntity>((a, it) => a.RecordId == it.RecordId)
.Where(a => a.OrganizeId.Equals(orgid))
.Where(a => a.IfUpload == 1)
.Select((a, it) => new Hidden_ManageYhpaZlgc
{
ID = a.DangerId,
COMPANY_CODE = a.CompanyCode.ToString(),
DANGER_ID = a.RecordId,
RELATION_ID="",
OPERATION_TIME = a.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
PROCESS_OPERATION=a.DangerState.ToString(),
PROCESS_RESULT="",
DEPARTMENT_ID = SqlFunc.Subqueryable<OrganizeEntity>().Where(u => u.Id.Equals(a.OrganizeId)).Select(u => u.FullName),
EXECUTOR = a.LiablePerson,
NEXT_PROCESS_OPERATION = a.DangerState.ToString(),
NEXT_DEPARTMENT= SqlFunc.Subqueryable<OrganizeEntity>().Where(u => u.Id.Equals(a.OrganizeId)).Select(u => u.FullName),
NEXT_EXECUTOR= a.CheckAcceptPerson,
IS_DELETED = a.DeleteMark.ToString(),
CREATED_BY = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id.Equals(a.CreateBy)).Select(u => u.RealName),
CREATED_DATE = a.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
MODIFIED_BY = a.UpdateBy,
MODIFIED_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
}).ToList();
await _sqlSugarClient.ThenMapperAsync(list, async item =>
{
if (!string.IsNullOrWhiteSpace(item.EXECUTOR))
{
var cjryUserSelect = item.EXECUTOR.ToObject<List<string>>();
item.EXECUTOR = string.Join(",", await _sqlSugarClient.Queryable<UserEntity>().Where(a => cjryUserSelect.Contains(a.Id)).Select(a => a.RealName).ToListAsync());
}
else
{
item.EXECUTOR = _sqlSugarClient.Queryable<UserEntity>().Where(u => u.Id.Equals(item.CREATED_BY)).Select(u => u.RealName).First();
}
if (!string.IsNullOrWhiteSpace(item.NEXT_EXECUTOR))
{
var cjryUserSelect = item.NEXT_EXECUTOR.ToObject<List<string>>();
item.NEXT_EXECUTOR = string.Join(",", await _sqlSugarClient.Queryable<UserEntity>().Where(a => cjryUserSelect.Contains(a.Id)).Select(a => a.RealName).ToListAsync());
}
else
{
item.NEXT_EXECUTOR = _sqlSugarClient.Queryable<UserEntity>().Where(u => u.Id.Equals(item.CREATED_BY)).Select(u => u.RealName).First();
}
if (item.PROCESS_OPERATION == "0" || item.PROCESS_OPERATION == "2")
{
item.PROCESS_OPERATION = "0";
}
if (item.PROCESS_OPERATION == "1" || item.PROCESS_OPERATION == "4" || item.PROCESS_OPERATION == "3")
{
item.PROCESS_OPERATION = "1";
}
if (item.PROCESS_OPERATION == "9" )
{
item.PROCESS_OPERATION = "3";
}
if (string.IsNullOrWhiteSpace(item.MODIFIED_BY))
{
item.MODIFIED_BY = item.CREATED_BY;
}
else
{
item.MODIFIED_BY = _sqlSugarClient.Queryable<UserEntity>().Where(it => item.MODIFIED_BY.Equals(it.Id)).Select(a => a.RealName).First();
}
});
if (list.Count == 0)
return state;
string strDate = DateTime.Now.ToString("yyyyMMddHHmmss");
List<string> strList = new List<string>();
var obj = new
{
datas = list
};
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
string menjson = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
try
{
if (!Directory.Exists(logPath1))
Directory.CreateDirectory(logPath1);
////将采集数据写入JSON文件
string jsonfile = logPath1 + COMPANY_CODE + "_YHPCGCXX_" + strDate + ".json";
FileStream fs = new FileStream(jsonfile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
sw.WriteLine(menjson);
sw.Dispose();
fs.Close();
string zippath = logPath1 + COMPANY_CODE + "_YHPCGCXX_" + strDate + ".zip";//压缩文件路径
CompressFileZip(jsonfile, zippath);//将json文件进行压缩ZIP
SFTPHelper SFTPHelper = new SFTPHelper(IP, USER, PWD, "22");//建立SFTP连接
remotePath = remotePath + "/" + COMPANY_CODE + "_YHPCGCXX_" + strDate + ".zip";//SFTP上传路径
bool isflag = SFTPHelper.Put(zippath, remotePath);//SFTP文件上传方法
if (isflag)
{
state = 1;
}
else
{
state = -1;
}
}
catch (Exception ex)
{
state = -1;
}
string reState = state.ToString();
if (state == -1)
{
strList.Add(reState);
}
m_entityDataList.Add(m_className, strList);
if (state == -1) return m_entityDataList; else return state;
}
/// <summary>
/// 隐患排查治理过程信息.
/// </summary>
public class Hidden_ManageYhpaZlgc
{
public string ID { get; set; }
public string COMPANY_CODE { get; set; }
public string DANGER_ID { get; set; }
public string RELATION_ID { get; set; }
public string OPERATION_TIME { get; set; }
public string PROCESS_OPERATION { get; set; }
public string PROCESS_RESULT { get; set; }
public string DEPARTMENT_ID { get; set; }
public string EXECUTOR { get; set; }
public string NEXT_PROCESS_OPERATION { get; set; }
public string NEXT_DEPARTMENT { get; set; }
public string NEXT_EXECUTOR { get; set; }
public string IS_DELETED { get; set; }
public string CREATED_BY { get; set; }
public string CREATED_DATE { get; set; }
public string MODIFIED_BY { get; set; }
public string MODIFIED_DATE { get; set; }
}
#endregion