...
|
...
|
@@ -3,10 +3,12 @@ package com.tianbo.controller.lost; |
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
...
|
...
|
@@ -26,17 +28,25 @@ import com.tianbo.model.Sendlog; |
|
|
import com.tianbo.service.ItemService;
|
|
|
import com.tianbo.service.LostChangeService;
|
|
|
import com.tianbo.service.SendLogService;
|
|
|
import com.tianbo.util.DateUtils;
|
|
|
import com.tianbo.util.json.AjaxJson;
|
|
|
import com.tianbo.util.json.JsonConversion;
|
|
|
import com.tianbo.util.xml.XmlGen;
|
|
|
import com.tianbo.xml.lost.AdditionalInformation;
|
|
|
import com.tianbo.xml.lost.AssociatedTransportDocument;
|
|
|
import com.tianbo.xml.lost.BorderTransportMeans;
|
|
|
import com.tianbo.xml.lost.Consignment;
|
|
|
import com.tianbo.xml.lost.DeclarationXmlEntity;
|
|
|
import com.tianbo.xml.lost.HeadXmlEntity;
|
|
|
import com.tianbo.xml.lost.ManifestXmlEntity;
|
|
|
import com.tianbo.xml.lost.TransportContractDocument;
|
|
|
import com.tianbo.xml.lostChange.AssociatedTransport;
|
|
|
import com.tianbo.xml.lostChange.ChangeBorderTransportMeans;
|
|
|
import com.tianbo.xml.lostChange.ChangeConsignment;
|
|
|
import com.tianbo.xml.lostChange.Commodity;
|
|
|
import com.tianbo.xml.lostChange.ConsignmentItem;
|
|
|
import com.tianbo.xml.lostChange.ConsignmentItemPackaging;
|
|
|
import com.tianbo.xml.lostChange.DeclarationXml;
|
|
|
import com.tianbo.xml.lostChange.GoodsMeasure;
|
|
|
import com.tianbo.xml.lostChange.HeadXml;
|
|
|
import com.tianbo.xml.lostChange.ManifestXml;
|
|
|
import com.tianbo.xml.lostChange.TransportContract;
|
|
|
|
|
|
@Controller
|
|
|
@RequestMapping("/lost/change")
|
...
|
...
|
@@ -116,11 +126,15 @@ public class LostChangeController { |
|
|
map.put("data", ltem);
|
|
|
}else {
|
|
|
map.put("code", 0);
|
|
|
map.put("msg", "");
|
|
|
map.put("msg", "success");
|
|
|
map.put("data", "");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}else{
|
|
|
map.put("code", 0);
|
|
|
map.put("msg", "success");
|
|
|
map.put("data", "");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
map.put("code", -1);
|
|
|
map.put("msg", "请检查网络连接或重试");
|
...
|
...
|
@@ -339,30 +353,98 @@ public class LostChangeController { |
|
|
* @param lost
|
|
|
* @param redirectAttributes
|
|
|
* @return
|
|
|
* @throws InvocationTargetException
|
|
|
* @throws IllegalAccessException
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "send")
|
|
|
public AjaxJson send(ModelMap model,HttpServletRequest request) {
|
|
|
public AjaxJson send(ModelMap model,HttpServletRequest request,@RequestParam Map<String, Object> params) throws IllegalAccessException, InvocationTargetException {
|
|
|
String id = request.getParameter("id");
|
|
|
String flightno = request.getParameter("flightno");
|
|
|
String flightdate = request.getParameter("flightdate");
|
|
|
String waybillnomaster = request.getParameter("waybillnomaster");
|
|
|
String waybillnosecondary = request.getParameter("waybillnosecondary");
|
|
|
String remark = request.getParameter("remark");
|
|
|
String message = null;
|
|
|
ManifestLostChange mf = new ManifestLostChange();
|
|
|
DateConvert();//日期转化
|
|
|
BeanUtils.populate(mf, params);
|
|
|
|
|
|
List<ManifestItem> iteamList = itemService.getIteamList(mf.getWaybillnomaster());
|
|
|
|
|
|
List<ConsignmentItem> consignmentItem = new ArrayList<>();
|
|
|
|
|
|
for (ManifestItem manifestItem : iteamList) {
|
|
|
|
|
|
ConsignmentItemPackaging consignmentItemPackaging = new ConsignmentItemPackaging();
|
|
|
consignmentItemPackaging.setQuantityQuantity(manifestItem.getPiece()); //件数
|
|
|
consignmentItemPackaging.setTypeCode(manifestItem.getPackageCode()); //包装代码
|
|
|
|
|
|
GoodsMeasure goodsMeasure = new GoodsMeasure();
|
|
|
goodsMeasure.setGrossMassMeasure(manifestItem.getWeight()); //重量
|
|
|
|
|
|
Commodity commodity = new Commodity();
|
|
|
commodity.setCargoDescription(manifestItem.getDescription());//货物描述
|
|
|
|
|
|
ConsignmentItem item = new ConsignmentItem();
|
|
|
item.setSequenceNumeric(manifestItem.getOrderNumber());//商品序号
|
|
|
item.setConsignmentItemPackaging(consignmentItemPackaging);//包装项信息
|
|
|
item.setGoodsMeasure(goodsMeasure);//货物毛重
|
|
|
item.setCommodity(commodity );
|
|
|
consignmentItem.add(item);
|
|
|
}
|
|
|
|
|
|
|
|
|
String message = null;
|
|
|
AjaxJson j = new AjaxJson();
|
|
|
try {
|
|
|
//保存至sendLog表
|
|
|
Sendlog sendlog = new Sendlog();
|
|
|
sendlog.setAutoid(id);
|
|
|
sendlog.setAutoid(UUID.randomUUID().toString());
|
|
|
sendlog.setMessageautoid(id);
|
|
|
sendlog.setCreatedate(new Date());
|
|
|
sendlog.setMessagetype("MT8203");
|
|
|
sendlog.setReceiption("发送落装改配申请");
|
|
|
sendLogService.save(sendlog);
|
|
|
//生成报文并发送至文件夹
|
|
|
ManifestXmlEntity manifestXml = new ManifestXmlEntity();
|
|
|
setParam(flightno, flightdate, waybillnomaster, waybillnosecondary, remark, manifestXml);
|
|
|
XmlGen.genLostXmlAndSend(manifestXml);
|
|
|
//生成报文并发送
|
|
|
ManifestXml manifestXml = new ManifestXml();
|
|
|
|
|
|
HeadXml headXml = new HeadXml();
|
|
|
DeclarationXml declaration = new DeclarationXml();
|
|
|
Consignment consign = new Consignment();
|
|
|
|
|
|
TransportContractDocument transportContractDocument = new TransportContractDocument();
|
|
|
AssociatedTransportDocument associatedTransportDocument = new AssociatedTransportDocument();
|
|
|
TransportContract transportContract= new TransportContract();
|
|
|
AssociatedTransport associatedTransport = new AssociatedTransport();
|
|
|
|
|
|
transportContractDocument.setId(mf.getWaybillnomaster());//改配前主单号
|
|
|
associatedTransportDocument.setId(mf.getWaybillnomaster()+"_"+mf.getWaybillnosecondary()); //改配前分单号
|
|
|
|
|
|
consign.setTransportContractDocument(transportContractDocument);
|
|
|
consign.setAssociatedTransportDocument(associatedTransportDocument);
|
|
|
|
|
|
ChangeConsignment changeConsignment = new ChangeConsignment();
|
|
|
|
|
|
transportContract.setId(mf.getCwaybillnomaster());//改配后主单号
|
|
|
associatedTransport.setId(mf.getCwaybillnomaster()+"_"+mf.getCwaybillnosecondary()); //改配分单号
|
|
|
|
|
|
changeConsignment.setTransportContractDocument(transportContract);
|
|
|
changeConsignment.setAssociatedTransportDocument(associatedTransport);
|
|
|
|
|
|
|
|
|
changeConsignment.setConsignmentItem(consignmentItem);
|
|
|
|
|
|
consign.setChangeConsignment(changeConsignment);
|
|
|
|
|
|
BorderTransportMeans borderTransportMeans = new BorderTransportMeans();
|
|
|
borderTransportMeans.setJourneyID(mf.getFlightno()+"/"+DateUtils.DateToString(mf.getFlightdate(), "yyyy-MM-dd HH:mm:ss").substring(0,10).replace("-", ""));//航次航班
|
|
|
|
|
|
ChangeBorderTransportMeans changeBorderTransportMeans = new ChangeBorderTransportMeans();
|
|
|
changeBorderTransportMeans.setJourneyID(mf.getCflightno()+"/"+DateUtils.DateToString(mf.getCflightdate(), "yyyy-MM-dd HH:mm:ss").substring(0,10).replace("-", ""));//航次航班
|
|
|
|
|
|
declaration.setBorderTransportMeans(borderTransportMeans);
|
|
|
declaration.setChangeBorderTransportMeans(changeBorderTransportMeans );
|
|
|
declaration.setConsignment(consign);
|
|
|
|
|
|
manifestXml.setHeadXml(headXml);
|
|
|
manifestXml.setDeclarationXml(declaration);
|
|
|
|
|
|
XmlGen.genLostChangeXmlAndSend(manifestXml);
|
|
|
j.setSuccess(true);
|
|
|
message = "已发送申报报文";
|
|
|
ManifestLostChange lost = lostChangeService.selectByPrimaryKey(id);
|
...
|
...
|
@@ -377,35 +459,4 @@ public class LostChangeController { |
|
|
return j;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @param flightno
|
|
|
* @param flightdate
|
|
|
* @param waybillnomaster
|
|
|
* @param waybillnosecondary
|
|
|
* @param remark
|
|
|
* @param manifestXml
|
|
|
*/
|
|
|
public void setParam(String flightno, String flightdate, String waybillnomaster, String waybillnosecondary,
|
|
|
String remark, ManifestXmlEntity manifestXml) {
|
|
|
HeadXmlEntity headXml = new HeadXmlEntity();
|
|
|
DeclarationXmlEntity declarationXml = new DeclarationXmlEntity();
|
|
|
BorderTransportMeans transportMeans = new BorderTransportMeans();
|
|
|
transportMeans.setJourneyID(flightno+"/"+flightdate.substring(0,10).replace("-", ""));//航次航班
|
|
|
AdditionalInformation information = new AdditionalInformation();
|
|
|
information.setContent(remark);
|
|
|
Consignment consignment = new Consignment();
|
|
|
TransportContractDocument transportContractDocument = new TransportContractDocument();
|
|
|
transportContractDocument.setId(waybillnomaster);//主单号
|
|
|
AssociatedTransportDocument associatedTransportDocument = new AssociatedTransportDocument();
|
|
|
associatedTransportDocument.setId(waybillnomaster+"_"+waybillnosecondary);//分单号
|
|
|
consignment.setAssociatedTransportDocument(associatedTransportDocument );
|
|
|
consignment.setTransportContractDocument(transportContractDocument );
|
|
|
declarationXml.setAdditionalInformation(information);
|
|
|
declarationXml.setBorderTransportMeans(transportMeans);
|
|
|
declarationXml.setConsignment(consignment);
|
|
|
manifestXml.setHeadXml(headXml);
|
|
|
manifestXml.setDeclarationXml(declarationXml);
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|