package com.foreverwin.mesnac.anomaly.controller;

/**
 * @Description TODO
 * @Author zhaojiawei
 * @Since 2021-08-23
 */

import com.foreverwin.mesnac.anomaly.dto.PartsManufacturing;
import com.foreverwin.mesnac.anomaly.service.ReportService;
import com.foreverwin.mesnac.integration.model.IntegrationLog;
import com.foreverwin.modular.core.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/REPORT")
public class ReportController {

    @Autowired
    public ReportService reportService;

    @PostMapping("/findIntegrationLog")
    public R findIntegrationLog(@RequestBody IntegrationLog integration){
        try{
            return R.ok(reportService.findIntegrationLog(integration));
        }catch(Exception e){
            return R.failed(e.getMessage());
        }
    }

    @PostMapping("/partsManufacturing")
    public R partsManufacturing(@RequestBody PartsManufacturing PartsManufacturing){
        try{
            return R.ok(reportService.partsManufacturing(PartsManufacturing));
        }catch(Exception e){
            return R.failed(e.getMessage());
        }
    }

    @GetMapping("/surplusReturnTable")
    public R surplusReturnTable(String item,String itemDescription){
        try{
            return  R.ok(reportService.surplusReturnTable(item,itemDescription));
        }catch(Exception e){
            return R.failed(e.getMessage());
        }
    }

    /**
     * 设备维修记录报表
     * @param map
     * @return
     */
    @PostMapping("/resourceRepair")
    public R resourceRepair(@RequestBody(required = false)Map<String, Object> map){
        try{
            return R.ok(reportService.resourceRepair(map));
        }catch (Exception e){
            return R.failed(e.getMessage());
        }
    }
}
