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
84bc1e6f
Commit
84bc1e6f
authored
Jan 04, 2021
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
f6259876
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
10 deletions
+106
-10
AccountingSubjectMapper.java
...om/blt/other/module/cost/dao/AccountingSubjectMapper.java
+2
-0
AccountingSubjectMapper.xml
.../resources/mapper/module/cost/AccountingSubjectMapper.xml
+6
-0
OtherApplicationTests.java
...re/src/test/java/com/blt/other/OtherApplicationTests.java
+98
-10
No files found.
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/dao/AccountingSubjectMapper.java
View file @
84bc1e6f
...
...
@@ -15,4 +15,6 @@ public interface AccountingSubjectMapper extends BaseMapper<AccountingSubject> {
//根据编号查
AccountingSubject
selectByNo
(
String
accountingSubjectNo
);
AccountingSubject
selectByName
(
String
accountType
);
}
bailuntec-cost-core/src/main/resources/mapper/module/cost/AccountingSubjectMapper.xml
View file @
84bc1e6f
...
...
@@ -7,4 +7,10 @@
from accounting_subject
where subject_no = #{accountingSubjectNo}
</select>
<select
id=
"selectByName"
resultType=
"com.blt.other.module.cost.model.AccountingSubject"
>
select *
from accounting_subject
where name = #{accountType}
</select>
</mapper>
bailuntec-cost-core/src/test/java/com/blt/other/OtherApplicationTests.java
View file @
84bc1e6f
package
com
.
blt
.
other
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.fastjson.JSON
;
import
com.bailuntec.api.bailuntec.oa.OaApi
;
import
com.bailuntec.api.bailuntec.oa.response.OaDepartmentResp
;
import
com.bailuntec.api.bailuntec.oa.response.OaUserResp
;
import
com.bailuntec.common.SpringContextUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.blt.other.database.model.CostTypeDomain
;
import
com.blt.other.module.auth.dao.OaDepartmentMapper
;
import
com.blt.other.module.auth.model.OaDepartment
;
import
com.blt.other.module.auth.model.OaUser
;
import
com.blt.other.module.auth.service.IOaDepartmentService
;
import
com.blt.other.module.auth.service.IOaUserService
;
import
com.blt.other.module.cost.service.impl.costcheck.CostContext
;
import
com.blt.other.module.cost.service.impl.costcheck.DepartmentCheckState
;
import
com.blt.other.module.cost.dao.AccountingSubjectMapper
;
import
com.blt.other.module.cost.dao.CostTypeDao
;
import
com.blt.other.module.cost.model.AccountingSubject
;
import
com.blt.other.module.sys.dao.CostReviewerMapper
;
import
com.blt.other.module.sys.dao.DepartmentReviewerMapper
;
import
com.blt.other.module.sys.model.CostReviewer
;
import
com.blt.other.module.sys.model.DepartmentReviewer
;
import
lombok.Data
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.annotation.Rollback
;
...
...
@@ -26,6 +38,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
@@ -49,12 +62,12 @@ public class OtherApplicationTests {
@Resource
DepartmentReviewerMapper
departmentReviewerMapper
;
@Rollback
@Rollback
(
value
=
false
)
@Test
public
void
syncDepartmentReviewer
()
{
departmentReviewerMapper
.
delete
(
new
LambdaQueryWrapper
<>());
costReviewerMapper
.
delete
(
new
LambdaQueryWrapper
<
CostReviewer
>()
.
eq
(
CostReviewer:
:
getType
,
CostReviewer
.
departmentReviewer
));
//
costReviewerMapper.delete(new LambdaQueryWrapper<CostReviewer>()
//
.eq(CostReviewer::getType, CostReviewer.departmentReviewer));
List
<
CostReviewer
>
costReviewerList
=
costReviewerMapper
.
selectList
(
new
LambdaQueryWrapper
<
CostReviewer
>()
.
eq
(
CostReviewer:
:
getType
,
1
));
...
...
@@ -155,14 +168,89 @@ public class OtherApplicationTests {
return
getPrimaryDepartment
(
departmentMap
,
departmentMap
.
get
(
oaDepartment
.
getParentId
()));
}
@Resource
DepartmentCheckState
departmentCheckState
;
@Rollback
(
value
=
false
)
@Test
public
void
importMallProduct
()
{
CostContext
costContext
=
new
CostContext
(
"F029432"
,
null
);
costContext
.
setCostState
(
departmentCheckState
);
costContext
.
handle
();
TypeListener
typeListener
=
new
TypeListener
();
EasyExcel
.
read
(
"/Users/huluobin/费用类型.xlsx"
,
TypeItem
.
class
,
typeListener
).
sheet
().
doRead
();
}
@Data
public
static
class
TypeItem
{
@ExcelProperty
(
"desc"
)
private
String
desc
;
@ExcelProperty
(
"type"
)
private
String
type
;
@ExcelProperty
(
value
=
"account_type"
)
private
String
accountType
;
@ExcelProperty
(
value
=
"cost_type"
)
private
Integer
costType
;
}
public
static
class
TypeListener
extends
AnalysisEventListener
<
TypeItem
>
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
TypeListener
.
class
);
TypeListener
()
{
}
private
static
final
int
BATCH_COUNT
=
2000
;
List
<
TypeItem
>
list
=
new
ArrayList
<>();
@Override
public
void
invoke
(
TypeItem
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
()
{
list
.
forEach
(
item
->
{
AccountingSubjectMapper
accountingSubjectMapper
=
SpringContextUtil
.
getBean
(
AccountingSubjectMapper
.
class
);
AccountingSubject
accountingSubject
=
accountingSubjectMapper
.
selectByName
(
item
.
getAccountType
());
if
(
accountingSubject
==
null
)
{
accountingSubject
=
new
AccountingSubject
();
accountingSubject
.
setName
(
item
.
getAccountType
());
accountingSubject
.
setSubjectNo
(
IdWorker
.
getIdStr
());
accountingSubjectMapper
.
insert
(
accountingSubject
);
}
CostTypeDao
costTypeDao
=
SpringContextUtil
.
getBean
(
CostTypeDao
.
class
);
CostTypeDomain
costTypeDomain
=
new
CostTypeDomain
();
if
(
item
.
getCostType
()
==
1
)
{
costTypeDomain
.
setCostTemplateType
(
CostTypeDomain
.
feeType
);
}
if
(
item
.
getCostType
()
==
2
)
{
costTypeDomain
.
setCostTemplateType
(
CostTypeDomain
.
incomeType
);
}
if
(
item
.
getCostType
()
==
3
)
{
costTypeDomain
.
setCostTemplateType
(
CostTypeDomain
.
borrow
);
}
costTypeDomain
.
setTypeName
(
item
.
getType
());
costTypeDomain
.
setTypeNo
(
IdWorker
.
getIdStr
());
costTypeDomain
.
setDescription
(
item
.
getDesc
());
costTypeDomain
.
setAccountingSubjectNo
(
accountingSubject
.
getSubjectNo
());
costTypeDao
.
insert
(
costTypeDomain
);
});
}
}
...
...
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