Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bailuntec-cost
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
huluobin
bailuntec-cost
Commits
7c46287b
Commit
7c46287b
authored
Jul 21, 2021
by
liyanlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
f091a576
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
16 deletions
+55
-16
Dockerfile
cost-service/src/main/docker/Dockerfile
+2
-7
FileController.java
...m/blt/other/module/commons/controller/FileController.java
+8
-3
CostApiServiceImpl.java
...lt/other/module/cost/service/impl/CostApiServiceImpl.java
+2
-2
CostDetailServiceImpl.java
...other/module/cost/service/impl/CostDetailServiceImpl.java
+9
-2
CostPlanServiceFactory.java
...le/cost/service/impl/costplan/CostPlanServiceFactory.java
+1
-0
CostFileUtil.java
...in/java/com/blt/other/module/cost/utils/CostFileUtil.java
+25
-0
PurchasingListDetailController.java
...purchasing/controller/PurchasingListDetailController.java
+8
-2
No files found.
cost-service/src/main/docker/Dockerfile
View file @
7c46287b
FROM
openjdk:8-jdk-alpine
VOLUME
/tmp
ADD
cost-service-1.0-SNAPSHOT.jar cost-service-1.0-SNAPSHOT.jar
ENV
LANG en_GB.UTF-8
RUN
echo
"Asia/Shanghai"
>
/etc/timezone
RUN
echo
-e
"https://mirror.tuna.tsinghua.edu.cn/alpine/v3.4/main
\n\
https://mirror.tuna.tsinghua.edu.cn/alpine/v3.4/community"
>
/etc/apk/repositories
RUN
apk
--update
add curl bash ttf-dejavu
&&
\
rm
-rf
/var/cache/apk/
*
ENTRYPOINT
["java","-Xms1G","-Xmx1G","-jar","-Dspring.profiles.active=test","/cost-service-1.0-SNAPSHOT.jar"]
ENTRYPOINT
["java","-Xms100m","-Xmx300m","-jar","-Dspring.profiles.active=prod","/app.jar"]
EXPOSE
8082
cost-service/src/main/java/com/blt/other/module/commons/controller/FileController.java
View file @
7c46287b
...
...
@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
/**
* <p>
*
...
...
@@ -30,10 +32,13 @@ public class FileController {
public
CostResult
<
String
>
upload
(
MultipartFile
file
)
{
/*附件字段*/
if
(
file
!=
null
)
{
// 文件上传的路径
String
filePath
=
PathUtil
.
getBasePath
()
+
PathUtil
.
getPath
(
"cost/"
);
// 调用工具类执行保存,并返回 path
String
path
=
CostFileUtil
.
upload
(
file
,
filePath
);
String
path
=
null
;
try
{
path
=
CostFileUtil
.
qiniuUpload
(
file
);
}
catch
(
IOException
e
)
{
throw
new
BizRuntimeException
(
"上传文件失败"
);
}
return
CostResult
.
success
(
path
);
}
throw
new
BizRuntimeException
(
"文件不能为空"
);
...
...
cost-service/src/main/java/com/blt/other/module/cost/service/impl/CostApiServiceImpl.java
View file @
7c46287b
...
...
@@ -242,9 +242,9 @@ public class CostApiServiceImpl implements CostApiService {
CostDetailDomain
costDetailDomain
=
new
CostDetailDomain
();
// 文件上传的路径
String
filePath
=
PathUtil
.
getBasePath
()
+
PathUtil
.
getPath
(
"cost/"
+
costDomain
.
getCostNo
()
+
"/"
);
//
String filePath = PathUtil.getBasePath() + PathUtil.getPath("cost/" + costDomain.getCostNo() + "/");
// 调用工具类执行保存,并返回 path
String
path
=
CostFileUtil
.
upload
(
wageCostDto
.
getFileUrl
(),
filePath
);
String
path
=
CostFileUtil
.
qiniuUpload
(
wageCostDto
.
getFileUrl
()
);
BeanUtils
.
copyProperties
(
costDomain
,
costDetailDomain
);
costDetailDomain
.
setDetailNo
(
costNo
+
"-1"
);
...
...
cost-service/src/main/java/com/blt/other/module/cost/service/impl/CostDetailServiceImpl.java
View file @
7c46287b
...
...
@@ -3,6 +3,7 @@ package com.blt.other.module.cost.service.impl;
import
com.bailuntec.common.BeanUtils
;
import
com.bailuntec.common.ListUtil
;
import
com.bailuntec.common.StringUtils
;
import
com.bailuntec.common.exception.BizException
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.blt.other.common.exception.BizRuntimeException
;
...
...
@@ -24,6 +25,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
@@ -74,9 +76,14 @@ public class CostDetailServiceImpl extends ServiceImpl<CostDetailDao, CostDetail
if
(
req
.
getFileSelect2
()
!=
null
)
{
// 文件上传的路径
String
filePath
=
PathUtil
.
getBasePath
()
+
PathUtil
.
getPath
(
"cost/"
+
costDetailDomain
.
getDetailNo
()
+
"/"
);
//
String filePath = PathUtil.getBasePath() + PathUtil.getPath("cost/" + costDetailDomain.getDetailNo() + "/");
// 调用工具类执行保存,并返回 path
String
path
=
CostFileUtil
.
upload
(
req
.
getFileSelect2
(),
filePath
);
String
path
=
null
;
try
{
path
=
CostFileUtil
.
qiniuUpload
(
req
.
getFileSelect2
());
}
catch
(
IOException
e
)
{
throw
new
BizException
(
"上传文件失败"
);
}
costDetailDomain
.
setFilePath
(
path
);
}
...
...
cost-service/src/main/java/com/blt/other/module/cost/service/impl/costplan/CostPlanServiceFactory.java
View file @
7c46287b
...
...
@@ -200,6 +200,7 @@ public class CostPlanServiceFactory {
throw
new
BizException
(
"找不到文件:"
+
costPlanDomain
.
getFilePath
());
}
String
path
=
CostFileUtil
.
qiniuUpload
(
currentFile
);
currentFile
.
deleteOnExit
();
if
(
path
==
null
)
{
throw
new
Exception
(
"上传附件失败"
);
}
...
...
cost-service/src/main/java/com/blt/other/module/cost/utils/CostFileUtil.java
View file @
7c46287b
...
...
@@ -102,6 +102,31 @@ public class CostFileUtil {
return
qiniuUpload
(
localFile
);
}
public
static
String
qiniuUpload
(
String
netUrl
)
throws
IOException
{
RestTemplate
restTemplate
=
new
RestTemplate
();
byte
[]
bytes
=
restTemplate
.
getForObject
(
netUrl
,
byte
[].
class
);
if
(
bytes
==
null
||
bytes
.
length
==
0
)
{
throw
new
RuntimeException
(
"附件内容为空"
);
}
int
dotIndex
=
netUrl
.
lastIndexOf
(
"."
);
File
tempFile
=
File
.
createTempFile
(
UidUtils
.
VM_ID
+
"fee-original"
,
"."
+
netUrl
.
substring
(
dotIndex
+
1
));
OutputStream
outputStream
=
new
FileOutputStream
(
tempFile
.
getAbsolutePath
());
outputStream
.
write
(
bytes
);
outputStream
.
close
();
String
path
=
"http://dcfile.blsct.com/"
+
qiniuUpload
(
tempFile
);
tempFile
.
deleteOnExit
();
return
path
;
}
public
static
String
qiniuUpload
(
MultipartFile
file
)
throws
IOException
{
File
tempFile
=
File
.
createTempFile
(
UidUtils
.
VM_ID
+
"fee-original"
,
file
.
getOriginalFilename
().
replaceAll
(
"_"
,
""
));
file
.
transferTo
(
tempFile
);
String
path
=
"http://dcfile.blsct.com/"
+
qiniuUpload
(
tempFile
);
tempFile
.
deleteOnExit
();
return
path
;
}
public
static
String
qiniuUpload
(
File
localFilePath
)
{
//1、构造一个带指定Zone对象的配置类
// Configuration cfg = new Configuration(Zone.zone2());
...
...
cost-service/src/main/java/com/blt/other/module/purchasing/controller/PurchasingListDetailController.java
View file @
7c46287b
package
com
.
blt
.
other
.
module
.
purchasing
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.bailuntec.common.exception.BizException
;
import
com.bailuntec.cost.api.domain.BuyDomain
;
import
com.blt.other.common.annotation.LoginIgnore
;
import
com.blt.other.common.config.property.CostUrlProperties
;
...
...
@@ -240,9 +241,14 @@ public class PurchasingListDetailController {
}
if
(
file
!=
null
)
{
// 文件上传的路径
String
filePath
=
PathUtil
.
getBasePath
()
+
PathUtil
.
getPath
(
"buy/"
+
buyDomain
.
getBuyno
()
+
"/"
);
//
String filePath = PathUtil.getBasePath() + PathUtil.getPath("buy/" + buyDomain.getBuyno() + "/");
// 调用工具类执行保存,并返回 path
String
path
=
CostFileUtil
.
upload
(
file
,
filePath
);
String
path
=
null
;
try
{
path
=
CostFileUtil
.
qiniuUpload
(
file
);
}
catch
(
IOException
e
)
{
throw
new
BizException
(
"上传文件失败"
);
}
buyDomain
.
setFilepath
(
path
);
}
Integer
update
=
buyService
.
getUpdate
(
buyDomain
);
...
...
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