Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-data-cloud
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
base_platform_enterprise
gic-data-cloud
Commits
12184c08
Commit
12184c08
authored
Aug 06, 2020
by
陶光胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
观云台小程序
parent
a32ac1d1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
299 additions
and
9 deletions
+299
-9
IndexController.java
...in/java/com/gic/cloud/web/controller/IndexController.java
+37
-3
DataFormatUtils.java
...rc/main/java/com/gic/cloud/web/utils/DataFormatUtils.java
+256
-0
IndexConsume.java
...rc/main/java/com/gic/cloud/web/vo/index/IndexConsume.java
+6
-6
No files found.
gic-data-cloud-wxapp/src/main/java/com/gic/cloud/web/controller/IndexController.java
View file @
12184c08
...
...
@@ -8,15 +8,16 @@ import com.gic.cloud.service.FunctionModuleApiService;
import
com.gic.cloud.service.IndexApiService
;
import
com.gic.cloud.web.auth.DataAuthUtils
;
import
com.gic.cloud.web.qo.DateTypeQo
;
import
com.gic.cloud.web.utils.DataFormatUtils
;
import
com.gic.cloud.web.vo.FunctionModuleVo
;
import
com.gic.cloud.web.vo.LevelNameVo
;
import
com.gic.cloud.web.vo.LevelVo
;
import
com.gic.cloud.web.vo.MbrVo
;
import
com.gic.cloud.web.vo.index.IndexConsume
;
import
com.gic.cloud.web.vo.index.IndexSalesVo
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.data.api.dto.IndexMemberDTO
;
import
com.gic.data.api.dto.IndexSalesDTO
;
import
com.gic.data.api.dto.*
;
import
com.gic.data.api.service.IndexSalesApiService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -72,7 +73,40 @@ public class IndexController {
List
<
Integer
>
list
=
this
.
storeSearchUtils
.
storeSearch
(
userId
,
enterpriseId
,
searchJSON
);
List
<
String
>
onLine
=
this
.
storeSearchUtils
.
onLineStoreSearch
(
userId
,
enterpriseId
,
searchJSON
);
List
<
Long
>
mbrAreaIdList
=
this
.
dataAuthUtils
.
getMbrAreaId
(
userId
,
enterpriseId
);
return
RestResponse
.
success
();
ServiceResponse
<
IndexMemberOrderCntDTO
>
response1
=
this
.
indexSalesApiService
.
getIndexMemberOrderCnt
(
enterpriseId
,
list
,
onLine
,
StringUtils
.
isNoneBlank
(
mbrAreaId
)
?
Long
.
valueOf
(
mbrAreaId
)
:
null
,
mbrAreaIdList
,
dateTypeQo
.
getType
(),
dateTypeQo
.
getDate
(),
1
);
ServiceResponse
<
IndexMemberOrderCntDTO
>
response2
=
this
.
indexSalesApiService
.
getIndexMemberOrderCnt
(
enterpriseId
,
list
,
onLine
,
StringUtils
.
isNoneBlank
(
mbrAreaId
)
?
Long
.
valueOf
(
mbrAreaId
)
:
null
,
mbrAreaIdList
,
dateTypeQo
.
getType
(),
dateTypeQo
.
getDate
(),
2
);
ServiceResponse
<
IndexMemberOldOrderCnt
>
oldOrderCnt
=
this
.
indexSalesApiService
.
getIndexMemberOldOrderCnt
(
enterpriseId
,
list
,
onLine
,
StringUtils
.
isNoneBlank
(
mbrAreaId
)
?
Long
.
valueOf
(
mbrAreaId
)
:
null
,
mbrAreaIdList
,
dateTypeQo
.
getType
(),
dateTypeQo
.
getDate
());
ServiceResponse
<
IndexMemberBirthCntDTO
>
birthOrderCnt
=
this
.
indexSalesApiService
.
getIndexMemberBirthOrderCnt
(
enterpriseId
,
list
,
onLine
,
StringUtils
.
isNoneBlank
(
mbrAreaId
)
?
Long
.
valueOf
(
mbrAreaId
)
:
null
,
mbrAreaIdList
,
dateTypeQo
.
getType
(),
dateTypeQo
.
getDate
());
IndexConsume
consume
=
new
IndexConsume
();
if
(
response1
.
isSuccess
()
&&
response1
.
getResult
()
!=
null
&&
response2
.
getResult
()
!=
null
){
IndexMemberOrderCntDTO
indexMemberOrderCntDTO1
=
response1
.
getResult
();
IndexMemberOrderCntDTO
indexMemberOrderCntDTO2
=
response2
.
getResult
();
consume
.
setMemberRate
(
DataFormatUtils
.
rate
(
indexMemberOrderCntDTO1
.
getOrderCnt
(),
indexMemberOrderCntDTO2
.
getOrderCnt
()));
String
divide
=
DataFormatUtils
.
divide
(
DataFormatUtils
.
divideDouble
(
indexMemberOrderCntDTO1
.
getOrderCnt
(),
indexMemberOrderCntDTO1
.
getOrderCntHb
()),
DataFormatUtils
.
divideDouble
(
indexMemberOrderCntDTO2
.
getOrderCnt
(),
indexMemberOrderCntDTO2
.
getOrderCntHb
()));
consume
.
setMemberHb
(
divide
);
}
if
(
oldOrderCnt
.
isSuccess
()
&&
oldOrderCnt
.
getResult
()
!=
null
){
IndexMemberOldOrderCnt
indexMemberOldOrderCnt
=
oldOrderCnt
.
getResult
();
consume
.
setOldRate
(
DataFormatUtils
.
rate
(
indexMemberOldOrderCnt
.
getOldCnt
(),
indexMemberOldOrderCnt
.
getAllCnt
()));
consume
.
setOldHb
(
DataFormatUtils
.
divide
(
DataFormatUtils
.
divideDouble
(
indexMemberOldOrderCnt
.
getOldCnt
(),
indexMemberOldOrderCnt
.
getOldCntHb
()),
DataFormatUtils
.
divideDouble
(
indexMemberOldOrderCnt
.
getAllCnt
(),
indexMemberOldOrderCnt
.
getAllCntHb
())));
}
if
(
birthOrderCnt
.
isSuccess
()
&&
birthOrderCnt
.
getResult
()
!=
null
){
IndexMemberBirthCntDTO
birthOrderCntResult
=
birthOrderCnt
.
getResult
();
consume
.
setBirthRate
(
DataFormatUtils
.
rate
(
birthOrderCntResult
.
getBirthCnt
(),
birthOrderCntResult
.
getAllCnt
()));
consume
.
setBirthHb
(
DataFormatUtils
.
divide
(
DataFormatUtils
.
divideDouble
(
birthOrderCntResult
.
getBirthCnt
(),
birthOrderCntResult
.
getBirthCntHb
()),
DataFormatUtils
.
divideDouble
(
birthOrderCntResult
.
getAllCnt
(),
birthOrderCntResult
.
getBirthCntHb
())));
}
return
RestResponse
.
success
(
consume
);
}
@RequestMapping
(
"function-list"
)
...
...
gic-data-cloud-wxapp/src/main/java/com/gic/cloud/web/utils/DataFormatUtils.java
0 → 100644
View file @
12184c08
package
com
.
gic
.
cloud
.
web
.
utils
;
import
java.text.DecimalFormat
;
/**
* 数据处理
* @ClassName: DataFormatUtils
* @Description:
* @author guojuxing
* @date 2020/7/28 11:09 AM
*/
public
class
DataFormatUtils
{
/**
* 如果大于十万,则以万为单位,否则就是元作为单位
* @param data
* @return
*/
public
static
String
toTenThousand
(
Double
data
)
{
if
(
data
==
null
)
{
return
"--"
;
}
if
(
data
>=
100000
)
{
return
data
/
10000
+
"万"
;
}
return
data
+
""
;
}
/**
* 数字每三位分割
* @param data
* @return
*/
public
static
String
splitData
(
Integer
data
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"###,###"
);
if
(
data
==
null
)
{
return
"--"
;
}
return
df
.
format
(
data
);
}
/**
* 相除
* 数字每三位分割 并且保留2位小数
* @param a
* @param b
* @return
*/
public
static
String
splitData
(
Double
a
,
Integer
b
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"###,###.##"
);
if
(
b
==
null
||
b
==
0
)
{
return
"--"
;
}
return
df
.
format
(
a
/
b
);
}
/**
* 相除
* 数字每三位分割 并且保留2位小数
* @param a
* @param b
* @return
*/
public
static
String
splitData
(
Double
a
,
Double
b
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"###,###.##"
);
if
(
b
==
null
||
b
==
0
)
{
return
"--"
;
}
return
df
.
format
(
a
/
b
);
}
/**
* 相除
* 数字每三位分割 并且保留2位小数
* @param a
* @param b
* @return
*/
public
static
String
splitData
(
Double
a
,
Long
b
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"###,###.##"
);
if
(
b
==
null
||
b
==
0
)
{
return
"--"
;
}
return
df
.
format
(
a
/
b
);
}
/**
* 相除
* 数字每三位分割 并且保留2位小数
* @param a
* @param b
* @return
*/
public
static
String
splitData
(
Long
a
,
Long
b
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"###,###.##"
);
if
(
b
==
null
||
b
==
0
)
{
return
"--"
;
}
return
df
.
format
(
a
/
b
);
}
/**
* 相除
* 数字每三位分割 并且保留2位小数
* @param a
* @param b
* @return
*/
public
static
String
splitData
(
Integer
a
,
Integer
b
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"###,###.##"
);
if
(
b
==
null
||
b
==
0
)
{
return
"--"
;
}
return
df
.
format
(
1.0
*
a
/
b
);
}
/**
* +/-(a-b)/|b|*100%
* @param a
* @param b
* @return
*/
public
static
String
divide
(
Double
a
,
Double
b
)
{
if
(
b
==
null
||
b
==
0
)
{
return
"--"
;
}
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
String
sign
=
""
;
if
((
a
-
b
)
>=
0
)
{
sign
=
"+"
;
}
if
(
b
<
0
)
{
return
sign
+
df
.
format
((
a
-
b
)
/
(-
1
*
b
)
*
100
)
+
"%"
;
}
return
sign
+
df
.
format
((
a
-
b
)
/
b
*
100
)
+
"%"
;
}
/**
* +/-(a-b)/|b|*100%
* @param a
* @param b
* @return
*/
public
static
String
divide
(
Double
a
,
Integer
b
)
{
if
(
b
==
null
||
b
==
0
)
{
return
"--"
;
}
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
String
sign
=
""
;
if
((
a
-
b
)
>=
0
)
{
sign
=
"+"
;
}
if
(
b
<
0
)
{
return
sign
+
df
.
format
((
a
-
b
)
/
(-
1
*
b
)
*
100
)
+
"%"
;
}
return
sign
+
df
.
format
((
a
-
b
)
/
b
*
100
)
+
"%"
;
}
/**
* (a-b)/|b|*100%
* @param a
* @param b
* @return
*/
public
static
String
divide
(
String
a
,
String
b
)
{
Double
a1
=
Double
.
parseDouble
(
a
);
Double
b1
=
Double
.
parseDouble
(
b
);
if
(
b1
==
null
||
b1
==
0
)
{
return
"--"
;
}
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
if
(
b1
<
0
)
{
return
df
.
format
((
a1
-
b1
)
/
(-
1
*
b1
)
*
100
)
+
"%"
;
}
return
df
.
format
((
a1
-
b1
)
/
b1
*
100
)
+
"%"
;
}
/**
* +/-(a-b)/|b|*100%
* @param a
* @param b
* @return
*/
public
static
String
divide
(
Integer
a
,
Integer
b
)
{
if
(
b
==
null
||
b
==
0
)
{
return
"--"
;
}
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
String
sign
=
""
;
if
((
a
-
b
)
>=
0
)
{
sign
=
"+"
;
}
if
(
b
<
0
)
{
return
sign
+
df
.
format
(
1.0
*
(
a
-
b
)
/
(-
1
*
b
)
*
100
)
+
"%"
;
}
return
sign
+
df
.
format
(
1.0
*
(
a
-
b
)
/
b
*
100
)
+
"%"
;
}
/**
* +/-(a-b)/|b|*100%
* @param a
* @param b
* @return
*/
public
static
Double
divideDouble
(
Integer
a
,
Integer
b
)
{
if
(
b
==
null
||
b
==
0
)
{
return
0
d
;
}
if
(
b
<
0
)
{
return
1.0
*
(
a
-
b
)
/
(-
1
*
b
)
*
100
;
}
return
1.0
*
(
a
-
b
)
/
b
*
100
;
}
/**
* 保留2位小数
* @param data
* @return
*/
public
static
String
twoFormat
(
Double
data
)
{
if
(
data
==
null
||
data
==
0
)
{
return
"--"
;
}
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
return
df
.
format
(
data
);
}
/**
* 占比
* @param a
* @param b
* @return
*/
public
static
String
rate
(
Long
a
,
Long
b
)
{
if
(
b
==
null
||
b
==
0
)
{
return
"--"
;
}
return
twoFormat
(
a
*
1.0
/
b
*
100
)
+
"%"
;
}
public
static
String
rate
(
Double
a
,
Double
b
)
{
if
(
b
==
null
||
b
==
0
)
{
return
"--"
;
}
return
twoFormat
(
a
/
b
*
100
)
+
"%"
;
}
public
static
String
rate
(
Integer
a
,
Integer
b
)
{
if
(
b
==
null
||
b
==
0
)
{
return
"--"
;
}
return
twoFormat
(
Double
.
valueOf
(
a
)
/
Double
.
valueOf
(
b
)
*
100
)
+
"%"
;
}
}
gic-data-cloud-wxapp/src/main/java/com/gic/cloud/web/vo/index/IndexConsume.java
View file @
12184c08
package
com
.
gic
.
cloud
.
web
.
vo
.
index
;
public
class
IndexConsume
{
private
String
memberRate
;
private
String
oldRate
;
private
String
birthRate
;
private
String
memberHb
;
private
String
oldHb
;
private
String
birthHb
;
private
String
memberRate
=
"--"
;
private
String
oldRate
=
"--"
;
private
String
birthRate
=
"--"
;
private
String
memberHb
=
"--"
;
private
String
oldHb
=
"--"
;
private
String
birthHb
=
"--"
;
public
String
getMemberRate
()
{
return
memberRate
;
...
...
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