ICSReceiptApi.java 8.9 KB
package com.huaheng.api.U8.controller;

import com.huaheng.common.constant.QuantityConstant;
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.config.documentWarning.service.IDocumentWarningService;
import com.huaheng.pc.u8.domain.ICSReceiptDetail;
import com.huaheng.pc.u8.domain.ICSReceiptHeader;
import com.huaheng.pc.u8.domain.ICSReceiptModel;
import com.huaheng.pc.u8.service.ICSReceiptAPIService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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


/**
 * u8-wms入库下发或回传接口
 *
 * @author huaheng
 * @date 2019-1-4
 */
@RestController
@RequestMapping("/api/icsReceipt1")
@Api(tags = {"icsReceipt"}, description = "ICS入库下发或回传接口")
public class ICSReceiptApi extends BaseController {

    @Autowired
    private ICSReceiptAPIService icsReceiptAPIService;
    @Resource
    private IDocumentWarningService documentWarningService;

    @Log(title = "采购订单", action = BusinessType.INSERT)
    @PostMapping("/GetICSPO_PO")
    @ApiOperation("ICS采购订单接口")
    @ResponseBody
    @ApiLogger(apiName = "ICS采购订单接口", from = "U8")
    public AjaxResult procureReceipt(@RequestBody ICSReceiptModel icsReceiptModel) {

        ICSReceiptHeader icsReceiptHeader = icsReceiptModel.getIcsReceiptHeader();
//        String wareHouseCode = icsReceiptHeader.getCWarehouseCode();
//        if(wareHouseCode!=null && !"".equals(wareHouseCode)){
//            return AjaxResult.error("入库单头信息仓库编码不能为空");
//        }
        List<ICSReceiptDetail> icsReceiptDetails = icsReceiptModel.getIcsReceiptDetails();

        if (icsReceiptHeader == null) {
//            documentWarningService.ErpSendWarning("","采购订单缺少主单据");
            return AjaxResult.error("缺少主单据");
        }
        if (icsReceiptDetails == null) {
//            documentWarningService.ErpSendWarning(icsReceiptHeader.getCCode(),"采购订单缺少子单据");
            return AjaxResult.error("缺少子单据");
        }
        icsReceiptHeader.setType("PCI");

        AjaxResult result = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = icsReceiptAPIService.procureReceipt(icsReceiptModel);
                return ajaxResult;
            }
        });
        return result;
    }

    @Log(title = "材料出库单(红字)", action = BusinessType.INSERT)
    @PostMapping("/GetICSRdRecord_11_Return")
    @ApiOperation("ICS材料出库单(红字)下发接口")
    @ResponseBody
    @ApiLogger(apiName = "ICS材料出库单(红字)下发接口", from = "U8")
    public AjaxResult GetICSRdRecord_11_Return(@RequestBody ICSReceiptModel icsReceiptModel) {
        ICSReceiptHeader icsReceiptHeader = icsReceiptModel.getIcsReceiptHeader();
        List<ICSReceiptDetail> icsReceiptDetails = icsReceiptModel.getIcsReceiptDetails();

        if (icsReceiptHeader == null) {
//            documentWarningService.ErpSendWarning("","材料出库单(红字)缺少主单据");
            return AjaxResult.error("缺少主单据");
        }
        if (icsReceiptDetails == null) {
//            documentWarningService.ErpSendWarning(icsReceiptHeader.getCCode(),"材料出库单(红字)缺少子单据");
            return AjaxResult.error("缺少子单据");
        }
        icsReceiptHeader.setType("CI");
        AjaxResult ajaxResult = icsReceiptAPIService.procureReceipt(icsReceiptModel);
        if (ajaxResult.hasErr()) {
            ajaxResult = AjaxResult.success(ajaxResult.getMsg());
        }
        return ajaxResult;
    }


    @Log(title = "采购到货单下发", action = BusinessType.INSERT)
    @PostMapping("/GetICSPU_ArrivalVouch")
    @ApiOperation("ICS采购到货单下发接口")
    @ResponseBody
    @ApiLogger(apiName = "ICS采购到货单下发接口", from = "U8")
    public AjaxResult procureArrive(@RequestBody ICSReceiptModel icsReceiptModel) throws ParseException {
        ICSReceiptHeader icsReceiptHeader = icsReceiptModel.getIcsReceiptHeader();
        List<ICSReceiptDetail> icsReceiptDetails = icsReceiptModel.getIcsReceiptDetails();
        if (icsReceiptHeader == null) {
//            documentWarningService.ErpSendWarning("","采购到货单缺少主单据");
            return AjaxResult.error("缺少主单据");
        }
        if (icsReceiptDetails == null) {
//            documentWarningService.ErpSendWarning(icsReceiptHeader.getCCode(),"采购到货单缺少子单据");
            return AjaxResult.error("缺少子单据");
        }
        icsReceiptHeader.setType(QuantityConstant.U8_RECEIPT_TYPE_PI);
        AjaxResult result = handleMultiProcessV1("GetICSPU_ArrivalVouch", new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = icsReceiptAPIService.procureArrive(icsReceiptModel);
                return ajaxResult;
            }
        });
        if (result.hasErr()) {
            result = AjaxResult.success(result.getMsg());
        }
        return result;
    }

    @Log(title = "销售退货入库单", action = BusinessType.INSERT)
    @PostMapping("/GetICSDispatchList_Return")
    @ApiOperation("ICS销售退货入库单下发接口")
    @ResponseBody
    @ApiLogger(apiName = "ICS销售退货入库单下发接口", from = "U8")
    public AjaxResult GetICSDispatchList_Return(@RequestBody ICSReceiptModel icsReceiptModel) {
        ICSReceiptHeader icsReceiptHeader = icsReceiptModel.getIcsReceiptHeader();
        List<ICSReceiptDetail> icsReceiptDetails = icsReceiptModel.getIcsReceiptDetails();
        if (icsReceiptHeader == null) {
//            documentWarningService.ErpSendWarning("","销售退货入库单缺少主单据");
            return AjaxResult.error("缺少主单据");
        }
        if (icsReceiptDetails == null) {
//            documentWarningService.ErpSendWarning(icsReceiptHeader.getCCode(),"销售退货入库单缺少子单据");
            return AjaxResult.error("缺少子单据");
        }
        icsReceiptHeader.setType("SRI");
        AjaxResult ajaxResult = icsReceiptAPIService.procureArrive(icsReceiptModel);
        return ajaxResult;
    }

    @Log(title = "其他入库单", action = BusinessType.INSERT)
    @PostMapping("/GetICSRdRecord_08")
    @ApiOperation("ICS其他入库单下发接口")
    @ResponseBody
    @ApiLogger(apiName = "ICS其他入库单下发接口",from = "U8")
    public AjaxResult GetICSRdRecord_08(@RequestBody ICSReceiptModel icsReceiptModel) throws ParseException {
        ICSReceiptHeader icsReceiptHeader=icsReceiptModel.getIcsReceiptHeader();
        List<ICSReceiptDetail> icsReceiptDetails = icsReceiptModel.getIcsReceiptDetails();
        if(icsReceiptHeader==null ){
            documentWarningService.ErpSendWarning("","其他入库单缺少主单据");
            return AjaxResult.error("缺少主单据");
        }
        if(icsReceiptDetails==null){
            documentWarningService.ErpSendWarning(icsReceiptHeader.getCCode(),"其他入库单缺少子单据");
            return AjaxResult.error("缺少子单据");
        }
        icsReceiptHeader.setType("QI");
        AjaxResult ajaxResult = handleMultiProcessV1("GetICSRdRecord_08", new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = icsReceiptAPIService.otherReceipt(icsReceiptModel);
                return ajaxResult;
            }
        });
        if(ajaxResult!=null&&ajaxResult.hasErr()){
            ajaxResult = AjaxResult.success(ajaxResult.getMsg());
        }
        return ajaxResult;
//        return AjaxResult.error("失败");
    }

    @Log(title = "调拨入库单", action = BusinessType.INSERT)
    @PostMapping("/TransVouch")
    @ApiOperation("ICS调拨入库单下发接口")
    @ResponseBody
    @ApiLogger(from = "U8", apiName = "ICS调拨入库单下发接口")
    public AjaxResult TransVouch(@RequestBody ICSReceiptModel icsReceiptModel) throws ParseException {
        ICSReceiptHeader icsReceiptHeader=icsReceiptModel.getIcsReceiptHeader();
        List<ICSReceiptDetail> icsReceiptDetails = icsReceiptModel.getIcsReceiptDetails();
        if(icsReceiptHeader==null ){
            return AjaxResult.error("缺少主单据");
        }
        if(icsReceiptDetails==null){
            return AjaxResult.error("缺少子单据");
        }
        icsReceiptHeader.setType("TI");
        AjaxResult ajaxResult = icsReceiptAPIService.otherReceipt(icsReceiptModel);
        return ajaxResult;
    }
}