Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
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
hujun
tl_estate
Commits
6abdb601
Commit
6abdb601
authored
Oct 14, 2019
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
service
parent
3d3c8170
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
56 deletions
+93
-56
OperationData.php
application/index/controller/OperationData.php
+12
-56
OperationDataService.php
application/index/service/OperationDataService.php
+81
-0
No files found.
application/index/controller/OperationData.php
View file @
6abdb601
...
...
@@ -9,6 +9,7 @@ namespace app\index\controller;
* Time: 15:40:20
*/
use
app\index\extend\Basic
;
use
app\index\service\OperationDataService
;
use
app\model\AAgents
;
use
app\model\ADistrict
;
use
app\model\AUserCallAgent
;
...
...
@@ -369,6 +370,15 @@ class OperationData extends Basic
return
$this
->
response
(
"101"
,
$checkResult
);
}
//验证时间是否合法
if
(
!
checkTimeData
(
$params
[
'time_start'
])){
return
$this
->
response
(
"101"
,
'开始日期异常!'
);
}
//验证时间是否合法
if
(
!
checkTimeData
(
$params
[
'time_end'
])){
return
$this
->
response
(
"101"
,
'结束日期异常!'
);
}
$time_start
=
$params
[
'time_start'
];
$time_end
=
$params
[
'time_end'
];
...
...
@@ -379,8 +389,8 @@ class OperationData extends Basic
$real_performance_time_end
=
$params
[
'real_performance_time_end'
];
//要计算的所有月份
$
month_num
=
$this
->
diffDate
(
$time_start
,
$time_end
);
$
s_operation_data
=
new
OperationDataService
(
);
$month_num
=
$s_operation_data
->
diffDate
(
$time_start
,
$time_end
);
$return
=
[
[
'city'
=>
'上海市'
,
'site_id'
=>
'10001'
,
'value'
=>
[]
],
...
...
@@ -454,61 +464,7 @@ class OperationData extends Basic
}
/**
* 找出两个日期之间的所有的月份
* @param $date1
* @param $date2
* @return array
*/
function
diffDate
(
$date1
,
$date2
)
{
//首次进入将分割开始与结束日期。
$startDate
=
explode
(
'-'
,
$date1
);
$endDate
=
explode
(
'-'
,
$date2
);
$startYear
=
$startDate
[
0
];
$endYear
=
$endDate
[
0
];
$startMonth
=
$startDate
[
1
];
$endMonth
=
$endDate
[
1
];
$YmArr
=
[];
//同一年和跨年分开处理。
if
(
$startYear
!=
$endYear
){
//找出跨年所有的月份
for
(
$year
=
$startYear
;
$year
<
$endYear
;
$year
++
)
{
for
(
$month
=
$startMonth
;
$month
<=
12
;
$month
++
)
{
$lenth
=
strlen
(
$month
);
if
(
$lenth
!=
2
){
$month
=
'0'
.
$month
;
}
$Ym
=
$year
.
'-'
.
$month
;
//拼接日期,根据自己需要的格式拼接。
$YmArr
[]
=
$Ym
;
}
$startMonth
=
1
;
//跨年的时候重置月份
}
//找出本年到现在的所有月份
for
(
$nowMonth
=
1
;
$nowMonth
<=
$endMonth
;
$nowMonth
++
)
{
$lenth
=
strlen
(
$nowMonth
);
if
(
$lenth
!=
2
){
$nowMonth
=
'0'
.
$nowMonth
;
}
$nowYm
=
$endYear
.
$nowMonth
;
$YmArr
[]
=
$nowYm
;
}
}
else
{
for
(
$nowMonth
=
$startMonth
;
$nowMonth
<=
$endMonth
;
$nowMonth
++
)
{
$lenth
=
strlen
(
$nowMonth
);
if
(
$lenth
!=
2
){
$nowMonth
=
'0'
.
$nowMonth
;
}
$nowYm
=
$endYear
.
'-'
.
$nowMonth
;
$YmArr
[]
=
$nowYm
;
}
}
return
$YmArr
;
}
...
...
application/index/service/OperationDataService.php
0 → 100644
View file @
6abdb601
<?php
/**
* Created by PhpStorm.
* User: zhuwei
* Date: 2019-10-14
* Time: 15:04:42
*/
namespace
app\index\service
;
class
OperationDataService
{
protected
$m_user
;
protected
$m_user_agent
;
public
function
__construct
()
{
}
/**
* 找出两个日期之间的所有的月份
* @param $date1
* @param $date2
* @return array
*/
function
diffDate
(
$date1
,
$date2
)
{
//首次进入将分割开始与结束日期。
$startDate
=
explode
(
'-'
,
$date1
);
$endDate
=
explode
(
'-'
,
$date2
);
$startYear
=
$startDate
[
0
];
$endYear
=
$endDate
[
0
];
$startMonth
=
$startDate
[
1
];
$endMonth
=
$endDate
[
1
];
$YmArr
=
[];
//同一年和跨年分开处理。
if
(
$startYear
!=
$endYear
){
//找出跨年所有的月份
for
(
$year
=
$startYear
;
$year
<
$endYear
;
$year
++
)
{
for
(
$month
=
$startMonth
;
$month
<=
12
;
$month
++
)
{
$lenth
=
strlen
(
$month
);
if
(
$lenth
!=
2
){
$month
=
'0'
.
$month
;
}
$Ym
=
$year
.
'-'
.
$month
;
//拼接日期,根据自己需要的格式拼接。
$YmArr
[]
=
$Ym
;
}
$startMonth
=
1
;
//跨年的时候重置月份
}
//找出本年到现在的所有月份
for
(
$nowMonth
=
1
;
$nowMonth
<=
$endMonth
;
$nowMonth
++
)
{
$lenth
=
strlen
(
$nowMonth
);
if
(
$lenth
!=
2
){
$nowMonth
=
'0'
.
$nowMonth
;
}
$nowYm
=
$endYear
.
'-'
.
$nowMonth
;
$YmArr
[]
=
$nowYm
;
}
}
else
{
for
(
$nowMonth
=
$startMonth
;
$nowMonth
<=
$endMonth
;
$nowMonth
++
)
{
$lenth
=
strlen
(
$nowMonth
);
if
(
$lenth
!=
2
){
$nowMonth
=
'0'
.
$nowMonth
;
}
$nowYm
=
$endYear
.
'-'
.
$nowMonth
;
$YmArr
[]
=
$nowYm
;
}
}
return
$YmArr
;
}
}
\ No newline at end of file
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