Commit d999d5ab by zxw

杭州自建平台 分支重整

parent d1103367
...@@ -48,9 +48,11 @@ namespace JunmpPoliceStation.Controllers ...@@ -48,9 +48,11 @@ namespace JunmpPoliceStation.Controllers
private ILogger<ChannelCfgController> _logger; private ILogger<ChannelCfgController> _logger;
private UnitOfWork _unitOfWork; private UnitOfWork _unitOfWork;
protected MQTTServer mqttServer; protected MQTTServer mqttServer;
private HttpHelper _httpHelper;
public ChannelCfgController(ILogger<ChannelCfgController> logger, INacosNamingClient serverManager2, INacosServerManager serverManager, IHttpClientFactory clientFactory, UnitOfWork unitOfWork, IWebHostEnvironment _hostingEnvironment, MQTTServer mqttServer) public ChannelCfgController(ILogger<ChannelCfgController> logger, INacosNamingClient serverManager2, INacosServerManager serverManager, IHttpClientFactory clientFactory, UnitOfWork unitOfWork, IWebHostEnvironment _hostingEnvironment, MQTTServer mqttServer, HttpHelper httpHelper)
{ {
_httpHelper = httpHelper;
_clientFactory = clientFactory; _clientFactory = clientFactory;
_serverManager2 = serverManager2; _serverManager2 = serverManager2;
_serverManager = serverManager; _serverManager = serverManager;
...@@ -1270,6 +1272,36 @@ namespace JunmpPoliceStation.Controllers ...@@ -1270,6 +1272,36 @@ namespace JunmpPoliceStation.Controllers
} }
/// <summary> /// <summary>
/// 获取服务器时间(远端)
/// </summary>
/// <returns></returns>
[HttpGet("GetRemoteServerTime")]
public async Task<HttpResponseMessage> GetRemoteServerTime()
{
return await Task.Run(() =>
{
var httpResult = _httpHelper.GetHtml(new HttpItem()
{
URL = _httpHelper._centerServerAddress + "/api/ChannelCfg/GetServerTime",
Encoding = Encoding.UTF8,
Method = "GET",
ContentType = "application/json",
Timeout = 5000,
});
if (httpResult.StatusCode != HttpStatusCode.OK || string.IsNullOrEmpty(httpResult.Html))
{
return JsonManager.SimpleCustResponse("远端上报数据失败");
}
var obj = JsonConvert.DeserializeObject<JmpBaseResponse<object>>(httpResult.Html);
if (obj.code != "10000")
{
return JsonManager.SimpleCustResponse(obj.msg);
}
return JsonManager.ReturnSuccessResponse(obj.data);
});
}
/// <summary>
/// 同步用户账号 /// 同步用户账号
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
......
...@@ -4876,6 +4876,194 @@ namespace JunmpPoliceStation.Controllers ...@@ -4876,6 +4876,194 @@ namespace JunmpPoliceStation.Controllers
} }
/// <summary> /// <summary>
/// 获取本组织机构物资信息(供应商聚合)
/// </summary>
/// <remarks>
///
/// ## 例子
///
/// {
/// "size":10,
/// "page":0,
/// "orgId":"当前组织机构代码",
/// "warehouseId":"选择的仓库代码",
/// "equipmentId":"装备名称",
/// "equipmentSizeId":"装备型号"
/// "supplierId":"供应商id"
/// "shelfId":"货架id",
/// "range":"货架排位置"
/// "row":"货架行位置",
/// "column":"货架列位置",
/// "orderby":"排序字段 warrantyCycle:质保期",
/// "sort":"排序模式 asc desc",
/// }
///
/// </remarks>
/// <param name="jdata"></param>
/// <returns></returns>
[HttpPost("GetListEquipmentByOrgGroupBySupplier")]
public async Task<HttpResponseMessage> GetListEquipmentByOrgGroupBySupplier([FromBody] JObject jdata)
{
return await Task.Run(() =>
{
try
{
if (jdata != null)
{
var entity = JsonManager.GetJsonEntity(jdata);
string orgCode = entity.orgId;
int.TryParse(entity.page, out int page);
int.TryParse(entity.size, out int size);
if (size == 0)
{
size = 10;
}
string OrgId = Guid.Empty.ToString();
if (String.IsNullOrEmpty(entity.orgId))
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
else
{
OrgId = entity.orgId;
}
var param = new string[] {
"EquipmentSizecodeNavigation" ,
"EquipmentCodeNavigation" ,
"WarehouseCodeNavigation" ,
"WarehouseCodeNavigation.Orgization",
"SupplierCodeNavigation"
};
Expression<Func<CommonJpEquipmentInventory, bool>> expression = t => OrgId.Equals(t.WarehouseCodeNavigation.OrgizationId);
expression = LambdaExtensions.AndAlso(expression, t => t.InventoryState != "loss");
//orgList.Add(orgInfo.Id);//查询所有组织机构仓库库存信息
if (!String.IsNullOrEmpty(entity.warehouseId))
{
string warehouseId = entity.warehouseId;
expression = LambdaExtensions.AndAlso(expression, t => t.WarehouseCode.Equals(warehouseId));
}
//装备名称
if (!String.IsNullOrEmpty(entity.equipmentId))
{
string equipmentId = entity.equipmentId;
expression = LambdaExtensions.AndAlso(expression, t => t.EquipmentCode.Contains(equipmentId));
}
//装备型号
if (!String.IsNullOrEmpty(entity.equipmentSizeId))
{
string equipmentSizeId = entity.equipmentSizeId;
expression = LambdaExtensions.AndAlso(expression, t => t.EquipmentSizecode.Contains(equipmentSizeId));
}
//供应商
if (!String.IsNullOrEmpty(entity.supplierId))
{
string supplierId = entity.supplierId;
expression = LambdaExtensions.AndAlso(expression, t => t.SupplierCode.Contains(supplierId));
}
if (!string.IsNullOrEmpty(entity.shelfId))
{
string shelfId = entity.shelfId;
expression = expression.AndAlso(t => t.ShelfId == shelfId);
if (int.TryParse(entity.range, out int range) && range > 0)
{
expression = expression.AndAlso(t => t.ShelfRange == range);
}
if (int.TryParse(entity.row, out int row) && row > 0)
{
expression = expression.AndAlso(t => t.ShelfRow == row);
}
if (int.TryParse(entity.column, out int column) && column > 0)
{
expression = expression.AndAlso(t => t.ShelfColumn == column);
}
}
var EquipmentList = _unitOfWork.EquipmentInventoryRepository.GetList(expression, null, false, param).ToList();
//var EquipmentList = _unitOfWork.EquipmentInventoryRepository.GetGroupPage(expression,t => new { t.WarehouseCode,t.EquipmentCode,t.EquipmentSizecode },"", page,size, false, param);
var datas = EquipmentList
.GroupBy(p => new
{
p.WarehouseCode,
p.EquipmentCode,
p.EquipmentSizecode,
p.SupplierCode,
p.WarrantyCycle
})
.Select(x => new
{
id = x.Key.WarehouseCode + x.Key.EquipmentSizecode,
warehouseName = x.FirstOrDefault().WarehouseCodeNavigation?.Name,
equipmentName = x.FirstOrDefault().EquipmentCodeNavigation?.Name,
warehouseId = x.FirstOrDefault().WarehouseCodeNavigation?.Id,
equipmentSizeName = x.FirstOrDefault().EquipmentSizecodeNavigation?.SizeName,
equipmentSizeId = x.FirstOrDefault().EquipmentSizecodeNavigation?.Id,
supplierCode = x.FirstOrDefault().SupplierCode,
supplierName = x.FirstOrDefault().SupplierCodeNavigation?.Name,
warrantyCycle = x.FirstOrDefault().WarrantyCycle,
sumCount = x.Count(),
zkCount = x.Count(c => c.CurrentState.Equals(3) || c.CurrentState.Equals(0)),
ckCount = x.Count(c => !(c.CurrentState.Equals(3) || c.CurrentState.Equals(0) || c.CurrentState.Equals(6))),
bfCount = x.Count(c => c.CurrentState.Equals(6))
})
.OrderBy(c => c.equipmentName)
.ThenBy(c => c.equipmentSizeName);
if (entity.orderby == "warrantyCycle")
{
if (entity.sort == "desc")
{
datas = datas.OrderByDescending(x => x.warrantyCycle)
.ThenBy(x => x.equipmentName)
.ThenBy(x => x.equipmentSizeName);
}
else
{
datas = datas.OrderBy(x => x.warrantyCycle)
.ThenBy(x => x.equipmentName)
.ThenBy(x => x.equipmentSizeName);
}
}
var content = new
{
totalElements = datas.Count(),
content = datas.Skip(page * size).Take(size).ToList()
};
return JsonManager.ReturnSuccessResponse(content);
// return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
}
catch (Exception ex)
{
//_logger.LogError("Login/SignIn 错误:" + ex.ToString());
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
}
});
}
/// <summary>
/// 获取织机构物资信息 /// 获取织机构物资信息
/// </summary> /// </summary>
/// <remarks> /// <remarks>
......
...@@ -1144,7 +1144,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -1144,7 +1144,7 @@ namespace JunmpPoliceStation.Controllers
{ {
org.OrderCount++; org.OrderCount++;
} }
order.PrintOrderCode = DateTime.Now.Year + "-类" + org.OrderCount.Value.ToString("D5") + "号"; order.PrintOrderCode = "类" + DateTime.Now.Year + "-" + org.OrderCount.Value.ToString("D5");
order.PrintOrderTime = DateTime.Now; order.PrintOrderTime = DateTime.Now;
printOrderCode = order.PrintOrderCode; printOrderCode = order.PrintOrderCode;
printOrderTime = order.PrintOrderTime.Value.ToString("yyyy年MM月dd日"); printOrderTime = order.PrintOrderTime.Value.ToString("yyyy年MM月dd日");
......
...@@ -853,7 +853,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -853,7 +853,7 @@ namespace JunmpPoliceStation.Controllers
}); });
} }
/// <summary> /// <summary>
/// 获取全部待审核订单列表 /// 获取全部待审核订单列表(杭州自建平台)
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// ## 例子 /// ## 例子
...@@ -864,6 +864,8 @@ namespace JunmpPoliceStation.Controllers ...@@ -864,6 +864,8 @@ namespace JunmpPoliceStation.Controllers
/// "orgId":"组织机构ID", /// "orgId":"组织机构ID",
/// "size":10, /// "size":10,
/// "page":0, /// "page":0,
/// "type":"出库单 入库单",
/// "orderType":""
/// } /// }
/// ///
/// </remarks> /// </remarks>
...@@ -884,6 +886,8 @@ namespace JunmpPoliceStation.Controllers ...@@ -884,6 +886,8 @@ namespace JunmpPoliceStation.Controllers
string userId = string.Empty; string userId = string.Empty;
string orgId = string.Empty; string orgId = string.Empty;
string orderCode = entity.orderCode ?? ""; string orderCode = entity.orderCode ?? "";
string type = entity.type ?? "";
string orderType = entity.orderType ?? "";
if (entity == null) if (entity == null)
{ {
...@@ -930,10 +934,28 @@ namespace JunmpPoliceStation.Controllers ...@@ -930,10 +934,28 @@ namespace JunmpPoliceStation.Controllers
var orderList = _unitOfWork.ViewAllOrderRepository.GetList(expression, null, false, param).OrderByDescending(p => p.UpdateTime); var orderList = _unitOfWork.ViewAllOrderRepository.GetList(expression, null, false, param).OrderByDescending(p => p.UpdateTime);
List<ViewAllOrder> resData = new List<ViewAllOrder>();
if (type == "出库单")
{
//借用、报废、调拨出库、维修
resData = orderList.Where(x => x.FlowName == "本库借用流程" || x.FlowName == "报废流程" || x.FlowName == "调拨下发流程" || x.FlowName == "维修流程" || (x.FlowName == "调拨申请流程" && x.DataScope == "上级")).ToList();
}
if (type == "入库单")
{
//采购、调拨入库
resData = orderList.Where(x => x.FlowName == "采购流程" || x.FlowName == "装备回库流程" || (x.FlowName == "调拨申请流程" && x.DataScope == "本级")).ToList();
}
if (!string.IsNullOrEmpty(orderType))
{
var arr = orderType.Split(",");
resData = resData.Where(x => arr.Contains(x.FlowName)).ToList();
}
var orderValue = new var orderValue = new
{ {
totalElements = orderList.Count(), totalElements = resData.Count,
content = orderList.Skip(page * size).Take(size).ToList() content = resData.Skip(page * size).Take(size).ToList()
}; };
var orderContent = new var orderContent = new
{ {
......
...@@ -1001,7 +1001,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -1001,7 +1001,7 @@ namespace JunmpPoliceStation.Controllers
{ {
FindCode = c.FirstOrDefault().FindCode, FindCode = c.FirstOrDefault().FindCode,
OrgName = codeLen < 6 ? OrgName = codeLen < 6 ?
ListEq.FirstOrDefault(x =>x.Code== c.FirstOrDefault().FindCode.Substring(0,codeLen).PadRight(12,'0')).AreaName ListEq.FirstOrDefault(x => x.Code == c.FirstOrDefault().FindCode.Substring(0, codeLen).PadRight(12, '0')).AreaName
: c.FirstOrDefault().AreaName, : c.FirstOrDefault().AreaName,
c.FirstOrDefault().OrgCode, c.FirstOrDefault().OrgCode,
yearStartCount = c.Count(f => !f.CurrentState.Equals(6) && f.CreateTime?.Year < year), yearStartCount = c.Count(f => !f.CurrentState.Equals(6) && f.CreateTime?.Year < year),
...@@ -1496,6 +1496,136 @@ namespace JunmpPoliceStation.Controllers ...@@ -1496,6 +1496,136 @@ namespace JunmpPoliceStation.Controllers
}); });
} }
/// <summary>
/// 数据统计-条件查询 将同品牌、同型号、同厂家的归为1条数据展示,增加数量显示
/// </summary>
/// <remarks>
///
/// ## 例子
///
/// {
/// "page": "0",
/// "size": "10",
/// "level":"本级、本级及下级",
/// "orgId":"组织机构ID",
/// "orderBy":"质保期升降序 asc desc 默认asc",
/// "supplierId":"供应商id",
/// }
///
/// </remarks>
/// <param name="jdata"></param>
/// <returns></returns>
[HttpPost("GetPageZBTJ")]
[NoSignAttribute]
public async Task<HttpResponseMessage> GetPageZBTJ([FromBody] JObject jdata)
{
return await Task.Run(() =>
{
try
{
if (jdata != null)
{
var entity = JsonManager.GetJsonEntity(jdata);
int.TryParse(entity.page, out int page);
int.TryParse(entity.size, out int size);
if (size == 0)
{
size = 10;
}
Expression<Func<BaseJpOrganization, bool>> expression = t => t.State == 1;
ListEq = _unitOfWork.OrganizationRepository.GetList(expression, t => t.Code).ToList();
string orgizationCode = Guid.Empty.ToString();
List<BaseJpOrganization> dataList = null;
if (!String.IsNullOrEmpty(entity.orgId))
{
orgizationCode = entity.orgId;
}
Expression<Func<CommonJpEquipmentInventory, bool>> expressionPoliceman = t => t.InventoryState != "loss";
string supplierId = entity.supplierId ?? "";
string orderBy = entity.orderBy ?? "asc";
string level = entity.level ?? "";
if (level == "本级")
{
expressionPoliceman = expressionPoliceman.AndAlso(t => t.WarehouseCodeNavigation.OrgizationId.Equals(orgizationCode));
}
else
{
dataList = GetClassID(orgizationCode);
dataList = dataList.ToList().Concat(ListEq.Where(c => c.Id.Equals(orgizationCode))).ToList();
List<string> IdList = dataList.Select(c => c.Id).ToList();
expressionPoliceman = expressionPoliceman.AndAlso(t => IdList.Contains(t.WarehouseCodeNavigation.OrgizationId));
}
if (!string.IsNullOrEmpty(supplierId))
{
expressionPoliceman = expressionPoliceman.AndAlso(t => t.SupplierCode.Equals(supplierId));
}
var arr = new[]
{
"WarehouseCodeNavigation",
"EquipmentCodeNavigation",
"EquipmentSizecodeNavigation",
"SupplierCodeNavigation",
};
var data = _unitOfWork.EquipmentInventoryRepository.GetList(expressionPoliceman, includes: arr)
.GroupBy(x => new { x.EquipmentCode, x.EquipmentSizecode, x.SupplierCode, x.WarrantyCycle })
.Select(x => new
{
equipmentId = x.Key.EquipmentCode,
equipmentName =
string.IsNullOrEmpty(x.FirstOrDefault().EquipmentCodeNavigation.AliasName)
? x.FirstOrDefault().EquipmentCodeNavigation.Name
: x.FirstOrDefault().EquipmentCodeNavigation.AliasName,
equipmentSizeId = x.Key.EquipmentSizecode,
equipmentSizeName = x.FirstOrDefault().EquipmentSizecodeNavigation.SizeName,
supplierId = x.Key.SupplierCode,
supplierName = x.FirstOrDefault().SupplierCodeNavigation.Name,
count = x.Count(),
warrantyCycle = x.Key.WarrantyCycle,
});
if (orderBy == "asc")
{
data = data.OrderBy(x => x.warrantyCycle);
}
else
{
data = data.OrderByDescending(x => x.warrantyCycle);
}
return JsonManager.ReturnSuccessResponse(new
{
totalElements = data.Count(),
content = data.Skip(page * size).Take(size)
});
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
}
catch (Exception ex)
{
//_logger.LogError("Login/SignIn 错误:" + ex.ToString());
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
}
});
}
//递归取数据 //递归取数据
private List<BaseJpOrganization> GetClassID(String id) private List<BaseJpOrganization> GetClassID(String id)
......
...@@ -158,7 +158,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -158,7 +158,7 @@ namespace JunmpPoliceStation.Controllers
/// <summary> /// <summary>
/// 总数统计(在库总量、领用总量、维修数量、报废总量、单警柜个数、仓库个数) /// 总数统计 杭州自建(在库总量、领用总量、维修数量、报废总量、单警柜个数、仓库个数)
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// ///
...@@ -251,6 +251,16 @@ namespace JunmpPoliceStation.Controllers ...@@ -251,6 +251,16 @@ namespace JunmpPoliceStation.Controllers
x.OrgId.Contains(orgId) && x.IsOverdue.Contains("true"))); x.OrgId.Contains(orgId) && x.IsOverdue.Contains("true")));
} }
var thisYear = new DateTime(DateTime.Now.Year, 1, 1);
//今年出库数 今年所有出入库记录为出库的数据
var jncksCount = _unitOfWork.EquipmentStateRepository.Count(x => x.OrgId == orgId && x.OutInState == 0 && x.OutTime > thisYear);
//今年报废数 统计今年所有报废单装备数量
var jnbfsCount = _unitOfWork.DbContext.CommonJpFixReceiveApplyDetails
.Include(x => x.Order)
.Count(x => x.Order.OrgId == orgId && x.Order.CurrentState == 1 && x.State == 1 &&
x.Order.CreateTime > thisYear);
var reData = new var reData = new
{ {
zkCount = zkCount, zkCount = zkCount,
...@@ -262,6 +272,8 @@ namespace JunmpPoliceStation.Controllers ...@@ -262,6 +272,8 @@ namespace JunmpPoliceStation.Controllers
jjbfCount = jjbfCount, jjbfCount = jjbfCount,
ycqCount = ycqCount, ycqCount = ycqCount,
cqwhCount = cqwhCount, cqwhCount = cqwhCount,
jncksCount = jncksCount,
jnbfsCount = jnbfsCount
}; };
return JsonManager.ReturnSuccessResponse(reData); return JsonManager.ReturnSuccessResponse(reData);
......
...@@ -6,6 +6,7 @@ using System.Diagnostics; ...@@ -6,6 +6,7 @@ using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using JmpCommon; using JmpCommon;
...@@ -16,11 +17,13 @@ using JunmpPoliceStation.Controllers; ...@@ -16,11 +17,13 @@ using JunmpPoliceStation.Controllers;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JunmpPoliceStation.Extensions namespace JunmpPoliceStation.Extensions
{ {
public class CronJob public class CronJob
{ {
public static string TRUSTAGW_ACCESS_TOKEN = "";
JunmppolicesqlContext _dbContext; JunmppolicesqlContext _dbContext;
HttpHelper _httpHelper; HttpHelper _httpHelper;
private IConfiguration Configuration; private IConfiguration Configuration;
...@@ -144,6 +147,50 @@ namespace JunmpPoliceStation.Extensions ...@@ -144,6 +147,50 @@ namespace JunmpPoliceStation.Extensions
return new Tuple<string, string>("19999", "操作失败"); return new Tuple<string, string>("19999", "操作失败");
} }
} }
public bool UpdateACCESS_TOKEN()
{
try
{
var app_id = "b6fcf1";
var appkey = "1803a86623306ae5";
var reqData = JsonConvert.SerializeObject(new
{
app_id = app_id,
fingerprint = Convert.ToBase64String(SHA1.Create()
.ComputeHash(Encoding.UTF8.GetBytes($"app_id={app_id}&app_key={appkey}")))
});
var res = _httpHelper.GetHtml(new HttpItem
{
URL = "https://139.66.16.10:6443/sts/token",
Encoding = Encoding.UTF8,
Method = "POST",
ContentType = "application/json",
Postdata = reqData,
IsNoTIP = true
});
if (res.StatusCode!=HttpStatusCode.Created)
{
_logger.LogError("获取ACCESS_TOKEN失败 code:" + res.StatusCode +JsonConvert.SerializeObject(res));
return false;
}
var jobj = JObject.Parse(res.Html);
TRUSTAGW_ACCESS_TOKEN = jobj["access_token"]?.Value<string>() ?? "";
if (string.IsNullOrEmpty(TRUSTAGW_ACCESS_TOKEN))
{
_logger.LogError("获取ACCESS_TOKEN失败 jobj:" + res.Html);
return false;
}
return true;
}
catch (Exception e)
{
_logger.LogError(e, "定时任务工作异常");
return false;
}
}
} }
public class respone<T> public class respone<T>
......
...@@ -9,6 +9,7 @@ using System.Security.Cryptography.X509Certificates; ...@@ -9,6 +9,7 @@ using System.Security.Cryptography.X509Certificates;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace JunmpPoliceStation.Extensions namespace JunmpPoliceStation.Extensions
...@@ -22,6 +23,7 @@ namespace JunmpPoliceStation.Extensions ...@@ -22,6 +23,7 @@ namespace JunmpPoliceStation.Extensions
private readonly string _secretKey; private readonly string _secretKey;
private readonly string _apiVersion; private readonly string _apiVersion;
private readonly string _organizationId; private readonly string _organizationId;
private readonly bool _noSignFlag;
public readonly string _centerServerAddress; public readonly string _centerServerAddress;
public HttpHelper(IConfiguration configuration) public HttpHelper(IConfiguration configuration)
{ {
...@@ -30,6 +32,7 @@ namespace JunmpPoliceStation.Extensions ...@@ -30,6 +32,7 @@ namespace JunmpPoliceStation.Extensions
_apiVersion = "1.0"; _apiVersion = "1.0";
_organizationId = configuration["ThirdConfig:OrganizationId"] ?? ""; _organizationId = configuration["ThirdConfig:OrganizationId"] ?? "";
_centerServerAddress = configuration["ThirdConfig:CenterServerAddress"] ?? ""; _centerServerAddress = configuration["ThirdConfig:CenterServerAddress"] ?? "";
bool.TryParse(configuration.GetSection("Auth:NoSign").Value, out _noSignFlag);
} }
#region 预定义方变量 #region 预定义方变量
...@@ -59,6 +62,33 @@ namespace JunmpPoliceStation.Extensions ...@@ -59,6 +62,33 @@ namespace JunmpPoliceStation.Extensions
try try
{ {
//准备参数 //准备参数
if (!_noSignFlag) //本地测试不添加验证
{
if (!item.IsNoTIP)
{
//补充杭州自建head头
if (string.IsNullOrEmpty(CronJob.TRUSTAGW_ACCESS_TOKEN))
{
//重新更新token
using (var scope = Startup.ServiceLocator.Instance.CreateScope())
{
var cronJob = scope.ServiceProvider.GetService<CronJob>();
if (cronJob?.UpdateACCESS_TOKEN() != true)
{
return new HttpResult()
{
Cookie = string.Empty,
Header = null,
Html = "更新TOKEN失败",
StatusDescription = "更新TOKEN失败"
};
}
}
}
item.Header.Add("X-trustagw-access-token", CronJob.TRUSTAGW_ACCESS_TOKEN);
item.Host = "jbzb.sjjhpt.hzs.zj";
}
}
SetRequest(item); SetRequest(item);
} }
catch (Exception ex) catch (Exception ex)
...@@ -311,6 +341,9 @@ namespace JunmpPoliceStation.Extensions ...@@ -311,6 +341,9 @@ namespace JunmpPoliceStation.Extensions
} }
else else
{ {
//这一句一定要写在创建连接的前面。使用回调的方法进行证书验证。(忽略证书验证)
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
//初始化对像,并设置请求的URL地址 //初始化对像,并设置请求的URL地址
request = (HttpWebRequest)WebRequest.Create(item.URL); request = (HttpWebRequest)WebRequest.Create(item.URL);
SetCerList(item); SetCerList(item);
...@@ -522,6 +555,11 @@ namespace JunmpPoliceStation.Extensions ...@@ -522,6 +555,11 @@ namespace JunmpPoliceStation.Extensions
public class HttpItem public class HttpItem
{ {
/// <summary> /// <summary>
/// 是否请求不需要TIP验证(杭州市局加密用,为获取TIP使用)
/// </summary>
public bool IsNoTIP { get; set; }
/// <summary>
/// 请求URL必须填写 /// 请求URL必须填写
/// </summary> /// </summary>
public string URL { get; set; } public string URL { get; set; }
......
...@@ -177,8 +177,9 @@ namespace JunmpPoliceStation ...@@ -177,8 +177,9 @@ namespace JunmpPoliceStation
using (var scope = app.ApplicationServices.CreateScope()) using (var scope = app.ApplicationServices.CreateScope())
{ {
var cronJob = scope.ServiceProvider.GetRequiredService<CronJob>(); var cronJob = scope.ServiceProvider.GetRequiredService<CronJob>();
RecurringJob.AddOrUpdate(() => cronJob.SyncEquipmentState(), "* 0/10 * * * *"); RecurringJob.AddOrUpdate(() => cronJob.SyncEquipmentState(), "* 0/10 * * * *", TimeZoneInfo.Local);
RecurringJob.AddOrUpdate(() => cronJob.SyncEquipmentData(), "0 0 1 1/1 * *"); RecurringJob.AddOrUpdate(() => cronJob.SyncEquipmentData(), "0 0 1 1/1 * *", TimeZoneInfo.Local);
RecurringJob.AddOrUpdate(() => cronJob.UpdateACCESS_TOKEN(), "0 0 0/6 * * *", TimeZoneInfo.Local);
} }
//app.UseMvc(routes => //app.UseMvc(routes =>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论