MT8204Controller.java 4.0 KB
package com.tianbo.analysis.controller;

import com.github.pagehelper.PageInfo;
import com.tianbo.analysis.annotation.UserPermissionCheck;
import com.tianbo.analysis.controller.bean.ResponseReason;

import com.tianbo.analysis.model.MANIFEST_AIR_CHANGE;
import com.tianbo.analysis.model.ResultJson;
import com.tianbo.analysis.service.MT8204Service;

import com.tianbo.util.Date.DateUtil;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

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


import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import java.io.File;

import java.io.IOException;
import java.util.Date;
import java.util.List;


@Slf4j
@RestController
@RequestMapping("/mt8204/")
public class MT8204Controller {

    @Autowired
    MT8204Service mt8204Service;

    @GetMapping("/index")
    public ResultJson index(@RequestParam(value = "page",defaultValue = "1") int page,
                            @RequestParam(value = "limit",defaultValue = "10") int limit,
                            @RequestParam(value = "flightno",required = false) String flightNo,
                            @RequestParam(value = "flightDate",required = false) String flightDate,
                            @RequestParam(value = "waybillnomaster",required = false) String waybillNo){
        MANIFEST_AIR_CHANGE manifest_air_change = new MANIFEST_AIR_CHANGE();
        if(StringUtils.isNotEmpty(flightDate)){
           Date flight_Date = DateUtil.parseDate(flightDate,"yyyyMMdd");
           manifest_air_change.setFlightDate(flight_Date);
        }
        manifest_air_change.setFlightno(flightNo);
        manifest_air_change.setWaybillnomaster(waybillNo);
        PageInfo<MANIFEST_AIR_CHANGE> result =  mt8204Service.selectList(manifest_air_change,page,limit);
        return new ResultJson("200","success",result);
    }

    @ApiOperation(value = "添加直接改配申请接口")
    @PostMapping("add")
    public ResultJson add(@RequestBody  MANIFEST_AIR_CHANGE manifest_air_change){
       return mt8204Service.add(manifest_air_change) ? new ResultJson(ResponseReason.MT8204_SUCCESS) :  new ResultJson(ResponseReason.MT8204_ADD_ERR);
    }

    @ApiOperation(value = "编辑直接改配申请接口")
    @PostMapping("edit")
    public ResultJson edit(@RequestBody  MANIFEST_AIR_CHANGE manifest_air_change){
        manifest_air_change.setChangetime(new Date());
        return mt8204Service.edit(manifest_air_change) ? new ResultJson(ResponseReason.MT8204_SUCCESS) :  new ResultJson(ResponseReason.MT8204_EDIT_ERR);
    }

    @ApiOperation(value = "删除直接改配申请接口")
    @UserPermissionCheck
    @PostMapping("del")
    public ResultJson del(@RequestBody  MANIFEST_AIR_CHANGE manifest_air_change,@CookieValue("username") String username,@CookieValue("userid") String userid){
        manifest_air_change.setChangetime(new Date());
        return mt8204Service.del(manifest_air_change) ? new ResultJson(ResponseReason.MT8204_SUCCESS) :  new ResultJson(ResponseReason.MT8204_DEL_ERR);
    }

    @ApiOperation(value = "发送直接改配申请接口")
    @UserPermissionCheck
    @PostMapping("send")
    public ResultJson send(@RequestBody  MANIFEST_AIR_CHANGE manifest_air_change,@CookieValue("username") String username,@CookieValue("userid") String userid){
        return  mt8204Service.send(manifest_air_change,username) ? new ResultJson(ResponseReason.MT8204_SUCCESS) :  new ResultJson(ResponseReason.MT8204_SEND_ERR);
    }

    @PostMapping("batchSend")
    public ResultJson batchSend(@RequestBody List<String> autoIDlist, @CookieValue("username") String username, @CookieValue("userid") String userid){
        ResultJson resultJson = mt8204Service.batchSend(autoIDlist,username);
        return  resultJson;
//        :  new ResultJson(ResponseReason.MT8204_SEND_ERR);
    }
}