作者 shenhailong

controller 方法添加 try catch

正在显示 30 个修改的文件 包含 195 行增加94 行删除
... ... @@ -4,6 +4,7 @@ import com.sunyo.wlpt.message.builder.service.MT1201Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@RestController
... ... @@ -27,7 +28,9 @@ public class MT1201Controller {
return mt1201Service.ffmcreate(map);
}catch (Exception e){
e.printStackTrace();
return null;
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
... ... @@ -46,7 +49,9 @@ public class MT1201Controller {
return mt1201Service.editMt1201(map);
}catch (Exception e){
e.printStackTrace();
return null;
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
... ... @@ -60,7 +65,9 @@ public class MT1201Controller {
return mt1201Service.removeMt1201(map);
}catch (Exception e){
e.printStackTrace();
return null;
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
... ...
... ... @@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
@RestController
... ... @@ -24,25 +25,52 @@ public class MT2201Controller {
@PostMapping("/creatMt2201")
@ApiOperation(value = "生成报文")
@ResponseBody
public Map<String, Object> creatMt2201(@RequestBody Map<String, Object> map) throws IOException, ParseException {
public Map<String, Object> creatMt2201(@RequestBody Map<String, Object> map) {
try {
return mt2201Service.creatMt2201(map);
}catch (Exception e){
e.printStackTrace();
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
return mt2201Service.creatMt2201(map);
}
@PutMapping("/editMt2201")
@ApiOperation(value = "修改报文")
@ResponseBody
public Map<String, Object> editMt2201(@RequestBody Map<String, Object> map) throws IOException, ParseException {
public Map<String, Object> editMt2201(@RequestBody Map<String, Object> map) {
try {
return mt2201Service.editMt2201(map);
}catch (Exception e){
e.printStackTrace();
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
return mt2201Service.editMt2201(map);
}
@PutMapping("/removeMt2201")
@ApiOperation(value = "删除报文")
@ResponseBody
public Map<String, Object> removeMt2201(@RequestBody Map<String, Object> map) throws IOException, ParseException {
public Map<String, Object> removeMt2201(@RequestBody Map<String, Object> map) {
try {
return mt2201Service.removeMt2201(map);
}catch (Exception e){
e.printStackTrace();
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
return mt2201Service.removeMt2201(map);
}
}
... ...
... ... @@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@RestController
... ... @@ -25,7 +26,9 @@ public class MT3201Controller {
return mt3201Service.fohcreate(map);
}catch (Exception e){
e.printStackTrace();
return null;
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
... ... @@ -39,7 +42,9 @@ public class MT3201Controller {
return mt3201Service.remove(map);
}catch (Exception e){
e.printStackTrace();
return null;
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
... ...
... ... @@ -4,6 +4,7 @@ import com.sunyo.wlpt.message.builder.service.MT3202Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@RestController
... ... @@ -22,7 +23,9 @@ public class MT3202Controller {
return mt3202Service.createMt3202(map);
}catch (Exception e){
e.printStackTrace();
return null;
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
... ... @@ -36,7 +39,9 @@ public class MT3202Controller {
return mt3202Service.removeMt3202(map);
}catch (Exception e){
e.printStackTrace();
return null;
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
... ...
... ... @@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
... ... @@ -19,19 +20,35 @@ public class MT4201Controller {
@PostMapping("/createMt4201")
@ResponseBody
public Map<String, Object> pffmcreate(@RequestBody Map<String, Object> map) throws IOException, ParseException {
public Map<String, Object> pffmcreate(@RequestBody Map<String, Object> map) {
try {
return mt4201Service.pffmcreate(map);
}catch (Exception e){
e.printStackTrace();
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
return mt4201Service.pffmcreate(map);
}
@PutMapping("/removeMt4201")
@ResponseBody
public Map<String, Object> remove4201(@RequestBody Map<String, Object> map) throws IOException, ParseException {
public Map<String, Object> remove4201(@RequestBody Map<String, Object> map) {
return mt4201Service.remove4201(map);
try {
return mt4201Service.remove4201(map);
}catch (Exception e){
e.printStackTrace();
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
... ...
... ... @@ -4,6 +4,7 @@ import com.sunyo.wlpt.message.builder.service.MT520XService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
... ... @@ -30,7 +31,9 @@ public class MT520XController {
}catch (Exception e){
e.printStackTrace();
return null;
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
... ... @@ -50,7 +53,9 @@ public class MT520XController {
}catch (Exception e){
e.printStackTrace();
return null;
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
... ...
... ... @@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
@RequestMapping(value = "/mt6202")
... ... @@ -17,16 +18,32 @@ public class MT6202Controller {
@PostMapping(value = "/createMt6202")
@ResponseBody
public Map<String, Object> creatMt8205(@RequestBody Map<String, Object> map) throws IOException, ParseException {
public Map<String, Object> creatMt8205(@RequestBody Map<String, Object> map) {
return mt6202Service.creatMt6202(map);
try {
return mt6202Service.creatMt6202(map);
}catch (Exception e){
e.printStackTrace();
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
@PutMapping(value = "/removeMt6202")
@ResponseBody
public Map<String, Object> removeMt6202(@RequestBody Map<String, Object> map) throws IOException, ParseException {
public Map<String, Object> removeMt6202(@RequestBody Map<String, Object> map) {
try {
return mt6202Service.removeMt6202(map);
return mt6202Service.removeMt6202(map);
}catch (Exception e){
e.printStackTrace();
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
}
... ...
... ... @@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
@RequestMapping(value = "/mt8205")
... ... @@ -17,9 +18,17 @@ public class MT8205Controller {
@PostMapping(value = "/creatMt8205")
@ResponseBody
public Map<String, Object> creatMt8205(@RequestBody Map<String, Object> map) throws IOException, ParseException {
public Map<String, Object> creatMt8205(@RequestBody Map<String, Object> map){
return mt8205Service.create8205(map);
try {
return mt8205Service.create8205(map);
}catch (Exception e){
e.printStackTrace();
Map<String, Object> maps = new HashMap<>();
maps.put("status", "0");
return maps;
}
}
}
... ...
... ... @@ -9,7 +9,7 @@ import java.util.Map;
public interface MT520XService {
public Map<String, Object> create(Map<String, Object> map);
public Map<String, Object> create(Map<String, Object> map) throws IOException, ParseException;
public Map<String, Object> remove520x(Map<String, Object> map) throws IOException, ParseException;
... ...
... ... @@ -73,7 +73,7 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{
hashMap.put("customResponse", nmmsCustomResponse);
return hashMap;
}else {
hashMap.put("staus", "0");
hashMap.put("status", "0");
return hashMap;
}
}
... ... @@ -91,11 +91,13 @@ public class MT1201ServiceImp extends CustomXmlMaker implements MT1201Service{
map.put("sendTime", DateUtil.getCurrentTime17());
// 航班起飞时间 sendTime(海关接受时间) + 1小时
String s = DateUtil.addDateMinut(new Date(), 1);
// 航班到达时间 航班起飞时间 + 2小时
// 航班到达时间 航班起飞时间 + 2小时/+当前是间加3个小时
String ss = DateUtil.addDateMinut(new Date(), 3);
map.put("arrivalDateTime", s);
map.put("departureDateTime", ss);
map.put("departureDateTime", s);
map.put("arrivalDateTime", ss);
// 到达卸货地时间
String arrival = ss.substring(0, 8);
map.put("arrival", arrival);
// 封装实体
map.put("mt", customMt1201);
map.put("awbAwbinfo", awbAwbinfo);
... ...
... ... @@ -105,7 +105,7 @@ public class MT2201ServiceImp extends CustomXmlMaker implements MT2201Service {
hashMap.put("customResponse", nmmsCustomResponse);
return hashMap;
}else {
hashMap.put("staus", "0");
hashMap.put("status", "0");
return hashMap;
}
}
... ...
... ... @@ -110,7 +110,7 @@ public class MT3201ServiceImp extends CustomXmlMaker implements MT3201Service {
map3201.put("customResponse", nmmsCustomResponse);
return map3201;
}else {
map3201.put("staus", "0");
map3201.put("status", "0");
return map3201;
}
}
... ...
... ... @@ -102,7 +102,7 @@ public class MT3202ServiceImp extends CustomXmlMaker implements MT3202Service {
map3201.put("customResponse", nmmsCustomResponse);
return map3201;
}else {
map3201.put("staus", "0");
map3201.put("status", "0");
return map3201;
}
}
... ...
... ... @@ -112,7 +112,7 @@ public class MT4201ServiceImp extends CustomXmlMaker implements MT4201Service {
map4201.put("customResponse", nmmsCustomResponse);
return map4201;
}else {
map4201.put("staus", "0");
map4201.put("status", "0");
return map4201;
}
}
... ...
... ... @@ -26,9 +26,7 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
private String orgCode;
@Override
public Map<String, Object> create(Map<String, Object> map) {
try {
public Map<String, Object> create(Map<String, Object> map) throws IOException, ParseException {
ObjectMapper objectMapper = new ObjectMapper();
... ... @@ -85,7 +83,7 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
maps.put("customResponse", nmmsCustomResponse);
return maps;
}else {
maps.put("staus", "0");
maps.put("status", "0");
return maps;
}
}else {
... ... @@ -132,16 +130,10 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
return maps;
}else {
maps.put("staus", "0");
maps.put("status", "0");
return maps;
}
}
}catch (Exception e){
e.printStackTrace();
return null;
}
}
@Override
... ... @@ -173,7 +165,7 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
maps.put("customResponse", nmmsCustomResponse);
return maps;
}else {
maps.put("staus", "0");
maps.put("status", "0");
return maps;
}
}else {
... ... @@ -198,7 +190,7 @@ public class MT520XServiceImp extends CustomXmlMaker implements MT520XService{
maps.put("customResponse", nmmsCustomResponse);
return maps;
}else {
maps.put("staus", "0");
maps.put("status", "0");
return maps;
}
}
... ...
... ... @@ -101,7 +101,7 @@ public class MT6202ServiceImp extends CustomXmlMaker implements MT6202Service{
map3201.put("customResponse", nmmsCustomResponse);
return map3201;
}else {
map3201.put("staus", "0");
map3201.put("status", "0");
return map3201;
}
}
... ...
... ... @@ -31,17 +31,19 @@
<ChangeReasonCode>999</ChangeReasonCode>
<ConditionCode>10</ConditionCode>
</TransportContractDocument>
<#if mt.awbh?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
<#if mt['awbh']??>
<#if mt.awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
</#if>
</#if>
<LoadingLocation>
<ID>${mt.originstation}</ID>
</LoadingLocation>
<UnloadingLocation>
<ID>${mt.destinationstation}/${mt.customcode}</ID>
<ArrivalDate>20200121</ArrivalDate>
<ArrivalDate>${arrival}</ArrivalDate>
</UnloadingLocation>
<GoodsConsignedPlace>
<ID>${mt.destinationstation}</ID>
... ...
... ... @@ -29,10 +29,12 @@
<ChangeReasonCode>9999</ChangeReasonCode>
<ConditionCode>10</ConditionCode>
</TransportContractDocument>
<#if mt.awbh?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
<#if mt['awbh']??>
<#if mt.awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
</#if>
</#if>
<LoadingLocation>
<ID>${mt.originstation}/${mt.customcode}</ID>
... ...
... ... @@ -30,17 +30,19 @@
<ID>${mt.awba}</ID>
<ConditionCode>10</ConditionCode>
</TransportContractDocument>
<#if mt.awbh?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
<#if mt['awbh']??>
<#if mt.awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
</#if>
</#if>
<LoadingLocation>
<ID>${mt.originstation}</ID>
</LoadingLocation>
<UnloadingLocation>
<ID>${mt.destinationstation}/${mt.customcode}</ID>
<ArrivalDate>20200121</ArrivalDate>
<ArrivalDate>${arrival}</ArrivalDate>
</UnloadingLocation>
<GoodsConsignedPlace>
<ID>${mt.destinationstation}</ID>
... ...
... ... @@ -27,10 +27,12 @@
<ID>${mt.awba}</ID>
<ConditionCode>10</ConditionCode>
</TransportContractDocument>
<#if mt.awbh?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
<#if mt['awbh']??>
<#if mt.awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
</#if>
</#if>
<LoadingLocation>
<ID>${mt.originstation}/${mt.customcode}</ID>
... ...
... ... @@ -24,10 +24,12 @@
<TransportContractDocument>
<ID>${mt.awba}</ID>
</TransportContractDocument>
<#if mt.awbh?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
<#if mt['awbh']??>
<#if mt.awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
</#if>
</#if>
<ConsignmentPackaging>
<QuantityQuantity>${mt.piece}</QuantityQuantity>
... ...
... ... @@ -22,10 +22,12 @@
<TransportContractDocument>
<ID>${mt.awba}</ID>
</TransportContractDocument>
<#if mt.awbh?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
<#if mt['awbh']??>
<#if mt.awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
</#if>
</#if>
<LoadingLocation>
<ID>${mt.originstation}/${mt.customcode}</ID>
... ...
... ... @@ -28,10 +28,12 @@
<TransportContractDocument>
<ID>${mt.awba}</ID>
</TransportContractDocument>
<#if mt.awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
<#if mt['awbh']??>
<#if mt.awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
</#if>
</#if>
<ConsignmentPackaging>
<QuantityQuantity>${mt.piece}</QuantityQuantity>
... ...
... ... @@ -29,7 +29,7 @@
<ID>${mt.awba}</ID>
</TransportContractDocument>
<#if mt['awbh']??>
<#if mt.awbh?length gt 1>
<#if mt.awbh?default("")?length gt 11>
<AssociatedTransportDocument>
<ID>${mt.awba}_${mt.awbh}</ID>
</AssociatedTransportDocument>
... ...
... ... @@ -20,11 +20,11 @@
<ID>${awba}</ID>
<ChangeReasonCode>999</ChangeReasonCode>
</TransportContractDocument>
<#if awbh?length gt 1>
<AssociatedTransportDocument>
<ID>${awba}_${awbh}</ID>
</AssociatedTransportDocument>
</#if>
<#if awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${awba}_${awbh}</ID>
</AssociatedTransportDocument>
</#if>
</Consignment>
<AdditionalInformation>
<Reason>${reason}</Reason>
... ...
... ... @@ -21,7 +21,7 @@
<ID>${awba}</ID>
<ChangeReasonCode>9999</ChangeReasonCode>
</TransportContractDocument>
<#if awbh?length gt 1>
<#if awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${awba}_${awbh}</ID>
</AssociatedTransportDocument>
... ...
... ... @@ -17,7 +17,7 @@
<TransportContractDocument>
<ID>${awba}</ID>
</TransportContractDocument>
<#if awbh?length gt 1>
<#if awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${awba}_${awbh}</ID>
</AssociatedTransportDocument>
... ...
... ... @@ -16,7 +16,7 @@
<TransportContractDocument>
<ID>${awba}</ID>
</TransportContractDocument>
<#if awbh?length gt 1>
<#if awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${awba}_${awbh}</ID>
</AssociatedTransportDocument>
... ...
... ... @@ -17,7 +17,7 @@
<TransportContractDocument>
<ID>${awba}</ID>
</TransportContractDocument>
<#if awbh?length gt 1>
<#if awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${awba}_${awbh}</ID>
</AssociatedTransportDocument>
... ...
... ... @@ -17,11 +17,11 @@
<TransportContractDocument>
<ID>${awba}</ID>
</TransportContractDocument>
<#if awbh?length gt 1>
<AssociatedTransportDocument>
<ID>${awba}_${awbh}</ID>
</AssociatedTransportDocument>
</#if>
<#if awbh?default("")?length gt 1>
<AssociatedTransportDocument>
<ID>${awba}_${awbh}</ID>
</AssociatedTransportDocument>
</#if>
</Consignment>
<AdditionalInformation>
<Reason>${reason}</Reason>
... ...