ReceiptApiController.java 2.93 KB
package com.huaheng.api.general.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.huaheng.api.general.domain.Receipt;
import com.huaheng.api.general.domain.ReceiptDomain;
import com.huaheng.api.general.service.ReceiptApiService;
import com.huaheng.api.general.service.ReceiptService;
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.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/receiptApi")
@Api(tags = {"入库单接口"}, value = "入库单接口receipt")
public class ReceiptApiController {

    @Resource
    private ReceiptApiService receiptApiService;

    /**
     * 同步入库单
     */
    @Log(title = "入库单添加", action = BusinessType.INSERT)
    @PostMapping("/receipt")
    @ApiOperation("入库单添加公共接口")
    @ApiLogger(apiName = "添加入库单", from="MES")
    public AjaxResult receipt(@RequestBody ReceiptDomain receiptDomain) {
        return receiptApiService.receipt(receiptDomain);
    }

    /**
     * 取消入库单
     */
    @Log(title = "入库-入库单 ", operating = "删除入库单", action = BusinessType.UPDATE)
    @PostMapping("/delete")
    @ApiLogger(apiName = "删除入库单", from = "ERP")
    public AjaxResult delete(@RequestBody List<String> referCodeList) {
        if (referCodeList == null || referCodeList.isEmpty()) {
            return AjaxResult.error("单号列表为空");
        }
        return receiptApiService.delete(referCodeList);
    }

    /**
     * 取消入库单
     */
    @Log(title = "入库-入库单 ", operating = "入库单删除", action = BusinessType.UPDATE)
    @PostMapping("/remove")
    @ApiLogger(apiName = "取消入库单", from = "ERP")
    public AjaxResult remove(@RequestBody List<String> receiptCodeList) {
        if (receiptCodeList == null && receiptCodeList.isEmpty()) {
            return AjaxResult.error("单号列表为空");
        }
        return receiptApiService.remove(receiptCodeList);
    }

    /**
     * 入库单查询
     */
    @Log(title = "入库-入库单 ", operating = "入库单删除", action = BusinessType.UPDATE)
    @GetMapping("/search")
    @ApiLogger(apiName = "查询入库单", from = "ERP")
    public AjaxResult search(@RequestParam String receiptCode,
                             @RequestParam String companyCode,
                             @RequestParam String warehouseCode) {
        return receiptApiService.search(receiptCode, companyCode, warehouseCode);
    }
}