| @@ 166-251 (lines=86) @@ | ||
| 163 | if "values" not in report['reporting_period'].keys() or len(report['reporting_period']['values']) == 0: |
|
| 164 | has_cost_data_flag = False |
|
| 165 | ||
| 166 | if has_cost_data_flag: |
|
| 167 | ws['B6'].font = title_font |
|
| 168 | ws['B6'] = name + '报告期成本' |
|
| 169 | ||
| 170 | reporting_period_data = report['reporting_period'] |
|
| 171 | category = report['offline_meter']['energy_category_name'] |
|
| 172 | ca_len = len(category) |
|
| 173 | ||
| 174 | ws['B7'].fill = table_fill |
|
| 175 | ||
| 176 | ws['B8'].font = title_font |
|
| 177 | ws['B8'].alignment = c_c_alignment |
|
| 178 | ws['B8'] = '成本' |
|
| 179 | ws['B8'].border = f_border |
|
| 180 | ||
| 181 | ws['B9'].font = title_font |
|
| 182 | ws['B9'].alignment = c_c_alignment |
|
| 183 | ws['B9'] = '环比' |
|
| 184 | ws['B9'].border = f_border |
|
| 185 | ||
| 186 | col = 'B' |
|
| 187 | ||
| 188 | for i in range(0, ca_len): |
|
| 189 | col = chr(ord('C')+i) |
|
| 190 | ||
| 191 | ws[col + '7'].fill = table_fill |
|
| 192 | ws[col + '7'].font = name_font |
|
| 193 | ws[col + '7'].alignment = c_c_alignment |
|
| 194 | ws[col + '7'] = report['offline_meter']['energy_category_name'] + \ |
|
| 195 | " (" + report['offline_meter']['unit_of_measure'] + ")" |
|
| 196 | ws[col + '7'].border = f_border |
|
| 197 | ||
| 198 | ws[col + '8'].font = name_font |
|
| 199 | ws[col + '8'].alignment = c_c_alignment |
|
| 200 | ws[col + '8'] = round(reporting_period_data['total_in_category'], 0) |
|
| 201 | ws[col + '8'].border = f_border |
|
| 202 | ||
| 203 | ws[col + '9'].font = name_font |
|
| 204 | ws[col + '9'].alignment = c_c_alignment |
|
| 205 | ws[col + '9'] = str(round(reporting_period_data['increment_rate'] * 100, 2)) + "%" \ |
|
| 206 | if reporting_period_data['increment_rate'] is not None else "-" |
|
| 207 | ws[col + '9'].border = f_border |
|
| 208 | ||
| 209 | # TCE TCO2E |
|
| 210 | end_col = col |
|
| 211 | # TCE |
|
| 212 | tce_col = chr(ord(end_col) + 1) |
|
| 213 | ws[tce_col + '7'].fill = table_fill |
|
| 214 | ws[tce_col + '7'].font = name_font |
|
| 215 | ws[tce_col + '7'].alignment = c_c_alignment |
|
| 216 | ws[tce_col + '7'] = "TCE" |
|
| 217 | ws[tce_col + '7'].border = f_border |
|
| 218 | ||
| 219 | ws[tce_col + '8'].font = name_font |
|
| 220 | ws[tce_col + '8'].alignment = c_c_alignment |
|
| 221 | ws[tce_col + '8'] = round(reporting_period_data['total_in_kgce'], 0) |
|
| 222 | ws[tce_col + '8'].border = f_border |
|
| 223 | ||
| 224 | ws[tce_col + '9'].font = name_font |
|
| 225 | ws[tce_col + '9'].alignment = c_c_alignment |
|
| 226 | ws[tce_col + '9'] = str(round(reporting_period_data['increment_rate'] * 100, 2)) + "%" \ |
|
| 227 | if reporting_period_data['increment_rate'] is not None else "-" |
|
| 228 | ws[tce_col + '9'].border = f_border |
|
| 229 | ||
| 230 | # TCO2E |
|
| 231 | tco2e_col = chr(ord(end_col) + 2) |
|
| 232 | ws[tco2e_col + '7'].fill = table_fill |
|
| 233 | ws[tco2e_col + '7'].font = name_font |
|
| 234 | ws[tco2e_col + '7'].alignment = c_c_alignment |
|
| 235 | ws[tco2e_col + '7'] = "TCO2E" |
|
| 236 | ws[tco2e_col + '7'].border = f_border |
|
| 237 | ||
| 238 | ws[tco2e_col + '8'].font = name_font |
|
| 239 | ws[tco2e_col + '8'].alignment = c_c_alignment |
|
| 240 | ws[tco2e_col + '8'] = round(reporting_period_data['total_in_kgco2e'], 0) |
|
| 241 | ws[tco2e_col + '8'].border = f_border |
|
| 242 | ||
| 243 | ws[tco2e_col + '9'].font = name_font |
|
| 244 | ws[tco2e_col + '9'].alignment = c_c_alignment |
|
| 245 | ws[tco2e_col + '9'] = str(round(reporting_period_data['increment_rate'] * 100, 2)) + "%" \ |
|
| 246 | if reporting_period_data['increment_rate'] is not None else "-" |
|
| 247 | ws[tco2e_col + '9'].border = f_border |
|
| 248 | ||
| 249 | else: |
|
| 250 | for i in range(6, 9+1): |
|
| 251 | ws.rows_dimensions[i].height = 0.1 |
|
| 252 | ||
| 253 | ###################################### |
|
| 254 | ||
| @@ 162-245 (lines=84) @@ | ||
| 159 | if "values" not in report['reporting_period'].keys() or len(report['reporting_period']['values']) == 0: |
|
| 160 | has_energy_data_flag = False |
|
| 161 | ||
| 162 | if has_energy_data_flag: |
|
| 163 | ws['B6'].font = title_font |
|
| 164 | ws['B6'] = name + '能耗分析' |
|
| 165 | ||
| 166 | reporting_period_data = report['reporting_period'] |
|
| 167 | # print(reporting_period_data) |
|
| 168 | category = report['meter']['energy_category_name'] |
|
| 169 | ca_len = len(category) |
|
| 170 | ||
| 171 | ws['B7'].fill = table_fill |
|
| 172 | ||
| 173 | ws['B8'].font = title_font |
|
| 174 | ws['B8'].alignment = c_c_alignment |
|
| 175 | ws['B8'] = '能耗' |
|
| 176 | ws['B8'].border = f_border |
|
| 177 | ||
| 178 | ws['B9'].font = title_font |
|
| 179 | ws['B9'].alignment = c_c_alignment |
|
| 180 | ws['B9'] = '环比' |
|
| 181 | ws['B9'].border = f_border |
|
| 182 | ||
| 183 | for i in range(0, ca_len): |
|
| 184 | col = chr(ord('C') + i) |
|
| 185 | row = '7' |
|
| 186 | cell = col + row |
|
| 187 | ws[col + '7'].fill = table_fill |
|
| 188 | ws[col + '7'].font = name_font |
|
| 189 | ws[col + '7'].alignment = c_c_alignment |
|
| 190 | ws[col + '7'] = report['meter']['energy_category_name'] + " (" + report['meter']['unit_of_measure'] + ")" |
|
| 191 | ws[col + '7'].border = f_border |
|
| 192 | ||
| 193 | ws[col + '8'].font = name_font |
|
| 194 | ws[col + '8'].alignment = c_c_alignment |
|
| 195 | ws[col + '8'] = round(reporting_period_data['total_in_category'], 0) |
|
| 196 | ws[col + '8'].border = f_border |
|
| 197 | ||
| 198 | ws[col + '9'].font = name_font |
|
| 199 | ws[col + '9'].alignment = c_c_alignment |
|
| 200 | ws[col + '9'] = str(round(reporting_period_data['increment_rate'] * 100, 2)) + "%" \ |
|
| 201 | if reporting_period_data['increment_rate'] is not None else "-" |
|
| 202 | ws[col + '9'].border = f_border |
|
| 203 | ||
| 204 | # TCE TCO2E |
|
| 205 | end_col = col |
|
| 206 | # TCE |
|
| 207 | tce_col = chr(ord(end_col) + 1) |
|
| 208 | ws[tce_col + '7'].fill = table_fill |
|
| 209 | ws[tce_col + '7'].font = name_font |
|
| 210 | ws[tce_col + '7'].alignment = c_c_alignment |
|
| 211 | ws[tce_col + '7'] = "TCE" |
|
| 212 | ws[tce_col + '7'].border = f_border |
|
| 213 | ||
| 214 | ws[tce_col + '8'].font = name_font |
|
| 215 | ws[tce_col + '8'].alignment = c_c_alignment |
|
| 216 | ws[tce_col + '8'] = round(reporting_period_data['total_in_category'], 0) |
|
| 217 | ws[tce_col + '8'].border = f_border |
|
| 218 | ||
| 219 | ws[tce_col + '9'].font = name_font |
|
| 220 | ws[tce_col + '9'].alignment = c_c_alignment |
|
| 221 | ws[tce_col + '9'] = str(round(reporting_period_data['increment_rate'] * 100, 2)) + "%" \ |
|
| 222 | if reporting_period_data['increment_rate'] is not None else "-" |
|
| 223 | ws[tce_col + '9'].border = f_border |
|
| 224 | ||
| 225 | # TCO2E |
|
| 226 | tco2e_col = chr(ord(end_col) + 2) |
|
| 227 | ws[tco2e_col + '7'].fill = table_fill |
|
| 228 | ws[tco2e_col + '7'].font = name_font |
|
| 229 | ws[tco2e_col + '7'].alignment = c_c_alignment |
|
| 230 | ws[tco2e_col + '7'] = "TCO2E" |
|
| 231 | ws[tco2e_col + '7'].border = f_border |
|
| 232 | ||
| 233 | ws[tco2e_col + '8'].font = name_font |
|
| 234 | ws[tco2e_col + '8'].alignment = c_c_alignment |
|
| 235 | ws[tco2e_col + '8'] = round(reporting_period_data['total_in_kgco2e'], 0) |
|
| 236 | ws[tco2e_col + '8'].border = f_border |
|
| 237 | ||
| 238 | ws[tco2e_col + '9'].font = name_font |
|
| 239 | ws[tco2e_col + '9'].alignment = c_c_alignment |
|
| 240 | ws[tco2e_col + '9'] = str(round(reporting_period_data['increment_rate'] * 100, 2)) + "%" \ |
|
| 241 | if reporting_period_data['increment_rate'] is not None else "-" |
|
| 242 | ws[tco2e_col + '9'].border = f_border |
|
| 243 | else: |
|
| 244 | for i in range(6, 9 + 1): |
|
| 245 | ws.row_dimensions[i].height = 0.1 |
|
| 246 | ################################################# |
|
| 247 | # Second: 能耗详情 |
|
| 248 | # 11: title |
|