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
91afe366
Commit
91afe366
authored
Jul 26, 2024
by
wangqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ExtIncomeContractController:业务代码迁入(2.x版本->4.1版本)
parent
ada8bd82
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
372 additions
and
2 deletions
+372
-2
BigDecimalUtil.java
.../java/com/yonde/dcs/plan/common/utils/BigDecimalUtil.java
+59
-0
DateUtils.java
.../main/java/com/yonde/dcs/plan/common/utils/DateUtils.java
+132
-0
ExtIncomeContractVO.java
...ava/com/yonde/dcs/plan/common/vo/ExtIncomeContractVO.java
+1
-1
ExtIncomeDetailVO.java
.../java/com/yonde/dcs/plan/common/vo/ExtIncomeDetailVO.java
+1
-1
ExtIncomeContractController.java
...dcs/plan/core/controller/ExtIncomeContractController.java
+20
-0
ExtIncomeContractService.java
...yonde/dcs/plan/core/service/ExtIncomeContractService.java
+24
-0
ExtIncomeContractServiceImpl.java
.../plan/core/service/impl/ExtIncomeContractServiceImpl.java
+135
-0
No files found.
dcs-plan-common/src/main/java/com/yonde/dcs/plan/common/utils/BigDecimalUtil.java
0 → 100644
View file @
91afe366
package
com
.
yonde
.
dcs
.
plan
.
common
.
utils
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
/**
* @author xfchai
* @ClassName BigDecimalUtil.java
* @Description BigDecimalgogn
* @createTime 2022/03/01 18:00:00
*/
public
class
BigDecimalUtil
{
/**
* 价格类型 保留小数点 2
*/
public
static
final
int
PRICE_DECIMAL_POINT
=
2
;
/**
* 价格类型 保留小数点 4
*/
public
static
final
int
FOUR_PRICE_DECIMAL_POINT
=
4
;
/**
* 价格类型 保留小数点 6i
*/
public
static
final
int
SIX_PRICE_DECIMAL_POINT
=
6
;
/**
* 重量类型保留小数点 3
*/
public
static
final
int
WEIGHT_DECIMAL_POINT
=
3
;
public
static
BigDecimal
add
(
BigDecimal
num1
,
BigDecimal
num2
)
{
return
setScale
(
num1
.
add
(
num2
),
PRICE_DECIMAL_POINT
);
}
public
static
BigDecimal
multiply
(
BigDecimal
num1
,
BigDecimal
num2
)
{
return
setScale
(
num1
.
multiply
(
num2
),
PRICE_DECIMAL_POINT
);
}
public
static
BigDecimal
subtract
(
BigDecimal
num1
,
BigDecimal
num2
)
{
return
setScale
(
num1
.
subtract
(
num2
),
PRICE_DECIMAL_POINT
);
}
public
static
BigDecimal
divide
(
BigDecimal
num1
,
BigDecimal
num2
)
{
return
num1
.
divide
(
num2
,
FOUR_PRICE_DECIMAL_POINT
,
RoundingMode
.
HALF_UP
);
// return setScale(num1.divide(num2, RoundingMode.HALF_UP), PRICE_DECIMAL_POINT);
}
/**
* 设置小数点类型为 四舍五入
*
* @param num
* @param point
* @return BigDecimal
*/
public
static
BigDecimal
setScale
(
BigDecimal
num
,
int
point
)
{
return
num
.
setScale
(
point
,
RoundingMode
.
HALF_UP
);
}
}
dcs-plan-common/src/main/java/com/yonde/dcs/plan/common/utils/DateUtils.java
0 → 100644
View file @
91afe366
package
com
.
yonde
.
dcs
.
plan
.
common
.
utils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Calendar
;
import
java.util.Date
;
/**
* @author xfchai
* @ClassName DateUtils.java
* @Description TODO
* @createTime 2021/11/22 11:42:00
*/
@Slf4j
public
class
DateUtils
{
/**
* 将日期yyyy-MM-dd HH:mm:ss转换为yyyy-MM-dd
*
* @param dealDate
* @return
*/
public
static
String
conversionDate
(
String
dealDate
)
{
if
(!
StringUtils
.
isEmpty
(
dealDate
))
{
try
{
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Date
date
=
sf
.
parse
(
dealDate
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
return
dateFormat
.
format
(
date
);
}
catch
(
Exception
e
)
{
log
.
error
(
"日期yyyy-MM-dd HH:mm:ss转换为yyyy-MM-dd错误:"
,
e
.
getMessage
());
return
""
;
}
}
return
""
;
}
/**
* 将yyyy.MM.dd格式转换为 yyyy-MM-dd
*
* @param dealDate
* @return
*/
public
static
String
conversionDateTwo
(
String
dealDate
)
{
if
(!
StringUtils
.
isEmpty
(
dealDate
))
{
try
{
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyy.MM.dd"
);
Date
date
=
sf
.
parse
(
dealDate
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
return
dateFormat
.
format
(
date
);
}
catch
(
Exception
e
)
{
log
.
error
(
"日期yyyy-MM-dd HH:mm:ss转换为yyyy-MM-dd错误:"
,
e
.
getMessage
());
return
""
;
}
}
return
""
;
}
/**
* LocalDateTime转换为字符串日期类型
*
* @param localDateTime
* @return
*/
public
static
String
converLocalDateToString
(
LocalDateTime
localDateTime
)
{
if
(
ObjectUtils
.
isEmpty
(
localDateTime
))
{
String
datetimeString
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
new
Date
());
return
datetimeString
;
}
else
{
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
String
dateStr
=
formatter
.
format
(
localDateTime
);
return
dateStr
;
}
}
/**
* 获取某年第一天日期
*
* @param year 年份
* @return Date
*/
public
static
Date
getYearFirst
(
int
year
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
clear
();
calendar
.
set
(
Calendar
.
YEAR
,
year
);
Date
currYearFirst
=
calendar
.
getTime
();
return
currYearFirst
;
}
/**
* 获取某年最后一天日期
*
* @param year 年份
* @return Date
*/
public
static
Date
getYearLast
(
int
year
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
clear
();
calendar
.
set
(
Calendar
.
YEAR
,
year
);
calendar
.
roll
(
Calendar
.
DAY_OF_YEAR
,
-
1
);
Date
currYearLast
=
calendar
.
getTime
();
return
currYearLast
;
}
/**
* 时间之差
*
* @param startDate
* @param endDate
* @return
* @throws ParseException
*/
public
static
int
getDayDiffer
(
Date
startDate
,
Date
endDate
)
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
try
{
if
(!
ObjectUtils
.
isEmpty
(
startDate
)
&&
!
ObjectUtils
.
isEmpty
(
endDate
))
{
long
startDateTime
=
dateFormat
.
parse
(
dateFormat
.
format
(
startDate
)).
getTime
();
long
endDateTime
=
dateFormat
.
parse
(
dateFormat
.
format
(
endDate
)).
getTime
();
return
(
int
)
((
endDateTime
-
startDateTime
)
/
(
1000
*
3600
*
24
));
}
return
0
;
}
catch
(
Exception
e
)
{
return
0
;
}
}
}
dcs-plan-common/src/main/java/com/yonde/dcs/plan/common/vo/ExtIncomeContractVO.java
View file @
91afe366
...
...
@@ -260,7 +260,7 @@ public class ExtIncomeContractVO extends IdOnlyVO implements IdVO ,DxLogicDelete
/**
* 待拨付
*/
private
Integer
toBedisbursed
;
private
BigDecimal
toBedisbursed
;
/**
* 审价额
...
...
dcs-plan-common/src/main/java/com/yonde/dcs/plan/common/vo/ExtIncomeDetailVO.java
View file @
91afe366
...
...
@@ -87,7 +87,7 @@ public class ExtIncomeDetailVO extends IdOnlyVO implements IdVO ,DxLogicDeleteVO
/**
* 到账时间
*/
private
LocalDateTim
e
arrivalTime
;
private
Dat
e
arrivalTime
;
/**
* 票据开具
...
...
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/controller/ExtIncomeContractController.java
View file @
91afe366
...
...
@@ -27,6 +27,26 @@ import org.springframework.stereotype.Controller;
@Controller
(
ExtIncomeContractController
.
BEAN_NAME
)
public
class
ExtIncomeContractController
<
V
extends
ExtIncomeContractVO
,
S
extends
ExtIncomeContractService
<
V
>>
extends
ExtIncomeContractControllerShadow
<
V
,
S
>
{
@Autowired
private
ExtIncomeContractService
extIncomeContractService
;
@ApiOperation
(
value
=
"合同收入计算"
,
notes
=
"合同收入计算"
,
httpMethod
=
"GET"
)
@GetMapping
(
"/calculateIncome/{id}"
)
public
ApiResult
calculateIncome
(
@PathVariable
Long
id
)
{
//通过收入基本属性id获取多个收入信息
ExtIncomeContractVO
extIncomeContract
=
extIncomeContractService
.
calculateIncome
(
id
);
return
ApiResult
.
ok
(
extIncomeContract
);
}
@ApiOperation
(
value
=
"xxx年到款计算"
,
notes
=
"xxx年到款计算"
,
httpMethod
=
"GET"
)
@GetMapping
(
"/calculateIncome"
)
public
ApiResult
calculateIncomeByYear
(
@RequestParam
Long
id
,
String
year
)
{
ExtIncomeContractVO
extIncomeContractVO
=
extIncomeContractService
.
findRecursionExtIncomeContractVO
(
id
);
//通过收入基本属性id获取多个收入信息
extIncomeContractService
.
calculateIncomeByYear
(
id
,
year
,
extIncomeContractVO
);
return
ApiResult
.
ok
(
extIncomeContractVO
);
}
}
...
...
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/ExtIncomeContractService.java
View file @
91afe366
...
...
@@ -10,4 +10,28 @@ import com.yonde.dcs.plan.core.service.shadow.ExtIncomeContractServiceShadow;
**/
public
interface
ExtIncomeContractService
<
V
extends
ExtIncomeContractVO
>
extends
ExtIncomeContractServiceShadow
<
V
>
{
/**
* 计算收入明细
*
* @param id
*/
ExtIncomeContractVO
calculateIncome
(
Long
id
);
/**
* 深度查询收入合同
*
* @param
* @return
*/
ExtIncomeContractVO
findRecursionExtIncomeContractVO
(
Long
id
);
/**
* 根据年份计算到款金额
*
* @param year
* @return
*/
void
calculateIncomeByYear
(
Long
id
,
String
year
,
ExtIncomeContractVO
extIncomeContractVO
);
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/ExtIncomeContractServiceImpl.java
View file @
91afe366
package
com
.
yonde
.
dcs
.
plan
.
core
.
service
.
impl
;
import
com.yonde.dcs.plan.common.utils.BigDecimalUtil
;
import
com.yonde.dcs.plan.common.utils.DateUtils
;
import
com.yonde.dcs.plan.common.vo.ExtIncomeDetailVO
;
import
com.yonde.dcs.plan.common.vo.ExtPaymentDetailsVO
;
import
com.yonde.dcs.plan.core.service.ExtPaymentDetailsService
;
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.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
com.yonde.dcs.plan.common.vo.ExtIncomeContractVO
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
com.yonde.dcs.plan.core.service.ExtIncomeContractService
;
import
com.yonde.dcs.plan.core.repository.ExtIncomeContractRepository
;
...
...
@@ -29,6 +47,123 @@ public class ExtIncomeContractServiceImpl<V extends ExtIncomeContractVO> impleme
@Autowired
ExtIncomeContractRepository
<
ExtIncomeContract
>
extIncomeContractRepository
;
@Autowired
private
ExtPaymentDetailsService
paymentDetailsService
;
@Override
@Transactional
public
ExtIncomeContractVO
calculateIncome
(
Long
id
)
{
ExtIncomeContractVO
extIncomeContractVO
=
this
.
findRecursionExtIncomeContractVO
(
id
);
List
<
ExtIncomeDetailVO
>
extIncomeDetails
=
extIncomeContractVO
.
getExtIncomeDetails
();
//金额List累加
BigDecimal
bigss
=
BigDecimal
.
ZERO
;
//定义所有支付进度安排金额list
List
<
BigDecimal
>
payAmoutList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
extIncomeDetails
))
{
for
(
ExtIncomeDetailVO
extIncomeDetailVO
:
extIncomeDetails
)
{
//到款情况-已到账
String
paySituation
=
extIncomeDetailVO
.
getPaySituation
();
if
(
"credited"
.
equals
(
paySituation
))
{
bigss
=
bigss
.
add
(
extIncomeDetailVO
.
getAmount
());
}
}
}
//已到款=已到账金额之和
extIncomeContractVO
.
setPaid
(
bigss
);
//待拨付 = 合同额 或 审价额 -已到款
BigDecimal
subtract
=
BigDecimal
.
ZERO
;
BigDecimal
trialPrice
=
extIncomeContractVO
.
getTrialPrice
();
BigDecimal
contractPrice
=
extIncomeContractVO
.
getContractPrice
();
if
(
trialPrice
!=
null
)
{
subtract
=
BigDecimalUtil
.
subtract
(
trialPrice
,
bigss
);
}
else
{
subtract
=
BigDecimalUtil
.
subtract
(
contractPrice
,
bigss
);
}
extIncomeContractVO
.
setToBedisbursed
(
subtract
);
extIncomeContractVO
.
setOperator
(
OperatorType
.
MODIFY
);
//todo wq:暂时将extIncomeContractVO 强转为V类型
ExtIncomeContractVO
extIncomeContractVO1
=
this
.
saveRecursion
((
V
)
extIncomeContractVO
);
return
extIncomeContractVO1
;
}
/**
* 深度查询收入合同
*
* @param
* @return
*/
@Override
public
ExtIncomeContractVO
findRecursionExtIncomeContractVO
(
Long
id
)
{
SearchQueryCondition
query
=
SearchQueryCondition
.
builder
()
.
openProp
(
SearchQueryCondition
.
builder
().
name
(
"extIncomeDetails"
).
build
())
.
openProp
(
SearchQueryCondition
.
builder
().
name
(
"paymentDetailss"
).
build
())
.
searchItems
(
SearchItems
.
builder
().
item
(
new
SearchItem
(
"id"
,
SearchItem
.
Operator
.
EQ
,
id
,
null
)).
build
()).
build
();
//todo wq:将DxPageImpl<ExtIncomeContractVO> 修改为 DxPageImpl<V>
//DxPageImpl<ExtIncomeContractVO> dexPage = this.findRecursion(query);
DxPageImpl
<
V
>
dexPage
=
this
.
findRecursion
(
query
);
if
(!
CollectionUtils
.
isEmpty
(
dexPage
.
getContent
()))
{
ExtIncomeContractVO
incomeContractVO
=
DxPageUtils
.
getFirst
(
dexPage
);
return
incomeContractVO
;
}
return
new
ExtIncomeContractVO
();
}
@Override
public
void
calculateIncomeByYear
(
Long
id
,
String
year
,
ExtIncomeContractVO
extIncomeContractVO
)
{
List
<
ExtIncomeDetailVO
>
extIncomeDetails
=
extIncomeContractVO
.
getExtIncomeDetails
();
//定义所以支付进度安排金额list
List
<
BigDecimal
>
payAmoutList
=
new
ArrayList
<>();
//year为空就是事件方法调用
if
(
StringUtils
.
isEmpty
(
year
))
{
List
<
ExtPaymentDetailsVO
>
paymentDetailss
=
extIncomeContractVO
.
getExtPaymentDetailss
();
if
(!
CollectionUtils
.
isEmpty
(
paymentDetailss
))
{
paymentDetailss
.
stream
().
forEach
(
item
->
{
item
.
setOperator
(
OperatorType
.
MODIFY
);
item
.
setAmount
(
calPaymentAmount
(
item
.
getYears
(),
extIncomeDetails
));
paymentDetailsService
.
saveRecursion
(
item
);
});
}
}
else
{
ExtPaymentDetailsVO
paymentDetailsVO
=
new
ExtPaymentDetailsVO
();
paymentDetailsVO
.
setExtIncomeContractId
(
id
);
paymentDetailsVO
.
setExtIncomeContractIdType
(
"ExtIncomeContract"
);
paymentDetailsVO
.
setExtIncomeContract
(
extIncomeContractVO
);
paymentDetailsVO
.
setYears
(
String
.
valueOf
(
year
));
paymentDetailsVO
.
setAmount
(
calPaymentAmount
(
year
,
extIncomeDetails
));
paymentDetailsVO
.
setOperator
(
OperatorType
.
ADD
);
paymentDetailsService
.
saveRecursion
(
paymentDetailsVO
);
}
}
/**
* @param year
* @param extIncomeDetails
*/
private
BigDecimal
calPaymentAmount
(
String
year
,
List
<
ExtIncomeDetailVO
>
extIncomeDetails
)
{
//金额List累加
BigDecimal
bigss
=
BigDecimal
.
ZERO
;
//获取某年的第一天日期
Date
yearFirst
=
DateUtils
.
getYearFirst
(
Integer
.
parseInt
(
year
));
//获取某年最后一天日期
Date
yearLast
=
DateUtils
.
getYearLast
(
Integer
.
parseInt
(
year
));
if
(!
CollectionUtils
.
isEmpty
(
extIncomeDetails
))
{
for
(
ExtIncomeDetailVO
item
:
extIncomeDetails
)
{
Date
arrivalTime
=
item
.
getArrivalTime
();
if
((
yearFirst
.
before
(
arrivalTime
)
||
yearFirst
.
equals
(
arrivalTime
))
&&
(
yearLast
.
after
(
arrivalTime
)
||
yearFirst
.
equals
(
arrivalTime
)))
{
//计算到款数据之和
bigss
=
bigss
.
add
(
item
.
getAmount
());
}
}
}
return
bigss
;
}
}
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