Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
JPSMysql
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
zxw
JPSMysql
Commits
acce1397
Commit
acce1397
authored
Sep 21, 2022
by
zonevg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix
parent
c434458c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
230 行增加
和
96 行删除
+230
-96
CabinetController.cs
JunmpPoliceStation/Controllers/CabinetController.cs
+2
-2
WarehouseController.cs
JunmpPoliceStation/Controllers/WarehouseController.cs
+227
-93
HttpHelper.cs
JunmpPoliceStation/Extensions/HttpHelper.cs
+1
-1
没有找到文件。
JunmpPoliceStation/Controllers/CabinetController.cs
View file @
acce1397
...
...
@@ -228,8 +228,8 @@ namespace JunmpPoliceStation.Controllers
bool
result
=
false
;
if
(
polices
.
Count
()
>
0
)
{
_unitOfWork
.
CabinetRepository
.
Delete
(
cabinet
s
,
false
);
result
=
_unitOfWork
.
PolicemanRepository
.
Update
(
police
s
,
true
);
_unitOfWork
.
PolicemanRepository
.
Update
(
police
s
,
false
);
result
=
_unitOfWork
.
CabinetRepository
.
Delete
(
cabinet
s
,
true
);
}
else
{
...
...
JunmpPoliceStation/Controllers/WarehouseController.cs
View file @
acce1397
...
...
@@ -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,80 +846,166 @@ namespace JunmpPoliceStation.Controllers
{
return
JsonManager
.
SimpleCustResponse
(
$"OrgizationId is require"
);
}
else
if
(!
string
.
IsNullOrEmpty
(
id
))
{
Expression
<
Func
<
BaseJpWarehouse
,
bool
>>
expression
=
t
=>
t
.
Id
.
Equals
(
id
);
BaseJpWarehouse
updateObject
=
_unitOfWork
.
WarehouseRepository
.
Get
(
expression
);
if
(
updateObject
!=
null
)
{
updateObject
.
Name
=
entity
.
name
;
updateObject
.
Location
=
entity
.
location
;
updateObject
.
LocationDetail
=
entity
.
locationDetail
;
updateObject
.
OrgizationId
=
entity
.
orgizationId
;
updateObject
.
Phone
=
entity
.
phone
;
updateObject
.
UpdateTime
=
System
.
DateTime
.
Now
;
updateObject
.
UpdateUser
=
entity
.
updateUser
;
updateObject
.
CameraUrl
=
entity
.
cameraUrl
;
}
else
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
bool
result
=
_unitOfWork
.
WarehouseRepository
.
Update
(
updateObject
);
if
(
result
)
{
return
JsonManager
.
ReturnSuccessResponse
(
new
{
id
=
updateObject
.
Id
,
name
=
updateObject
.
Name
,
orgizationId
=
updateObject
.
OrgizationId
,
location
=
updateObject
.
Location
,
phone
=
updateObject
.
Phone
,
cameraUrl
=
updateObject
.
CameraUrl
});
}
else
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
}
else
using
(
var
scope
=
_unitOfWork
.
BeginTransaction
())
{
//新增数据
BaseJpWarehouse
addObject
=
new
BaseJpWarehouse
()
{
Id
=
Guid
.
NewGuid
().
ToString
(),
Sort
=
null
,
Name
=
entity
.
name
,
Location
=
entity
.
location
,
LocationDetail
=
entity
.
locationDetail
,
OrgizationId
=
entity
.
orgizationId
,
Phone
=
entity
.
phone
,
CreateTime
=
System
.
DateTime
.
Now
,
UpdateTime
=
System
.
DateTime
.
Now
,
UpdateUser
=
entity
.
updateUser
,
CameraUrl
=
entity
.
cameraUrl
};
bool
result
=
_unitOfWork
.
WarehouseRepository
.
Insert
(
addObject
);
if
(
result
)
try
{
return
JsonManager
.
ReturnSuccessResponse
(
new
if
(!
string
.
IsNullOrEmpty
(
id
))
{
id
=
addObject
.
Id
,
name
=
addObject
.
Name
,
orgizationId
=
addObject
.
OrgizationId
,
location
=
addObject
.
Location
,
phone
=
addObject
.
Phone
,
cameraUrl
=
addObject
.
CameraUrl
});
Expression
<
Func
<
BaseJpWarehouse
,
bool
>>
expression
=
t
=>
t
.
Id
.
Equals
(
id
);
BaseJpWarehouse
updateObject
=
_unitOfWork
.
WarehouseRepository
.
Get
(
expression
);
if
(
updateObject
!=
null
)
{
updateObject
.
Name
=
entity
.
name
;
updateObject
.
Location
=
entity
.
location
;
updateObject
.
LocationDetail
=
entity
.
locationDetail
;
updateObject
.
OrgizationId
=
entity
.
orgizationId
;
updateObject
.
Phone
=
entity
.
phone
;
updateObject
.
UpdateTime
=
System
.
DateTime
.
Now
;
updateObject
.
UpdateUser
=
entity
.
updateUser
;
updateObject
.
CameraUrl
=
entity
.
cameraUrl
;
}
else
{
scope
.
Rollback
();
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
bool
result
=
_unitOfWork
.
WarehouseRepository
.
Update
(
updateObject
);
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
,
name
=
updateObject
.
Name
,
orgizationId
=
updateObject
.
OrgizationId
,
location
=
updateObject
.
Location
,
phone
=
updateObject
.
Phone
,
cameraUrl
=
updateObject
.
CameraUrl
});
}
else
{
scope
.
Rollback
();
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
}
else
{
//新增数据
BaseJpWarehouse
addObject
=
new
BaseJpWarehouse
()
{
Id
=
Guid
.
NewGuid
().
ToString
(),
Sort
=
null
,
Name
=
entity
.
name
,
Location
=
entity
.
location
,
LocationDetail
=
entity
.
locationDetail
,
OrgizationId
=
entity
.
orgizationId
,
Phone
=
entity
.
phone
,
CreateTime
=
System
.
DateTime
.
Now
,
UpdateTime
=
System
.
DateTime
.
Now
,
UpdateUser
=
entity
.
updateUser
,
CameraUrl
=
entity
.
cameraUrl
};
bool
result
=
_unitOfWork
.
WarehouseRepository
.
Insert
(
addObject
);
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
,
name
=
addObject
.
Name
,
orgizationId
=
addObject
.
OrgizationId
,
location
=
addObject
.
Location
,
phone
=
addObject
.
Phone
,
cameraUrl
=
addObject
.
CameraUrl
});
}
else
{
scope
.
Rollback
();
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
}
}
else
catch
(
Exception
e
)
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
scope
.
Rollback
();
throw
;
}
}
}
...
...
@@ -1045,38 +1136,81 @@ namespace JunmpPoliceStation.Controllers
return
JsonManager
.
SimpleCustResponse
(
$"isDisabled is require"
);
}
BaseJpWarehouse
warehouse
=
_unitOfWork
.
WarehouseRepository
.
Get
(
t
=>
t
.
Id
.
Equals
(
id
));
if
(
warehouse
!=
null
)
using
(
var
scope
=
_unitOfWork
.
BeginTransaction
())
{
if
(
isDisabled
)
try
{
//停用
if
(
_unitOfWork
.
EquipmentInventoryRepository
.
Count
(
x
=>
x
.
WarehouseCode
==
warehouse
.
Id
)
>
0
)
BaseJpWarehouse
warehouse
=
_unitOfWork
.
WarehouseRepository
.
Get
(
t
=>
t
.
Id
.
Equals
(
id
));
if
(
warehouse
!=
null
)
{
return
JsonManager
.
SimpleCustResponse
(
$"当前仓库存在装备,禁止停用"
);
if
(
isDisabled
)
{
//停用
if
(
_unitOfWork
.
EquipmentInventoryRepository
.
Count
(
x
=>
x
.
WarehouseCode
==
warehouse
.
Id
)
>
0
)
{
scope
.
Rollback
();
return
JsonManager
.
SimpleCustResponse
(
$"当前仓库存在装备,禁止停用"
);
}
warehouse
.
IsDisabled
=
true
;
}
else
{
//启用
warehouse
.
IsDisabled
=
false
;
}
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
);
}
warehouse
.
IsDisabled
=
true
;
}
else
{
//启用
warehouse
.
IsDisabled
=
false
;
}
if
(
_unitOfWork
.
WarehouseRepository
.
Update
(
warehouse
))
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
OPERATE_SUCCESS
);
}
else
catch
(
Exception
e
)
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
scope
.
Rollback
();
throw
;
}
}
else
{
return
JsonManager
.
SimpleStatusResponse
(
ResultCode
.
REQUEST_DATA_ERROR
);
}
}
else
{
...
...
JunmpPoliceStation/Extensions/HttpHelper.cs
View file @
acce1397
...
...
@@ -468,7 +468,7 @@ namespace JunmpPoliceStation.Extensions
sign
=
body_result
.
Item2
,
timestamp
=
body_result
.
Item3
,
version
=
_apiVersion
,
orgId
=
_organizationId
,
orgId
=
""
,
});
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论