SAPApiController.java 2.41 KB
package com.huaheng.api.sap.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.*;

import com.huaheng.api.general.service.ReceiptApiService;
import com.huaheng.api.sap.domain.ZarDomain;
import com.huaheng.api.sap.service.ZarApiService;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.sap.domain.Zarsh;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/api/zarapi")
@Api(tags = {"入库单接口"}, value = "入库单接口receipt")
public class SAPApiController extends BaseController {

    @Resource
    private ReceiptApiService receiptApiService;
    @Resource
    private ZarApiService zarApiService;

    /**
     * SAP下发任务单据
     */
    @Log(title = "SAP下发任务单据", action = BusinessType.INSERT)
    @PostMapping("/save")
    @ApiOperation("SAP下发任务单据")
    @ResponseBody
    @ApiLogger(apiName = "SAP下发任务单据", from = "ERP")
    public AjaxResult save(@RequestBody ZarDomain zarDomain) {
        if (StringUtils.isNull(zarDomain)) {
            throw new ServiceException("参数为空");
        }
        Zarsh zarsh = zarDomain.getZarsh();
        if (zarsh == null) {
            throw new ServiceException("zarsh参数为空");
        }
        if (StringUtils.isEmpty(zarsh.getUniqueId())) {
            throw new ServiceException("唯一号uniqueId参数为空");
        }
        // 判断出库、入库,然后在判断是否空托盘出入库
        if (StringUtils.isEmpty(zarsh.getLgnum())) {
            throw new ServiceException("仓库号为空");
        }
        if (StringUtils.isEmpty(zarsh.getMFlag())) {
            throw new ServiceException("入库出库标志为空");
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = zarApiService.saveSapData(zarDomain);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

}