Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dc-cost-system
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
bltdc
dc-cost-system
Commits
433fdc01
Commit
433fdc01
authored
Nov 13, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
aeee3783
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
208 additions
and
21 deletions
+208
-21
pom.xml
bailuntec-cost-core/pom.xml
+24
-7
OaDepartment.java
...in/java/com/blt/other/module/auth/model/OaDepartment.java
+4
-0
CostTemplate.java
...in/java/com/blt/other/module/cost/model/CostTemplate.java
+4
-1
CostTemplateCol.java
...java/com/blt/other/module/cost/model/CostTemplateCol.java
+0
-11
DepartmentCheckState.java
...ule/cost/service/impl/costcheck/DepartmentCheckState.java
+22
-1
CostCompanyDomainListener.java
...rc/test/java/com/blt/other/CostCompanyDomainListener.java
+107
-0
CostCompanyExcel.java
...st-core/src/test/java/com/blt/other/CostCompanyExcel.java
+31
-0
OtherApplicationTests.java
...re/src/test/java/com/blt/other/OtherApplicationTests.java
+16
-1
No files found.
bailuntec-cost-core/pom.xml
View file @
433fdc01
...
@@ -43,6 +43,30 @@
...
@@ -43,6 +43,30 @@
<artifactId>
bailuntec-cost-api
</artifactId>
<artifactId>
bailuntec-cost-api
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
easyexcel
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
3.17
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
3.17
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml-schemas
</artifactId>
<version>
3.17
</version>
</dependency>
<dependency>
<dependency>
<groupId>
com.bailuntec
</groupId>
<groupId>
com.bailuntec
</groupId>
<artifactId>
bailuntec-api
</artifactId>
<artifactId>
bailuntec-api
</artifactId>
...
@@ -176,13 +200,6 @@
...
@@ -176,13 +200,6 @@
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<!-- POI begin -->
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
${org.apache.poi}
</version>
</dependency>
<dependency>
<dependency>
<groupId>
commons-fileupload
</groupId>
<groupId>
commons-fileupload
</groupId>
<artifactId>
commons-fileupload
</artifactId>
<artifactId>
commons-fileupload
</artifactId>
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/auth/model/OaDepartment.java
View file @
433fdc01
...
@@ -10,6 +10,7 @@ import lombok.Data;
...
@@ -10,6 +10,7 @@ import lombok.Data;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.List
;
...
@@ -55,6 +56,7 @@ public class OaDepartment implements Serializable {
...
@@ -55,6 +56,7 @@ public class OaDepartment implements Serializable {
@ApiModelProperty
(
value
=
"排序"
)
@ApiModelProperty
(
value
=
"排序"
)
private
Integer
sort
;
private
Integer
sort
;
private
BigDecimal
departmentMinimumReviewAmount
;
@ApiModelProperty
(
value
=
"创建人id"
)
@ApiModelProperty
(
value
=
"创建人id"
)
private
Integer
createUserId
;
private
Integer
createUserId
;
...
@@ -74,4 +76,6 @@ public class OaDepartment implements Serializable {
...
@@ -74,4 +76,6 @@ public class OaDepartment implements Serializable {
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
List
<
CostReviewer
>
costReviewerList
;
private
List
<
CostReviewer
>
costReviewerList
;
}
}
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/model/CostTemplate.java
View file @
433fdc01
...
@@ -92,7 +92,10 @@ public class CostTemplate implements Serializable {
...
@@ -92,7 +92,10 @@ public class CostTemplate implements Serializable {
}
}
public
boolean
shouldFinalCheck
(
BigDecimal
amount
)
{
public
boolean
shouldFinalCheck
(
BigDecimal
amount
)
{
return
amount
.
compareTo
(
finalMinimumReviewAmount
)
>=
0
;
return
finalMinimumReviewAmount
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
&&
amount
.
compareTo
(
finalMinimumReviewAmount
)
>=
0
;
}
}
public
boolean
shouldDepartmentCheck
(
BigDecimal
amount
,
BigDecimal
departmentMinimumReviewAmount
)
{
return
departmentMinimumReviewAmount
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
&&
amount
.
compareTo
(
departmentMinimumReviewAmount
)
>=
0
;
}
}
}
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/model/CostTemplateCol.java
View file @
433fdc01
...
@@ -103,19 +103,8 @@ public class CostTemplateCol implements Serializable {
...
@@ -103,19 +103,8 @@ public class CostTemplateCol implements Serializable {
default
:
default
:
return
true
;
return
true
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
false
;
return
false
;
}
}
}
}
/**
* 表单必填校准
*
* @param costDomain
* @return
*/
public
Boolean
formCheck
(
CostDomain
costDomain
)
{
return
true
;
}
}
}
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/costcheck/DepartmentCheckState.java
View file @
433fdc01
package
com
.
blt
.
other
.
module
.
cost
.
service
.
impl
.
costcheck
;
package
com
.
blt
.
other
.
module
.
cost
.
service
.
impl
.
costcheck
;
import
com.blt.other.common.exception.BizRuntimeException
;
import
com.blt.other.common.exception.BizRuntimeException
;
import
com.blt.other.module.auth.dao.OaDepartmentMapper
;
import
com.blt.other.module.auth.model.CostReviewer
;
import
com.blt.other.module.auth.model.CostReviewer
;
import
com.blt.other.module.auth.model.OaDepartment
;
import
com.blt.other.module.auth.model.OaUser
;
import
com.blt.other.module.auth.model.OaUser
;
import
com.blt.other.module.auth.service.IOaUserService
;
import
com.blt.other.module.auth.service.IOaUserService
;
import
com.blt.other.module.cost.model.CostDomain
;
import
com.blt.other.module.cost.model.CostDomain
;
...
@@ -26,7 +28,8 @@ public class DepartmentCheckState extends CostState {
...
@@ -26,7 +28,8 @@ public class DepartmentCheckState extends CostState {
@Autowired
@Autowired
FinancialCheckState
financialCheckState
;
FinancialCheckState
financialCheckState
;
@Resource
OaDepartmentMapper
oaDepartmentMapper
;
@Resource
@Resource
IOaUserService
oaUserService
;
IOaUserService
oaUserService
;
...
@@ -56,6 +59,24 @@ public class DepartmentCheckState extends CostState {
...
@@ -56,6 +59,24 @@ public class DepartmentCheckState extends CostState {
return
;
return
;
}
}
//如果不需要审核 直接通过
OaUser
oaUser
=
oaUserService
.
getById
(
currentUserId
);
OaDepartment
oaDepartment
=
oaDepartmentMapper
.
selectByDepartmentId
(
oaUser
.
getPrimaryDepartmentId
());
if
(
costTemplate
.
shouldDepartmentCheck
(
costDomain
.
getAmount
(),
oaDepartment
.
getDepartmentMinimumReviewAmount
()))
{
costDomain
.
setCostStatus
(
CostDomain
.
STATUS_FINANCIAL_CHECK
);
costDao
.
updateById
(
costDomain
);
//流转状态
nextState
(
financialCheckState
);
costSubscribe
.
subscribe
(
costContext
);
costLogService
.
saveByManage
(
costDomain
.
getCostNo
(),
"部门审核自动通过"
,
CostLogDomain
.
DEPARTMENT_AUTO_PASS
);
return
;
}
//需要自动审核
//需要自动审核
if
(
costTemplate
.
shouldDepartmentAutoCheck
())
{
if
(
costTemplate
.
shouldDepartmentAutoCheck
())
{
//自动审核通过
//自动审核通过
...
...
bailuntec-cost-core/src/test/java/com/blt/other/CostCompanyDomainListener.java
0 → 100644
View file @
433fdc01
package
com
.
blt
.
other
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.fastjson.JSON
;
import
com.bailuntec.common.SpringContextUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.blt.other.module.auth.dao.CostReviewerMapper
;
import
com.blt.other.module.auth.dao.OaUserMapper
;
import
com.blt.other.module.auth.model.CostReviewer
;
import
com.blt.other.module.auth.model.OaUser
;
import
com.blt.other.module.cost.dao.CostCompanyDao
;
import
com.blt.other.module.database.model.CostCompanyDomain
;
import
com.google.common.collect.Lists
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/11/12 2:27 下午
*/
public
class
CostCompanyDomainListener
extends
AnalysisEventListener
<
CostCompanyExcel
>
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CostCompanyDomain
.
class
);
/**
* 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收
*/
private
static
final
int
BATCH_COUNT
=
5
;
List
<
CostCompanyExcel
>
list
=
new
ArrayList
<>();
@Override
public
void
invoke
(
CostCompanyExcel
data
,
AnalysisContext
context
)
{
LOGGER
.
info
(
"解析到一条数据:{}"
,
JSON
.
toJSONString
(
data
));
list
.
add
(
data
);
if
(
list
.
size
()
>=
BATCH_COUNT
)
{
syncData
();
list
.
clear
();
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
syncData
();
LOGGER
.
info
(
"所有数据解析完成!"
);
}
/**
* 加上存储数据库
*/
private
void
syncData
()
{
LOGGER
.
info
(
"{}条数据,开始存储数据库!"
,
list
.
size
());
list
.
forEach
(
costCompanyExcel
->
{
CostCompanyDao
costCompanyDao
=
SpringContextUtil
.
getBean
(
CostCompanyDao
.
class
);
CostReviewerMapper
costReviewerMapper
=
SpringContextUtil
.
getBean
(
CostReviewerMapper
.
class
);
OaUserMapper
oaUserMapper
=
SpringContextUtil
.
getBean
(
OaUserMapper
.
class
);
CostCompanyDomain
costCompanyDomain
=
costCompanyDao
.
selectByNo
(
costCompanyExcel
.
getCompanyNo
());
costReviewerMapper
.
delete
(
new
LambdaQueryWrapper
<
CostReviewer
>()
.
eq
(
CostReviewer:
:
getType
,
CostReviewer
.
financialReviewer
)
.
eq
(
CostReviewer:
:
getReferId
,
costCompanyDomain
.
getId
()));
costReviewerMapper
.
delete
(
new
LambdaQueryWrapper
<
CostReviewer
>()
.
eq
(
CostReviewer:
:
getType
,
CostReviewer
.
finalReviewer
)
.
eq
(
CostReviewer:
:
getReferId
,
costCompanyDomain
.
getId
()));
Lists
.
newArrayList
(
costCompanyExcel
.
getFinancialCheckUserName
().
split
(
"、"
)).
forEach
(
name
->
{
OaUser
oaUser
=
oaUserMapper
.
selectByUserName
(
name
);
CostReviewer
costReviewer
=
CostReviewer
.
builder
()
.
reviewerUserId
(
oaUser
.
getOaUserId
())
.
reviewerUserName
(
oaUser
.
getUserName
())
.
referId
(
costCompanyDomain
.
getId
())
.
type
(
CostReviewer
.
financialReviewer
)
.
build
();
costReviewerMapper
.
insert
(
costReviewer
);
}
);
OaUser
oaUser
=
oaUserMapper
.
selectByUserName
(
costCompanyExcel
.
getFinalCheckUserName
());
CostReviewer
costReviewer
=
CostReviewer
.
builder
()
.
reviewerUserId
(
oaUser
.
getOaUserId
())
.
reviewerUserName
(
oaUser
.
getUserName
())
.
referId
(
costCompanyDomain
.
getId
())
.
type
(
CostReviewer
.
finalReviewer
)
.
build
();
costReviewerMapper
.
insert
(
costReviewer
);
});
LOGGER
.
info
(
"存储数据库成功!"
);
}
}
bailuntec-cost-core/src/test/java/com/blt/other/CostCompanyExcel.java
0 → 100644
View file @
433fdc01
package
com
.
blt
.
other
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/11/12 2:27 下午
*/
@Data
public
class
CostCompanyExcel
implements
Serializable
{
@ExcelProperty
(
"编码"
)
private
String
companyNo
;
@ExcelProperty
(
"财务主体"
)
private
String
companyName
;
@ExcelProperty
(
"财务审核人"
)
private
String
financialCheckUserName
;
@ExcelProperty
(
"最终审核人"
)
private
String
finalCheckUserName
;
}
bailuntec-cost-core/src/test/java/com/blt/other/OtherApplicationTests.java
View file @
433fdc01
package
com
.
blt
.
other
;
package
com
.
blt
.
other
;
import
com.alibaba.excel.EasyExcel
;
import
com.bailuntec.api.bailuntec.oa.OaApi
;
import
com.bailuntec.api.bailuntec.oa.OaApi
;
import
com.bailuntec.api.bailuntec.oa.response.OaDepartmentResp
;
import
com.bailuntec.api.bailuntec.oa.response.OaDepartmentResp
;
import
com.bailuntec.api.bailuntec.oa.response.OaUserResp
;
import
com.bailuntec.api.bailuntec.oa.response.OaUserResp
;
...
@@ -7,6 +8,8 @@ import com.blt.other.module.auth.model.OaDepartment;
...
@@ -7,6 +8,8 @@ import com.blt.other.module.auth.model.OaDepartment;
import
com.blt.other.module.auth.model.OaUser
;
import
com.blt.other.module.auth.model.OaUser
;
import
com.blt.other.module.auth.service.IOaDepartmentService
;
import
com.blt.other.module.auth.service.IOaDepartmentService
;
import
com.blt.other.module.auth.service.IOaUserService
;
import
com.blt.other.module.auth.service.IOaUserService
;
import
com.blt.other.module.cost.dao.CostCompanyDao
;
import
com.blt.other.module.database.model.CostCompanyDomain
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -14,6 +17,7 @@ import org.springframework.boot.test.context.SpringBootTest;
...
@@ -14,6 +17,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -31,7 +35,7 @@ public class OtherApplicationTests {
...
@@ -31,7 +35,7 @@ public class OtherApplicationTests {
@Autowired
@Autowired
private
IOaDepartmentService
oaDepartmentService
;
private
IOaDepartmentService
oaDepartmentService
;
// @Transactional(rollbackFor = Exception.class)
// @Transactional(rollbackFor = Exception.class)
@Test
@Test
public
void
syncOa
()
{
public
void
syncOa
()
{
List
<
OaUserResp
>
oaUserRespList
=
oaApi
.
getAllUser
();
List
<
OaUserResp
>
oaUserRespList
=
oaApi
.
getAllUser
();
...
@@ -86,5 +90,16 @@ public class OtherApplicationTests {
...
@@ -86,5 +90,16 @@ public class OtherApplicationTests {
}
}
return
getPrimaryDepartment
(
departmentMap
,
departmentMap
.
get
(
oaDepartment
.
getParentId
()));
return
getPrimaryDepartment
(
departmentMap
,
departmentMap
.
get
(
oaDepartment
.
getParentId
()));
}
}
@Resource
CostCompanyDao
costCompanyDao
;
@Test
public
void
importMallProduct
()
{
String
filePath
=
"/Users/huluobin/Library/Containers/com.tencent.WeWorkMac/Data/Library/Application Support/WXWork/Data/1688853793439460/Cache/File/2020-11/cost_company_updated(1).xlsx"
;
EasyExcel
.
read
(
filePath
,
CostCompanyExcel
.
class
,
new
CostCompanyDomainListener
()).
sheet
().
doRead
();
}
}
}
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