Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TakeStock
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pengjinyang
TakeStock
Commits
28e18c4d
Commit
28e18c4d
authored
Nov 03, 2022
by
zhoujinhui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导出盘点数据新增产品名称字段
parent
150f873a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
145 additions
and
7 deletions
+145
-7
HttpClientService.cs
Common/Http/HttpClientService.cs
+17
-1
ProductSkusRequestDto.cs
Domain/Dto/ProductSkusRequestDto.cs
+22
-0
ProductSkusResponseDto.cs
Domain/Dto/ProductSkusResponseDto.cs
+33
-0
appsettings.Development.json
TakeStock.API/appsettings.Development.json
+2
-1
appsettings.json
TakeStock.API/appsettings.json
+3
-1
TakeStockAppService.cs
TakeStock.Application/TakeStock/TakeStockAppService.cs
+68
-4
No files found.
Common/Http/HttpClientService.cs
View file @
28e18c4d
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Net.Http
;
using
System.Net.Http.Headers
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Common.Http
namespace
Common.Http
{
{
public
class
HttpClientService
public
class
HttpClientService
{
{
/// <summary>
/// Json Post方法
/// </summary>
/// <param name="url"></param>
/// <param name="jsonData"></param>
/// <returns></returns>
public
static
async
Task
<
string
>
PostJsonAsync
(
string
url
,
string
jsonData
,
int
timeout
=
100
)
{
var
httpClient
=
new
HttpClient
{
Timeout
=
TimeSpan
.
FromSeconds
(
timeout
)
};
HttpContent
httpContent
=
new
StringContent
(
jsonData
);
httpContent
.
Headers
.
ContentType
=
new
MediaTypeHeaderValue
(
"application/json"
);
var
response
=
await
httpClient
.
PostAsync
(
url
,
httpContent
);
return
await
response
.
Content
.
ReadAsStringAsync
();
}
}
}
}
}
Domain/Dto/ProductSkusRequestDto.cs
0 → 100644
View file @
28e18c4d
namespace
Domain.Dto
{
/// <summary>
/// 查询产品库资料信息请求参数
/// </summary>
public
class
ProductSkusRequestDto
{
/// <summary>
/// json 字符串 ProductSkusRequestBodyDto
/// </summary>
public
string
ConditionJson
{
get
;
set
;
}
}
public
class
ProductSkusRequestBodyDto
{
public
int
IsResultSup
{
get
;
set
;
}
=
1
;
public
int
IsResultWare
{
get
;
set
;
}
=
1
;
public
string
Skus
{
get
;
set
;
}
}
}
Domain/Dto/ProductSkusResponseDto.cs
0 → 100644
View file @
28e18c4d
using
System.Collections.Generic
;
namespace
Domain.Dto
{
/// <summary>
/// 查询产品库资料信息返回参数
/// </summary>
public
class
ProductSkusResponseDto
{
public
ProductSkusResultDto
Result
{
get
;
set
;
}
}
public
class
ProductSkusResultDto
{
public
List
<
ProductSkusItemDto
>
Data
{
get
;
set
;
}
}
public
class
ProductSkusItemDto
{
public
string
sku
{
get
;
set
;
}
public
string
productCode
{
get
;
set
;
}
public
string
ctitle
{
get
;
set
;
}
public
string
etitle
{
get
;
set
;
}
public
string
cbaoguan
{
get
;
set
;
}
public
string
ebaoguan
{
get
;
set
;
}
/// <summary>
/// 海关编码
/// </summary>
public
string
hscode
{
get
;
set
;
}
}
}
TakeStock.API/appsettings.Development.json
View file @
28e18c4d
...
@@ -22,5 +22,6 @@
...
@@ -22,5 +22,6 @@
"AccessKey"
:
"QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn"
,
"AccessKey"
:
"QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn"
,
"SecretKey"
:
"yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm"
,
"SecretKey"
:
"yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm"
,
"CdnUrl"
:
"http://imgcache.bailuntec.com/"
"CdnUrl"
:
"http://imgcache.bailuntec.com/"
}
},
"SkumsProductApiUrl"
:
"http://api.skums.bailuntec.com/api/sku/productsku/postproductskusapi"
}
}
TakeStock.API/appsettings.json
View file @
28e18c4d
...
@@ -24,5 +24,6 @@
...
@@ -24,5 +24,6 @@
"AccessKey"
:
"QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn"
,
"AccessKey"
:
"QSvtvN4Ons1CiNzaMGqx8XmDaiM1L0ZqSwJ2YoTn"
,
"SecretKey"
:
"yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm"
,
"SecretKey"
:
"yagRd-cBOVhkRGGT-o_reMqNVjI8_k7YwoTXkhrm"
,
"CdnUrl"
:
"http://imgcache.bailuntec.com/"
"CdnUrl"
:
"http://imgcache.bailuntec.com/"
}
},
"SkumsProductApiUrl"
:
"http://api.skums.bailuntec.com/api/sku/productsku/postproductskusapi"
}
}
\ No newline at end of file
TakeStock.Application/TakeStock/TakeStockAppService.cs
View file @
28e18c4d
using
AutoMapper
;
using
AutoMapper
;
using
Common
;
using
Common.Extensions
;
using
Common.Extensions
;
using
Common.Helper
;
using
Common.Helper
;
using
Common.Http
;
using
Domain.Dto
;
using
Domain.Dto
;
using
Domain.TakeStock
;
using
Domain.TakeStock
;
using
IService.TakeStock
;
using
IService.TakeStock
;
...
@@ -170,6 +172,7 @@ namespace TakeStock.Application.TakeStock
...
@@ -170,6 +172,7 @@ namespace TakeStock.Application.TakeStock
var
titles
=
new
Dictionary
<
string
,
string
>()
var
titles
=
new
Dictionary
<
string
,
string
>()
{
{
{
"Sku"
,
"Sku"
},
{
"Sku"
,
"Sku"
},
{
"SkuTitle"
,
"产品名称"
},
{
"BeforeQuantity"
,
"盘点前数量"
},
{
"BeforeQuantity"
,
"盘点前数量"
},
{
"AfterQuantity"
,
"盘点后数量"
},
{
"AfterQuantity"
,
"盘点后数量"
},
{
"Code"
,
"计划单号"
},
{
"Code"
,
"计划单号"
},
...
@@ -187,15 +190,76 @@ namespace TakeStock.Application.TakeStock
...
@@ -187,15 +190,76 @@ namespace TakeStock.Application.TakeStock
{
"CreatorUserName"
,
"盘点人"
},
{
"CreatorUserName"
,
"盘点人"
},
{
"CreationTime"
,
"盘点时间"
}
{
"CreationTime"
,
"盘点时间"
}
};
};
var
list
=
dataList
.
Select
(
x
=>
new
{
var
skus
=
dataList
.
Select
(
x
=>
x
.
Sku
).
Distinct
().
ToList
();
x
.
Sku
,
x
.
BeforeQuantity
,
x
.
AfterQuantity
,
x
.
Code
,
x
.
StateStr
,
x
.
TakeStockTypeStr
,
x
.
InventoryLossTypeStr
,
var
skumsProductList
=
GetProductSkusPage
(
skus
);
x
.
AuditUserName
,
x
.
AuditDateTime
,
x
.
AuditExplain
,
x
.
WarehouseName
,
x
.
SysSerialNumber
,
x
.
Description
,
var
list
=
dataList
.
Select
(
x
=>
new
x
.
CreatorUserName
,
x
.
CreationTime
,
x
.
CredentialsImgUrl
,
x
.
SkuTotalAmount
{
x
.
Sku
,
SkuTitle
=
skumsProductList
.
FirstOrDefault
(
p
=>
p
.
sku
==
x
.
Sku
)?.
ctitle
,
x
.
BeforeQuantity
,
x
.
AfterQuantity
,
x
.
Code
,
x
.
StateStr
,
x
.
TakeStockTypeStr
,
x
.
InventoryLossTypeStr
,
x
.
AuditUserName
,
x
.
AuditDateTime
,
x
.
AuditExplain
,
x
.
WarehouseName
,
x
.
SysSerialNumber
,
x
.
Description
,
x
.
CreatorUserName
,
x
.
CreationTime
,
x
.
CredentialsImgUrl
,
x
.
SkuTotalAmount
}).
ToList
();
}).
ToList
();
var
ms
=
EPPlusUtils
.
ExportStream
(
list
,
titles
);
var
ms
=
EPPlusUtils
.
ExportStream
(
list
,
titles
);
return
ms
;
return
ms
;
}
}
private
List
<
ProductSkusItemDto
>
GetProductSkusPage
(
List
<
string
>
skus
)
{
var
resultList
=
new
List
<
ProductSkusItemDto
>();
if
(
skus
.
Count
<=
0
)
return
resultList
;
if
(
skus
.
Count
<=
20
)
{
resultList
=
GetProductSkus
(
string
.
Join
(
","
,
skus
));
return
resultList
;
}
int
row
=
20
;
for
(
int
i
=
1
;
i
<
10000
;
i
++)
{
var
limitSku
=
skus
.
Skip
(
row
*
(
i
-
1
)).
Take
(
row
).
ToArray
();
if
(
limitSku
.
Length
<=
0
)
break
;
var
list
=
GetProductSkus
(
string
.
Join
(
","
,
limitSku
));
resultList
.
AddRange
(
list
);
}
return
resultList
;
}
/// <summary>
/// 查询
/// </summary>
/// <param name="skus"></param>
/// <returns></returns>
private
List
<
ProductSkusItemDto
>
GetProductSkus
(
string
skus
)
{
try
{
var
configuration
=
Configurations
.
Get
(
DirectoryFinder
.
CalculateContentRootFolder
());
var
apiUrl
=
configuration
[
"SkumsProductApiUrl"
];
var
skusStr
=
JsonConvert
.
SerializeObject
(
new
ProductSkusRequestBodyDto
{
Skus
=
skus
});
var
jsonStr
=
JsonConvert
.
SerializeObject
(
new
ProductSkusRequestDto
{
ConditionJson
=
skusStr
});
var
responseStr
=
HttpClientService
.
PostJsonAsync
(
apiUrl
,
jsonStr
).
Result
;
var
responseData
=
JsonConvert
.
DeserializeObject
<
ProductSkusResponseDto
>(
responseStr
);
return
responseData
.
Result
.
Data
;
}
catch
(
Exception
)
{
return
new
List
<
ProductSkusItemDto
>();
}
}
/// <summary>
/// <summary>
/// 查询
/// 查询
/// </summary>
/// </summary>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment