()
return jsonify(d)
查看报告
查看报告
查看报告
def get_report():
    """ 查看报告 """
    data = request.json
    report_id = data.get('reportId')
    state = data.get('state')
    _address = REPORT_ADDRESS + str(report_id) + '.txt'

    if not os.path.exists(_address):
        report_data = Report.query.filter_by(id=report_id).first()
        report_data.read_status = '异常'
        db.session.commit()
        return jsonify({'msg': '报告还未生成、或生成失败', 'status': 0})

    report_data = Report.query.filter_by(id=report_id).first()
    report_data.read_status = '已读'
    db.session.commit()
    with open(_address, 'r') as f:
        d = json.loads(f.read())

    if state == 'success':
        _d = copy.deepcopy(d['details'])
        d['details'].clear()
        for d1 in _d:
            if d1['success']:
                d['details'].append(d1)
    elif state == 'error':
        _d = copy.deepcopy(d['details'])
        d['details'].clear()
        for d1 in _d:
            if not d1['success']:
                d['details'].append(d1)
    return jsonify(d)
def get_report ( ) : data = request . json report_id = data . get ( 'reportId' ) state = data . get ( 'state' ) _address = REPORT_ADDRESS + str ( report_id ) + '.txt' if not os . path . exists ( _address ) : report_data = Report . query . filter_by ( id = report_id ) . first ( ) report_data . read_status = '异常' db . session . commit ( ) return jsonify ( { 'msg' : '报告还未生成、或生成失败', 'status': 0}) report_data = Report . query . filter_by ( id = report_id ) . first ( ) report_data . read_status = '已读' db . session . commit ( ) with open ( _address , 'r' ) as f : d = json . loads ( f . read ( ) ) if state == 'success' : _d = copy . deepcopy ( d [ 'details' ] ) d [ 'details' ] . clear ( ) for d1 in _d : if d1 [ 'success' ] : d [ 'details' ] . append ( d1 ) elif state == 'error' : _d = copy . deepcopy ( d [ 'details' ] ) d [ 'details' ] . clear ( ) for d1 in _d : if not d1 [ 'success' ] : d [ 'details' ] . append ( d1 ) return jsonify ( d )