Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dcs-plan
Project
Project
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
INET-TWO
server
dcs-plan
Commits
d15e5f24
Commit
d15e5f24
authored
Jul 29, 2024
by
wangqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ExtSpendingContractController:业务代码迁入(2.x版本->4.1版本)
parent
9dfa2af4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
0 deletions
+90
-0
ExtSpendingContractController.java
...s/plan/core/controller/ExtSpendingContractController.java
+10
-0
ExtSpendingContractService.java
...nde/dcs/plan/core/service/ExtSpendingContractService.java
+7
-0
ExtSpendingContractServiceImpl.java
...lan/core/service/impl/ExtSpendingContractServiceImpl.java
+73
-0
No files found.
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/controller/ExtSpendingContractController.java
View file @
d15e5f24
...
...
@@ -29,7 +29,17 @@ import org.springframework.stereotype.Controller;
@BasePermission
(
"inet-plan:ExtSpendingContract"
)
public
class
ExtSpendingContractController
<
V
extends
ExtSpendingContractVO
,
S
extends
ExtSpendingContractService
<
V
>>
extends
ExtSpendingContractControllerShadow
<
V
,
S
>
{
@Autowired
private
ExtSpendingContractService
extSpendingContractService
;
@ApiOperation
(
value
=
"支出合同金额计算"
,
notes
=
"支出合同金额计算"
,
httpMethod
=
"GET"
)
@GetMapping
(
"/calculateSpending/{id}"
)
public
ApiResult
calculateSpending
(
@PathVariable
Long
id
)
{
//通过收入基本属性id获取付款明细
ExtSpendingContractVO
extSpendingContractVO
=
extSpendingContractService
.
calculateSpending
(
id
);
return
ApiResult
.
ok
(
extSpendingContractVO
);
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/ExtSpendingContractService.java
View file @
d15e5f24
...
...
@@ -10,4 +10,11 @@ import com.yonde.dcs.plan.core.service.shadow.ExtSpendingContractServiceShadow;
**/
public
interface
ExtSpendingContractService
<
V
extends
ExtSpendingContractVO
>
extends
ExtSpendingContractServiceShadow
<
V
>
{
/**
* 支出合同金额计算
*
* @param id
* @return
*/
ExtSpendingContractVO
calculateSpending
(
Long
id
);
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/ExtSpendingContractServiceImpl.java
View file @
d15e5f24
package
com
.
yonde
.
dcs
.
plan
.
core
.
service
.
impl
;
import
com.yonde.dcs.plan.common.utils.BigDecimalUtil
;
import
com.yonde.dcs.plan.common.vo.ExtSpendingDetailVO
;
import
com.yonde.dex.basedata.data.search.SearchItem
;
import
com.yonde.dex.basedata.data.search.SearchItems
;
import
com.yonde.dex.basedata.data.search.SearchQueryCondition
;
import
com.yonde.dex.basedata.entity.data.DxPageImpl
;
import
com.yonde.dex.basedata.entity.data.OperatorType
;
import
com.yonde.dex.dao.service.util.DxPageUtils
;
import
org.springframework.stereotype.Service
;
import
io.swagger.annotations.ApiOperation
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.yonde.dcs.plan.common.vo.ExtSpendingContractVO
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.*
;
import
com.yonde.dcs.plan.core.service.ExtSpendingContractService
;
import
com.yonde.dcs.plan.core.repository.ExtSpendingContractRepository
;
...
...
@@ -29,6 +42,66 @@ public class ExtSpendingContractServiceImpl<V extends ExtSpendingContractVO> imp
@Autowired
ExtSpendingContractRepository
<
ExtSpendingContract
>
extSpendingContractRepository
;
@Override
public
ExtSpendingContractVO
calculateSpending
(
Long
id
)
{
ExtSpendingContractVO
recursionSpendingDetail
=
this
.
findRecursionSpendingDetail
(
id
);
List
<
ExtSpendingDetailVO
>
extSpendingDetails
=
recursionSpendingDetail
.
getExtSpendingDetails
();
//金额List累加
BigDecimal
bigss
=
BigDecimal
.
ZERO
;
//所有付款明细金额
List
<
BigDecimal
>
payAmoutList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
extSpendingDetails
))
{
//已付金额=付款明细之和
extSpendingDetails
.
stream
().
forEach
(
item
->
{
payAmoutList
.
add
(
item
.
getAmount
());
});
}
//计算已付金额
if
(!
CollectionUtils
.
isEmpty
(
payAmoutList
))
{
for
(
BigDecimal
bigDecimal
:
payAmoutList
)
{
bigss
=
bigss
.
add
(
bigDecimal
);
}
}
// 如果支出明细为空,已付金额为零
recursionSpendingDetail
.
setPaidAmount
(
bigss
);
DecimalFormat
df
=
new
DecimalFormat
(
"0.00%"
);
//计算未付金额 = 合同金额- 已付金额
BigDecimal
contractAmount
=
recursionSpendingDetail
.
getContractAmount
();
if
(
contractAmount
!=
null
)
{
BigDecimal
subtract
=
BigDecimalUtil
.
subtract
(
contractAmount
,
bigss
);
recursionSpendingDetail
.
setUnpaidAmount
(
subtract
);
//计算付款比例 = 已付金额/合同额
BigDecimal
paymentRatio
=
BigDecimalUtil
.
divide
(
bigss
,
contractAmount
);
String
percent
=
df
.
format
(
paymentRatio
);
recursionSpendingDetail
.
setPaymentRatio
(
percent
);
}
recursionSpendingDetail
.
setOperator
(
OperatorType
.
MODIFY
);
ExtSpendingContractVO
extSpendingContractVO
=
this
.
saveRecursion
((
V
)
recursionSpendingDetail
);
return
extSpendingContractVO
;
}
/**
* 深度查询支出合同
*
* @param
* @return
*/
public
ExtSpendingContractVO
findRecursionSpendingDetail
(
Long
id
)
{
SearchQueryCondition
query
=
SearchQueryCondition
.
builder
()
.
openProp
(
SearchQueryCondition
.
builder
().
name
(
"extSpendingDetails"
).
build
())
.
searchItems
(
SearchItems
.
builder
().
item
(
new
SearchItem
(
"id"
,
SearchItem
.
Operator
.
EQ
,
id
,
null
)).
build
()).
build
();
;
DxPageImpl
<
V
>
dexPage
=
this
.
findRecursion
(
query
);
if
(!
CollectionUtils
.
isEmpty
(
dexPage
.
getContent
()))
{
ExtSpendingContractVO
spendingContractVO
=
DxPageUtils
.
getFirst
(
dexPage
);
return
spendingContractVO
;
}
return
new
ExtSpendingContractVO
();
}
}
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