Commit 8de6fa57 by zxw

1

parent 99a8e7a9
......@@ -167,69 +167,70 @@ namespace JunmpPoliceStation.Controllers
{
try
{
if (jdata != null)
{
var entity = JsonManager.GetJsonEntity(jdata);
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
//if (jdata != null)
//{
// var entity = JsonManager.GetJsonEntity(jdata);
if (entity == null)
{
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
}
else if (string.IsNullOrEmpty(entity.orgId ?? ""))
{
return JsonManager.SimpleCustResponse($"orgId is require");
}
else if (string.IsNullOrEmpty(entity.equName ?? ""))
{
return JsonManager.SimpleCustResponse($"equName is require");
}
else if (string.IsNullOrEmpty(entity.equCode ?? ""))
{
return JsonManager.SimpleCustResponse($"equCode is require");
}
else if (string.IsNullOrEmpty(entity.epc ?? ""))
{
return JsonManager.SimpleCustResponse($"epc is require");
}
else if (string.IsNullOrEmpty(entity.startTime ?? ""))
{
return JsonManager.SimpleCustResponse($"startTime is require");
}
else if (string.IsNullOrEmpty(entity.endTime ?? ""))
{
return JsonManager.SimpleCustResponse($"endTime is require");
}
else
{
string startTime = entity.startTime;
//新增数据
BaseCharge addObject = new BaseCharge()
{
Id = Guid.NewGuid(),
OrgId = entity.orgId,
EquName = entity.equName,
EquCode = entity.equCode,
Epc = entity.epc,
StartTime = Convert.ToDateTime(startTime),
EndTime = System.DateTime.Now
};
// if (entity == null)
// {
// return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
// }
// else if (string.IsNullOrEmpty(entity.orgId ?? ""))
// {
// return JsonManager.SimpleCustResponse($"orgId is require");
// }
// else if (string.IsNullOrEmpty(entity.equName ?? ""))
// {
// return JsonManager.SimpleCustResponse($"equName is require");
// }
// else if (string.IsNullOrEmpty(entity.equCode ?? ""))
// {
// return JsonManager.SimpleCustResponse($"equCode is require");
// }
// else if (string.IsNullOrEmpty(entity.epc ?? ""))
// {
// return JsonManager.SimpleCustResponse($"epc is require");
// }
// else if (string.IsNullOrEmpty(entity.startTime ?? ""))
// {
// return JsonManager.SimpleCustResponse($"startTime is require");
// }
// else if (string.IsNullOrEmpty(entity.endTime ?? ""))
// {
// return JsonManager.SimpleCustResponse($"endTime is require");
// }
// else
// {
// string startTime = entity.startTime;
// //新增数据
// BaseCharge addObject = new BaseCharge()
// {
// Id = Guid.NewGuid(),
// OrgId = entity.orgId,
// EquName = entity.equName,
// EquCode = entity.equCode,
// Epc = entity.epc,
// StartTime = Convert.ToDateTime(startTime),
// EndTime = System.DateTime.Now
// };
bool result = _unitOfWork.BaseChargeRepository.Insert(addObject);
// bool result = _unitOfWork.BaseChargeRepository.Insert(addObject);
if (result)
{
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
}
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
// 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)
{
......
......@@ -446,15 +446,16 @@ namespace JunmpPoliceStation.Controllers
order.Note = entity.note;
List<string> tmpList = JsonManager.GetDetailIds(entity.detailList);
//移除不在上传数据内数据
order.CommonJpPoliceShiftJobsApplyDetails = order
.CommonJpPoliceShiftJobsApplyDetails.Where(x => tmpList.Contains(x.Id))
.ToList();
if (entity.detailList is IEnumerable)
{
List<string> tmpList = JsonManager.GetDetailIds(entity.detailList);
//移除不在上传数据内数据
order.CommonJpPoliceShiftJobsApplyDetails = order
.CommonJpPoliceShiftJobsApplyDetails.Where(x => tmpList.Contains(x.Id))
.ToList();
foreach (var item in entity.detailList)
{
if (string.IsNullOrEmpty(item.equipmentId ?? ""))
......@@ -510,6 +511,11 @@ namespace JunmpPoliceStation.Controllers
}
}
}
else
{
//清空所有携带的装备
order.CommonJpPoliceShiftJobsApplyDetails.Clear();
}
bool result = _unitOfWork.CommonJpPoliceShiftJobsApplyRepository.Update(order, true);
if (result)
......
......@@ -3800,7 +3800,8 @@ namespace JunmpPoliceStation.Controllers
if (entity.data == null && entity.xbdata == null)
{
return JsonManager.SimpleCustResponse($"无效参数");
//无数据更新
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
}
var addList = new List<CommonJpEquipmentInventory>();
......@@ -3918,9 +3919,9 @@ namespace JunmpPoliceStation.Controllers
{
string editType = item.editType ?? "";
string id = item.id ?? "";
string bCreateTime = DateTime.TryParse(item.createTime ?? "", out DateTime createTime);
bool bCreateTime = DateTime.TryParse(item.createTime ?? "", out DateTime createTime);
string epc = item.epc ?? "";
string bOneBoxNum = int.TryParse(item.oneBoxNum ?? "", out int oneBoxNum);
bool bOneBoxNum = int.TryParse(item.oneBoxNum ?? "", out int oneBoxNum);
string equipmentDetailId = item.equipmentDetailId ?? "";
string sizeId = item.sizeId ?? "";
string supplierId = item.supplierId ?? "";
......
......@@ -12,6 +12,9 @@ using System.Linq.Expressions;
using System.Net.Http;
using System.Threading.Tasks;
using JunmpPoliceStation.App_Start;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using System.Text;
namespace JunmpPoliceStation.Controllers
{
......@@ -98,12 +101,20 @@ namespace JunmpPoliceStation.Controllers
imgurl = "http://192.168.2.39:5000/Screen3DShow/1.png"
})
.ToList();
var content = new
{
totalElements = data.Count,
content = data.Skip(page * size).Take(size)
};
return JsonManager.ReturnSuccessResponse(content);
//var content = new
//{
// totalElements = data.Count,
// content = data.Skip(page * size).Take(size)
//};
JsonSerializerSettings setting = new JsonSerializerSettings();
setting.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat;
setting.DateFormatString = "yyyy-MM-dd HH:mm:ss";
setting.ContractResolver = new CamelCasePropertyNamesContractResolver();
setting.MaxDepth = 10; //设置序列化的最大层数
setting.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
return new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(data, Formatting.Indented, setting), Encoding.GetEncoding("UTF-8"), "application/json") };
}
else
......@@ -187,12 +198,21 @@ namespace JunmpPoliceStation.Controllers
imgurl = "http://192.168.2.39:5000/Screen3DShow/1.png"
})
.ToList();
var content = new
{
totalElements = equipmentStates.totalElements,
content = data
};
return JsonManager.ReturnSuccessResponse(content);
//var content = new
//{
// totalElements = equipmentStates.totalElements,
// content = data
//};
JsonSerializerSettings setting = new JsonSerializerSettings();
setting.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat;
setting.DateFormatString = "yyyy-MM-dd HH:mm:ss";
setting.ContractResolver = new CamelCasePropertyNamesContractResolver();
setting.MaxDepth = 10; //设置序列化的最大层数
setting.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
return new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(data, Formatting.Indented, setting), Encoding.GetEncoding("UTF-8"), "application/json") };
}
else
......@@ -274,12 +294,21 @@ namespace JunmpPoliceStation.Controllers
value = x.Count()
})
.ToList();
var content = new
{
totalElements = data.Count,
content = data.Skip(page * size).Take(size)
};
return JsonManager.ReturnSuccessResponse(content);
//var content = new
//{
// totalElements = data.Count,
// content = data.Skip(page * size).Take(size)
//};
JsonSerializerSettings setting = new JsonSerializerSettings();
setting.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat;
setting.DateFormatString = "yyyy-MM-dd HH:mm:ss";
setting.ContractResolver = new CamelCasePropertyNamesContractResolver();
setting.MaxDepth = 10; //设置序列化的最大层数
setting.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
return new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(data, Formatting.Indented, setting), Encoding.GetEncoding("UTF-8"), "application/json") };
}
else
......@@ -360,12 +389,21 @@ namespace JunmpPoliceStation.Controllers
x.CurrentState==3?"在库":"不在库"
})
.ToList();
var content = new
{
totalElements = data.Count,
content = data.Skip(page * size).Take(size)
};
return JsonManager.ReturnSuccessResponse(content);
//var content = new
//{
// totalElements = data.Count,
// content = data.Skip(page * size).Take(size)
//};
JsonSerializerSettings setting = new JsonSerializerSettings();
setting.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat;
setting.DateFormatString = "yyyy-MM-dd HH:mm:ss";
setting.ContractResolver = new CamelCasePropertyNamesContractResolver();
setting.MaxDepth = 10; //设置序列化的最大层数
setting.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
return new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(data, Formatting.Indented, setting), Encoding.GetEncoding("UTF-8"), "application/json") };
}
else
......
......@@ -162,7 +162,7 @@ namespace JunmpPoliceStation.Extensions
foreach (var reality in borrow.CommonJpBorrowReturnDetailRealities.Where(x => x.State != 2))
{
var equConfigSingle = equConfig.FirstOrDefault(x => x.EquipmentDetailId == reality.EquipmentDetailId);
if (equConfigSingle != null && equConfigSingle.OverdueBorrowDay != -1)
if (equConfigSingle is { IsNotReturned: true })
{
//计算是否超期未还
if (view.ExpectedTime < DateTime.Now.AddDays(-equConfigSingle.OverdueBorrowDay))
......@@ -264,7 +264,11 @@ namespace JunmpPoliceStation.Extensions
/// </summary>
public bool IsNeedRemind { get; set; }
/// <summary>
/// 超期未还x天后提醒(-1不提醒)
/// 是否需要提醒(超期未还)
/// </summary>
public bool IsNotReturned { get; set; }
/// <summary>
/// 超期未还x天后提醒
/// </summary>
public int OverdueBorrowDay { get; set; }
}
......
......@@ -10,6 +10,7 @@ using System;
using System.Text;
using JunmpPoliceStation.Controllers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
namespace JunmpPoliceStation.Extensions
......@@ -20,6 +21,7 @@ namespace JunmpPoliceStation.Extensions
//public JunmppolicesqlContext _dbContext;
private IConfiguration _configuration;
public MQTTServer(IConfiguration configuration)
{
_configuration = configuration;
......@@ -236,6 +238,7 @@ namespace JunmpPoliceStation.Extensions
{
//通道回复
message.Token = jObj["token"]?.Value<string>();
dbContext?.ApiMqttMessages.Add(message);
break;
}
case "ShelfGetData":
......@@ -252,21 +255,23 @@ namespace JunmpPoliceStation.Extensions
{
//获取单据信息
var warehouseId = jObj["warehouseId"]?.Value<string>();
var shelfController = scope.ServiceProvider.GetService<ShelfController>();
await shelfController?.GetOpenOrderInvInfo(JObject.Parse(@$"{{""warehouseId"":""{warehouseId}"",""pushClientId"":""{e.ClientId}""}}"))!;
break;
}
}
}
dbContext?.SaveChanges();
}
else
{
//保存文件
var str = message.CreateTime + "|" + message.DeviceNo + "|" + message.Topic + "|" + message.Payload;
var logger = scope.ServiceProvider.GetService<ILogger<MQTTServer>>();
logger.LogInformation(str);
}
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}");
}
......
......@@ -10,12 +10,14 @@
<target xsi:type="File" name="Debug" fileName="Nlogs/Debug/nlog-Debug-${shortdate}.log" layout="${longdate}|${logger}|${uppercase:${level}}|${message} ${exception}" />
<target xsi:type="File" name="Error" fileName="Nlogs/Error/nlog-Error-${shortdate}.log" layout="${longdate}|${logger}|${uppercase:${level}}|${message} ${exception}" />
<target xsi:type="File" name="Information" fileName="Nlogs/Information/nlog-Information-${shortdate}.log" layout="${longdate}|${logger}|${uppercase:${level}}|${message} ${exception}" />
<target xsi:type="File" name="MQTT" fileName="Nlogs/MQTT/${shortdate}.log" layout="${longdate}|${logger}|${uppercase:${level}}|${message} ${exception}" />
<target xsi:type="Null" name="blackhole" />
</targets>
<rules>
<!--<logger name="*" minlevel="Trace" writeTo="file" />-->
<!--<logger name="*" minlevel="Information" maxlevel="Information" writeTo="Information" />-->
<logger name="JunmpPoliceStation.Extensions.MQTTServer" minlevel="Information" maxlevel="Information" writeTo="MQTT" />
<logger name="JunmpPoliceStation.*" minlevel="Debug" maxlevel="Debug" writeTo="Debug" />
<logger name="*" minlevel="Error" maxlevel="Error" writeTo="Error" />
<!--日志级别:Trace -》Debug-》 Information -》Warning-》 Error-》 Critical-->
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论