Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
d51868f9
Commit
d51868f9
authored
May 07, 2022
by
神话
Browse files
解决多账户金额计算的bug
parent
3c35db87
Changes
2
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/service/account/AccountService.java
View file @
d51868f9
...
...
@@ -526,10 +526,10 @@ public class AccountService {
public
String
getAccountStrByIdAndMoney
(
Map
<
Long
,
String
>
accountMap
,
String
accountIdList
,
String
accountMoneyList
){
StringBuffer
sb
=
new
StringBuffer
();
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
accountIdList
);
List
<
Long
>
moneyList
=
StringUtil
.
strTo
Long
List
(
accountMoneyList
);
List
<
BigDecimal
>
moneyList
=
StringUtil
.
strTo
BigDecimal
List
(
accountMoneyList
);
for
(
int
i
=
0
;
i
<
idList
.
size
();
i
++)
{
Long
id
=
idList
.
get
(
i
);
BigDecimal
money
=
BigDecimal
.
valueOf
(
moneyList
.
get
(
i
)
)
.
abs
();
BigDecimal
money
=
moneyList
.
get
(
i
).
abs
();
sb
.
append
(
accountMap
.
get
(
id
)
+
"("
+
money
+
"元) "
);
}
return
sb
.
toString
();
...
...
jshERP-boot/src/main/java/com/jsh/erp/utils/StringUtil.java
View file @
d51868f9
...
...
@@ -4,6 +4,7 @@ import org.springframework.util.StringUtils;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
java.math.BigDecimal
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
...
...
@@ -177,10 +178,10 @@ public class StringUtil {
return
new
ArrayList
<
String
>();
}
public
static
int
getArrSum
(
String
[]
strings
)
{
int
sum
=
0
;
public
static
BigDecimal
getArrSum
(
String
[]
strings
)
{
BigDecimal
sum
=
BigDecimal
.
ZERO
;
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++){
sum
=
sum
+
Integer
.
parseInt
(
strings
[
i
]);
sum
=
sum
.
add
(
new
BigDecimal
(
strings
[
i
])
)
;
}
return
sum
;
}
...
...
@@ -203,6 +204,24 @@ public class StringUtil {
return
idList
;
}
/**
* String字符串转成List<BigDecimal>数据格式
* String str = "1,2,3,4,5,6" -> List<BigDecimal> listBigDecimal [1,2,3,4,5,6];
*
* @param strArr
* @return
*/
public
static
List
<
BigDecimal
>
strToBigDecimalList
(
String
strArr
)
{
List
<
BigDecimal
>
idList
=
new
ArrayList
<>();
String
[]
d
=
strArr
.
split
(
","
);
for
(
int
i
=
0
,
size
=
d
.
length
;
i
<
size
;
i
++)
{
if
(
d
[
i
]!=
null
)
{
idList
.
add
(
new
BigDecimal
(
d
[
i
]));
}
}
return
idList
;
}
/**
* String字符串转成List<String>数据格式
* String str = "1,2,3,4,5,6" -> List<Long> listLong [1,2,3,4,5,6];
...
...
Write
Preview
Supports
Markdown
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