jiangping
2024-09-14 ccc10c31c93733544212e88bc880744a0595f0d7
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/WmsPushCloudController.java
@@ -1,5 +1,6 @@
package com.doumee.cloud.admin;
import com.alibaba.cloud.commons.io.IOUtils;
import com.alibaba.fastjson.JSONObject;
import com.doumee.api.BaseController;
import com.doumee.config.annotation.LoginNoRequired;
@@ -15,12 +16,18 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
/**
@@ -30,119 +37,68 @@
@Api(tags = "WMS平台数据推送接口")
@RestController
@Slf4j
@LoginNoRequired
@RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/wms")
public class WmsPushCloudController extends BaseController {
    @Autowired
    private WmsService wmsService;
    @PreventRepeat
    @ApiOperation("【CMS】推送入库单通知任务")
    @ApiOperation("【WMS】推送入库单通知任务")
    @PostMapping("/push/inboundNotice")
    public WmsBaseResponse inboundNotice(@RequestBody WmsBaseRequest<WmsInboundNoticeRequest> param) {
        int success = Constants.ZERO;
        WmsBaseResponse result =null;
        try {
            result = wmsService.inboundNotice(param);
        }catch (BusinessException e){
            log.error("【CMS】推送入库单通知任务===失败:"+e.getMessage());
            success = Constants.ONE;
        }catch (Exception e){
            log.error("【CMS】推送入库单通知任务===失败:"+e.getMessage());
            e.printStackTrace();
            success = Constants.ONE;
        }finally {
            wmsService.saveInterfaceLog("/wms/push/inboundNotice", "推送入库单通知任务",JSONObject.toJSONString(param),
                    success, JSONObject.toJSONString(result),Constants.ONE);
    @LoginNoRequired
    public WmsBaseResponse inboundNotice(HttpServletRequest request, HttpServletResponse response)   {
        doPringParam(request,"【WMS】推送入库单通知任务");
        return new WmsBaseResponse();
        }
        return result;
    }
    @PreventRepeat
    @ApiOperation("【CMS】推送出库单通知任务")
    @ApiOperation("【WMS】推送出库单通知任务")
    @LoginNoRequired
    @PostMapping("/push/outboundNotice")
    public WmsBaseResponse outboundNotice(@RequestBody WmsBaseRequest<WmsOutboundNoticeRequest> param) {
        int success = Constants.ZERO;
        WmsBaseResponse result =null;
        try {
            result = wmsService.outboundNotice(param);
        }catch (BusinessException e){
            log.error("【CMS】推送出库单通知任务===失败:"+e.getMessage());
            success = Constants.ONE;
        }catch (Exception e){
            log.error("【CMS】推送出库单通知任务===失败:"+e.getMessage());
            e.printStackTrace();
            success = Constants.ONE;
        }finally {
            wmsService.saveInterfaceLog("/wms/push/outboundNotice", "推送出库单通知任务",JSONObject.toJSONString(param),success
                    , JSONObject.toJSONString(result),Constants.ONE);
    public WmsBaseResponse outboundNotice(HttpServletRequest request, HttpServletResponse response)   {
        doPringParam(request,"【WMS】推送出库单通知任务");
        return new WmsBaseResponse();
    }
    @ApiOperation("【WMS】推送取消入库单通知任务")
    @LoginNoRequired
    @PostMapping("/push/cancelInbound")
    public WmsBaseResponse cancelInbound(HttpServletRequest request, HttpServletResponse response)   {
        doPringParam(request,"【WMS】推送取消入库单通知任务");
        return new WmsBaseResponse();
    }
    @ApiOperation("【WMS】推送取消出库单通知任务")
    @LoginNoRequired
    @PostMapping("/push/cancelOutbound")
    public WmsBaseResponse cancelOutbound(HttpServletRequest request, HttpServletResponse response)   {
        doPringParam(request,"【WMS】推送取消出库单通知任务");
        return new WmsBaseResponse();
        }
        return result;
    }
    @PreventRepeat
    @ApiOperation("【CMS】推送取消入库单通知任务")
    @PostMapping("/push/cancelInbound")
    public WmsBaseResponse cancelInbound(@RequestBody WmsBaseRequest<WmsActionNoticeRequest> param) {
        int success = Constants.ZERO;
        WmsBaseResponse result =null;
        try {
            result = wmsService.cancelInbound(param);
        }catch (BusinessException e){
            log.error("【CMS】推送取消入库单通知任务===失败:"+e.getMessage());
            success = Constants.ONE;
        }catch (Exception e){
            log.error("【CMS】推送取消入库单通知任务===失败:"+e.getMessage());
            e.printStackTrace();
            success = Constants.ONE;
        }finally {
            wmsService.saveInterfaceLog("/wms/push/cancelInbound", "推送取消入库单通知任务",JSONObject.toJSONString(param),
                    success, JSONObject.toJSONString(result),Constants.ONE);
        }
        return result;
    }
    @PreventRepeat
    @ApiOperation("【CMS】推送取消出库单通知任务")
    @PostMapping("/push/cancelOutbound")
    public WmsBaseResponse cancelOutbound(@RequestBody WmsBaseRequest<WmsActionNoticeRequest> param) {
        int success = Constants.ZERO;
        WmsBaseResponse result =null;
        try {
            result = wmsService.cancelOutbound(param);
        }catch (BusinessException e){
            log.error("【CMS】推送取消出库单通知任务===失败:"+e.getMessage());
            success = Constants.ONE;
        }catch (Exception e){
            log.error("【CMS】推送取消出库单通知任务===失败:"+e.getMessage());
            e.printStackTrace();
            success = Constants.ONE;
        }finally {
            wmsService.saveInterfaceLog("/wms/push/cancelOutbound", "推送取消出库单通知任务",
                    JSONObject.toJSONString(param),  success, JSONObject.toJSONString(result),Constants.ONE);
        }
        return result;
    }
    @PreventRepeat
    @ApiOperation("【CMS】推送出入库作业完成通知任务")
    @ApiOperation("【WMS】推送出入库作业完成通知任务")
    @LoginNoRequired
    @PostMapping("/push/doneTask")
    public WmsBaseResponse doneTask(@RequestBody WmsBaseRequest<WmsActionNoticeRequest> param) {
        int success = Constants.ZERO;
        WmsBaseResponse result =null;
    public WmsBaseResponse doneTask(HttpServletRequest request, HttpServletResponse response)   {
        doPringParam(request,"【WMS】推送出入库作业完成通知任务");
        return new WmsBaseResponse();
    }
    private void doPringParam(HttpServletRequest request,String name) {
        try {
            result = wmsService.doneTask(param);
        }catch (BusinessException e){
            log.error("【CMS】推送出入库作业完成通知任务===失败:"+e.getMessage());
            success = Constants.ONE;
            StringBuilder data =new StringBuilder();
            String line;
            BufferedReader reader =request.getReader();
            while(null !=(line = reader.readLine())) {
                data.append(line);
            }
            if(StringUtils.isNotBlank( data.toString())){
                log.info(name+"=================参数:"+ data.toString());
            }else {
                log.info(name+"=================:参数为空");
            }
        }catch (Exception e){
            log.error("【CMS】推送出入库作业完成通知任务===失败:"+e.getMessage());
            e.printStackTrace();
            success = Constants.ONE;
        }finally {
            wmsService.saveInterfaceLog("/wms/push/doneTask", "推送出入库作业完成通知任务",JSONObject.toJSONString(param),
                    success, JSONObject.toJSONString(result),Constants.ONE);
            log.info(name+"================= 参数异常:"+e.getMessage());
        }
        return result;
    }
}