ICSShipmentApi.java 9.24 KB
package com.huaheng.api.U8.controller;

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.ICSShipmentDetail;
import com.huaheng.pc.u8.domain.ICSShipmentHeader;
import com.huaheng.pc.u8.domain.ICSShipmentModel;
import com.huaheng.pc.u8.service.ICSShipmentApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

/**
 * u8-wms出库下发或回传接口
 */
@RestController
@RequestMapping("/api/icsShipment1")
@Api(tags = {"icsShipment"}, description = "ICS出库下发或回传接口")
public class ICSShipmentApi extends BaseController {

    @Resource
    private ICSShipmentApiService icsShipmentApiService;

    @Resource
    private IDocumentWarningService documentWarningService;

    //出库下发
    @Log(title = "采购退货单出库下发", action = BusinessType.INSERT)
    @PostMapping("/GetICSPU_ArrivalVouch_Return")
    @ApiOperation("ICS采购退货单出库下发接口")
    @ResponseBody
    @ApiLogger(apiName = "ICS采购退货单出库下发接口", from = "U8")
    public AjaxResult GetICSPU_ArrivalVouch_Return(@RequestBody ICSShipmentModel icsShipmentModel) {
        ICSShipmentHeader icsShipmentHeader = icsShipmentModel.getIcsShipmentHeader();
        List<ICSShipmentDetail> icsShipmentDetails = icsShipmentModel.getIcsShipmentDetails();
        if (icsShipmentHeader == null) {
//            documentWarningService.ErpSendWarning("","采购退货单缺少主单据");
            return AjaxResult.error("缺少主单据");
        }
        if (icsShipmentDetails == null) {
//            documentWarningService.ErpSendWarning(icsShipmentHeader.getCCode(),"采购退货单缺少子单据");
            return AjaxResult.error("缺少子单据");
        }
        icsShipmentHeader.setType("PRO");
        AjaxResult result = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = icsShipmentApiService.saleShipmentOrPurchReturn(icsShipmentModel);
                return ajaxResult;
            }
        });
        return result;
    }

    @Log(title = "销售发货单出库下发", action = BusinessType.INSERT)
    @PostMapping("/GetICSDispatchList")
    @ApiOperation("ICS销售发货单出库下发接口")
    @ResponseBody
    @ApiLogger(apiName = "ICS销售发货单出库下发接口", from = "U8")
    public AjaxResult saleShipment(@RequestBody ICSShipmentModel icsShipmentModel) {
        ICSShipmentHeader icsShipmentHeader = icsShipmentModel.getIcsShipmentHeader();
        List<ICSShipmentDetail> icsShipmentDetails = icsShipmentModel.getIcsShipmentDetails();
        if (icsShipmentHeader == null) {
//            documentWarningService.ErpSendWarning("","销售发货单缺少主单据");
            return AjaxResult.error("缺少主单据");
        }
        if (icsShipmentDetails == null) {
//            documentWarningService.ErpSendWarning(icsShipmentHeader.getCDLCode(),"销售发货单缺少子单据");
            return AjaxResult.error("缺少子单据");
        }
        icsShipmentHeader.setType("SO");
        AjaxResult result = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = icsShipmentApiService.saleShipmentOrPurchReturn(icsShipmentModel);
                return ajaxResult;
            }
        });
        if (result != null && result.hasErr()) {
            return AjaxResult.success(result.getMsg());
        }
        return result;
    }


    @Log(title = "领料申请单出库下发", action = BusinessType.INSERT)
    @PostMapping("/GetICSMaterialAppVouch")
    @ApiOperation("ICS领料申请单出库下发接口")
    @ResponseBody
    @ApiLogger(apiName = "ICS领料申请单出库下发接口", from = "U8")
    public AjaxResult GetICSMaterialAppVouch(@RequestBody ICSShipmentModel icsShipmentModel) {
        ICSShipmentHeader icsShipmentHeader = icsShipmentModel.getIcsShipmentHeader();
        List<ICSShipmentDetail> icsShipmentDetails = icsShipmentModel.getIcsShipmentDetails();
        if (icsShipmentHeader == null) {
            return AjaxResult.error("缺少主单据");
        }
        if (icsShipmentDetails == null) {
            return AjaxResult.error("缺少子单据");
        }
        icsShipmentHeader.setType("PKO");
        return AjaxResult.success("成功");
    }

    @Log(title = "材料出库单出库下发", action = BusinessType.INSERT)
    @PostMapping("/GetICSRdRecord_11")
    @ApiOperation("ICS材料出库单出库下发接口")
    @ResponseBody
    @ApiLogger(apiName = "ICS材料出库单出库下发接口", from = "U8")
    public AjaxResult GetICSRdRecord_11(@RequestBody ICSShipmentModel icsShipmentModel) {
        ICSShipmentHeader icsShipmentHeader = icsShipmentModel.getIcsShipmentHeader();
        List<ICSShipmentDetail> icsShipmentDetails = icsShipmentModel.getIcsShipmentDetails();
        if (icsShipmentHeader == null) {
//            documentWarningService.ErpSendWarning("","材料出库单缺少主单据");
            return AjaxResult.error("缺少主单据");
        }
        if (icsShipmentDetails == null) {
//            documentWarningService.ErpSendWarning(icsShipmentHeader.getCCode(),"材料出库单缺少子单据");
            return AjaxResult.error("缺少子单据");
        }
        icsShipmentHeader.setType("MO");
        AjaxResult ajaxResult = icsShipmentApiService.procureShipment(icsShipmentModel);
        if (ajaxResult.hasErr()) {
            ajaxResult = AjaxResult.success(ajaxResult.getMsg());
        }
        return ajaxResult;
    }

    @Log(title = "生产订单出库下发", action = BusinessType.INSERT)
    @PostMapping("/GetICSmom_order")
    @ApiOperation("ICS生产订单出库下发接口")
    @ResponseBody
    @ApiLogger(apiName = "ICS生产订单出库下发接口", from = "U8")
    public AjaxResult GetICSmom_order(@RequestBody ICSShipmentModel icsShipmentModel) {
        ICSShipmentHeader icsShipmentHeader = icsShipmentModel.getIcsShipmentHeader();
        List<ICSShipmentDetail> icsShipmentDetails = icsShipmentModel.getIcsShipmentDetails();
        if (icsShipmentHeader == null) {
//            documentWarningService.ErpSendWarning("","生产订单缺少主单据");
            return AjaxResult.error("缺少主单据");
        }
        if (icsShipmentDetails == null) {
//            documentWarningService.ErpSendWarning(icsShipmentHeader.getCCode(),"生产订单缺少主单据");
            return AjaxResult.error("缺少子单据");
        }
        icsShipmentHeader.setType("OO");
        AjaxResult ajaxResult = icsShipmentApiService.procureShipment(icsShipmentModel);
        return ajaxResult;
    }

    @Log(title = "调拨单出库下发", action = BusinessType.INSERT)
    @PostMapping("/TransVouch")
    @ApiOperation("ICS调拨单出库下发接口")
    @ResponseBody
    @ApiLogger(from = "U8", apiName = "ICS调拨单出库下发接口")
    public AjaxResult TransVouch(@RequestBody ICSShipmentModel icsShipmentModel) throws ParseException {
        ICSShipmentHeader icsShipmentHeader=icsShipmentModel.getIcsShipmentHeader();
        List<ICSShipmentDetail> icsShipmentDetails=icsShipmentModel.getIcsShipmentDetails();
        if(icsShipmentHeader==null ){
            return AjaxResult.error("缺少主单据");
        }
        if(icsShipmentDetails==null){
            return AjaxResult.error("缺少子单据");
        }
        icsShipmentHeader.setType("TO");
        AjaxResult ajaxResult = icsShipmentApiService.otherShipment(icsShipmentModel);
        return ajaxResult;
    }

    @Log(title = "其他出库单出库下发", action = BusinessType.INSERT)
    @PostMapping("/GetICSRdRecord_09")
    @ApiOperation("ICS其他出库单出库下发接口")
    @ResponseBody
    @ApiLogger(from = "U8", apiName = "ICS其他出库单出库下发接口")
    public AjaxResult GetICSRdRecord_09(@RequestBody ICSShipmentModel icsShipmentModel) throws ParseException {
        ICSShipmentHeader icsShipmentHeader=icsShipmentModel.getIcsShipmentHeader();
        List<ICSShipmentDetail> icsShipmentDetails=icsShipmentModel.getIcsShipmentDetails();
        if(icsShipmentHeader==null ){
            return AjaxResult.error("缺少主单据");
        }
        if(icsShipmentDetails==null){
            return AjaxResult.error("缺少子单据");
        }
        icsShipmentHeader.setType("QO");
        AjaxResult ajaxResult = handleMultiProcessV1("GetICSRdRecord_09", new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = icsShipmentApiService.otherShipment(icsShipmentModel);
                return ajaxResult;
            }
        });
        if (ajaxResult.hasErr()) {
            ajaxResult = AjaxResult.success(ajaxResult.getMsg());
        }
        return ajaxResult;
    }

}