package com.rongwei.bsserver.controller;


import com.rongwei.bscommon.sys.service.ApsReportRecordsService;
import com.rongwei.bsentity.vo.SaveReportReq;
import com.rongwei.bsentity.vo.StartRePortReq;
import com.rongwei.rwcommon.base.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 作业报工记录 前端控制器
 * </p>
 *
 * @author sc
 * @since 2024-03-28
 */
@Slf4j
@RestController
@RequestMapping("/apsReportRecord")
public class ApsReportRecordController {
    @Autowired
    private ApsReportRecordsService apsReportRecordsService;

    /**
     *  取消报工
     * @param req
     * @return
     */
    @PostMapping("/cancelRecord")
    public R cancelRecord(@RequestBody Map<String, String> req) {
        try {
            log.info("取消报工;参数为：{}", req);
            return apsReportRecordsService.cancelRecord(req);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error("取消报工错误");
        }
    }

    /**
     * 开工
     */
    @PostMapping("/startReport")
    public R startReport(@RequestBody StartRePortReq req){
        return apsReportRecordsService.startReport(req);
    }

    /**
     * 报工保存
     */
    @PostMapping("/saveReport")
    public R saveReport(@RequestBody SaveReportReq req){
        return apsReportRecordsService.saveReport(req);
    }
}

