Commit acce1397 by zonevg

bug fix

parent c434458c
......@@ -228,8 +228,8 @@ namespace JunmpPoliceStation.Controllers
bool result = false;
if (polices.Count() > 0)
{
_unitOfWork.CabinetRepository.Delete(cabinets, false);
result = _unitOfWork.PolicemanRepository.Update(polices, true);
_unitOfWork.PolicemanRepository.Update(polices, false);
result = _unitOfWork.CabinetRepository.Delete(cabinets, true);
}
else
{
......
......@@ -14,8 +14,11 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using JunmpPoliceStation.Extensions;
namespace JunmpPoliceStation.Controllers
{
......@@ -26,13 +29,15 @@ namespace JunmpPoliceStation.Controllers
//private ICabinetRepository _CabinetRepository;
private ILogger<WarehouseController> _logger;
UnitOfWork _unitOfWork;
HttpHelper _httpHelper;
public List<BaseJpOrganization> ListEq = new List<BaseJpOrganization>();
public WarehouseController(ILogger<WarehouseController> logger, UnitOfWork unitOfWork)
public WarehouseController(ILogger<WarehouseController> logger, UnitOfWork unitOfWork, HttpHelper httpHelper)
{
_logger = logger;
//_CabinetRepository = CabinetRepository;
_unitOfWork = unitOfWork;
_httpHelper = httpHelper;
}
/// <summary>
......@@ -841,7 +846,12 @@ namespace JunmpPoliceStation.Controllers
{
return JsonManager.SimpleCustResponse($"OrgizationId is require");
}
else if (!string.IsNullOrEmpty(id))
using (var scope = _unitOfWork.BeginTransaction())
{
try
{
if (!string.IsNullOrEmpty(id))
{
Expression<Func<BaseJpWarehouse, bool>> expression = t => t.Id.Equals(id);
BaseJpWarehouse updateObject = _unitOfWork.WarehouseRepository.Get(expression);
......@@ -858,6 +868,7 @@ namespace JunmpPoliceStation.Controllers
}
else
{
scope.Rollback();
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
......@@ -865,6 +876,42 @@ namespace JunmpPoliceStation.Controllers
if (result)
{
//上报更新数据
var pushdata = new
{
id = updateObject.Id,
name = updateObject.Name,
location = updateObject.Location,
locationDetail = updateObject.LocationDetail,
orgizationId = updateObject.OrgizationId,
phone = updateObject.Phone,
updateUser = updateObject.UpdateUser,
cameraUrl = updateObject.CameraUrl,
};
var res = _httpHelper.GetHtml(new HttpItem()
{
URL = _httpHelper._centerServerAddress + "/api/Warehouse/AddOrUpdateWarehouse",
Encoding = Encoding.UTF8,
Method = "POST",
ContentType = "application/json",
Postdata = _httpHelper.CreatePostData(JsonConvert.SerializeObject(pushdata)),
Timeout = 5000
});
if (res.StatusCode != HttpStatusCode.OK || string.IsNullOrEmpty(res.Html))
{
scope.Rollback();
return JsonManager.SimpleStatusResponse(ResultCode.REMOTE_REPORTING_ERROR);
}
var obj = JsonConvert.DeserializeObject<dynamic>(res.Html);
if (obj.code != "10000")
{
scope.Rollback();
return JsonManager.SimpleCustResponse(obj.msg ?? "操作失败");
}
scope.Commit();
return JsonManager.ReturnSuccessResponse(new
{
id = updateObject.Id,
......@@ -872,11 +919,12 @@ namespace JunmpPoliceStation.Controllers
orgizationId = updateObject.OrgizationId,
location = updateObject.Location,
phone = updateObject.Phone,
cameraUrl= updateObject.CameraUrl
cameraUrl = updateObject.CameraUrl
});
}
else
{
scope.Rollback();
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
}
......@@ -902,6 +950,41 @@ namespace JunmpPoliceStation.Controllers
if (result)
{
//上报新增数据
var pushdata = new
{
name = addObject.Name,
location = addObject.Location,
locationDetail = addObject.LocationDetail,
orgizationId = addObject.OrgizationId,
phone = addObject.Phone,
updateUser = addObject.UpdateUser,
cameraUrl = addObject.CameraUrl,
thirdWarehouseId = addObject.Id
};
var res = _httpHelper.GetHtml(new HttpItem()
{
URL = _httpHelper._centerServerAddress + "/api/Warehouse/AddOrUpdateWarehouse",
Encoding = Encoding.UTF8,
Method = "POST",
ContentType = "application/json",
Postdata = _httpHelper.CreatePostData(JsonConvert.SerializeObject(pushdata)),
Timeout = 5000
});
if (res.StatusCode != HttpStatusCode.OK || string.IsNullOrEmpty(res.Html))
{
scope.Rollback();
return JsonManager.SimpleStatusResponse(ResultCode.REMOTE_REPORTING_ERROR);
}
var obj = JsonConvert.DeserializeObject<dynamic>(res.Html);
if (obj.code != "10000")
{
scope.Rollback();
return JsonManager.SimpleCustResponse(obj.msg ?? "操作失败");
}
scope.Commit();
return JsonManager.ReturnSuccessResponse(new
{
id = addObject.Id,
......@@ -914,10 +997,18 @@ namespace JunmpPoliceStation.Controllers
}
else
{
scope.Rollback();
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
}
}
catch (Exception e)
{
scope.Rollback();
throw;
}
}
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
......@@ -1045,6 +1136,10 @@ namespace JunmpPoliceStation.Controllers
return JsonManager.SimpleCustResponse($"isDisabled is require");
}
using (var scope = _unitOfWork.BeginTransaction())
{
try
{
BaseJpWarehouse warehouse = _unitOfWork.WarehouseRepository.Get(t => t.Id.Equals(id));
if (warehouse != null)
{
......@@ -1053,6 +1148,7 @@ namespace JunmpPoliceStation.Controllers
//停用
if (_unitOfWork.EquipmentInventoryRepository.Count(x => x.WarehouseCode == warehouse.Id) > 0)
{
scope.Rollback();
return JsonManager.SimpleCustResponse($"当前仓库存在装备,禁止停用");
}
warehouse.IsDisabled = true;
......@@ -1066,18 +1162,56 @@ namespace JunmpPoliceStation.Controllers
if (_unitOfWork.WarehouseRepository.Update(warehouse))
{
//上报更新数据
var pushdata = new
{
id = warehouse.Id,
isDisabled = warehouse.IsDisabled,
};
var res = _httpHelper.GetHtml(new HttpItem()
{
URL = _httpHelper._centerServerAddress + "/api/Warehouse/DisabledWarehouse",
Encoding = Encoding.UTF8,
Method = "POST",
ContentType = "application/json",
Postdata = _httpHelper.CreatePostData(JsonConvert.SerializeObject(pushdata)),
Timeout = 5000
});
if (res.StatusCode != HttpStatusCode.OK || string.IsNullOrEmpty(res.Html))
{
scope.Rollback();
return JsonManager.SimpleStatusResponse(ResultCode.REMOTE_REPORTING_ERROR);
}
var obj = JsonConvert.DeserializeObject<dynamic>(res.Html);
if (obj.code != "10000")
{
scope.Rollback();
return JsonManager.SimpleCustResponse(obj.msg ?? "操作失败");
}
scope.Commit();
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
}
else
{
scope.Rollback();
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
}
else
{
scope.Rollback();
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
}
catch (Exception e)
{
scope.Rollback();
throw;
}
}
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
......
......@@ -468,7 +468,7 @@ namespace JunmpPoliceStation.Extensions
sign = body_result.Item2,
timestamp = body_result.Item3,
version = _apiVersion,
orgId = _organizationId,
orgId = "",
});
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论