Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
smalltools
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王家辉
smalltools
Commits
e50f2f21
Commit
e50f2f21
authored
Feb 12, 2019
by
wjh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复sku功能
parent
85c5c37a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
136 additions
and
12 deletions
+136
-12
pom.xml
+1
-0
src/main/java/com/freemud/Controller/OrdersController.java
+10
-4
src/main/java/com/freemud/Service/Impl/OrdersServiceImpl.java
+38
-6
src/main/java/com/freemud/Service/OrdersService.java
+2
-2
src/main/java/com/freemud/dto/BaseResponse.java
+28
-0
src/main/java/com/freemud/utils/ExcelOperationUtils.java
+57
-0
No files found.
pom.xml
View file @
e50f2f21
...
...
@@ -124,6 +124,7 @@
<artifactId>
xercesImpl
</artifactId>
<version>
2.9.1
</version>
</dependency>
<!-- excel 工具类结束 -->
<dependency>
<groupId>
commons-beanutils
</groupId>
<artifactId>
commons-beanutils
</artifactId>
...
...
src/main/java/com/freemud/Controller/OrdersController.java
View file @
e50f2f21
...
...
@@ -42,14 +42,20 @@ public class OrdersController {
@ApiOperation
(
"根据正确的sku进行补推"
)
@PostMapping
(
"/getRightSkuAndOrderPush"
)
@ResponseBody
public
String
getRightSkuAndOrderPush
(
@RequestBody
OrderProductDTO
orderProductDTO
){
public
OrderProductDTO
getRightSkuAndOrderPush
(
@RequestBody
OrderProductDTO
orderProductDTO
){
String
orderId
=
orderProductDTO
.
getOrderCode
();
String
sku
=
orderProductDTO
.
getSku
();
Long
id
=
orderProductDTO
.
getId
();
String
channel
=
orderProductDTO
.
getChannel
();
ordersService
.
RepairByRightSku
(
id
,
sku
);
ordersService
.
OrderPush
(
channel
,
orderId
);
return
null
;
// 修复sku
// boolean isMod = ordersService.RepairByRightSku(id,sku);
// if (isMod){
// return "修复成功";
// } else {
// return "修复失败";
// }
return
orderProductDTO
;
// ordersService.OrderPush(channel,orderId);
}
...
...
src/main/java/com/freemud/Service/Impl/OrdersServiceImpl.java
View file @
e50f2f21
...
...
@@ -14,14 +14,24 @@ package com.freemud.Service.Impl;
import
com.freemud.Mapper.OrderProductMapper
;
import
com.freemud.Service.OrdersService
;
import
com.freemud.dto.BaseResponse
;
import
com.freemud.dto.OrderProductDTO
;
import
com.freemud.utils.ExcelOperationUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.io.FileSystemResource
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
@Slf4j
public
class
OrdersServiceImpl
implements
OrdersService
{
@Autowired
...
...
@@ -30,23 +40,45 @@ public class OrdersServiceImpl implements OrdersService {
@Autowired
private
RestTemplate
restTemplate
;
private
String
RequestUrl
=
"http://172.16.15.179:3017"
;
@Override
public
List
<
OrderProductDTO
>
getOrderProductDTOByOrderId
(
String
orderId
)
{
return
orderProductMapper
.
getOrderProductDTOByOrderId
(
orderId
);
}
@Override
public
void
RepairByRightSku
(
Long
id
,
String
sku
)
{
public
Boolean
RepairByRightSku
(
Long
id
,
String
sku
)
{
// 请求修复接口
// String url = "10.50.1.40:9929/order/repairByRightSku";
// restTemplate.getForObject(url,String.class);
String
url
=
RequestUrl
+
"/order/repairByRightSku"
;
String
titles
[]
=
{
"订单联合表主键"
,
"正确的sku"
};
List
<
String
>
cells
=
new
ArrayList
<>();
cells
.
add
(
id
+
""
);
cells
.
add
(
sku
);
File
file
=
ExcelOperationUtils
.
WriteExcel
(
titles
,
cells
);
FileSystemResource
resource
=
new
FileSystemResource
(
file
.
getPath
());
MultiValueMap
<
String
,
Object
>
param
=
new
LinkedMultiValueMap
<>();
param
.
add
(
"file"
,
resource
);
String
code
=
restTemplate
.
postForObject
(
url
,
param
,
String
.
class
);
if
(
code
.
equals
(
"100"
)){
log
.
info
(
"修改sku成功"
);
return
true
;
}
log
.
info
(
"修改sku失败:{}"
);
return
false
;
}
@Override
public
void
OrderPush
(
String
channel
,
String
orderId
)
{
public
Boolean
OrderPush
(
String
channel
,
String
orderId
)
{
// 补推订单
String
checkAndPushUrl
=
RequestUrl
+
"/order/checkOrderPush"
;
BaseResponse
baseResponse
=
restTemplate
.
getForObject
(
checkAndPushUrl
,
BaseResponse
.
class
,
channel
,
orderId
);
if
(
baseResponse
.
getCode
().
equals
(
"100"
)){
log
.
info
(
"补推订单成功:{}"
,
baseResponse
.
getResult
());
return
true
;
}
log
.
info
(
"补推订单失败:{}"
,
baseResponse
.
getResult
());
return
false
;
}
...
...
src/main/java/com/freemud/Service/OrdersService.java
View file @
e50f2f21
...
...
@@ -25,7 +25,7 @@ public interface OrdersService {
*/
List
<
OrderProductDTO
>
getOrderProductDTOByOrderId
(
String
orderId
);
void
RepairByRightSku
(
Long
id
,
String
sku
);
Boolean
RepairByRightSku
(
Long
id
,
String
sku
);
void
OrderPush
(
String
channel
,
String
orderId
);
Boolean
OrderPush
(
String
channel
,
String
orderId
);
}
src/main/java/com/freemud/dto/BaseResponse.java
0 → 100644
View file @
e50f2f21
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: orderProductDTO
* @Package com.freemud.dto
* @Description: 简单描述下这个类是做什么用的
* @author: jiahui.wang
* @date: 2019/1/26 10:25
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目的
*/
package
com
.
freemud
.
dto
;
import
lombok.Data
;
@Data
public
class
BaseResponse
<
T
>{
protected
String
code
;
protected
String
message
;
protected
String
ver
;
protected
T
result
;
}
src/main/java/com/freemud/utils/ExcelOperationUtils.java
0 → 100644
View file @
e50f2f21
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: HandleExcelException
* @Package com.freemud.apps.promotion.exception
* @Description: 简单描述下这个类是做什么用的
* @author: jiahui.wang
* @date: 2019/1/30 17:31
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目的
*/
package
com
.
freemud
.
utils
;
import
org.apache.poi.hssf.usermodel.HSSFCell
;
import
org.apache.poi.hssf.usermodel.HSSFRow
;
import
org.apache.poi.hssf.usermodel.HSSFSheet
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.List
;
public
class
ExcelOperationUtils
{
public
static
File
WriteExcel
(
String
[]
titles
,
List
<
String
>
cells
){
HSSFWorkbook
workbook
=
new
HSSFWorkbook
();
HSSFSheet
sheet
=
workbook
.
createSheet
();
// 创建第一行 ( 表头 )
HSSFRow
row
=
sheet
.
createRow
(
0
);
HSSFCell
cell
=
null
;
for
(
int
i
=
0
;
i
<
titles
.
length
;
i
++){
cell
=
row
.
createCell
(
i
);
cell
.
setCellValue
(
titles
[
i
]);
}
//写入数据
HSSFRow
nrow
=
sheet
.
createRow
(
1
);
HSSFCell
ncell
=
nrow
.
createCell
(
0
);
ncell
.
setCellValue
(
cells
.
get
(
0
));
ncell
=
nrow
.
createCell
(
1
);
ncell
.
setCellValue
(
cells
.
get
(
1
));
//创建excel文件
File
file
=
new
File
(
"/opt/test.xls"
);
try
{
file
.
createNewFile
();
//将excel写入
FileOutputStream
stream
=
new
FileOutputStream
(
file
);
workbook
.
write
(
stream
);
stream
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
file
;
}
}
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