package com.rongwei.bsserver.controller;


import com.rongwei.bscommon.sys.service.ApsCraftRouteService;
import com.rongwei.bscommon.sys.service.ApsCraftStepService;
import com.rongwei.bsentity.vo.UpdateApsRouteAboutVo;
import com.rongwei.rwcommon.base.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author xh
 * @since 2024-03-13
 */
@RestController
@RequestMapping("/route")
public class ApsRouteController {

    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());

    @Autowired
    private ApsCraftStepService apsCraftStepService;

    @Autowired
    private ApsCraftRouteService apsCraftRouteService;

    @PostMapping("/update/about/data")
    public R update(@RequestBody List<UpdateApsRouteAboutVo> updateApsRouteAboutVos,
                    @RequestParam(name = "routeId",required = true)String routeId) {
        apsCraftStepService.updateApsRouteAboutVos(updateApsRouteAboutVos, routeId);
        return R.ok();
    }

    /*
    复制工艺路线
     */
    @PostMapping("/copyCraftRoute")
    public R copyCraftRoute(@RequestBody Map<String, Object> params) {
        try {
            log.info("复制工艺路线;参数为：{}", params);
            return apsCraftRouteService.copyCraftRoute(params);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error("复制工艺路线失败");
        }
    }
}

