c80_estate 0.1.0.9 → 0.1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/admin/c80_estate/admin_user.rb +4 -1
- data/app/admin/c80_estate/areas.rb +30 -20
- data/app/admin/c80_estate/astatuses.rb +1 -0
- data/app/admin/c80_estate/comments.rb +3 -1
- data/app/admin/c80_estate/dashboard.rb +14 -4
- data/app/admin/c80_estate/properties.rb +1 -1
- data/app/admin/c80_estate/pstats.rb +1 -0
- data/app/assets/javascript/c80_estate/backend/admin/areas.js +180 -19
- data/app/assets/javascript/c80_estate/backend/admin/pstats.js +155 -147
- data/app/assets/javascript/c80_estate/lib/bootstrap-slider.js +1641 -0
- data/app/assets/stylesheets/c80_estate/backend/admin_areas.scss +7 -3
- data/app/assets/stylesheets/c80_estate/backend/admin_pstats.scss +19 -11
- data/app/assets/stylesheets/c80_estate/backend/common.scss +5 -0
- data/app/controllers/c80_estate/ajax_areas_controller.rb +38 -0
- data/app/helpers/c80_estate/app_helper.rb +45 -36
- data/app/models/c80_estate/area.rb +94 -0
- data/app/models/c80_estate/item_prop.rb +4 -2
- data/app/models/c80_estate/owner.rb +8 -2
- data/app/models/c80_estate/pstat.rb +53 -35
- data/app/views/admin/dashboard/_prop_in_list.html.erb +1 -2
- data/app/views/c80_estate/ajax_areas/exel_import.html.erb +1 -0
- data/app/views/c80_estate/ajax_areas/exel_import.js.erb +6 -0
- data/app/views/c80_estate/shared/_form_upload_areas_excel.erb +37 -0
- data/app/views/c80_estate/shared/_table_properties_coef_busy.html.erb +12 -8
- data/app/views/c80_estate/shared/_table_properties_coef_busy_sq.html.erb +12 -8
- data/config/routes.rb +2 -0
- data/lib/c80_estate/version.rb +1 -1
- metadata +7 -3
- data/app/assets/javascript/c80_estate/lib/bootstrap-slider.min.js +0 -29
@@ -122,14 +122,14 @@ body.admin_areas {
|
|
122
122
|
&.index {
|
123
123
|
|
124
124
|
.min_text_input {
|
125
|
-
margin
|
125
|
+
margin: 10px 0;
|
126
126
|
width: 45% !important;
|
127
|
+
padding-left: 15px;
|
127
128
|
}
|
128
129
|
|
129
130
|
.max_text_input {
|
130
|
-
margin
|
131
|
+
margin: 10px 0 0 10% !important;
|
131
132
|
width: 45% !important;
|
132
|
-
margin-left: 10%;
|
133
133
|
}
|
134
134
|
|
135
135
|
a.delete_link {
|
@@ -174,6 +174,10 @@ body.admin_areas {
|
|
174
174
|
|
175
175
|
}
|
176
176
|
|
177
|
+
.blank_slate_container {
|
178
|
+
display: none !important;
|
179
|
+
}
|
180
|
+
|
177
181
|
}
|
178
182
|
|
179
183
|
&.show {
|
@@ -24,8 +24,9 @@ body.admin_pstats {
|
|
24
24
|
height: 183px;
|
25
25
|
|
26
26
|
&#coef {
|
27
|
-
width:
|
27
|
+
width: 33%;
|
28
28
|
text-align: center;
|
29
|
+
margin-bottom: 15px;
|
29
30
|
|
30
31
|
p {
|
31
32
|
width: 100%;
|
@@ -40,8 +41,7 @@ body.admin_pstats {
|
|
40
41
|
}
|
41
42
|
|
42
43
|
&#coef_sq {
|
43
|
-
width:
|
44
|
-
margin-left: 30px;
|
44
|
+
width: 33%;
|
45
45
|
text-align: center;
|
46
46
|
|
47
47
|
p {
|
@@ -57,8 +57,9 @@ body.admin_pstats {
|
|
57
57
|
}
|
58
58
|
|
59
59
|
&#text_stats, &#text_stats_sq {
|
60
|
-
width: calc(
|
60
|
+
width: calc(33% - 30px);
|
61
61
|
margin-left: 30px;
|
62
|
+
margin-bottom: 15px;
|
62
63
|
|
63
64
|
ul {
|
64
65
|
padding: 0 5px;
|
@@ -70,16 +71,23 @@ body.admin_pstats {
|
|
70
71
|
|
71
72
|
}
|
72
73
|
|
73
|
-
&#
|
74
|
-
width: calc(
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
&#graph_radial {
|
75
|
+
width: calc(33% - 30px);
|
76
|
+
margin-left: 30px;
|
77
|
+
margin-bottom: 15px;
|
78
|
+
padding: 0;
|
78
79
|
|
80
|
+
-webkit-transition: opacity .2s ease-in;
|
81
|
+
-moz-transition: opacity .2s ease-in;
|
82
|
+
-ms-transition: opacity .2s ease-in;
|
83
|
+
-o-transition: opacity .2s ease-in;
|
84
|
+
transition: opacity .2s ease-in;
|
85
|
+
}
|
86
|
+
|
87
|
+
&#graph_radial_sq {
|
88
|
+
width: calc(33% - 30px);
|
79
89
|
margin-left: 30px;
|
80
90
|
padding: 0;
|
81
|
-
display: none;
|
82
|
-
opacity: 0;
|
83
91
|
|
84
92
|
-webkit-transition: opacity .2s ease-in;
|
85
93
|
-moz-transition: opacity .2s ease-in;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module C80Estate
|
2
|
+
class AjaxAreasController < ActionController::Base
|
3
|
+
|
4
|
+
def exel_import
|
5
|
+
|
6
|
+
is_ok = true
|
7
|
+
errs = {
|
8
|
+
"areas_exel" => [
|
9
|
+
|
10
|
+
]
|
11
|
+
}
|
12
|
+
|
13
|
+
begin
|
14
|
+
@import_result = Area.import_excel(params[:file])
|
15
|
+
rescue => e
|
16
|
+
Rails.logger.debug "ERROR: #{e}"
|
17
|
+
errs["areas_exel"].push(e.to_s)
|
18
|
+
is_ok = false
|
19
|
+
end
|
20
|
+
|
21
|
+
# TODO:: Excel: реализовать вывод тех ошибок, которые возникли при импорте: например: таблица была импортирована за исключением таких-то полей
|
22
|
+
|
23
|
+
respond_to do |format|
|
24
|
+
if is_ok
|
25
|
+
format.js { render json: errs, status: :ok }
|
26
|
+
format.json
|
27
|
+
format.html
|
28
|
+
else
|
29
|
+
format.js { render json: errs, status: :unprocessable_entity }
|
30
|
+
format.json
|
31
|
+
format.html
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -5,50 +5,59 @@ module C80Estate
|
|
5
5
|
# Rails.logger.debug "<render_table_prop_busy_coef> atype_id = #{atype_id}"
|
6
6
|
|
7
7
|
props = Property.all
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
8
|
+
if props.count > 0
|
9
|
+
list = []
|
10
|
+
|
11
|
+
props.all.each do |prop|
|
12
|
+
pp = Pstat.busy_coef(prop_id: prop.id, atype_id: atype_id)
|
13
|
+
# Rails.logger.debug "<render_table_prop_busy_coef> pp = #{pp}"
|
14
|
+
busy_coef = pp[:busy_coef]
|
15
|
+
props = pp[:raw_props]
|
16
|
+
list << {
|
17
|
+
title: prop.title,
|
18
|
+
busy_coef: busy_coef,
|
19
|
+
props: props
|
20
|
+
}
|
21
|
+
# Rails.logger.debug "<render_table_prop_busy_coef> #{prop.title}"
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
render :partial => 'c80_estate/shared/table_properties_coef_busy',
|
25
|
+
:locals => {
|
26
|
+
list: list
|
27
|
+
}
|
28
|
+
end
|
27
29
|
end
|
28
30
|
|
29
31
|
def render_table_prop_busy_coef_sq(atype_id: nil)
|
30
|
-
Rails.logger.debug "<render_table_prop_busy_coef_sq> atype_id = #{atype_id}"
|
32
|
+
# Rails.logger.debug "<render_table_prop_busy_coef_sq> atype_id = #{atype_id}"
|
31
33
|
|
32
34
|
props = Property.all
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
|
36
|
+
if props.count > 0
|
37
|
+
list = []
|
38
|
+
|
39
|
+
props.all.each do |prop|
|
40
|
+
pp = Pstat.busy_coef(prop_id: prop.id, atype_id: atype_id)
|
41
|
+
# Rails.logger.debug "<render_table_prop_busy_coef> pp = #{pp}"
|
42
|
+
busy_coef_sq = pp[:busy_coef_sq]
|
43
|
+
props = pp[:raw_props_sq]
|
44
|
+
list << {
|
45
|
+
title: prop.title,
|
46
|
+
busy_coef: busy_coef_sq,
|
47
|
+
props: props
|
48
|
+
}
|
49
|
+
# Rails.logger.debug "<render_table_prop_busy_coef> #{prop.title}"
|
50
|
+
end
|
51
|
+
|
52
|
+
render :partial => 'c80_estate/shared/table_properties_coef_busy_sq',
|
53
|
+
:locals => {
|
54
|
+
list: list
|
55
|
+
}
|
46
56
|
end
|
57
|
+
end
|
47
58
|
|
48
|
-
|
49
|
-
|
50
|
-
list: list
|
51
|
-
}
|
59
|
+
def render_upload_areas_excel_form
|
60
|
+
render :partial => 'c80_estate/shared/form_upload_areas_excel'
|
52
61
|
end
|
53
62
|
|
54
63
|
end
|
@@ -109,6 +109,69 @@ module C80Estate
|
|
109
109
|
.where(c80_estate_item_props: {value: v})
|
110
110
|
end
|
111
111
|
|
112
|
+
def self.import_excel(file)
|
113
|
+
|
114
|
+
Rails.logger.debug "------------------------------------------------------------- self.import [BEGIN] "
|
115
|
+
|
116
|
+
import_result = ''
|
117
|
+
spreadsheet = open_spreadsheet(file)
|
118
|
+
header = spreadsheet.row(1)
|
119
|
+
|
120
|
+
# Rails.logger.debug(header)
|
121
|
+
# ["title", "atype", "square", "price", "status"]
|
122
|
+
|
123
|
+
(2..spreadsheet.last_row).each do |i|
|
124
|
+
|
125
|
+
row = Hash[[header, spreadsheet.row(i)].transpose]
|
126
|
+
|
127
|
+
Rails.logger.debug("---------- #{row} -----------")
|
128
|
+
# {"title"=>"С2-1.18", "atype"=>"Торговое помещение", "square"=>"0", "price"=>800.0, "status"=>"Занята"}
|
129
|
+
|
130
|
+
# area_where = Area.where(:slug => row["ID"])
|
131
|
+
# if area_where.count > 0
|
132
|
+
#
|
133
|
+
# area = Area.where(:slug => row["ID"]).first
|
134
|
+
# puts "--- Обновляем данные для #{area.id}, #{area.slug}: "
|
135
|
+
# puts "--- Хотим вставить данные: " + row.to_hash.to_s
|
136
|
+
# area.price = row["Цена"]
|
137
|
+
# area.space = row["Площадь"]
|
138
|
+
# area.save
|
139
|
+
# puts "."
|
140
|
+
#
|
141
|
+
# else
|
142
|
+
# s = "В базе не найден павильон: #{row.to_hash}"
|
143
|
+
# import_result += s + "\n"
|
144
|
+
# puts s
|
145
|
+
#
|
146
|
+
# end
|
147
|
+
#
|
148
|
+
#
|
149
|
+
|
150
|
+
area = C80Estate::Area.create!({
|
151
|
+
title: row['title'],
|
152
|
+
property_id: row['property_id'].to_i,
|
153
|
+
atype_id: row['atype_id'].to_i,
|
154
|
+
owner_type: 'AdminUser',
|
155
|
+
owner_id: 2,
|
156
|
+
assigned_person_type: 'AdminUser',
|
157
|
+
assigned_person_id: 2
|
158
|
+
})
|
159
|
+
|
160
|
+
C80Estate::ItemProp.create!([
|
161
|
+
{value: row['price'].to_i, area_id: area.id, prop_name_id: 1},
|
162
|
+
{value: row['square'].to_f, area_id: area.id, prop_name_id: 9},
|
163
|
+
])
|
164
|
+
|
165
|
+
area.astatuses << C80Estate::Astatus.find(row['astatus'].to_i)
|
166
|
+
area.save
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
puts "------------------------------------------------------------- self.import [END] "
|
171
|
+
import_result
|
172
|
+
|
173
|
+
end
|
174
|
+
|
112
175
|
def atype_title
|
113
176
|
res = "-"
|
114
177
|
if atype.present?
|
@@ -165,6 +228,24 @@ module C80Estate
|
|
165
228
|
res
|
166
229
|
end
|
167
230
|
|
231
|
+
def price_value
|
232
|
+
res = '-'
|
233
|
+
p = item_props.where(:prop_name_id => 1)
|
234
|
+
if p.count > 0
|
235
|
+
res = p.first.value
|
236
|
+
end
|
237
|
+
res
|
238
|
+
end
|
239
|
+
|
240
|
+
def square_value
|
241
|
+
res = '-'
|
242
|
+
p = item_props.where(:prop_name_id => 9)
|
243
|
+
if p.count > 0
|
244
|
+
res = p.first.value
|
245
|
+
end
|
246
|
+
res
|
247
|
+
end
|
248
|
+
|
168
249
|
ransacker :item_prop_price_val,
|
169
250
|
formatter: proc { |price_range| # 10,156
|
170
251
|
results = C80Estate::Area.where_price_range(price_range).map(&:id)
|
@@ -302,5 +383,18 @@ module C80Estate
|
|
302
383
|
|
303
384
|
end
|
304
385
|
|
386
|
+
private
|
387
|
+
|
388
|
+
def self.open_spreadsheet(file)
|
389
|
+
case File.extname(file.original_filename)
|
390
|
+
when ".xls" then
|
391
|
+
Roo::Excel.new(file.path)
|
392
|
+
when ".xlsx" then
|
393
|
+
Roo::Excelx.new(file.path)
|
394
|
+
else
|
395
|
+
raise "Неизвестный формат файла: #{file.original_filename}"
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
305
399
|
end
|
306
400
|
end
|
@@ -8,8 +8,10 @@ module C80Estate
|
|
8
8
|
before_save :before_save_format_value
|
9
9
|
|
10
10
|
def self.all_uniq_values(prop_name_id)
|
11
|
-
self.where(prop_name_id: prop_name_id)
|
12
|
-
.map { |ip| ip.value }.uniq
|
11
|
+
r = self.where(prop_name_id: prop_name_id)
|
12
|
+
.map { |ip| ip.value.to_i }.uniq
|
13
|
+
# Rails.logger.debug("<ItemProp.all_uniq_values> #{prop_name_id}: #{r}")
|
14
|
+
r
|
13
15
|
end
|
14
16
|
|
15
17
|
private
|
@@ -74,7 +74,10 @@ module C80Estate
|
|
74
74
|
def can_edit_area?(area)
|
75
75
|
r1 = roles.where(role_type: 1)
|
76
76
|
# mark_is_owner = area.owner.id == id
|
77
|
-
mark_is_assigned =
|
77
|
+
mark_is_assigned = false
|
78
|
+
if area.property.assigned_person.present?
|
79
|
+
mark_is_assigned = area.property.assigned_person.id == id
|
80
|
+
end
|
78
81
|
r1.count > 0 || mark_is_assigned # || mark_is_owner
|
79
82
|
# true
|
80
83
|
end
|
@@ -83,7 +86,10 @@ module C80Estate
|
|
83
86
|
def can_edit_property?(property)
|
84
87
|
r1 = roles.where(role_type: 1)
|
85
88
|
# mark_is_owner = property.owner.id == id
|
86
|
-
mark_is_assigned =
|
89
|
+
mark_is_assigned = false
|
90
|
+
if property.assigned_person.present?
|
91
|
+
mark_is_assigned = property.assigned_person.id == id
|
92
|
+
end
|
87
93
|
r1.count > 0 || mark_is_assigned # || mark_is_owner
|
88
94
|
# true
|
89
95
|
end
|
@@ -23,6 +23,11 @@ module C80Estate
|
|
23
23
|
# Rails.logger.debug "<Pstat.busy_coef> prop_id = #{prop_id}, atype_id = #{atype_id}"
|
24
24
|
result = {}
|
25
25
|
|
26
|
+
# если нет событий - не считаем busy_coef
|
27
|
+
if self.all.count == 0
|
28
|
+
return result
|
29
|
+
end
|
30
|
+
|
26
31
|
# обозначим диапазон фильтрации
|
27
32
|
first_created_at = Time.at(self.first.created_at)
|
28
33
|
time_now = Time.now
|
@@ -60,7 +65,6 @@ module C80Estate
|
|
60
65
|
|
61
66
|
free_areas_atnow = tt[:sum_free_areas] #*1.0/all_props.count #pstats.last.free_areas
|
62
67
|
busy_areas_atnow = tt[:sum_busy_areas] #*1.0/all_props.count #pstats.last.busy_areas
|
63
|
-
graph_data = _parse_for_js_dynamic_graph_canvasjs(pstats.ordered_by_created_at)
|
64
68
|
|
65
69
|
# защищаемся от деления на ноль
|
66
70
|
if free_areas_atnow + busy_areas_atnow == 0
|
@@ -75,7 +79,7 @@ module C80Estate
|
|
75
79
|
|
76
80
|
result[:busy_coef] = sprintf "%.2f%", bcoef
|
77
81
|
result[:comment] = "<abbr title='Период рассчёта занятости'>C #{ddd} по #{ tcut[:used_end_date_str] }</abbr>"
|
78
|
-
result[:abbr] = 'Показана занятость для ВСЕХ площадей ВСЕХ объектов недвижимости
|
82
|
+
result[:abbr] = 'Показана занятость для ВСЕХ площадей ВСЕХ объектов недвижимости в конце указанного периода'
|
79
83
|
result[:props] = [
|
80
84
|
{tag: 'all_areas_count', val: "Площадей всего: #{free_areas_atnow + busy_areas_atnow}"},
|
81
85
|
{tag: 'free_areas_count', val: "Площадей свободно: #{free_areas_atnow}"},
|
@@ -85,7 +89,8 @@ module C80Estate
|
|
85
89
|
result[:raw_props][:all_areas_count] = free_areas_atnow + busy_areas_atnow
|
86
90
|
result[:raw_props][:free_areas_count] = free_areas_atnow
|
87
91
|
result[:raw_props][:busy_areas_atnow] = busy_areas_atnow
|
88
|
-
result[:graph_dynamic] =
|
92
|
+
result[:graph_dynamic] = _parse_for_js_dynamic_graph_canvasjs(pstats.ordered_by_created_at)
|
93
|
+
result[:graph_radial] = _parse_for_js_radial_graph(free_areas_atnow,busy_areas_atnow)
|
89
94
|
|
90
95
|
# Rails.logger.debug "<Pstat.busy_coef> busy_areas_count = #{ busy_areas_count }"
|
91
96
|
# Rails.logger.debug "<Pstat.busy_coef> all_areas_count = #{ all_areas_count }"
|
@@ -95,7 +100,6 @@ module C80Estate
|
|
95
100
|
|
96
101
|
free_areas_atnow_sq = pstats.where(:atype_id => nil).last.free_areas_sq
|
97
102
|
busy_areas_atnow_sq = pstats.where(:atype_id => nil).last.busy_areas_sq
|
98
|
-
graph_data_sq = _parse_for_js_dynamic_graph3_canvasjs(pstats.where(:atype_id => nil).ordered_by_created_at)
|
99
103
|
|
100
104
|
# защищаемся от деления на ноль
|
101
105
|
if busy_areas_atnow_sq + free_areas_atnow_sq == 0
|
@@ -106,7 +110,7 @@ module C80Estate
|
|
106
110
|
|
107
111
|
result[:busy_coef_sq] = sprintf "%.2f%", bcoef_sq
|
108
112
|
result[:comment_sq] = "<abbr title='Период рассчёта занятости в МЕТРАХ КВ'>C #{tcut[:used_start_date_str]} по #{tcut[:used_end_date_str]}</abbr>"
|
109
|
-
result[:abbr_sq] = 'Занятость объекта в МЕТРАХ
|
113
|
+
result[:abbr_sq] = 'Занятость объекта в МЕТРАХ в конце указанного периода: число b/N, где b - кол-во свободных МЕТРОВ, N - всего МЕТРОВ КВ'
|
110
114
|
result[:props_sq] = [
|
111
115
|
{tag: 'all_areas_count_sq', val: "Кв.м. всего: #{busy_areas_atnow_sq + free_areas_atnow_sq}"},
|
112
116
|
{tag: 'free_areas_count_sq', val: "Свободных: #{free_areas_atnow_sq}"},
|
@@ -116,7 +120,8 @@ module C80Estate
|
|
116
120
|
result[:raw_props_sq][:all_areas_count_sq] = free_areas_atnow_sq + busy_areas_atnow_sq
|
117
121
|
result[:raw_props_sq][:free_areas_count_sq] = free_areas_atnow_sq
|
118
122
|
result[:raw_props_sq][:busy_areas_atnow_sq] = busy_areas_atnow_sq
|
119
|
-
result[:graph_dynamic_sq] =
|
123
|
+
result[:graph_dynamic_sq] = _parse_for_js_dynamic_graph3_canvasjs(pstats.where(:atype_id => nil).ordered_by_created_at)
|
124
|
+
result[:graph_radial_sq] = _parse_for_js_radial_graph_sq(free_areas_atnow_sq, busy_areas_atnow_sq)
|
120
125
|
|
121
126
|
# common
|
122
127
|
|
@@ -218,7 +223,9 @@ module C80Estate
|
|
218
223
|
|
219
224
|
result[:busy_coef] = sprintf "%.2f%", bcoef
|
220
225
|
result[:comment] = "<abbr title='Период рассчёта занятости'>C #{used_start_date_str} по #{used_end_date_str}</abbr>"
|
221
|
-
result[:abbr] = 'Занятость объекта
|
226
|
+
result[:abbr] = 'Занятость объекта в конце указанного периода: число b/N, где b - кол-во свободных, N - всего площадей'
|
227
|
+
result[:graph_radial] = _parse_for_js_radial_graph(free_areas_atnow,busy_areas_atnow)
|
228
|
+
result[:graph_dynamic] = graph_data
|
222
229
|
|
223
230
|
result[:raw_props] = {}
|
224
231
|
result[:raw_props][:all_areas_count] = free_areas_atnow + busy_areas_atnow
|
@@ -246,7 +253,10 @@ module C80Estate
|
|
246
253
|
|
247
254
|
result[:busy_coef_sq] = sprintf "%.2f%", bcoef_sq
|
248
255
|
result[:comment_sq] = "<abbr title='Период рассчёта занятости в МЕТРАХ КВ'>C #{used_start_date_str} по #{used_end_date_str}</abbr>"
|
249
|
-
result[:abbr_sq] = 'Занятость объекта в МЕТРАХ
|
256
|
+
result[:abbr_sq] = 'Занятость объекта в МЕТРАХ в конце указанного периода: число b/N, где b - кол-во свободных МЕТРОВ, N - всего МЕТРОВ КВ'
|
257
|
+
result[:graph_dynamic_sq] = graph_data_sq
|
258
|
+
result[:graph_radial_sq] = _parse_for_js_radial_graph_sq(free_areas_atnow_sq,busy_areas_atnow_sq)
|
259
|
+
|
250
260
|
result[:props_sq] = [
|
251
261
|
{tag: 'all_areas_count_sq', val: "Кв.м. всего: #{busy_areas_atnow_sq + free_areas_atnow_sq}"},
|
252
262
|
{tag: 'free_areas_count_sq', val: "Свободных: #{free_areas_atnow_sq}"},
|
@@ -262,8 +272,7 @@ module C80Estate
|
|
262
272
|
|
263
273
|
result[:title] = "Статистика - Объект - #{property.title}"
|
264
274
|
# result[:graph] = _parse_for_js_radial_graph(free_areas_atnow,busy_areas_atnow)
|
265
|
-
|
266
|
-
result[:graph_dynamic_sq] = graph_data_sq
|
275
|
+
|
267
276
|
|
268
277
|
# if atype_id.present?
|
269
278
|
# result[:title] += " (#{Atype.find(atype_id).title})"
|
@@ -352,7 +361,6 @@ module C80Estate
|
|
352
361
|
|
353
362
|
free_areas_atnow = tt[:sum_free_areas] #*1.0/all_props.count #pstats.last.free_areas
|
354
363
|
busy_areas_atnow = tt[:sum_busy_areas] #*1.0/all_props.count #pstats.last.busy_areas
|
355
|
-
graph_data = _parse_for_js_dynamic_graph_canvasjs(pstats.ordered_by_created_at)
|
356
364
|
|
357
365
|
# Rails.logger.debug("\t\t atype_id = #{atype_id}")
|
358
366
|
# Rails.logger.debug("\t\t free_areas_atnow = #{free_areas_atnow}")
|
@@ -367,7 +375,9 @@ module C80Estate
|
|
367
375
|
|
368
376
|
result[:busy_coef] = sprintf "%.2f%", bcoef
|
369
377
|
result[:comment] = "<abbr title='Период рассчёта занятости'>C #{used_start_date_str} по #{used_end_date_str}</abbr>"
|
370
|
-
result[:abbr] = 'Занятость объекта
|
378
|
+
result[:abbr] = 'Занятость объекта в конце указанного периода: число b/N, где b - кол-во свободных, N - всего площадей'
|
379
|
+
result[:graph_dynamic] = _parse_for_js_dynamic_graph_canvasjs(pstats.ordered_by_created_at)
|
380
|
+
result[:graph_radial] = _parse_for_js_radial_graph(free_areas_atnow,busy_areas_atnow)
|
371
381
|
|
372
382
|
result[:raw_props] = {}
|
373
383
|
result[:raw_props][:all_areas_count] = free_areas_atnow + busy_areas_atnow
|
@@ -389,7 +399,10 @@ module C80Estate
|
|
389
399
|
|
390
400
|
result[:busy_coef_sq] = sprintf "%.2f%", bcoef_sq
|
391
401
|
result[:comment_sq] = "<abbr title='Период рассчёта занятости в МЕТРАХ КВ'>C #{used_start_date_str} по #{used_end_date_str}</abbr>"
|
392
|
-
result[:abbr_sq] = 'Занятость объекта в МЕТРАХ
|
402
|
+
result[:abbr_sq] = 'Занятость объекта в МЕТРАХ в конце указанного периода: число b/N, где b - кол-во свободных МЕТРОВ, N - всего МЕТРОВ КВ'
|
403
|
+
result[:graph_dynamic_sq] = graph_data_sq
|
404
|
+
result[:graph_radial_sq] = _parse_for_js_radial_graph_sq(free_areas_atnow_sq,busy_areas_atnow_sq)
|
405
|
+
|
393
406
|
result[:props_sq] = [
|
394
407
|
{tag: 'all_areas_count_sq', val: "Кв.м. всего: #{busy_areas_atnow_sq + free_areas_atnow_sq}"},
|
395
408
|
{tag: 'free_areas_count_sq', val: "Свободных: #{free_areas_atnow_sq}"},
|
@@ -404,9 +417,6 @@ module C80Estate
|
|
404
417
|
# common
|
405
418
|
|
406
419
|
result[:title] = "Статистика - Объекты - Фильтр по типу площади '#{ Atype.find(atype_id).title }'"
|
407
|
-
# result[:graph] = _parse_for_js_radial_graph(free_areas_atnow,busy_areas_atnow)
|
408
|
-
result[:graph_dynamic] = graph_data
|
409
|
-
result[:graph_dynamic_sq] = graph_data_sq
|
410
420
|
|
411
421
|
# if atype_id.present?
|
412
422
|
# result[:title] += " (#{Atype.find(atype_id).title})"
|
@@ -504,24 +514,30 @@ module C80Estate
|
|
504
514
|
end
|
505
515
|
|
506
516
|
def self._parse_for_js_radial_graph(free_areas_atnow, busy_areas_atnow)
|
507
|
-
#
|
508
|
-
#
|
509
|
-
#
|
510
|
-
#
|
511
|
-
#
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
#
|
517
|
-
|
518
|
-
|
519
|
-
|
517
|
+
# data:
|
518
|
+
# [
|
519
|
+
# { y: 6, legendText:"", label: "Площадей свободно" },
|
520
|
+
# { y: 4, legendText:"", label: "Площадей занято" }
|
521
|
+
# ]
|
522
|
+
|
523
|
+
res = []
|
524
|
+
res << {label: 'Площадей свободно', y: free_areas_atnow, legendText: ''}
|
525
|
+
res << {label: 'Площадей занято', y: busy_areas_atnow, legendText: ''}
|
526
|
+
# Rails.logger.debug "<_parse_for_js_radial_graph> res: #{res}"
|
527
|
+
res
|
528
|
+
|
529
|
+
end
|
520
530
|
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
531
|
+
def self._parse_for_js_radial_graph_sq(free_areas_atnow_sq, busy_areas_atnow_sq)
|
532
|
+
# data:
|
533
|
+
# [
|
534
|
+
# { y: 6, legendText:"", label: "Метров свободно" },
|
535
|
+
# { y: 4, legendText:"", label: "Метров занято" }
|
536
|
+
# ]
|
537
|
+
|
538
|
+
res = []
|
539
|
+
res << {label: 'Метров свободно', y: free_areas_atnow_sq, legendText: ''}
|
540
|
+
res << {label: 'Метров занято', y: busy_areas_atnow_sq, legendText: ''}
|
525
541
|
res
|
526
542
|
|
527
543
|
end
|
@@ -665,8 +681,10 @@ module C80Estate
|
|
665
681
|
all_props = Property.all
|
666
682
|
all_props.each do |prop|
|
667
683
|
ppstats = pstats.where(:property_id => prop.id).ordered_by_created_at.last
|
668
|
-
|
669
|
-
|
684
|
+
if ppstats.present?
|
685
|
+
sum_free_areas += ppstats.free_areas
|
686
|
+
sum_busy_areas += ppstats.busy_areas
|
687
|
+
end
|
670
688
|
end
|
671
689
|
{
|
672
690
|
sum_free_areas:sum_free_areas,
|