Commit 8de6fa57 by zxw

1

parent 99a8e7a9
...@@ -167,69 +167,70 @@ namespace JunmpPoliceStation.Controllers ...@@ -167,69 +167,70 @@ namespace JunmpPoliceStation.Controllers
{ {
try try
{ {
if (jdata != null) return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
{ //if (jdata != null)
var entity = JsonManager.GetJsonEntity(jdata); //{
// var entity = JsonManager.GetJsonEntity(jdata);
if (entity == null) // if (entity == null)
{ // {
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED); // return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
} // }
else if (string.IsNullOrEmpty(entity.orgId ?? "")) // else if (string.IsNullOrEmpty(entity.orgId ?? ""))
{ // {
return JsonManager.SimpleCustResponse($"orgId is require"); // return JsonManager.SimpleCustResponse($"orgId is require");
} // }
else if (string.IsNullOrEmpty(entity.equName ?? "")) // else if (string.IsNullOrEmpty(entity.equName ?? ""))
{ // {
return JsonManager.SimpleCustResponse($"equName is require"); // return JsonManager.SimpleCustResponse($"equName is require");
} // }
else if (string.IsNullOrEmpty(entity.equCode ?? "")) // else if (string.IsNullOrEmpty(entity.equCode ?? ""))
{ // {
return JsonManager.SimpleCustResponse($"equCode is require"); // return JsonManager.SimpleCustResponse($"equCode is require");
} // }
else if (string.IsNullOrEmpty(entity.epc ?? "")) // else if (string.IsNullOrEmpty(entity.epc ?? ""))
{ // {
return JsonManager.SimpleCustResponse($"epc is require"); // return JsonManager.SimpleCustResponse($"epc is require");
} // }
else if (string.IsNullOrEmpty(entity.startTime ?? "")) // else if (string.IsNullOrEmpty(entity.startTime ?? ""))
{ // {
return JsonManager.SimpleCustResponse($"startTime is require"); // return JsonManager.SimpleCustResponse($"startTime is require");
} // }
else if (string.IsNullOrEmpty(entity.endTime ?? "")) // else if (string.IsNullOrEmpty(entity.endTime ?? ""))
{ // {
return JsonManager.SimpleCustResponse($"endTime is require"); // return JsonManager.SimpleCustResponse($"endTime is require");
} // }
else // else
{ // {
string startTime = entity.startTime; // string startTime = entity.startTime;
//新增数据 // //新增数据
BaseCharge addObject = new BaseCharge() // BaseCharge addObject = new BaseCharge()
{ // {
Id = Guid.NewGuid(), // Id = Guid.NewGuid(),
OrgId = entity.orgId, // OrgId = entity.orgId,
EquName = entity.equName, // EquName = entity.equName,
EquCode = entity.equCode, // EquCode = entity.equCode,
Epc = entity.epc, // Epc = entity.epc,
StartTime = Convert.ToDateTime(startTime), // StartTime = Convert.ToDateTime(startTime),
EndTime = System.DateTime.Now // EndTime = System.DateTime.Now
}; // };
bool result = _unitOfWork.BaseChargeRepository.Insert(addObject); // bool result = _unitOfWork.BaseChargeRepository.Insert(addObject);
if (result) // if (result)
{ // {
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS); // return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
} // }
else // else
{ // {
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR); // return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
} // }
} // }
} //}
else //else
{ //{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR); // return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
} //}
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -446,15 +446,16 @@ namespace JunmpPoliceStation.Controllers ...@@ -446,15 +446,16 @@ namespace JunmpPoliceStation.Controllers
order.Note = entity.note; 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) 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) foreach (var item in entity.detailList)
{ {
if (string.IsNullOrEmpty(item.equipmentId ?? "")) if (string.IsNullOrEmpty(item.equipmentId ?? ""))
...@@ -510,6 +511,11 @@ namespace JunmpPoliceStation.Controllers ...@@ -510,6 +511,11 @@ namespace JunmpPoliceStation.Controllers
} }
} }
} }
else
{
//清空所有携带的装备
order.CommonJpPoliceShiftJobsApplyDetails.Clear();
}
bool result = _unitOfWork.CommonJpPoliceShiftJobsApplyRepository.Update(order, true); bool result = _unitOfWork.CommonJpPoliceShiftJobsApplyRepository.Update(order, true);
if (result) if (result)
......
...@@ -3800,7 +3800,8 @@ namespace JunmpPoliceStation.Controllers ...@@ -3800,7 +3800,8 @@ namespace JunmpPoliceStation.Controllers
if (entity.data == null && entity.xbdata == null) if (entity.data == null && entity.xbdata == null)
{ {
return JsonManager.SimpleCustResponse($"无效参数"); //无数据更新
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
} }
var addList = new List<CommonJpEquipmentInventory>(); var addList = new List<CommonJpEquipmentInventory>();
...@@ -3918,9 +3919,9 @@ namespace JunmpPoliceStation.Controllers ...@@ -3918,9 +3919,9 @@ namespace JunmpPoliceStation.Controllers
{ {
string editType = item.editType ?? ""; string editType = item.editType ?? "";
string id = item.id ?? ""; 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 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 equipmentDetailId = item.equipmentDetailId ?? "";
string sizeId = item.sizeId ?? ""; string sizeId = item.sizeId ?? "";
string supplierId = item.supplierId ?? ""; string supplierId = item.supplierId ?? "";
......
...@@ -12,6 +12,9 @@ using System.Linq.Expressions; ...@@ -12,6 +12,9 @@ using System.Linq.Expressions;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using JunmpPoliceStation.App_Start; using JunmpPoliceStation.App_Start;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using System.Text;
namespace JunmpPoliceStation.Controllers namespace JunmpPoliceStation.Controllers
{ {
...@@ -98,12 +101,20 @@ namespace JunmpPoliceStation.Controllers ...@@ -98,12 +101,20 @@ namespace JunmpPoliceStation.Controllers
imgurl = "http://192.168.2.39:5000/Screen3DShow/1.png" imgurl = "http://192.168.2.39:5000/Screen3DShow/1.png"
}) })
.ToList(); .ToList();
var content = new //var content = new
{ //{
totalElements = data.Count, // totalElements = data.Count,
content = data.Skip(page * size).Take(size) // content = data.Skip(page * size).Take(size)
}; //};
return JsonManager.ReturnSuccessResponse(content); 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 else
...@@ -187,12 +198,21 @@ namespace JunmpPoliceStation.Controllers ...@@ -187,12 +198,21 @@ namespace JunmpPoliceStation.Controllers
imgurl = "http://192.168.2.39:5000/Screen3DShow/1.png" imgurl = "http://192.168.2.39:5000/Screen3DShow/1.png"
}) })
.ToList(); .ToList();
var content = new //var content = new
{ //{
totalElements = equipmentStates.totalElements, // totalElements = equipmentStates.totalElements,
content = data // content = data
}; //};
return JsonManager.ReturnSuccessResponse(content); 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 else
...@@ -274,12 +294,21 @@ namespace JunmpPoliceStation.Controllers ...@@ -274,12 +294,21 @@ namespace JunmpPoliceStation.Controllers
value = x.Count() value = x.Count()
}) })
.ToList(); .ToList();
var content = new //var content = new
{ //{
totalElements = data.Count, // totalElements = data.Count,
content = data.Skip(page * size).Take(size) // content = data.Skip(page * size).Take(size)
}; //};
return JsonManager.ReturnSuccessResponse(content); 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 else
...@@ -360,12 +389,21 @@ namespace JunmpPoliceStation.Controllers ...@@ -360,12 +389,21 @@ namespace JunmpPoliceStation.Controllers
x.CurrentState==3?"在库":"不在库" x.CurrentState==3?"在库":"不在库"
}) })
.ToList(); .ToList();
var content = new //var content = new
{ //{
totalElements = data.Count, // totalElements = data.Count,
content = data.Skip(page * size).Take(size) // content = data.Skip(page * size).Take(size)
}; //};
return JsonManager.ReturnSuccessResponse(content); 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 else
......
...@@ -162,7 +162,7 @@ namespace JunmpPoliceStation.Extensions ...@@ -162,7 +162,7 @@ namespace JunmpPoliceStation.Extensions
foreach (var reality in borrow.CommonJpBorrowReturnDetailRealities.Where(x => x.State != 2)) foreach (var reality in borrow.CommonJpBorrowReturnDetailRealities.Where(x => x.State != 2))
{ {
var equConfigSingle = equConfig.FirstOrDefault(x => x.EquipmentDetailId == reality.EquipmentDetailId); 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)) if (view.ExpectedTime < DateTime.Now.AddDays(-equConfigSingle.OverdueBorrowDay))
...@@ -264,7 +264,11 @@ namespace JunmpPoliceStation.Extensions ...@@ -264,7 +264,11 @@ namespace JunmpPoliceStation.Extensions
/// </summary> /// </summary>
public bool IsNeedRemind { get; set; } public bool IsNeedRemind { get; set; }
/// <summary> /// <summary>
/// 超期未还x天后提醒(-1不提醒) /// 是否需要提醒(超期未还)
/// </summary>
public bool IsNotReturned { get; set; }
/// <summary>
/// 超期未还x天后提醒
/// </summary> /// </summary>
public int OverdueBorrowDay { get; set; } public int OverdueBorrowDay { get; set; }
} }
......
...@@ -10,6 +10,7 @@ using System; ...@@ -10,6 +10,7 @@ using System;
using System.Text; using System.Text;
using JunmpPoliceStation.Controllers; using JunmpPoliceStation.Controllers;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace JunmpPoliceStation.Extensions namespace JunmpPoliceStation.Extensions
...@@ -20,6 +21,7 @@ namespace JunmpPoliceStation.Extensions ...@@ -20,6 +21,7 @@ namespace JunmpPoliceStation.Extensions
//public JunmppolicesqlContext _dbContext; //public JunmppolicesqlContext _dbContext;
private IConfiguration _configuration; private IConfiguration _configuration;
public MQTTServer(IConfiguration configuration) public MQTTServer(IConfiguration configuration)
{ {
_configuration = configuration; _configuration = configuration;
...@@ -236,6 +238,7 @@ namespace JunmpPoliceStation.Extensions ...@@ -236,6 +238,7 @@ namespace JunmpPoliceStation.Extensions
{ {
//通道回复 //通道回复
message.Token = jObj["token"]?.Value<string>(); message.Token = jObj["token"]?.Value<string>();
dbContext?.ApiMqttMessages.Add(message);
break; break;
} }
case "ShelfGetData": case "ShelfGetData":
...@@ -252,21 +255,23 @@ namespace JunmpPoliceStation.Extensions ...@@ -252,21 +255,23 @@ namespace JunmpPoliceStation.Extensions
{ {
//获取单据信息 //获取单据信息
var warehouseId = jObj["warehouseId"]?.Value<string>(); var warehouseId = jObj["warehouseId"]?.Value<string>();
var shelfController = scope.ServiceProvider.GetService<ShelfController>(); var shelfController = scope.ServiceProvider.GetService<ShelfController>();
await shelfController?.GetOpenOrderInvInfo(JObject.Parse(@$"{{""warehouseId"":""{warehouseId}"",""pushClientId"":""{e.ClientId}""}}"))!; await shelfController?.GetOpenOrderInvInfo(JObject.Parse(@$"{{""warehouseId"":""{warehouseId}"",""pushClientId"":""{e.ClientId}""}}"))!;
break; 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}"); //Console.WriteLine($"客户端[{e.ClientId}]>> 主题:{e.ApplicationMessage.Topic} 负荷:{Encoding.UTF8.GetString(e.ApplicationMessage.Payload)} Qos:{e.ApplicationMessage.QualityOfServiceLevel} 保留:{e.ApplicationMessage.Retain}");
} }
......
...@@ -10,12 +10,14 @@ ...@@ -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="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="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="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" /> <target xsi:type="Null" name="blackhole" />
</targets> </targets>
<rules> <rules>
<!--<logger name="*" minlevel="Trace" writeTo="file" />--> <!--<logger name="*" minlevel="Trace" writeTo="file" />-->
<!--<logger name="*" minlevel="Information" maxlevel="Information" writeTo="Information" />--> <!--<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="JunmpPoliceStation.*" minlevel="Debug" maxlevel="Debug" writeTo="Debug" />
<logger name="*" minlevel="Error" maxlevel="Error" writeTo="Error" /> <logger name="*" minlevel="Error" maxlevel="Error" writeTo="Error" />
<!--日志级别:Trace -》Debug-》 Information -》Warning-》 Error-》 Critical--> <!--日志级别:Trace -》Debug-》 Information -》Warning-》 Error-》 Critical-->
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论