Commit 8fa4380a by zxw

1

parent e4279208
......@@ -100,6 +100,11 @@ namespace JmpModel.Model
[Column("file_url")]
[StringLength(255)]
public string FileUrl { get; set; }
/// <summary>
/// 是否绑定单警柜(领用)
/// </summary>
[Column("is_bind_cabinet")]
public bool? IsBindCabinet { get; set; }
[ForeignKey(nameof(ApplyId))]
[InverseProperty(nameof(BaseJpPoliceman.CommonJpBorrowReturnApplyApplies))]
......
......@@ -1221,6 +1221,8 @@ Smart:智能货架
.IsUnicode(false)
.HasComment("单据附加文件地址(上传)");
entity.Property(e => e.IsBindCabinet).HasComment("是否绑定单警柜(领用)");
entity.Property(e => e.Note).IsUnicode(false);
entity.Property(e => e.OrderCode).IsUnicode(false);
......
......@@ -3,6 +3,7 @@ using JmpCommon.Tools;
using JmpModel.Model;
using JmpModel.Model.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
......@@ -34,13 +35,13 @@ namespace JunmpPoliceStation.App_Start
private readonly INacosNamingClient _serverNamingClient;
private readonly IHttpClientFactory _clientFactory;
public IConfiguration Configuration { get; }
private ILogger<PrintController> _logger;
private ILogger<AuthLoginAttribute> _logger;
private Boolean flg;
ApiConfig apicfg;
string urlGetSecretKey = string.Empty;//获取seckey的路由
string urlCheckApp = string.Empty;//获取审核的路由
public AuthLoginAttribute(IConfiguration configuration, ApiConfig apicfg, INacosServerManager _serverManager, INacosNamingClient _serverNamingClient, IHttpClientFactory _clientFactory, Boolean AuthFlg = true)
public AuthLoginAttribute(IConfiguration configuration, ApiConfig apicfg, INacosServerManager _serverManager, INacosNamingClient _serverNamingClient, IHttpClientFactory _clientFactory, ILogger<AuthLoginAttribute> _logger, Boolean AuthFlg = true)
{
flg = AuthFlg;
this.apicfg = apicfg;
......@@ -48,6 +49,7 @@ namespace JunmpPoliceStation.App_Start
this._serverNamingClient = _serverNamingClient;
this._clientFactory = _clientFactory;
this.Configuration = configuration;
this._logger = _logger;
_serverNamingClient.RegisterInstanceAsync(new RegisterInstanceRequest
{
ServiceName = apicfg.serviceName,
......@@ -65,6 +67,14 @@ namespace JunmpPoliceStation.App_Start
public override void OnActionExecuting(ActionExecutingContext context)
{
//获取访问ip
var userHostAddress = context.HttpContext.Connection.RemoteIpAddress?.MapToIPv4().ToString();
if (!string.IsNullOrEmpty(userHostAddress) && IsIP(userHostAddress))
{
//有效ip
_logger.LogDebug("获取访问ip:" + userHostAddress);
}
if (bool.TryParse(Configuration.GetSection("Auth:NoSign").Value, out bool noSignFlag) && noSignFlag)
{
return;
......@@ -191,6 +201,16 @@ namespace JunmpPoliceStation.App_Start
}
}
/// <summary>
/// 检查IP地址格式
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
private static bool IsIP(string ip)
{
return System.Text.RegularExpressions.Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
}
}
public class PlaInfo
{
......
......@@ -750,6 +750,7 @@ namespace JunmpPoliceStation.Controllers
var entity = JsonManager.GetJsonEntity(jdata);
string id = entity?.id ?? "";
bool bExpectedTime = DateTime.TryParse(entity?.expectedTime ?? "", out DateTime expectedTime);
bool bIsBindCabinet = bool.TryParse(entity?.isBindCabinet ?? "", out bool isBindCabinet);
if (entity == null)
{
return JsonManager.SimpleCustResponse($"model is null");
......@@ -795,6 +796,7 @@ namespace JunmpPoliceStation.Controllers
order.PoliceNote = entity.policeNote;
order.PoliceId = entity.policeId;
order.FileUrl = string.IsNullOrEmpty(entity.fileUrl) ? null : entity.fileUrl;
order.IsBindCabinet = isBindCabinet;
List<string> tmpList = JsonManager.GetDetails(entity.detailList);
List<string> tmpList2 = JsonManager.GetDetailIds(entity.detailList);
......@@ -959,7 +961,8 @@ namespace JunmpPoliceStation.Controllers
Note = entity.note,
PoliceNote = entity.policeNote,
PoliceId = entity.policeId,
FileUrl = string.IsNullOrEmpty(entity.fileUrl) ? null : entity.fileUrl
FileUrl = string.IsNullOrEmpty(entity.fileUrl) ? null : entity.fileUrl,
IsBindCabinet = isBindCabinet
};
//if (entity.police!=null)
......@@ -1409,7 +1412,7 @@ namespace JunmpPoliceStation.Controllers
order.ApplyUser = entity.applyId;
order.ApplyUserName = entity.applyName;
order.PoliceNote = entity.policeNote;
order.PoliceId = entity.policeId;
order.PoliceId = string.IsNullOrEmpty(entity.policeId) ? null : entity.policeId;
order.ExpectedReturnTime = expectedTime;
......@@ -1558,7 +1561,7 @@ namespace JunmpPoliceStation.Controllers
ProcessCurrentId = processCurrentId,
ExpectedReturnTime = expectedTime,
PoliceNote = entity.policeNote,
PoliceId = entity.policeId
PoliceId = string.IsNullOrEmpty(entity.policeId) ? null : entity.policeId
};
List<CommonJpBorrowReturnDetailEstimate> detailsList = new List<CommonJpBorrowReturnDetailEstimate>();
foreach (var item in entity.detailList)
......@@ -2018,7 +2021,7 @@ namespace JunmpPoliceStation.Controllers
t.PoliceId,
policeName = t.Police?.Name,
processActionType = t.ProcessCurrent?.ActionType,
fileUrl= t.FileUrl,
fileUrl = t.FileUrl,
historyList = t.ProcessCurrent?.CommonJpProcessHistories?.Select(x => new
{
x.Id,
......
......@@ -285,7 +285,7 @@ namespace JunmpPoliceStation.Controllers
{
var entity = JsonManager.GetJsonEntity(jdata);
string currentCabinetNum = entity?.currentCabinetNum ?? "";
bool bType = int.TryParse(entity?.type,out int type);
bool bType = int.TryParse(entity?.type, out int type);
var param = new string[]
{
"Cabinet",
......@@ -294,7 +294,7 @@ namespace JunmpPoliceStation.Controllers
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
if (!bType|| type>2)
if (!bType || type > 2)
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
......@@ -969,7 +969,9 @@ namespace JunmpPoliceStation.Controllers
// stateCode = s.CurrentState,
// epc = s.Epc
//}).ToList(),
equList = cab.CommonJpEquipmentInventories?.Select(s => new
equList = cab.CommonJpEquipmentInventories?
.Where(s => s.CurrentState == 3 || s.CurrentState == 7)
.Select(s => new
{
id = s.Id,
name = s.EquipmentCodeNavigation?.Name,
......@@ -2777,7 +2779,7 @@ namespace JunmpPoliceStation.Controllers
editEpcEquipment = EpcEquipments.Where(p => p.Epc.Contains(rfid)).FirstOrDefault();
if (editEpcEquipment == null )
if (editEpcEquipment == null)
{
continue;
}
......@@ -2889,7 +2891,7 @@ namespace JunmpPoliceStation.Controllers
}
if (rebind.Equals("true"))
{
var CurrentBindEquipments = _unitOfWork.EquipmentInventoryRepository.GetList(t => t.InventoryState != "loss" &&(t.CabinetId.Equals(cabinet.Id)|| t.PoliceCode== cabinet.BaseJpPolicemen.FirstOrDefault().Id), null, false, param);//单警柜的东西
var CurrentBindEquipments = _unitOfWork.EquipmentInventoryRepository.GetList(t => t.InventoryState != "loss" && (t.CabinetId.Equals(cabinet.Id) || t.PoliceCode == cabinet.BaseJpPolicemen.FirstOrDefault().Id), null, false, param);//单警柜的东西
SendMsg equipmentDic = new SendMsg();
equipmentDic.State = "rebind";
equipmentDic.Msg = "";
......@@ -2902,7 +2904,7 @@ namespace JunmpPoliceStation.Controllers
{
if (!Rfids.Contains(item.Epc))
{
if (item.PoliceCode==policeman.Id)
if (item.PoliceCode == policeman.Id)
{
item.PoliceCode = null;
OutEpc.Add(item);
......@@ -2923,7 +2925,7 @@ namespace JunmpPoliceStation.Controllers
}
if (invBind.Count>0)
if (invBind.Count > 0)
{
foreach (var item in invBind)
{
......
......@@ -12,6 +12,7 @@ using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -652,12 +653,21 @@ namespace JunmpPoliceStation.Controllers
{
detail.State = 1;
}
//江北仓库特殊处理
if (order.OrgId == "E05CC28D-C189-4389-8081-DD0D6E483B40")
{
//生成流水表
GenerateRecordMK2(order);
//反写库存状态
UpdateInvStateMK2(order.CommonJpFixReceiveApplyDetails?.Select(x => x.Epc).ToList(), order.Action, order.OrderCode, false);
}
else
{
//生成流水表
GenerateRecord(order);
//反写库存状态
UpdateInvState(order.CommonJpFixReceiveApplyDetails?.Select(x => x.Epc).ToList(), order.Action, order.OrderCode, false);
}
}
bool result = _unitOfWork.FixReceiveApplyRepository.Insert(order, true);
......@@ -1032,11 +1042,21 @@ namespace JunmpPoliceStation.Controllers
{
detail.State = 1;
}
//江北仓库特殊处理
if (orderInfo.OrgId == "E05CC28D-C189-4389-8081-DD0D6E483B40")
{
//生成流水表
GenerateRecordMK2(orderInfo);
//反写库存状态
UpdateInvStateMK2(orderInfo.CommonJpFixReceiveApplyDetails?.Select(x => x.Epc).ToList(), orderInfo.Action, orderInfo.OrderCode, false);
}
else
{
//生成流水表
GenerateRecord(orderInfo);
//反写库存状态
UpdateInvState(orderInfo.CommonJpFixReceiveApplyDetails?.Select(x => x.Epc).ToList(), orderInfo.Action, orderInfo.OrderCode, isLost);
UpdateInvState(orderInfo.CommonJpFixReceiveApplyDetails?.Select(x => x.Epc).ToList(), orderInfo.Action, orderInfo.OrderCode, false);
}
}
......
......@@ -210,7 +210,7 @@ namespace JunmpPoliceStation.Controllers
IsPushParentWithBorrow = isPushParentWithBorrow,
IsPushParentWithFailWarehouse = isPushParentWithFailWarehouse,
Enable = enable,
EquipmentJson= equipmentJson,
EquipmentJson = equipmentJson,
});
if (_unitOfWork.SaveChanges() > 0)
{
......@@ -343,36 +343,40 @@ namespace JunmpPoliceStation.Controllers
var bjLogList = _unitOfWork.DbContext
.BaseJpMessageReminderLogs
.Where(x => x.OrgId == orgId)
.Where(x => x.OrgId == orgId && x.EquCount != 0)
.ToList();
var xjLogList = _unitOfWork.DbContext
.BaseJpMessageReminderLogs
.Where(x => x.ParentOrgId == orgId && x.IsNeedPushParent)
.Where(x => x.ParentOrgId == orgId && x.IsNeedPushParent && x.EquCount != 0)
.ToList();
return JsonManager.ReturnSuccessResponse(new
var message = new List<string>();
foreach (var log in bjLogList)
{
bj = bjLogList.Select(x => new
{
id = x.Id,
createTime = x.CreateTime,
type = x.Type,
orgId = x.OrgId,
orgName = x.OrgName,
equCount = x.EquCount,
configId = x.ConfigId,
}),
xj = xjLogList.Select(x => new
{
id = x.Id,
createTime = x.CreateTime,
type = x.Type,
orgId = x.OrgId,
orgName = x.OrgName,
equCount = x.EquCount,
configId = x.ConfigId,
})
});
switch (log.Type)
{
case 0:
{
//已超期未报废
message.Add($"已超期未报废装备共{log.EquCount}件,请尽快处理");
break;
}
case 1:
{
//超期未归还
message.Add($"超期未归还装备共{log.EquCount}件,请尽快处理");
break;
}
case 2:
{
//非本仓库装备
message.Add($"本仓库存在其他仓库装备{log.EquCount}件,请尽快处理");
break;
}
}
}
return JsonManager.ReturnSuccessResponse(message);
}
else
{
......
......@@ -615,6 +615,15 @@ namespace JunmpPoliceStation.Controllers
if (string.IsNullOrEmpty(entity.cabinetId))
{
updateObject.CabinetId = null;
//解绑装备
var equList = _unitOfWork.EquipmentInventoryRepository
.GetList(x => x.PoliceCode == updateObject.Id && (x.CurrentState == 3 || x.CurrentState == 7))
.ToList();
foreach (var inventory in equList)
{
inventory.PoliceCode = null;
}
_unitOfWork.EquipmentInventoryRepository.Update(equList, false);
}
else
{
......
......@@ -637,14 +637,12 @@ namespace JunmpPoliceStation.Controllers
if (findcode.Length == 6)
{
var data = equipmentList.GroupBy(t => t.OrgCode).Select(c => new
var data = equipmentList.GroupBy(t => t.OrgName).Select(c => new
{
OrgName = c.OrderBy(f => f.OrgCode).FirstOrDefault().OrgName,
NameJc = c.OrderBy(f => f.OrgCode).FirstOrDefault().NameJc,
c.FirstOrDefault().OrgName,
c.FirstOrDefault().FindCode,
c.FirstOrDefault().OrgCode,
c.FirstOrDefault().SortCode,
zsCount = c.Count(f => f.CurrentState != null && f.InventoryState != "loss"),
zsCount = c.Count(f => f.CurrentState != null),
zkCount = c.Where(f => f.CurrentState.Equals(0) || f.CurrentState.Equals(3)).Count(),
ckCount = c.Where(f => !(f.CurrentState == null || f.CurrentState.Equals(0) || f.CurrentState.Equals(3) || f.CurrentState.Equals(6))).Count(),
bfCount = c.Where(f => f.CurrentState.Equals(6)).Count(),
......@@ -653,7 +651,7 @@ namespace JunmpPoliceStation.Controllers
{
id = c.FirstOrDefault().EquipmentCode,
name = c.FirstOrDefault().EquipmentName,
zsCount = c.Count(f => f.CurrentState != null && f.InventoryState != "loss"),
zsCount = c.Count(f => f.CurrentState != null),
zkCount = c.Where(f => f.CurrentState.Equals(0) || f.CurrentState.Equals(3)).Count(),
ckCount = c.Where(f => !(f.CurrentState == null || f.CurrentState.Equals(0) || f.CurrentState.Equals(3) || f.CurrentState.Equals(6))).Count(),
bfCount = c.Where(f => f.CurrentState.Equals(6)).Count(),
......@@ -662,7 +660,7 @@ namespace JunmpPoliceStation.Controllers
}).ToList();
data = data.Where(c => c.zsCount != 0)
.OrderBy(c => c.SortCode.Length)
.OrderBy(c => c.FindCode.Length)
.ThenBy(c => c.FindCode)
.ThenBy(c => c.OrgCode)
.ToList();
......@@ -682,15 +680,12 @@ namespace JunmpPoliceStation.Controllers
else
{
var codeLen = findcode.Length + 2;
//var data = equipmentList.GroupBy(t => t.FindCode.PadLeft(codeLen, '0').Substring(0, codeLen)).Select(c => new
var data = equipmentList.GroupBy(t => t.OrgCode).Select(c => new
var data = equipmentList.GroupBy(t => t.FindCode.PadLeft(codeLen, '0').Substring(0, codeLen)).Select(c => new
{
OrgName = c.OrderBy(f => f.OrgCode).FirstOrDefault().OrgName,
NameJc = c.OrderBy(f => f.OrgCode).FirstOrDefault().NameJc,
OrgName = c.OrderBy(f => f.OrgCode).FirstOrDefault().AreaName,
c.OrderBy(f => f.OrgCode).FirstOrDefault().FindCode,
c.OrderBy(f => f.OrgCode).FirstOrDefault().OrgCode,
c.FirstOrDefault().SortCode,
zsCount = c.Count(f => f.CurrentState != null && f.InventoryState != "loss"),
zsCount = c.Count(f => f.CurrentState != null),
zkCount = c.Where(f => f.CurrentState.Equals(0) || f.CurrentState.Equals(3)).Count(),
ckCount = c.Where(f => !(f.CurrentState == null || f.CurrentState.Equals(0) || f.CurrentState.Equals(3) || f.CurrentState.Equals(6))).Count(),
bfCount = c.Where(f => f.CurrentState.Equals(6)).Count(),
......@@ -699,7 +694,7 @@ namespace JunmpPoliceStation.Controllers
{
id = c.FirstOrDefault().EquipmentCode,
name = c.FirstOrDefault().EquipmentName,
zsCount = c.Count(f => f.CurrentState != null && f.InventoryState != "loss"),
zsCount = c.Count(f => f.CurrentState != null),
zkCount = c.Where(f => f.CurrentState.Equals(0) || f.CurrentState.Equals(3)).Count(),
ckCount = c.Where(f => !(f.CurrentState == null || f.CurrentState.Equals(0) || f.CurrentState.Equals(3) || f.CurrentState.Equals(6))).Count(),
bfCount = c.Where(f => f.CurrentState.Equals(6)).Count(),
......@@ -708,7 +703,7 @@ namespace JunmpPoliceStation.Controllers
}).ToList();
data = data.Where(c => c.zsCount != 0)
.OrderBy(c => c.SortCode.Length)
.OrderBy(c => c.FindCode.Length)
.ThenBy(c => c.FindCode)
.ThenBy(c => c.OrgCode)
.ToList();
......
......@@ -956,6 +956,7 @@ namespace JunmpPoliceStation.Extensions
InsideItem.EquipmentLocation = 0;
InsideItem.UpdateUser = policeId;
InsideItem.WarehouseCode = warehouseId;
InsideItem.PoliceCode = null; //借用归还清空人员绑定
if (borrowIntoRealDetailEpcItem.InsideRealCount == null)
{
borrowIntoRealDetailEpcItem.InsideRealCount = 0;
......@@ -1069,9 +1070,30 @@ namespace JunmpPoliceStation.Extensions
{
brCount++;
invenItem.PoliceCode = realityItem.Reality?.Apply?.PoliceId;
if (realityItem.Reality?.Apply?.IsBindCabinet == true)
{
var police = _unitOfWork.PolicemanRepository.Get(invenItem.PoliceCode);
if (police != null && !string.IsNullOrEmpty(police.CabinetId))
{
//绑定单警柜
invenItem.CabinetId = police.CabinetId;
invenItem.CurrentState = 7;
invenItem.EquipmentLocation = 3;//外出
}
else
{
//无效设置,不绑定单警柜
invenItem.CurrentState = 8;
invenItem.EquipmentLocation = 3;//外出
invenItem.PoliceCode = realityItem.Reality?.Apply?.PoliceId;
}
}
else
{
invenItem.CurrentState = 8;
invenItem.EquipmentLocation = 3;//外出
}
invenItem.UpdateUser = policeId;
if (reRealEpcDetailList.Count.Equals(0))
{
......
......@@ -35,6 +35,7 @@ using Nacos.AspNetCore;
using NLog.Extensions.Logging;
using Rextec.SOA.Infrastructure;
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
using Microsoft.AspNetCore.HttpOverrides;
namespace JunmpPoliceStation
{
......@@ -147,6 +148,13 @@ namespace JunmpPoliceStation
.UseMemoryStorage());//使用内存
services.AddHangfireServer();//添加hangfire服务
services.AddScoped<CronJob>();//注册执行类
services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
options.KnownNetworks.Clear();
options.KnownProxies.Clear();
});
}
}
......@@ -204,6 +212,8 @@ namespace JunmpPoliceStation
RecurringJob.AddOrUpdate(() => cronJob.UpdateMessageReminderData(), "0 0 2 1/1 * *", TimeZoneInfo.Local);
}
app.UseForwardedHeaders();
//app.UseMvc(routes =>
//{
// routes.MapRoute(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论