package com.steerinfo.dil.controller;


import com.steerinfo.dil.mapper.BackgroundProcessingMapper;
import com.steerinfo.dil.service.impl.BackgroundProcessingServiceImpl;
import com.steerinfo.dil.util.BaseRESTfulController;
import com.steerinfo.framework.controller.RESTfulResult;
import io.swagger.annotations.ApiOperation;
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.List;
import java.util.Map;

/*
 * 后台处理程序
 */

@RestController
@RequestMapping("${api.version}/bp")
public class BackgroundProcessingController extends BaseRESTfulController {

    @Autowired
    private BackgroundProcessingMapper backgroundProcessingMapper;

    @Autowired
    private BackgroundProcessingServiceImpl backgroundProcessingService;


    @ApiOperation(value = "关闭一车多趟方法")
    @PostMapping("/closePurOrderMoreTrips")
    public RESTfulResult closePurOrderMoreTrips(String purchaseOrderNo) {
        int i = backgroundProcessingMapper.closePurOrderMoreTrips(purchaseOrderNo);
        if(i != 1){
            return failed("关闭失败!没有此采购订单");
        }
        return success("关闭成功");
    }

    @ApiOperation(value = "更改所属厂区方法")
    @PostMapping("/updatePurOrgId")
    public RESTfulResult updatePurOrgId(@RequestBody(required = false) Map<String, Object> map){
        return success(backgroundProcessingService.updatePurOrgId(map));
    }

    @ApiOperation(value = "删除没用的表实绩 ")
    @PostMapping("/deleteErrorResult")
    public RESTfulResult deleteErrorResult(String orderNumber){
        return success(backgroundProcessingService.deleteErrorResult(orderNumber));
    }
}