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
d5238943
Commit
d5238943
authored
Sep 03, 2021
by
liyanlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
db98d6e8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
112 additions
and
0 deletions
+112
-0
IndexController.java
.../blt/other/module/commons/controller/IndexController.java
+33
-0
IndexService.java
...va/com/blt/other/module/commons/service/IndexService.java
+4
-0
IndexServiceImpl.java
...t/other/module/commons/service/impl/IndexServiceImpl.java
+75
-0
No files found.
cost-service/src/main/java/com/blt/other/module/commons/controller/IndexController.java
View file @
d5238943
...
...
@@ -7,6 +7,7 @@ import com.blt.other.module.commons.service.IndexService;
import
com.blt.other.module.purchasing.dto.BuyPlanDto
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
...
...
@@ -45,6 +46,20 @@ public class IndexController {
return
result
;
}
@GetMapping
(
"/costPlanList"
)
public
Map
<
String
,
Object
>
costPlanList
(
Integer
userid
,
Integer
status
,
String
condition
,
@RequestParam
(
value
=
"statusList"
,
required
=
false
)
List
<
Integer
>
statusList
,
Integer
limit
)
{
List
<
CostPlanDto
>
costPlanDtos
=
null
;
costPlanDtos
=
indexService
.
getCostPlanList
(
userid
,
status
,
condition
,
statusList
,
limit
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"costPlanList"
,
costPlanDtos
);
result
.
put
(
"success"
,
true
);
return
result
;
}
@GetMapping
(
"/getCostList"
)
public
Map
<
String
,
Object
>
getCostList
(
HttpServletResponse
response
,
HttpServletRequest
request
)
{
AxiosUtil
.
setCors
(
response
,
request
);
...
...
@@ -55,4 +70,22 @@ public class IndexController {
result
.
put
(
"success"
,
true
);
return
result
;
}
@GetMapping
(
"/costList"
)
public
Map
<
String
,
Object
>
costList
(
Integer
userid
,
Integer
status
,
String
condition
,
@RequestParam
(
value
=
"statusList"
,
required
=
false
)
List
<
Integer
>
statusList
,
Integer
limit
)
{
List
<
CostDto
>
costDtos
=
null
;
try
{
costDtos
=
indexService
.
getCostList
(
userid
,
status
,
condition
,
statusList
,
limit
);
}
catch
(
NoSuchMethodException
e
)
{
e
.
printStackTrace
();
}
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"costList"
,
costDtos
);
result
.
put
(
"success"
,
true
);
return
result
;
}
}
cost-service/src/main/java/com/blt/other/module/commons/service/IndexService.java
View file @
d5238943
...
...
@@ -12,5 +12,9 @@ public interface IndexService {
List
<
CostPlanDto
>
getCostPlanList
(
Integer
userid
);
List
<
CostPlanDto
>
getCostPlanList
(
Integer
userid
,
Integer
status
,
String
condition
,
List
<
Integer
>
statusList
,
Integer
limit
);
List
<
CostDto
>
getCostList
(
Integer
userid
);
List
<
CostDto
>
getCostList
(
Integer
userid
,
Integer
status
,
String
condition
,
List
<
Integer
>
statusList
,
Integer
limit
)
throws
NoSuchMethodException
;
}
cost-service/src/main/java/com/blt/other/module/commons/service/impl/IndexServiceImpl.java
View file @
d5238943
...
...
@@ -2,17 +2,31 @@ package com.blt.other.module.commons.service.impl;
import
com.bailuntec.cost.api.dto.CostDto
;
import
com.bailuntec.cost.api.dto.CostPlanDto
;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.baomidou.mybatisplus.core.conditions.interfaces.Func
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.support.SFunction
;
import
com.blt.other.database.model.BuyPlanDomain
;
import
com.blt.other.database.model.CostPlanDomain
;
import
com.blt.other.module.commons.dao.IndexDao
;
import
com.blt.other.module.commons.service.IndexService
;
import
com.blt.other.module.cost.dao.CostDao
;
import
com.blt.other.module.cost.dao.CostPlanDao
;
import
com.blt.other.module.cost.model.CostDomain
;
import
com.blt.other.module.purchasing.dto.BuyPlanDto
;
import
com.blt.other.module.purchasing.service.BuyPlanService
;
import
lombok.var
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.el.MethodNotFoundException
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.Collection
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -22,6 +36,10 @@ public class IndexServiceImpl implements IndexService {
private
IndexDao
indexDao
;
@Resource
private
BuyPlanService
buyPlanService
;
@Resource
private
CostDao
costDao
;
@Resource
private
CostPlanDao
costPlanDao
;
@Override
public
List
<
BuyPlanDto
>
getBuyPlanList
(
Integer
userid
)
{
...
...
@@ -36,9 +54,66 @@ public class IndexServiceImpl implements IndexService {
}
@Override
public
List
<
CostPlanDto
>
getCostPlanList
(
Integer
userid
,
Integer
status
,
String
condition
,
List
<
Integer
>
statusList
,
Integer
limit
)
{
LambdaQueryWrapper
<
CostPlanDomain
>
query
=
new
LambdaQueryWrapper
<
CostPlanDomain
>().
eq
(
CostPlanDomain:
:
getCreateUserid
,
userid
);
if
(
condition
!=
null
&&
!
condition
.
isEmpty
())
{
try
{
SFunction
<
CostPlanDomain
,
Integer
>
getStatus
=
CostPlanDomain:
:
getCostPlanStatus
;
if
(
statusList
!=
null
&&
!
statusList
.
isEmpty
()
&&
(
condition
.
equals
(
"in"
)
||
condition
.
equals
(
"notIn"
)))
{
query
.
getClass
().
getMethod
(
condition
,
Object
.
class
,
Collection
.
class
)
.
invoke
(
query
,
getStatus
,
statusList
);
}
else
if
(
status
!=
null
)
{
query
.
getClass
().
getMethod
(
condition
,
Object
.
class
,
Object
.
class
)
.
invoke
(
query
,
getStatus
,
status
);
}
}
catch
(
NoSuchMethodException
ex
)
{
ex
.
printStackTrace
();
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
}
query
.
orderByDesc
(
CostPlanDomain:
:
getId
);
if
(
limit
!=
null
&&
limit
>
0
)
query
.
last
(
"limit "
+
limit
);
List
<
CostPlanDomain
>
costDomainList
=
costPlanDao
.
selectList
(
query
);
return
costDomainList
.
stream
().
map
(
CostPlanDomain:
:
castToDto
).
collect
(
Collectors
.
toList
());
}
@Override
public
List
<
CostDto
>
getCostList
(
Integer
userid
)
{
List
<
CostDomain
>
costDomains
=
indexDao
.
selectCostList
(
userid
);
//costDao.selectList(new LambdaQueryWrapper<CostDomain>().in(CostDomain::getCostNo,""));
return
costDomains
.
stream
().
map
(
CostDomain:
:
castToDto
).
collect
(
Collectors
.
toList
());
}
@Override
public
List
<
CostDto
>
getCostList
(
Integer
userid
,
Integer
status
,
String
condition
,
List
<
Integer
>
statusList
,
Integer
limit
)
{
LambdaQueryWrapper
<
CostDomain
>
query
=
new
LambdaQueryWrapper
<
CostDomain
>().
eq
(
CostDomain:
:
getCreateUserid
,
userid
);
if
(
condition
!=
null
&&
!
condition
.
isEmpty
())
{
try
{
SFunction
<
CostDomain
,
Integer
>
getCostStatus
=
CostDomain:
:
getCostStatus
;
if
(
statusList
!=
null
&&
!
statusList
.
isEmpty
()
&&
(
condition
.
equals
(
"in"
)
||
condition
.
equals
(
"notIn"
)))
{
query
.
getClass
().
getMethod
(
condition
,
Object
.
class
,
Collection
.
class
)
.
invoke
(
query
,
getCostStatus
,
statusList
);
}
else
if
(
status
!=
null
)
{
query
.
getClass
().
getMethod
(
condition
,
Object
.
class
,
Object
.
class
)
.
invoke
(
query
,
getCostStatus
,
status
);
}
}
catch
(
NoSuchMethodException
ex
)
{
ex
.
printStackTrace
();
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
}
query
.
orderByDesc
(
CostDomain:
:
getId
);
if
(
limit
!=
null
&&
limit
>
0
)
query
.
last
(
"limit "
+
limit
);
List
<
CostDomain
>
costDomainList
=
costDao
.
selectList
(
query
);
return
costDomainList
.
stream
().
map
(
CostDomain:
:
castToDto
).
collect
(
Collectors
.
toList
());
}
}
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