Commit d42254db by zonevg

同步主平台3097

*忽略宁波市局特供调拨单有物资价格
parent 7beb6dc0
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace JmpModel.Model
{
[Table("base_jp_cabinet_inv_error_msg")]
public partial class BaseJpCabinetInvErrorMsg
{
[Key]
[Column("id")]
[StringLength(36)]
public string Id { get; set; }
[Required]
[Column("cabinet_real_num")]
[StringLength(36)]
public string CabinetRealNum { get; set; }
[Required]
[Column("cabinet_num")]
[StringLength(36)]
public string CabinetNum { get; set; }
[Column("cabinet_child_num", TypeName = "int(11)")]
public int CabinetChildNum { get; set; }
[Column("organization_id")]
[StringLength(36)]
public string OrganizationId { get; set; }
[Column("state")]
[StringLength(255)]
public string State { get; set; }
[Column("msg", TypeName = "text")]
public string Msg { get; set; }
[Column("push_time", TypeName = "datetime")]
public DateTime? PushTime { get; set; }
[Column("user_name")]
[StringLength(255)]
public string UserName { get; set; }
[Column("current_user_name")]
[StringLength(255)]
public string CurrentUserName { get; set; }
[Column("cabinet_id")]
[StringLength(36)]
public string CabinetId { get; set; }
[Column("epc", TypeName = "text")]
public string Epc { get; set; }
}
}
\ No newline at end of file
...@@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore; ...@@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore;
namespace JmpModel.Model namespace JmpModel.Model
{ {
[Table("base_jp_equipment_detail")] [Table("base_jp_equipment_detail")]
[Index(nameof(Code), Name = "UQ__base_jp___357D4CF97AE516C8", IsUnique = true)] [Index(nameof(Code), Name = "UQ__base_jp___357D4CF97AE516C8")]
[Index(nameof(Id), Name = "_dta_index_base_jp_equipment_detail_8_773577794__K1_3_4")] [Index(nameof(Id), Name = "_dta_index_base_jp_equipment_detail_8_773577794__K1_3_4")]
[Index(nameof(EquipmentId), Name = "equipment_id")] [Index(nameof(EquipmentId), Name = "equipment_id")]
public partial class BaseJpEquipmentDetail public partial class BaseJpEquipmentDetail
......
...@@ -83,6 +83,18 @@ namespace JmpModel.Model ...@@ -83,6 +83,18 @@ namespace JmpModel.Model
/// </summary> /// </summary>
[Column("order_count", TypeName = "int(11)")] [Column("order_count", TypeName = "int(11)")]
public int? OrderCount { get; set; } public int? OrderCount { get; set; }
/// <summary>
/// 经度
/// </summary>
[Column("longitude")]
[StringLength(255)]
public string Longitude { get; set; }
/// <summary>
/// 纬度
/// </summary>
[Column("latitude")]
[StringLength(255)]
public string Latitude { get; set; }
[InverseProperty(nameof(BaseJpBag.Org))] [InverseProperty(nameof(BaseJpBag.Org))]
public virtual ICollection<BaseJpBag> BaseJpBags { get; set; } public virtual ICollection<BaseJpBag> BaseJpBags { get; set; }
......
...@@ -89,6 +89,11 @@ namespace JmpModel.Model ...@@ -89,6 +89,11 @@ namespace JmpModel.Model
/// </summary> /// </summary>
[Column("is_enable_channel_read_equ")] [Column("is_enable_channel_read_equ")]
public bool? IsEnableChannelReadEqu { get; set; } public bool? IsEnableChannelReadEqu { get; set; }
/// <summary>
/// 是否停用仓库
/// </summary>
[Column("is_disabled")]
public bool? IsDisabled { get; set; }
[ForeignKey(nameof(OrgizationId))] [ForeignKey(nameof(OrgizationId))]
[InverseProperty(nameof(BaseJpOrganization.BaseJpWarehouses))] [InverseProperty(nameof(BaseJpOrganization.BaseJpWarehouses))]
......
...@@ -27,6 +27,7 @@ namespace JmpModel.Model.DataContext ...@@ -27,6 +27,7 @@ namespace JmpModel.Model.DataContext
public virtual DbSet<BaseJpBag> BaseJpBags { get; set; } public virtual DbSet<BaseJpBag> BaseJpBags { get; set; }
public virtual DbSet<BaseJpBagMap> BaseJpBagMaps { get; set; } public virtual DbSet<BaseJpBagMap> BaseJpBagMaps { get; set; }
public virtual DbSet<BaseJpCabinet> BaseJpCabinets { get; set; } public virtual DbSet<BaseJpCabinet> BaseJpCabinets { get; set; }
public virtual DbSet<BaseJpCabinetInvErrorMsg> BaseJpCabinetInvErrorMsgs { get; set; }
public virtual DbSet<BaseJpCabinetOutinlog> BaseJpCabinetOutinlogs { get; set; } public virtual DbSet<BaseJpCabinetOutinlog> BaseJpCabinetOutinlogs { get; set; }
public virtual DbSet<BaseJpCabinetPoliceman> BaseJpCabinetPolicemen { get; set; } public virtual DbSet<BaseJpCabinetPoliceman> BaseJpCabinetPolicemen { get; set; }
public virtual DbSet<BaseJpCabinetPolicemanMultiple> BaseJpCabinetPolicemanMultiples { get; set; } public virtual DbSet<BaseJpCabinetPolicemanMultiple> BaseJpCabinetPolicemanMultiples { get; set; }
...@@ -145,7 +146,7 @@ namespace JmpModel.Model.DataContext ...@@ -145,7 +146,7 @@ namespace JmpModel.Model.DataContext
if (!optionsBuilder.IsConfigured) if (!optionsBuilder.IsConfigured)
{ {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263. #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
optionsBuilder.UseMySql("data source=192.168.2.112;port=13306;initial catalog=junmppolicesqlb;user id=root;password=Junmp123;charset=utf8;treattinyasboolean=false", Microsoft.EntityFrameworkCore.ServerVersion.Parse("5.7.38-mysql")); optionsBuilder.UseMySql("data source=192.168.2.15;port=13306;initial catalog=junmppolicesqlb;user id=root;password=Junmp123;charset=utf8;treattinyasboolean=false", Microsoft.EntityFrameworkCore.ServerVersion.Parse("5.7.38-mysql"));
} }
} }
...@@ -266,6 +267,10 @@ namespace JmpModel.Model.DataContext ...@@ -266,6 +267,10 @@ namespace JmpModel.Model.DataContext
{ {
entity.Property(e => e.IsMap).HasDefaultValueSql("'0'"); entity.Property(e => e.IsMap).HasDefaultValueSql("'0'");
entity.Property(e => e.Latitude).HasComment("纬度");
entity.Property(e => e.Longitude).HasComment("经度");
entity.Property(e => e.OrderCount).HasComment("打印单据数量"); entity.Property(e => e.OrderCount).HasComment("打印单据数量");
}); });
...@@ -330,6 +335,10 @@ namespace JmpModel.Model.DataContext ...@@ -330,6 +335,10 @@ namespace JmpModel.Model.DataContext
{ {
entity.Property(e => e.ChannelReadEquTypeJson).HasComment("通道读取装备类型json"); entity.Property(e => e.ChannelReadEquTypeJson).HasComment("通道读取装备类型json");
entity.Property(e => e.IsDisabled)
.HasDefaultValueSql("b'0'")
.HasComment("是否停用仓库");
entity.Property(e => e.IsEnableChannelReadEqu).HasComment("是否启用通道读取指定类型装备"); entity.Property(e => e.IsEnableChannelReadEqu).HasComment("是否启用通道读取指定类型装备");
entity.Property(e => e.IsLocked).HasDefaultValueSql("b'0'"); entity.Property(e => e.IsLocked).HasDefaultValueSql("b'0'");
......
...@@ -11,6 +11,9 @@ namespace JmpModel.Model ...@@ -11,6 +11,9 @@ namespace JmpModel.Model
[Keyless] [Keyless]
public partial class ViewEquipmentType public partial class ViewEquipmentType
{ {
[Column("warehouse_id")]
[StringLength(36)]
public string WarehouseId { get; set; }
[Column("current_state", TypeName = "int(11)")] [Column("current_state", TypeName = "int(11)")]
public int? CurrentState { get; set; } public int? CurrentState { get; set; }
[Column("equipment_code")] [Column("equipment_code")]
......
...@@ -50,6 +50,10 @@ ...@@ -50,6 +50,10 @@
"ObjectType": 0 "ObjectType": 0
}, },
{ {
"Name": "base_jp_cabinet_inv_error_msg",
"ObjectType": 0
},
{
"Name": "base_jp_cabinet_outinlog", "Name": "base_jp_cabinet_outinlog",
"ObjectType": 0 "ObjectType": 0
}, },
......
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace JunmpPoliceStation.App_Start
{
/// <summary>
/// ignore some api on swagger.json
/// </summary>
[AttributeUsage(AttributeTargets.Class| AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public class SwaggerIgnoreAttribute : Attribute
{
}
/// <summary>
/// 过滤具备SwaggerIgnore特性的api
/// </summary>
public class SwaggerIgnoreFilter : IDocumentFilter
{
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
{
var ignoreApis = context.ApiDescriptions.Where(wh => wh.CustomAttributes().Any(any => any is SwaggerIgnoreAttribute));
if (ignoreApis != null)
{
foreach (var ignoreApi in ignoreApis)
{
swaggerDoc.Paths.Remove("/" + ignoreApi.RelativePath);
}
}
}
}
}
...@@ -3566,6 +3566,27 @@ namespace JunmpPoliceStation.Controllers ...@@ -3566,6 +3566,27 @@ namespace JunmpPoliceStation.Controllers
} }
} }
//预警记录 记录 error:异常 exceed:过期
_unitOfWork.DbContext.BaseJpCabinetInvErrorMsgs.AddRange(InvStates
.Where(x => x.State == "error" || x.State == "exceed")
.Select(x => new BaseJpCabinetInvErrorMsg
{
Id = Guid.NewGuid().ToString(),
CabinetRealNum = cabinet.CabinetRealNum,
CabinetNum = cabinet.CabinetNum,
CabinetChildNum = cabinet.CabinetChildNum,
CabinetId = cabinet.Id,
OrganizationId = cabinet.OrganizationId,
State = x.State,
Msg = x.Msg,
PushTime = DateTime.Now,
UserName = x.UserName,
CurrentUserName = x.CurrentUserName,
Epc = x.EPC,
}));
_unitOfWork.SaveChanges();
_logger.LogDebug("Cabinet/UploadRFIDInner数据上报数据返回:" + JsonConvert.SerializeObject(InvStates).ToString()); _logger.LogDebug("Cabinet/UploadRFIDInner数据上报数据返回:" + JsonConvert.SerializeObject(InvStates).ToString());
return JsonManager.ReturnSuccessResponse(InvStates); return JsonManager.ReturnSuccessResponse(InvStates);
} }
......
...@@ -880,6 +880,160 @@ namespace JunmpPoliceStation.Controllers ...@@ -880,6 +880,160 @@ namespace JunmpPoliceStation.Controllers
} }
/// <summary> /// <summary>
/// 修改组织机构经纬度信息
/// </summary>
/// <remarks>
///
/// ## 例子
///
/// {
/// "id" : "编号",
/// "longitude":"经度"
/// "latitude":"纬度"
/// }
///
/// </remarks>
/// <param name="jdata"></param>
/// <returns></returns>
[HttpPost("UpdateOrgJWD")]
public async Task<HttpResponseMessage> UpdateOrgJWD([FromBody] JObject jdata)
{
return await Task.Run(() =>
{
try
{
if (jdata != null)
{
var entity = JsonManager.GetJsonEntity(jdata);
string id = entity?.id ?? "";
string longitude = entity?.longitude ?? "";
string latitude = entity?.latitude ?? "";
if (entity == null)
{
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
}
if (string.IsNullOrEmpty(entity.id ?? ""))
{
return JsonManager.SimpleCustResponse($"id is require");
}
if (string.IsNullOrEmpty(entity.longitude ?? ""))
{
return JsonManager.SimpleCustResponse($"longitude is require");
}
if (string.IsNullOrEmpty(entity.latitude ?? ""))
{
return JsonManager.SimpleCustResponse($"latitude is require");
}
Expression<Func<BaseJpOrganization, bool>> expression = t => t.Id.Equals(id);
BaseJpOrganization updateObject = _unitOfWork.OrganizationRepository.Get(expression);
if (updateObject != null)
{
updateObject.Longitude = longitude;
updateObject.Latitude = latitude;
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
bool result = _unitOfWork.OrganizationRepository.Update(updateObject);
if (result)
{
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
}
else
{
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>
/// 通过代码(6位)获取组织机构经纬度信息
/// </summary>
/// <remarks>
///
/// ## 例子
///
/// {
/// "code" : "代码"
/// }
///
/// </remarks>
/// <param name="jdata"></param>
/// <returns></returns>
[HttpPost("GetOrgJWDByCode")]
[NoSign]
public async Task<HttpResponseMessage> GetOrgJWDByCode([FromBody] JObject jdata)
{
return await Task.Run(() =>
{
try
{
if (jdata != null)
{
var entity = JsonManager.GetJsonEntity(jdata);
string code = entity?.code ?? "";
if (entity == null)
{
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
}
if (string.IsNullOrEmpty(entity.code ?? ""))
{
return JsonManager.SimpleCustResponse($"code is require");
}
Expression<Func<BaseJpOrganization, bool>> expression = t =>
t.Code.Substring(0, 6) == code
&& t.Code.Substring(8, 4) == "0000"
&& !string.IsNullOrEmpty(t.Longitude)
&& !string.IsNullOrEmpty(t.Latitude)
&& t.State == 1;
var res = _unitOfWork.OrganizationRepository.GetList(expression, t => t.Code)
.Select(x => new
{
Name = string.IsNullOrEmpty(x.DName) ? x.Name : x.DName,
x.Code,
x.Longitude,
x.Latitude,
}).ToList();
return JsonManager.ReturnSuccessResponse(res);
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
}
catch (Exception ex)
{
//_logger.LogError("Login/SignIn 错误:" + ex.ToString());
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
}
});
}
/// <summary>
/// 通过orgId返回当前组织机构生成单据序号(并累加1) /// 通过orgId返回当前组织机构生成单据序号(并累加1)
/// </summary> /// </summary>
/// <remarks> /// <remarks>
......
...@@ -525,7 +525,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -525,7 +525,7 @@ namespace JunmpPoliceStation.Controllers
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost("UploadSoftPackage")] [HttpPost("UploadSoftPackage")]
[RequestSizeLimit(419430400)/*文件大小上限,400M,可自定义*/] [RequestSizeLimit(4194304000)/*文件大小上限,4000M,可自定义*/]
[NoSign] [NoSign]
public async Task<HttpResponseMessage> UploadSoftPackage() public async Task<HttpResponseMessage> UploadSoftPackage()
{ {
......
...@@ -1226,7 +1226,8 @@ namespace JunmpPoliceStation.Controllers ...@@ -1226,7 +1226,8 @@ namespace JunmpPoliceStation.Controllers
/// "orgId":"组织机构ID", /// "orgId":"组织机构ID",
/// "typeId":"资产类型ID", /// "typeId":"资产类型ID",
/// "equipmentCode":"资产名称", /// "equipmentCode":"资产名称",
/// "equipmentSizecode":"型号名称" /// "equipmentSizecode":"型号名称",
/// "warehouseId":"仓库id"
/// } /// }
/// ///
/// </remarks> /// </remarks>
...@@ -1262,6 +1263,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -1262,6 +1263,7 @@ namespace JunmpPoliceStation.Controllers
string typeId = entity.typeId; string typeId = entity.typeId;
string equipmentCode = entity.equipmentCode; string equipmentCode = entity.equipmentCode;
string equipmentSizecode = entity.equipmentSizecode; string equipmentSizecode = entity.equipmentSizecode;
string warehouseId = entity.warehouseId;
string level = entity.level; string level = entity.level;
if (level == "本级") if (level == "本级")
...@@ -1292,19 +1294,25 @@ namespace JunmpPoliceStation.Controllers ...@@ -1292,19 +1294,25 @@ namespace JunmpPoliceStation.Controllers
expressionPoliceman = LambdaExtensions.AndAlso(expressionPoliceman, t => t.EquipmentSizecode.Equals(equipmentSizecode)); expressionPoliceman = LambdaExtensions.AndAlso(expressionPoliceman, t => t.EquipmentSizecode.Equals(equipmentSizecode));
} }
List<ViewEquipmentType> equipmentList = _unitOfWork.ViewEquipmentTypeRepository.GetList(expressionPoliceman).OrderBy(c => c.TypeOneId).ThenBy(c => c.TypeTwoId).ThenBy(c => c.TypeThreeId).ToList(); if (!String.IsNullOrEmpty(warehouseId))
var data = equipmentList.GroupBy(t => new { t.TypeOneId, t.EquipmentCode, t.Price, t.EquipmentSizecode }).Select(c => new
{ {
id = c.FirstOrDefault().TypeOneId, expressionPoliceman = LambdaExtensions.AndAlso(expressionPoliceman, t => t.WarehouseId.Equals(warehouseId));
ParentName = c.FirstOrDefault().ParentName,
EquipmentName = c.FirstOrDefault().EquipmentName,
SizeName = c.FirstOrDefault().SizeName,
zsCount = c.Count(f => f.CurrentState != null),
Price = c.FirstOrDefault().Price,
sumPrice = c.Count(f => f.CurrentState != null) * c.Key.Price,
} }
).OrderBy(c => c.id).ToList();
List<ViewEquipmentType> equipmentList = _unitOfWork.ViewEquipmentTypeRepository.GetList(expressionPoliceman)
.OrderBy(c => c.TypeOneId).ThenBy(c => c.TypeTwoId).ThenBy(c => c.TypeThreeId).ToList();
var data = equipmentList.GroupBy(t => new { t.TypeOneId, t.EquipmentCode, t.Price, t.EquipmentSizecode }).Select(c => new
{
id = c.FirstOrDefault().TypeOneId,
ParentName = c.FirstOrDefault().Name,
EquipmentName = c.FirstOrDefault().EquipmentName,
SizeName = c.FirstOrDefault().SizeName,
zsCount = c.Count(f => f.CurrentState != null),
Price = c.FirstOrDefault().Price,
sumPrice = c.Count(f => f.CurrentState != null) * c.Key.Price,
}
).ToList();
return JsonManager.ReturnSuccessResponse(data); return JsonManager.ReturnSuccessResponse(data);
...@@ -1336,7 +1344,8 @@ namespace JunmpPoliceStation.Controllers ...@@ -1336,7 +1344,8 @@ namespace JunmpPoliceStation.Controllers
/// "orgId":"组织机构ID", /// "orgId":"组织机构ID",
/// "typeId":"资产类型ID", /// "typeId":"资产类型ID",
/// "equipmentCode":"资产名称", /// "equipmentCode":"资产名称",
/// "equipmentSizecode":"型号名称" /// "equipmentSizecode":"型号名称",
/// "warehouseId":"仓库id"
/// } /// }
/// ///
/// </remarks> /// </remarks>
...@@ -1372,6 +1381,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -1372,6 +1381,7 @@ namespace JunmpPoliceStation.Controllers
string typeId = entity.typeId; string typeId = entity.typeId;
string equipmentCode = entity.equipmentCode; string equipmentCode = entity.equipmentCode;
string equipmentSizecode = entity.equipmentSizecode; string equipmentSizecode = entity.equipmentSizecode;
string warehouseId = entity.warehouseId;
string level = entity.level; string level = entity.level;
if (level == "本级") if (level == "本级")
...@@ -1402,6 +1412,11 @@ namespace JunmpPoliceStation.Controllers ...@@ -1402,6 +1412,11 @@ namespace JunmpPoliceStation.Controllers
expressionPoliceman = LambdaExtensions.AndAlso(expressionPoliceman, t => t.EquipmentSizecode.Equals(equipmentSizecode)); expressionPoliceman = LambdaExtensions.AndAlso(expressionPoliceman, t => t.EquipmentSizecode.Equals(equipmentSizecode));
} }
if (!String.IsNullOrEmpty(warehouseId))
{
expressionPoliceman = LambdaExtensions.AndAlso(expressionPoliceman, t => t.WarehouseId.Equals(warehouseId));
}
List<ViewEquipmentType> equipmentList = _unitOfWork.ViewEquipmentTypeRepository.GetList(expressionPoliceman).OrderBy(c => c.TypeOneId).ThenBy(c => c.TypeTwoId).ThenBy(c => c.TypeThreeId).ToList(); List<ViewEquipmentType> equipmentList = _unitOfWork.ViewEquipmentTypeRepository.GetList(expressionPoliceman).OrderBy(c => c.TypeOneId).ThenBy(c => c.TypeTwoId).ThenBy(c => c.TypeThreeId).ToList();
var data = equipmentList.OrderBy(c => c.TypeOneId).GroupBy(t => t.TypeOneId).Select((c, idx) => new var data = equipmentList.OrderBy(c => c.TypeOneId).GroupBy(t => t.TypeOneId).Select((c, idx) => new
......
...@@ -79,15 +79,15 @@ namespace JunmpPoliceStation.Controllers ...@@ -79,15 +79,15 @@ namespace JunmpPoliceStation.Controllers
dataList = dataList.ToList().Concat(ListEq.Where(c => c.Id.Equals(orgizationId))).ToList(); dataList = dataList.ToList().Concat(ListEq.Where(c => c.Id.Equals(orgizationId))).ToList();
Expression<Func<BaseJpWarehouse, bool>> expressionHouse = null; Expression<Func<BaseJpWarehouse, bool>> expressionHouse = t => t.IsDisabled == false;
if (!String.IsNullOrEmpty(entity.name)) if (!String.IsNullOrEmpty(entity.name))
{ {
string Name = entity.name; string Name = entity.name;
expressionHouse = t => dataList.Select(c => c.Id).Contains(t.OrgizationId) && t.Name.Contains(Name); expressionHouse = expressionHouse.AndAlso(t => dataList.Select(c => c.Id).Contains(t.OrgizationId) && t.Name.Contains(Name));
} }
else else
{ {
expressionHouse = t => dataList.Select(c => c.Id).Contains(t.OrgizationId); expressionHouse = expressionHouse.AndAlso(t => dataList.Select(c => c.Id).Contains(t.OrgizationId));
} }
var param = new string[] { var param = new string[] {
...@@ -248,15 +248,15 @@ namespace JunmpPoliceStation.Controllers ...@@ -248,15 +248,15 @@ namespace JunmpPoliceStation.Controllers
dataList = dataList.ToList().Concat(ListEq.Where(c => c.Id.Equals(orgizationId))).ToList(); dataList = dataList.ToList().Concat(ListEq.Where(c => c.Id.Equals(orgizationId))).ToList();
Expression<Func<BaseJpWarehouse, bool>> expressionHouse = null; Expression<Func<BaseJpWarehouse, bool>> expressionHouse = t => t.IsDisabled == false;
if (!String.IsNullOrEmpty(entity.name)) if (!String.IsNullOrEmpty(entity.name))
{ {
string Name = entity.name; string Name = entity.name;
expressionHouse = t => dataList.Select(c => c.Id).Contains(t.OrgizationId) && t.Name.Contains(Name); expressionHouse = expressionHouse.AndAlso(t => dataList.Select(c => c.Id).Contains(t.OrgizationId) && t.Name.Contains(Name));
} }
else else
{ {
expressionHouse = t => dataList.Select(c => c.Id).Contains(t.OrgizationId); expressionHouse = expressionHouse.AndAlso(t => dataList.Select(c => c.Id).Contains(t.OrgizationId));
} }
var param = new string[] { var param = new string[] {
...@@ -401,8 +401,8 @@ namespace JunmpPoliceStation.Controllers ...@@ -401,8 +401,8 @@ namespace JunmpPoliceStation.Controllers
} }
Expression<Func<BaseJpWarehouse, bool>> expressionHouse = null; Expression<Func<BaseJpWarehouse, bool>> expressionHouse = t => t.IsDisabled == false;
expressionHouse = t => t.OrgizationId.Equals(orgizationId); expressionHouse = expressionHouse.AndAlso(t => t.OrgizationId.Equals(orgizationId));
var param = new string[] { var param = new string[] {
"Orgization" "Orgization"
...@@ -649,7 +649,9 @@ namespace JunmpPoliceStation.Controllers ...@@ -649,7 +649,9 @@ namespace JunmpPoliceStation.Controllers
c.UpdateTime, c.UpdateTime,
c.UpdateUser, c.UpdateUser,
c.IsLocked, c.IsLocked,
c.CameraUrl c.CameraUrl,
c.IsDisabled,
c.IsEnableChannelReadEqu,
} }
).ToList(); ).ToList();
...@@ -731,11 +733,11 @@ namespace JunmpPoliceStation.Controllers ...@@ -731,11 +733,11 @@ namespace JunmpPoliceStation.Controllers
} }
Expression<Func<BaseJpWarehouse, bool>> expressionHouse = null; Expression<Func<BaseJpWarehouse, bool>> expressionHouse = t => t.IsDisabled == false;
expressionHouse = t => t.OrgizationId.Equals(orgizationId) && t.UpdateTime >= DateTime.Parse(createTime); expressionHouse = expressionHouse.AndAlso(t => t.OrgizationId.Equals(orgizationId) && t.UpdateTime >= DateTime.Parse(createTime));
...@@ -958,7 +960,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -958,7 +960,7 @@ namespace JunmpPoliceStation.Controllers
var entity = JsonManager.GetJsonEntity(jdata); var entity = JsonManager.GetJsonEntity(jdata);
string id = entity?.id ?? ""; string id = entity?.id ?? "";
var bEnable = bool.TryParse(entity?.id, out bool enable); var bEnable = bool.TryParse(entity?.enable, out bool enable);
if (entity == null) if (entity == null)
{ {
...@@ -1003,6 +1005,95 @@ namespace JunmpPoliceStation.Controllers ...@@ -1003,6 +1005,95 @@ namespace JunmpPoliceStation.Controllers
} }
/// <summary> /// <summary>
/// 停启用仓库
/// </summary>
/// <remarks>
///
/// ## 例子
///
/// {
/// "id" : "编号",
/// "isDisabled" : "是否停用",
/// }
///
/// </remarks>
/// <param name="jdata"></param>
/// <returns></returns>
[HttpPost("DisabledWarehouse")]
public async Task<HttpResponseMessage> DisabledWarehouse([FromBody] JObject jdata)
{
return await Task.Run(() =>
{
try
{
if (jdata != null)
{
var entity = JsonManager.GetJsonEntity(jdata);
string id = entity?.id ?? "";
bool bIsDisabled = bool.TryParse(entity?.isDisabled ?? "", out bool isDisabled);
if (entity == null)
{
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
}
if (string.IsNullOrEmpty(id))
{
return JsonManager.SimpleCustResponse($"id is require");
}
if (!bIsDisabled)
{
return JsonManager.SimpleCustResponse($"isDisabled is require");
}
BaseJpWarehouse warehouse = _unitOfWork.WarehouseRepository.Get(t => t.Id.Equals(id));
if (warehouse != null)
{
if (isDisabled)
{
//停用
if (_unitOfWork.EquipmentInventoryRepository.Count(x => x.WarehouseCode == warehouse.Id) > 0)
{
return JsonManager.SimpleCustResponse($"当前仓库存在装备,禁止停用");
}
warehouse.IsDisabled = true;
}
else
{
//启用
warehouse.IsDisabled = false;
}
if (_unitOfWork.WarehouseRepository.Update(warehouse))
{
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
}
else
{
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>
......
...@@ -8,6 +8,7 @@ using MQTTnet.Protocol; ...@@ -8,6 +8,7 @@ using MQTTnet.Protocol;
using MQTTnet.Server; using MQTTnet.Server;
using System; using System;
using System.Text; using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace JunmpPoliceStation.Extensions namespace JunmpPoliceStation.Extensions
...@@ -16,15 +17,14 @@ namespace JunmpPoliceStation.Extensions ...@@ -16,15 +17,14 @@ namespace JunmpPoliceStation.Extensions
{ {
public MqttServer mqttServer { get; set; } public MqttServer mqttServer { get; set; }
public JunmppolicesqlContext context; private IConfiguration _configuration;
public MQTTServer(string connection) public MQTTServer(IConfiguration configuration)
{ {
var options = new DbContextOptionsBuilder<JunmppolicesqlContext>(); _configuration = configuration;
options.UseMySql(connection, ServerVersion.AutoDetect(connection)); StartMqttServer();
context = new JunmppolicesqlContext(options.Options);
} }
public async void StartMqttServer(IConfiguration configuration) public async void StartMqttServer()
{ {
try try
{ {
...@@ -32,12 +32,12 @@ namespace JunmpPoliceStation.Extensions ...@@ -32,12 +32,12 @@ namespace JunmpPoliceStation.Extensions
{ {
var optionsBuilder = new MqttServerOptionsBuilder() var optionsBuilder = new MqttServerOptionsBuilder()
.WithDefaultEndpoint() .WithDefaultEndpoint()
.WithDefaultEndpointPort(int.Parse(configuration.GetSection("MQTT:Port").Value)) .WithDefaultEndpointPort(int.Parse(_configuration.GetSection("MQTT:Port").Value))
.WithConnectionValidator( .WithConnectionValidator(
c => c =>
{ {
var currentUser = configuration["MQTT:UserName"].ToString(); var currentUser = _configuration["MQTT:UserName"].ToString();
var currentPWD = configuration["MQTT:Password"].ToString(); var currentPWD = _configuration["MQTT:Password"].ToString();
if (string.IsNullOrEmpty(currentUser) || string.IsNullOrEmpty(currentPWD)) if (string.IsNullOrEmpty(currentUser) || string.IsNullOrEmpty(currentPWD))
{ {
...@@ -134,45 +134,63 @@ namespace JunmpPoliceStation.Extensions ...@@ -134,45 +134,63 @@ namespace JunmpPoliceStation.Extensions
public void OnMqttServerClientConnected(MqttServerClientConnectedEventArgs e) public void OnMqttServerClientConnected(MqttServerClientConnectedEventArgs e)
{ {
context.ApiMqttMessages.Add(new ApiMqttMessage using (var scope = Startup.ServiceLocator.Instance.CreateScope())
{ {
Id = Guid.NewGuid().ToString(), var dbContext = scope.ServiceProvider.GetService<JunmppolicesqlContext>();
CreateTime = DateTime.Now,
DeviceNo = e.ClientId, dbContext?.ApiMqttMessages.Add(new ApiMqttMessage
DeviceType = e.ClientId.Substring(0, 2), {
Topic = "Connected", Id = Guid.NewGuid().ToString(),
Payload = $"客户端[{e.ClientId}]已连接" CreateTime = DateTime.Now,
}); DeviceNo = e.ClientId,
context.SaveChanges(); DeviceType = e.ClientId.Substring(0, 2),
Topic = "Connected",
Payload = $"客户端[{e.ClientId}]已连接"
});
dbContext?.SaveChanges();
}
//Console.WriteLine($"客户端[{e.ClientId}]已连接"); //Console.WriteLine($"客户端[{e.ClientId}]已连接");
} }
public void OnMqttServerClientDisconnected(MqttServerClientDisconnectedEventArgs e) public void OnMqttServerClientDisconnected(MqttServerClientDisconnectedEventArgs e)
{ {
context.ApiMqttMessages.Add(new ApiMqttMessage using (var scope = Startup.ServiceLocator.Instance.CreateScope())
{ {
Id = Guid.NewGuid().ToString(), var dbContext = scope.ServiceProvider.GetService<JunmppolicesqlContext>();
CreateTime = DateTime.Now,
DeviceNo = e.ClientId, dbContext?.ApiMqttMessages.Add(new ApiMqttMessage
DeviceType = e.ClientId.Substring(0, 2), {
Topic = "Disconnected", Id = Guid.NewGuid().ToString(),
Payload = $"客户端[{e.ClientId}]已断开连接!" CreateTime = DateTime.Now,
}); DeviceNo = e.ClientId,
context.SaveChanges(); DeviceType = e.ClientId.Substring(0, 2),
Topic = "Disconnected",
Payload = $"客户端[{e.ClientId}]已断开连接!"
});
dbContext?.SaveChanges();
}
//Console.WriteLine($"客户端[{e.ClientId}]已断开连接!"); //Console.WriteLine($"客户端[{e.ClientId}]已断开连接!");
} }
public void OnMqttServerClientSubscribedTopic(MqttServerClientSubscribedTopicEventArgs e) public void OnMqttServerClientSubscribedTopic(MqttServerClientSubscribedTopicEventArgs e)
{ {
var message = new ApiMqttMessage using (var scope = Startup.ServiceLocator.Instance.CreateScope())
{ {
Id = Guid.NewGuid().ToString(), var dbContext = scope.ServiceProvider.GetService<JunmppolicesqlContext>();
CreateTime = DateTime.Now,
DeviceNo = e.ClientId, var message = new ApiMqttMessage
DeviceType = e.ClientId.Substring(0, 2), {
Topic = e.TopicFilter.Topic, Id = Guid.NewGuid().ToString(),
Payload = $"客户端[{e.ClientId}]已成功订阅主题[{e.TopicFilter}]!" CreateTime = DateTime.Now,
}; DeviceNo = e.ClientId,
context.ApiMqttMessages.Add(message); DeviceType = e.ClientId.Substring(0, 2),
context.SaveChanges(); Topic = e.TopicFilter.Topic,
Payload = $"客户端[{e.ClientId}]已成功订阅主题[{e.TopicFilter}]!"
};
dbContext?.ApiMqttMessages.Add(message);
dbContext?.SaveChanges();
}
//Console.WriteLine($"客户端[{e.ClientId}]已成功订阅主题[{e.TopicFilter}]!"); //Console.WriteLine($"客户端[{e.ClientId}]已成功订阅主题[{e.TopicFilter}]!");
} }
public void OnMqttServerClientUnsubscribedTopic(MqttServerClientUnsubscribedTopicEventArgs e) public void OnMqttServerClientUnsubscribedTopic(MqttServerClientUnsubscribedTopicEventArgs e)
...@@ -206,8 +224,14 @@ namespace JunmpPoliceStation.Extensions ...@@ -206,8 +224,14 @@ namespace JunmpPoliceStation.Extensions
message.Token = jObj["token"]?.Value<string>(); message.Token = jObj["token"]?.Value<string>();
} }
} }
context.ApiMqttMessages.Add(message);
context.SaveChanges(); using (var scope = Startup.ServiceLocator.Instance.CreateScope())
{
var dbContext = scope.ServiceProvider.GetService<JunmppolicesqlContext>();
dbContext?.ApiMqttMessages.Add(message);
dbContext?.SaveChanges();
}
//Console.WriteLine($"客户端[{e.ClientId}]>> 主题:{e.ApplicationMessage.Topic} 负荷:{Encoding.UTF8.GetString(e.ApplicationMessage.Payload)} Qos:{e.ApplicationMessage.QualityOfServiceLevel} 保留:{e.ApplicationMessage.Retain}"); //Console.WriteLine($"客户端[{e.ClientId}]>> 主题:{e.ApplicationMessage.Topic} 负荷:{Encoding.UTF8.GetString(e.ApplicationMessage.Payload)} Qos:{e.ApplicationMessage.QualityOfServiceLevel} 保留:{e.ApplicationMessage.Retain}");
} }
......
...@@ -4,6 +4,16 @@ ...@@ -4,6 +4,16 @@
<name>JunmpPoliceStation</name> <name>JunmpPoliceStation</name>
</assembly> </assembly>
<members> <members>
<member name="T:JunmpPoliceStation.App_Start.SwaggerIgnoreAttribute">
<summary>
ignore some api on swagger.json
</summary>
</member>
<member name="T:JunmpPoliceStation.App_Start.SwaggerIgnoreFilter">
<summary>
过滤具备SwaggerIgnore特性的api
</summary>
</member>
<member name="M:JunmpPoliceStation.Controllers.BaseChargeController.AddChargeDevelop(Newtonsoft.Json.Linq.JObject)"> <member name="M:JunmpPoliceStation.Controllers.BaseChargeController.AddChargeDevelop(Newtonsoft.Json.Linq.JObject)">
<summary> <summary>
上报充电信息第三方 上报充电信息第三方
...@@ -3601,6 +3611,40 @@ ...@@ -3601,6 +3611,40 @@
<param name="jdata"></param> <param name="jdata"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:JunmpPoliceStation.Controllers.OrganizationController.UpdateOrgJWD(Newtonsoft.Json.Linq.JObject)">
<summary>
修改组织机构经纬度信息
</summary>
<remarks>
## 例子
{
"id" : "编号",
"longitude":"经度"
"latitude":"纬度"
}
</remarks>
<param name="jdata"></param>
<returns></returns>
</member>
<member name="M:JunmpPoliceStation.Controllers.OrganizationController.GetOrgJWDByCode(Newtonsoft.Json.Linq.JObject)">
<summary>
通过代码(6位)获取组织机构经纬度信息
</summary>
<remarks>
## 例子
{
"code" : "代码"
}
</remarks>
<param name="jdata"></param>
<returns></returns>
</member>
<member name="M:JunmpPoliceStation.Controllers.OrganizationController.GetOrderCountByOrgId(Newtonsoft.Json.Linq.JObject)"> <member name="M:JunmpPoliceStation.Controllers.OrganizationController.GetOrderCountByOrgId(Newtonsoft.Json.Linq.JObject)">
<summary> <summary>
通过orgId返回当前组织机构生成单据序号(并累加1) 通过orgId返回当前组织机构生成单据序号(并累加1)
...@@ -4945,7 +4989,8 @@ ...@@ -4945,7 +4989,8 @@
"orgId":"组织机构ID", "orgId":"组织机构ID",
"typeId":"资产类型ID", "typeId":"资产类型ID",
"equipmentCode":"资产名称", "equipmentCode":"资产名称",
"equipmentSizecode":"型号名称" "equipmentSizecode":"型号名称",
"warehouseId":"仓库id"
} }
</remarks> </remarks>
...@@ -4965,7 +5010,8 @@ ...@@ -4965,7 +5010,8 @@
"orgId":"组织机构ID", "orgId":"组织机构ID",
"typeId":"资产类型ID", "typeId":"资产类型ID",
"equipmentCode":"资产名称", "equipmentCode":"资产名称",
"equipmentSizecode":"型号名称" "equipmentSizecode":"型号名称",
"warehouseId":"仓库id"
} }
</remarks> </remarks>
...@@ -5600,6 +5646,23 @@ ...@@ -5600,6 +5646,23 @@
<param name="jdata"></param> <param name="jdata"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:JunmpPoliceStation.Controllers.WarehouseController.DisabledWarehouse(Newtonsoft.Json.Linq.JObject)">
<summary>
停启用仓库
</summary>
<remarks>
## 例子
{
"id" : "编号",
"isDisabled" : "是否停用",
}
</remarks>
<param name="jdata"></param>
<returns></returns>
</member>
<member name="M:JunmpPoliceStation.Controllers.WarehouseController.DeleteWarehouse(Newtonsoft.Json.Linq.JObject)"> <member name="M:JunmpPoliceStation.Controllers.WarehouseController.DeleteWarehouse(Newtonsoft.Json.Linq.JObject)">
<summary> <summary>
删除仓库信息 删除仓库信息
......
...@@ -89,6 +89,7 @@ namespace JunmpPoliceStation ...@@ -89,6 +89,7 @@ namespace JunmpPoliceStation
//注册Swagger生成器,定义一个Swagger 文档 //注册Swagger生成器,定义一个Swagger 文档
services.AddSwaggerGen(c => services.AddSwaggerGen(c =>
{ {
c.DocumentFilter<SwaggerIgnoreFilter>();
c.SwaggerDoc("v1", new OpenApiInfo c.SwaggerDoc("v1", new OpenApiInfo
{ {
Version = "v1", Version = "v1",
...@@ -115,9 +116,7 @@ namespace JunmpPoliceStation ...@@ -115,9 +116,7 @@ namespace JunmpPoliceStation
.AddNacosAspNetCore(Configuration); .AddNacosAspNetCore(Configuration);
//启动MQTT //启动MQTT
var mqtt = new MQTTServer(connection); services.AddSingleton<MQTTServer>();
mqtt.StartMqttServer(Configuration);
services.AddSingleton(mqtt);
services.AddHangfire(configuration => configuration services.AddHangfire(configuration => configuration
.UseMemoryStorage());//使用内存 .UseMemoryStorage());//使用内存
...@@ -133,7 +132,7 @@ namespace JunmpPoliceStation ...@@ -133,7 +132,7 @@ namespace JunmpPoliceStation
public static IServiceProvider Instance { get; set; } public static IServiceProvider Instance { get; set; }
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, INacosNamingClient _namingClient) public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, INacosNamingClient _namingClient, MQTTServer mqttServer)
{ {
ServiceLocator.Instance = app.ApplicationServices; ServiceLocator.Instance = app.ApplicationServices;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论