MT2201Controller.java 1.8 KB
package com.sunyo.wlpt.message.builder.controller;

import com.sunyo.wlpt.message.builder.model.CUSTOM_RESPONSE;
import com.sunyo.wlpt.message.builder.util.CustomXmlMaker;
import freemarker.template.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;

@RestController
@RequestMapping("/mt2201")
public class MT2201Controller extends CustomXmlMaker {

    @Autowired
    private Configuration freemakerTemplate;

    private static String businessType = "MT2201";

    /**
     * MAP包含运单实体与舱单实体
     * @param awb_manifest {awb:AWB_AWBINFO,man:}
     * @return
     * @throws Exception
     */
    @RequestMapping("/send")
    public Boolean mt1201New(@RequestBody Map awb_manifest) throws Exception{
        try {
            CUSTOM_RESPONSE response = new CUSTOM_RESPONSE();
            response.setAwbano("17212345678");
            response.setCusfunctioncode("2");

            response.setCusreciverid("4604");
            response.setCusversion("1.2");
            response.setBusdate(new Date());
            response.setBustype(businessType);

            String msgId =  makeMsgID(businessType,"460470678920X","17212345678");
            response.setCusmsgid(msgId);
            response.setCussenderid(makeSenderID("4604","460470678920X"));

            String filename = response.getCusmsgid()+".xml";
            makeXmlToFile("/manifest/MT2201.ftlx",filename,awb_manifest);
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
        return true;
    }
}