|
|
package com.agent.controller.agent;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import com.agent.controller.BasicController;
|
|
|
import com.agent.entity.Constant;
|
|
|
import com.agent.entity.agent.BasicAgentEntity;
|
|
|
import com.agent.entity.agent.ConsigneeEntity;
|
|
|
import com.agent.entity.agent.DeliveryInfoEntity;
|
|
|
import com.agent.entity.agent.HawbOtherFeeEntity;
|
|
|
import com.agent.entity.agent.MakeHawbEntity;
|
|
|
import com.agent.entity.agent.MakeMawbEntity;
|
|
|
import com.agent.entity.agent.MawbOtherFeeEntity;
|
|
|
import com.agent.entity.agent.PackageTypeEntity;
|
|
|
import com.agent.entity.agent.PubStationEntity;
|
|
|
import com.agent.service.agent.BasicAgentService;
|
|
|
import com.agent.service.agent.ConsigneeService;
|
|
|
import com.agent.service.agent.DeliveryInfoService;
|
|
|
import com.agent.service.agent.HawbOtherFeeService;
|
|
|
import com.agent.service.agent.MakeHawbService;
|
|
|
import com.agent.service.agent.MakeMawbService;
|
|
|
import com.agent.service.agent.MawbOtherFeeService;
|
|
|
import com.agent.service.agent.PackageSizeService;
|
|
|
import com.agent.service.agent.PackageTypeService;
|
|
|
import com.agent.service.agent.PubStationService;
|
|
|
import com.agent.util.HttpJsonMsg;
|
|
|
import com.agent.vo.ResponseModel;
|
|
|
import com.agent.xml.bill.ApplicableFreightRateServiceChargeXml;
|
|
|
import com.agent.xml.bill.ApplicableLogisticsAllowanceChargeXml;
|
|
|
import com.agent.xml.bill.ApplicableTradeCurrencyExchangeXml;
|
|
|
import com.agent.xml.bill.AssociatedPartyXml;
|
|
|
import com.agent.xml.bill.AssociatedUnitLoadTransportEquipmentXml;
|
|
|
import com.agent.xml.bill.BillHeadXml;
|
|
|
import com.agent.xml.bill.BillXmlBody;
|
|
|
import com.agent.xml.bill.ConsignorPartyXml;
|
|
|
import com.agent.xml.bill.DepartureEventXml;
|
|
|
import com.agent.xml.bill.DirectTelephoneCommunicationXml;
|
|
|
import com.agent.xml.bill.EventTimeXml;
|
|
|
import com.agent.xml.bill.HandlingInstructionsXml;
|
|
|
import com.agent.xml.bill.IncludedMasterConsignmentItemXml;
|
|
|
import com.agent.xml.bill.LinearSpatialDimensionXml;
|
|
|
import com.agent.xml.bill.MasterConsignmentXml;
|
|
|
import com.agent.xml.bill.NatureIdentificationTransportCargoXml;
|
|
|
import com.agent.xml.bill.OccurrenceArrivalLocationXml;
|
|
|
import com.agent.xml.bill.OperatingPartyXml;
|
|
|
import com.agent.xml.bill.PostalStructuredAddressXml;
|
|
|
import com.agent.xml.bill.ReportedStatusXml;
|
|
|
import com.agent.xml.bill.SignatoryCarrierAuthenticationXml;
|
|
|
import com.agent.xml.bill.SpecifiedLogisticsTransportMovementXml;
|
|
|
import com.agent.xml.bill.TransportLogisticsPackageXml;
|
|
|
import com.agent.xml.common.IDXml;
|
|
|
import com.agent.xml.common.NameXml;
|
|
|
import com.agent.xml.common.XmlUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.framework.core.Servlets;
|
|
|
import com.framework.shiro.SessionUtil;
|
|
|
import com.plugin.easyui.DataGrid;
|
|
|
import com.plugin.easyui.EasyPage;
|
|
|
|
|
|
import tools.Tools;
|
|
|
|
|
|
/**
|
|
|
* Created by cohesion on 2017/3/29.
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/bill")
|
|
|
public class BillController extends BasicController{
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(BillController.class);
|
|
|
|
|
|
@Resource
|
|
|
private MakeMawbService makeMawbService;
|
|
|
|
|
|
@Resource
|
|
|
private ConsigneeService consigneeService;
|
|
|
|
|
|
@Resource
|
|
|
private PubStationService stationService;
|
|
|
|
|
|
@Resource
|
|
|
private MawbOtherFeeService otherFeeService;
|
|
|
|
|
|
@Resource
|
|
|
private BasicAgentService agentService;
|
|
|
|
|
|
@Resource
|
|
|
private MakeHawbService makeHawbService;
|
|
|
|
|
|
@Resource
|
|
|
private HawbOtherFeeService hawbOtherFeeService;
|
|
|
|
|
|
@Resource
|
|
|
private PackageTypeService packageTypeService;
|
|
|
|
|
|
@Resource
|
|
|
private DeliveryInfoService deliveryInfoService;
|
|
|
|
|
|
@Resource
|
|
|
private PackageSizeService sizeService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 国内制单页面
|
|
|
* @return
|
|
|
*/
|
|
|
/* @RequiresRoles("agent")*/
|
|
|
@RequestMapping(value = "/list")
|
|
|
public ModelAndView getList(String type){
|
|
|
ModelAndView mav = new ModelAndView();
|
|
|
mav.addObject("type",type);
|
|
|
mav.setViewName("bill/list");
|
|
|
return mav;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 制单浏览
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/CheckThrough")
|
|
|
public ModelAndView CheckThrough(String type){
|
|
|
ModelAndView mav = new ModelAndView();
|
|
|
mav.addObject("type",type);
|
|
|
mav.setViewName("bill/view");
|
|
|
return mav;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询主制单分页数据
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value="/grid.json")
|
|
|
@ResponseBody
|
|
|
public DataGrid<MakeMawbEntity> grid(HttpServletRequest request,EasyPage<MakeMawbEntity> pageForm,String type) {
|
|
|
Map<String, Object> searchParams = Servlets.getParametersStartingWith(request, "search_");
|
|
|
searchParams.put("EQ_isdelete", 0);
|
|
|
searchParams.put("LIKE_billType",type);
|
|
|
searchParams.put("EQ_USER_ID", Tools.getUserId());
|
|
|
pageForm.setSearchParams(searchParams);
|
|
|
pageForm.parseData(makeMawbService.getPage(pageForm));
|
|
|
return pageForm.getData();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询分制单分页数据
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value="/sub/grid.json")
|
|
|
@ResponseBody
|
|
|
public DataGrid<MakeHawbEntity> gridSub(Long mawbId,HttpServletRequest request) {
|
|
|
DataGrid<MakeHawbEntity> dg = new DataGrid<>();
|
|
|
dg.setRows(makeHawbService.findByMawbId(mawbId));
|
|
|
return dg;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 临时跳转打印用
|
|
|
*/
|
|
|
@RequestMapping(value="/billprint")
|
|
|
@ResponseBody
|
|
|
public MakeMawbEntity billprint(Long id,Model model){
|
|
|
MakeMawbEntity make = makeMawbService.findOne(id);
|
|
|
model.addAttribute("make", make);
|
|
|
return make;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 编辑
|
|
|
* @param id
|
|
|
* @param model
|
|
|
* @return
|
|
|
* @throws ParseException
|
|
|
*/
|
|
|
@RequestMapping(value = "/edit" , method = {RequestMethod.GET })
|
|
|
public String edit(Long id,String mawbNo,String type,Long deliveryId, Model model) throws ParseException {
|
|
|
|
|
|
MakeMawbEntity bill = null;
|
|
|
if(id!=null){
|
|
|
//主制单
|
|
|
bill = makeMawbService.findOne(id);
|
|
|
|
|
|
//其他费用
|
|
|
if(bill!=null){
|
|
|
MawbOtherFeeEntity otherFee = otherFeeService.findByMawbId(bill.getId());
|
|
|
model.addAttribute("otherFee",otherFee);
|
|
|
}
|
|
|
}
|
|
|
if(bill==null){
|
|
|
bill = new MakeMawbEntity();
|
|
|
}
|
|
|
//货站
|
|
|
List<PubStationEntity> stations = stationService.findAll();
|
|
|
model.addAttribute("stations",stations);
|
|
|
|
|
|
if(SessionUtil.getUser() != null && SessionUtil.getUser().getAgent() != null)
|
|
|
{
|
|
|
//代理人
|
|
|
BasicAgentEntity agent = agentService.findOne(SessionUtil.getUser().getAgent());
|
|
|
if(agent!=null){
|
|
|
bill.setAgent(agent.getThreeCode());
|
|
|
if(StringUtils.isNotEmpty(mawbNo)){
|
|
|
bill.setMawbNo(mawbNo);
|
|
|
}
|
|
|
bill.setfTel(agent.getTel());
|
|
|
// bill.setfName(agent.getNameCn());
|
|
|
bill.setfName(agent.getContact());
|
|
|
|
|
|
bill.setfAddress(agent.getAddress());
|
|
|
bill.setfCode(agent.getThreeCode());
|
|
|
bill.setBillType(type);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
model.addAttribute("bill", bill);
|
|
|
|
|
|
|
|
|
String printStr ="";
|
|
|
//打印用到的时间
|
|
|
if(bill.getFlightOneDate() !=null){
|
|
|
printStr =Constant.dateFormat.format(bill.getFlightOneDate());
|
|
|
}
|
|
|
model.addAttribute("printStr",printStr);
|
|
|
|
|
|
//费用类型(其他费用)
|
|
|
List<String> feeTypes = getFeeTypes();
|
|
|
model.addAttribute("feeTypes",feeTypes);
|
|
|
|
|
|
//支付方式
|
|
|
List<String> payTypes = getPayTypes();
|
|
|
model.addAttribute("payTypes",payTypes);
|
|
|
|
|
|
//包装种类
|
|
|
List<PackageTypeEntity> typeList = packageTypeService.findAll();
|
|
|
model.addAttribute("typeList",typeList);
|
|
|
|
|
|
//下一票ID
|
|
|
Long nextId = null;
|
|
|
Long minId = makeMawbService.findMinId();
|
|
|
if(bill!=null){
|
|
|
nextId = findNext(bill.getId(),minId);
|
|
|
}
|
|
|
model.addAttribute("nextId",nextId);
|
|
|
|
|
|
//交运信息
|
|
|
if(deliveryId!=null){
|
|
|
DeliveryInfoEntity deliveryInfo = deliveryInfoService.findOne(deliveryId);
|
|
|
if(deliveryInfo!=null){
|
|
|
bill.setDestinationStation(deliveryInfo.getDestination());
|
|
|
bill.setMawbNo(deliveryInfo.getMawbNo());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//打印专用 --开始
|
|
|
if(bill.getMawbNo() !=null){
|
|
|
model.addAttribute("way1",bill.getMawbNo().substring(0, 3));
|
|
|
model.addAttribute("cgo",bill.getCgo());
|
|
|
model.addAttribute("way2",bill.getMawbNo().substring(4, 11));
|
|
|
}
|
|
|
|
|
|
if(bill.getDate_one() !=null){
|
|
|
model.addAttribute("dateOne",Constant.dateFormat.format(bill.getDate_one()));
|
|
|
}
|
|
|
if(bill.getDate_two() !=null){
|
|
|
model.addAttribute("dateTwe",Constant.dateFormat.format(bill.getDate_two()));
|
|
|
}
|
|
|
if(bill.getExecute_date() !=null){
|
|
|
model.addAttribute("execute_date",Constant.dateFormat.format(bill.getExecute_date()));
|
|
|
}
|
|
|
//结束
|
|
|
|
|
|
return "bill/edit";
|
|
|
}
|
|
|
|
|
|
private Long findNext(Long id,Long minId){
|
|
|
if(id==null || minId==null || id<=minId){
|
|
|
return null;
|
|
|
}
|
|
|
MakeMawbEntity next = makeMawbService.findOne(id - 1);
|
|
|
if(next==null){
|
|
|
return findNext(id-1,minId);
|
|
|
}
|
|
|
else {
|
|
|
return next.getId();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑
|
|
|
* @param id
|
|
|
* @param model
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/sub/edit" , method = {RequestMethod.GET })
|
|
|
public String subEdit(Long id,Long mawbId,String type, Model model) {
|
|
|
MakeHawbEntity subBill = null;
|
|
|
if(id!=null){
|
|
|
//分制单
|
|
|
subBill = makeHawbService.findOne(id);
|
|
|
|
|
|
//其他费用
|
|
|
if(subBill!=null){
|
|
|
List<HawbOtherFeeEntity> feeList = hawbOtherFeeService.findByHawbId(subBill.getId());
|
|
|
model.addAttribute("feeList",feeList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//货站
|
|
|
List<PubStationEntity> stations = stationService.findAll();
|
|
|
model.addAttribute("stations",stations);
|
|
|
|
|
|
//代理人
|
|
|
BasicAgentEntity agent = agentService.findOne(SessionUtil.getUser().getAgent());
|
|
|
if(subBill==null && agent!=null){
|
|
|
subBill = new MakeHawbEntity();
|
|
|
if(mawbId!=null){
|
|
|
MakeMawbEntity mawb = makeMawbService.findOne(mawbId);
|
|
|
subBill.setMawbNo(mawb.getMawbNo());
|
|
|
subBill.setfName(agent.getNameCn());
|
|
|
}
|
|
|
subBill.setMawbId(mawbId);
|
|
|
}
|
|
|
model.addAttribute("bill", subBill);
|
|
|
|
|
|
//费用类型(其他费用)
|
|
|
List<String> feeTypes = getFeeTypes();
|
|
|
model.addAttribute("feeTypes",feeTypes);
|
|
|
|
|
|
//支付方式
|
|
|
List<String> payTypes = getPayTypes();
|
|
|
model.addAttribute("payTypes",payTypes);
|
|
|
|
|
|
//包装种类
|
|
|
List<PackageTypeEntity> typeList = packageTypeService.findAll();
|
|
|
model.addAttribute("typeList",typeList);
|
|
|
|
|
|
model.addAttribute("type",type);
|
|
|
return "bill/edit_sub";
|
|
|
}
|
|
|
|
|
|
private List<String> getFeeTypes(){
|
|
|
List<String> list = new ArrayList<>();
|
|
|
list.add("燃油费");
|
|
|
list.add("地面费");
|
|
|
list.add("操作费");
|
|
|
list.add("装卸费");
|
|
|
list.add("直航费");
|
|
|
list.add("分单直航费");
|
|
|
list.add("查验费(危险品)");
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
private List<String> getPayTypes(){
|
|
|
List<String> list = new ArrayList<>();
|
|
|
list.add("现金");
|
|
|
list.add("银行转账");
|
|
|
list.add("汇款");
|
|
|
list.add("支票");
|
|
|
list.add("支付宝");
|
|
|
list.add("微信");
|
|
|
list.add("其他");
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询分制单费用信息
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value="/sub/fee/grid.json")
|
|
|
@ResponseBody
|
|
|
public String gridSubFee(Long id,HttpServletRequest request) {
|
|
|
String feeList = JSONArray.toJSONString(hawbOtherFeeService.findByHawbId(id),filter);
|
|
|
return feeList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取收货人信息
|
|
|
*
|
|
|
* @param sCode
|
|
|
* @param sName
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/getCon",method = {RequestMethod.POST})
|
|
|
@ResponseBody
|
|
|
public ResponseModel getConsignee(String sCode,String sName){
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
ConsigneeEntity consignee = null;
|
|
|
try {
|
|
|
consignee = consigneeService.findByCompanyAndUserId(sCode, Tools.getUserId());
|
|
|
model.setData(consignee);
|
|
|
model.setStatus(200);
|
|
|
}catch (Exception e){
|
|
|
model.setStatus(500);
|
|
|
logger.error("系统异常 >>", e);
|
|
|
}
|
|
|
if(consignee==null){
|
|
|
model.setStatus(500);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询主单号是否存在
|
|
|
*
|
|
|
* @param mawbNo
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/queryMawbNo",method = {RequestMethod.POST})
|
|
|
@ResponseBody
|
|
|
public ResponseModel queryMawbId(Long id,String mawbNo){
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
List<MakeMawbEntity> list = null;
|
|
|
if(StringUtils.isNotEmpty(mawbNo)){
|
|
|
list = makeMawbService.findByMawbNo(mawbNo);
|
|
|
}
|
|
|
boolean exist = false;
|
|
|
if(CollectionUtils.isNotEmpty(list)){
|
|
|
if(list.size()>1){
|
|
|
exist = true;
|
|
|
}else if(!list.get(0).getId().equals(id)) {
|
|
|
exist = true;
|
|
|
}
|
|
|
}
|
|
|
if(exist){
|
|
|
model.setStatus(500);
|
|
|
}
|
|
|
else {
|
|
|
model.setStatus(200);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询分单号是否存在
|
|
|
*
|
|
|
* @param hawbNo
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/queryHawbNo",method = {RequestMethod.POST})
|
|
|
@ResponseBody
|
|
|
public ResponseModel queryHawbId(Long id,String hawbNo){
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
List<MakeHawbEntity> list = null;
|
|
|
if(StringUtils.isNotEmpty(hawbNo)){
|
|
|
list = makeHawbService.findByHawbNo(hawbNo);
|
|
|
}
|
|
|
boolean exist = false;
|
|
|
if(CollectionUtils.isNotEmpty(list)){
|
|
|
if(list.size()>1){
|
|
|
exist = true;
|
|
|
}else if(!list.get(0).getId().equals(id)) {
|
|
|
exist = true;
|
|
|
}
|
|
|
}
|
|
|
if(exist){
|
|
|
model.setStatus(500);
|
|
|
}
|
|
|
else {
|
|
|
model.setStatus(200);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询主单号是否存在
|
|
|
*
|
|
|
* @param model
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/viewcheck",method = {RequestMethod.POST})
|
|
|
@ResponseBody
|
|
|
public ResponseModel viewcheck(String ids){
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
MakeMawbEntity me = null;
|
|
|
if(StringUtils.isNotEmpty(ids)){
|
|
|
me = makeMawbService.findNo(ids);
|
|
|
}
|
|
|
|
|
|
if(me != null){
|
|
|
model.setStatus(200);
|
|
|
}else{
|
|
|
model.setStatus(500);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 返回主单号
|
|
|
*
|
|
|
* @param String
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/viewlist", method = {RequestMethod.GET })
|
|
|
public String viewlist(String ids,Model model){
|
|
|
MakeMawbEntity me = null;
|
|
|
if(StringUtils.isNotEmpty(ids)){
|
|
|
me = makeMawbService.findNo(ids);
|
|
|
}
|
|
|
model.addAttribute("bill", me);
|
|
|
return "bill/printedit";
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
// * 保存
|
|
|
// * @param billJson
|
|
|
// * @return
|
|
|
// */
|
|
|
// @RequestMapping(value = "/save" , method = {RequestMethod.POST })
|
|
|
// @ResponseBody
|
|
|
// public ResponseModel save(String billJson,String otherFeeJson,String conJson,String sizeJson) {
|
|
|
// ResponseModel model = new ResponseModel();
|
|
|
// try {
|
|
|
// MakeMawbEntity bill = JSONObject.parseObject(billJson,MakeMawbEntity.class);
|
|
|
// MawbOtherFeeEntity otherFee = JSONObject.parseObject(otherFeeJson,MawbOtherFeeEntity.class);
|
|
|
// ConsigneeEntity consignee = new ConsigneeEntity();
|
|
|
// if(bill!=null){
|
|
|
// consignee.setCode(bill.getsCode());
|
|
|
// consignee.setName(bill.getsName());
|
|
|
// consignee.setAddress(bill.getsAddress());
|
|
|
// consignee.setTel(bill.getsTel());
|
|
|
// }
|
|
|
// List<PackageSizeEntity> sizeList = JSONArray.parseArray(sizeJson,PackageSizeEntity.class);
|
|
|
// bill = makeMawbService.save(bill,otherFee,consignee,sizeList);
|
|
|
// model.setData(bill);
|
|
|
// model.setStatus(200);
|
|
|
// } catch (Exception e) {
|
|
|
// model.setStatus(500);
|
|
|
// logger.error("系统异常 >>", e);
|
|
|
// }
|
|
|
// return model;
|
|
|
// }
|
|
|
/**
|
|
|
* 保存
|
|
|
* @param billJson
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/save" , method = {RequestMethod.POST })
|
|
|
@ResponseBody
|
|
|
public ResponseModel save(MakeMawbEntity make) {
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
try {
|
|
|
make.setUSER_ID(Tools.getUserId());
|
|
|
make.setCreateDate(new Date(System.currentTimeMillis()));
|
|
|
make = makeMawbService.save(make);
|
|
|
model.setData(make);
|
|
|
model.setStatus(200);
|
|
|
} catch (Exception e) {
|
|
|
model.setStatus(500);
|
|
|
logger.error("系统异常 >>", e);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存
|
|
|
* @param billJson
|
|
|
* @return
|
|
|
*/
|
|
|
/**
|
|
|
* 保存
|
|
|
* @param billJson
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/sub/save" , method = {RequestMethod.POST })
|
|
|
@ResponseBody
|
|
|
public ResponseModel saveSub(MakeHawbEntity make) {
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
try {
|
|
|
make.setUSER_ID(Tools.getUserId());
|
|
|
make = makeHawbService.savemessage(make);
|
|
|
model.setData(make);
|
|
|
model.setStatus(200);
|
|
|
} catch (Exception e) {
|
|
|
model.setStatus(500);
|
|
|
logger.error("系统异常 >>", e);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
// @RequestMapping(value = "/sub/save" , method = {RequestMethod.POST })
|
|
|
// @ResponseBody
|
|
|
// public ResponseModel saveSub(String billJson,String fJson,String sJson,String feeJson,String sizeJson) {
|
|
|
// ResponseModel model = new ResponseModel();
|
|
|
// try {
|
|
|
// MakeHawbEntity bill = JSONObject.parseObject(billJson,MakeHawbEntity.class);
|
|
|
// PubFhrEntity fhr = JSONObject.parseObject(fJson,PubFhrEntity.class);
|
|
|
// ConsigneeEntity consignee = JSONObject.parseObject(sJson, ConsigneeEntity.class);
|
|
|
// List<HawbOtherFeeEntity> feeList = JSONArray.parseArray(feeJson, HawbOtherFeeEntity.class);
|
|
|
// List<PackageSizeEntity> sizeList = JSONArray.parseArray(sizeJson,PackageSizeEntity.class);
|
|
|
// makeHawbService.save(bill,feeList,fhr,consignee,sizeList);
|
|
|
// model.setStatus(200);
|
|
|
// } catch (Exception e) {
|
|
|
// model.setStatus(500);
|
|
|
// logger.error("系统异常 >>", e);
|
|
|
// }
|
|
|
// return model;
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 删除
|
|
|
* @param ids
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/delete" , method = {RequestMethod.POST })
|
|
|
@ResponseBody
|
|
|
public ResponseModel delete(String ids) {
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
try {
|
|
|
makeMawbService.deleteAll(ids);
|
|
|
model.setStatus(200);
|
|
|
model.setMsg(HttpJsonMsg.SUCCESS);
|
|
|
} catch (Exception e) {
|
|
|
model.setStatus(500);
|
|
|
model.setMsg(HttpJsonMsg.ERROR);
|
|
|
logger.error("系统异常 >>", e);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/sub/delete" , method = {RequestMethod.POST })
|
|
|
@ResponseBody
|
|
|
public ResponseModel subDelete(Long id) {
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
try {
|
|
|
makeHawbService.delete(id);
|
|
|
model.setStatus(200);
|
|
|
model.setMsg(HttpJsonMsg.SUCCESS);
|
|
|
} catch (Exception e) {
|
|
|
model.setStatus(500);
|
|
|
model.setMsg(HttpJsonMsg.ERROR);
|
|
|
logger.error("系统异常 >>", e);
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取包装类型
|
|
|
*
|
|
|
* @param hostId
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/size/get" , method = {RequestMethod.POST })
|
|
|
@ResponseBody
|
|
|
public String getSize(Long hostId) {
|
|
|
return JSON.toJSONString(sizeService.getList(Constant.packageSizeBill, hostId), filter);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取包装类型
|
|
|
*
|
|
|
* @param hostId
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/sub/size/get" , method = {RequestMethod.POST })
|
|
|
@ResponseBody
|
|
|
public String getSubSize(Long hostId) {
|
|
|
return JSON.toJSONString(sizeService.getList(Constant.packageSizeSubBill, hostId), filter);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/xml",method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public ResponseModel createXml(Long id,HttpServletRequest request,HttpServletResponse response) throws IOException {
|
|
|
|
|
|
ResponseModel model = new ResponseModel();
|
|
|
String rootPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
String path = rootPath+"/excel/bill"+new Date().getTime()+".xml";
|
|
|
String xml = "";
|
|
|
if(id!=null){
|
|
|
xml = beanToXml(path, id);
|
|
|
}
|
|
|
model.setData(xml);
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
private String beanToXml(String path,Long id){
|
|
|
|
|
|
MakeMawbEntity mawb = makeMawbService.findOne(id);
|
|
|
mawb.setSendXml(1);
|
|
|
mawb = makeMawbService.save(mawb);
|
|
|
if(mawb==null){
|
|
|
mawb = new MakeMawbEntity();
|
|
|
}
|
|
|
|
|
|
BillXmlBody body = new BillXmlBody();
|
|
|
|
|
|
BillHeadXml headXml = new BillHeadXml();
|
|
|
headXml.setDdtm(Constant.dateFormat.format(new Date()));
|
|
|
headXml.setSender(SessionUtil.getUser().getRealName());
|
|
|
headXml.setSeqn(String.valueOf(new Date().getTime()));
|
|
|
|
|
|
body.setHead(headXml);
|
|
|
|
|
|
MasterConsignmentXml consignmentXml = new MasterConsignmentXml();
|
|
|
consignmentXml.setId(mawb.getMawbNo());
|
|
|
consignmentXml.setTypeCode(mawb.getBillType());
|
|
|
consignmentXml.setNilCarriageValueIndicator(StringUtils.isEmpty(mawb.getTdv()) ? "false" : "true");
|
|
|
consignmentXml.setDeclaredValueForCarriageAmount(StringUtils.isEmpty(mawb.getTdv()) ? "NVC" : "NVD");
|
|
|
consignmentXml.setNilCustomsValueIndicator(mawb.getIsCs().equals(1) ? "true" : "false");//是否包含海关声明价值(现在为海关监管货)
|
|
|
consignmentXml.setDeclaredValueForCustomsAmount(mawb.getIsCs().equals(1) ? "NCV" : "");// true 为 NCV,false ?
|
|
|
consignmentXml.setNilInsuranceValueIndicator(StringUtils.isEmpty(mawb.getTiv()) ? "false" : "true");
|
|
|
consignmentXml.setInsuranceValueAmount(StringUtils.isNotEmpty(mawb.getTiv()) ? "XXX" : mawb.getTiv());
|
|
|
consignmentXml.setTotalChargePrepaidIndicator(mawb.getPpcc());
|
|
|
consignmentXml.setWeightTotalChargeAmount(mawb.getWeightCharge() != null ? mawb.getWeightCharge().toString() : "");
|
|
|
consignmentXml.setValuationTotalChargeAmount(mawb.getExtraCharge());
|
|
|
consignmentXml.setTotalDisbursementPrepaidIndicator(mawb.getPpcc());
|
|
|
consignmentXml.setTotalPrepaidChargeAmount("pp".equals(mawb.getPpcc())?mawb.getTotalCharge():"");//总预付费用
|
|
|
consignmentXml.setTotalCollectChargeAmount("cc".equals(mawb.getPpcc())?mawb.getTotalCharge():"");//总到付费用
|
|
|
consignmentXml.setDestinationCurrencyTotalCollectChargeAmount("");//到付费用?
|
|
|
consignmentXml.setIncludedTareGrossWeightMeasure(mawb.getGrossWeight()!=null?mawb.getGrossWeight().toString():"");
|
|
|
consignmentXml.setNetWeightMeasure("");//?
|
|
|
consignmentXml.setGrossVolumeMeasure(mawb.getCbm());
|
|
|
consignmentXml.setTotalChargeableWeightMeasure(mawb.getFeeWeight()!=null?mawb.getFeeWeight().toString():"");//是否是计费重量?
|
|
|
consignmentXml.setConsignmentItemQuantity("");//?
|
|
|
consignmentXml.setTotalPieceQuantity(mawb.getTotalPieces()!=null?mawb.getTotalPieces().toString():"");
|
|
|
consignmentXml.setTotalLoadedPackageQuantity("");//总SLAC件数?
|
|
|
consignmentXml.setPackageInfo(mawb.getPackingType());
|
|
|
consignmentXml.setFreightRateTypeCode(mawb.getFreightType());
|
|
|
|
|
|
//发货人信息
|
|
|
ConsignorPartyXml consignXml = new ConsignorPartyXml();
|
|
|
consignXml.setPrimaryID(mawb.getfCode());//内部ID
|
|
|
consignXml.setName(mawb.getfName());
|
|
|
consignXml.setAccountID(mawb.getAgentAccount());//银行账户从哪来?
|
|
|
PostalStructuredAddressXml addressXml = new PostalStructuredAddressXml();
|
|
|
addressXml.setStreetName(mawb.getfAddress());
|
|
|
addressXml.setCityName("");//街道从哪来?
|
|
|
addressXml.setCountryID("");//国家代码从哪来?
|
|
|
addressXml.setSpecifiedAddressLocation("");//?
|
|
|
consignXml.setPostalStructuredAddress(addressXml);
|
|
|
consignXml.setSpecifiedCargoAgentLocation("");//?
|
|
|
DirectTelephoneCommunicationXml directCommunicationXml = new DirectTelephoneCommunicationXml();
|
|
|
directCommunicationXml.setCompleteNumber("");//传真号从哪来?
|
|
|
consignXml.setDefinedTradeContact(directCommunicationXml);
|
|
|
consignmentXml.setConsignorParty(consignXml);
|
|
|
|
|
|
//收货人信息
|
|
|
ConsignorPartyXml consignXml1 = new ConsignorPartyXml();
|
|
|
consignXml1.setPrimaryID(mawb.getsCode());//内部ID
|
|
|
consignXml1.setName(mawb.getsName());
|
|
|
consignXml1.setAccountID(mawb.getAgentAccount());//银行账户从哪来?
|
|
|
PostalStructuredAddressXml addressXml1 = new PostalStructuredAddressXml();
|
|
|
addressXml1.setStreetName(mawb.getsAddress());
|
|
|
addressXml1.setCityName("");//街道从哪来?
|
|
|
addressXml1.setCountryID("");//国家代码从哪来?
|
|
|
addressXml1.setSpecifiedAddressLocation("");//?
|
|
|
consignXml1.setPostalStructuredAddress(addressXml1);
|
|
|
consignXml1.setSpecifiedCargoAgentLocation("");//?
|
|
|
DirectTelephoneCommunicationXml directCommunicationXml1 = new DirectTelephoneCommunicationXml();
|
|
|
directCommunicationXml1.setCompleteNumber("");//传真号从哪来?
|
|
|
consignXml1.setDefinedTradeContact(directCommunicationXml1);
|
|
|
consignmentXml.setConsigneeParty(consignXml1);
|
|
|
|
|
|
//填开代理人
|
|
|
ConsignorPartyXml consignXml2 = new ConsignorPartyXml();
|
|
|
consignXml2.setName(mawb.getFillOpenName());
|
|
|
consignXml2.setAccountID("");//填开代理人代码?
|
|
|
PostalStructuredAddressXml addressXml2 = new PostalStructuredAddressXml();
|
|
|
addressXml2.setCityName("");//城市?
|
|
|
addressXml2.setCountryID("");//国家代码从哪来?
|
|
|
addressXml2.setSpecifiedAddressLocation(mawb.getFillOpenAddress());
|
|
|
consignXml2.setPostalStructuredAddress(addressXml2);
|
|
|
consignmentXml.setFreightForwarderParty(consignXml2);
|
|
|
|
|
|
//相关参与方
|
|
|
AssociatedPartyXml associatedPartyXml = new AssociatedPartyXml();
|
|
|
associatedPartyXml.setPrimaryID("");//内部ID?
|
|
|
associatedPartyXml.setName("");//参与方名称?
|
|
|
associatedPartyXml.setAccountID("");//?
|
|
|
associatedPartyXml.setRoleCode("");//?
|
|
|
associatedPartyXml.setRole("");//参与方类型?
|
|
|
PostalStructuredAddressXml addressXml3 = new PostalStructuredAddressXml();
|
|
|
addressXml3.setCityName("");//城市?
|
|
|
addressXml3.setCountryID("");//国家代码?
|
|
|
addressXml3.setSpecifiedAddressLocation("");//?
|
|
|
associatedPartyXml.setPostalStructuredAddress(addressXml3);
|
|
|
consignmentXml.setAssociatedParty(associatedPartyXml);
|
|
|
|
|
|
IDXml idXml = new IDXml();
|
|
|
idXml.setId(mawb.getDepartureStation());
|
|
|
consignmentXml.setOriginLocation(idXml);
|
|
|
IDXml idXml1 = new IDXml();
|
|
|
idXml1.setId(mawb.getDestinationStation());
|
|
|
consignmentXml.setFinalDestinationLocation(idXml1);
|
|
|
|
|
|
//订舱单类信息
|
|
|
SpecifiedLogisticsTransportMovementXml transportMovementXml = new SpecifiedLogisticsTransportMovementXml();
|
|
|
transportMovementXml.setStageCode((StringUtils.isEmpty(mawb.getFlightOne())||StringUtils.isEmpty(mawb.getFlightTwo())?(mawb.getFlightOne()+mawb.getFlightTwo()):(mawb.getFlightOne()+"/"+mawb.getFlightTwo())));
|
|
|
transportMovementXml.setModeCode("");//运输代号?
|
|
|
transportMovementXml.setMode("");//运输模式?
|
|
|
transportMovementXml.setId("");//运输工具代号?
|
|
|
transportMovementXml.setSequenceNumeric("");//序号?
|
|
|
NameXml nameXml = new NameXml();
|
|
|
nameXml.setName("");//飞机号?
|
|
|
transportMovementXml.setUsedLogisticsTransportMeans(nameXml);
|
|
|
OccurrenceArrivalLocationXml arrivalLocationXml = new OccurrenceArrivalLocationXml();
|
|
|
IDXml idXml2 = new IDXml();
|
|
|
idXml2.setId(mawb.getDestinationOne()+ " " + mawb.getDestinationTwo() + " " + mawb.getDestinationThree());
|
|
|
arrivalLocationXml.setOccurrenceArrivalLocation(idXml2);
|
|
|
transportMovementXml.setArrivalEvent(arrivalLocationXml);
|
|
|
DepartureEventXml departureEventXml = new DepartureEventXml();
|
|
|
departureEventXml.setScheduledOccurrenceDateTime("");//计划起飞时间?
|
|
|
IDXml idXml3 = new IDXml();
|
|
|
idXml3.setId("");//出发站代码
|
|
|
departureEventXml.setOccurrenceDepartureLocation(idXml3);
|
|
|
transportMovementXml.setDepartureEvent(departureEventXml);
|
|
|
consignmentXml.setSpecifiedLogisticsTransportMovement(transportMovementXml);
|
|
|
|
|
|
//特殊处理
|
|
|
HandlingInstructionsXml handlingXml = new HandlingInstructionsXml();
|
|
|
handlingXml.setDescription("");//特殊处理描述?
|
|
|
handlingXml.setDescriptionCode("");//特殊处理代码?
|
|
|
consignmentXml.setHandlingInstructions(handlingXml);
|
|
|
|
|
|
ApplicableTradeCurrencyExchangeXml exchangeXml = new ApplicableTradeCurrencyExchangeXml();
|
|
|
exchangeXml.setSourceCurrencyCode("");//始发地货币种类?
|
|
|
exchangeXml.setTargetCurrencyCode("");//目的地货币种类?
|
|
|
exchangeXml.setMarketID("");//汇率代号?
|
|
|
exchangeXml.setConversionRate("");//汇率?
|
|
|
consignmentXml.setApplicableTradeCurrencyExchange(exchangeXml);
|
|
|
|
|
|
//其他费用
|
|
|
MawbOtherFeeEntity otherFee = otherFeeService.findByMawbId(mawb.getId());
|
|
|
ApplicableLogisticsAllowanceChargeXml allowanceChargeXml = new ApplicableLogisticsAllowanceChargeXml();
|
|
|
allowanceChargeXml.setId("");//费用代码?
|
|
|
allowanceChargeXml.setReason(otherFee.getFeeType());//费用描述
|
|
|
allowanceChargeXml.setActualAmount(otherFee.getFee() != null ? otherFee.getFee().toString() : "");
|
|
|
allowanceChargeXml.setPartyTypeCode("");//应付标识
|
|
|
consignmentXml.setApplicableLogisticsAllowanceCharge(allowanceChargeXml);
|
|
|
|
|
|
SignatoryCarrierAuthenticationXml signtoryXml = new SignatoryCarrierAuthenticationXml();
|
|
|
signtoryXml.setActualDateTime("");//航空公司声明日期?
|
|
|
signtoryXml.setSignatory("");//航空公司签名?
|
|
|
NameXml nameXml1 = new NameXml();
|
|
|
nameXml1.setName("");//航空公司声明地点?
|
|
|
signtoryXml.setIssueAuthenticationLocation(nameXml1);
|
|
|
consignmentXml.setSignatoryCarrierAuthentication(signtoryXml);
|
|
|
|
|
|
//货物信息
|
|
|
IncludedMasterConsignmentItemXml masterItemXml = new IncludedMasterConsignmentItemXml();
|
|
|
masterItemXml.setSequenceNumeric("1");//?
|
|
|
masterItemXml.setTypeCode(mawb.getGoodsCode());
|
|
|
masterItemXml.setGrossWeightMeasure(mawb.getGrossWeight() != null ? mawb.getGrossWeight().toString() : "");
|
|
|
masterItemXml.setGrossVolumeMeasure(mawb.getCbm());
|
|
|
masterItemXml.setPieceQuantity(mawb.getTotalPieces() != null ? mawb.getTotalPieces().toString() : "");
|
|
|
masterItemXml.setTareWeightMeasure(mawb.getWeightCharge() != null ? mawb.getWeightCharge().toString() : "");
|
|
|
NatureIdentificationTransportCargoXml cargoXml = new NatureIdentificationTransportCargoXml();
|
|
|
cargoXml.setIdentification(mawb.getGoodsName());
|
|
|
masterItemXml.setNatureIdentificationTransportCargo(cargoXml);
|
|
|
IDXml idXml4 = new IDXml();
|
|
|
idXml4.setId("");//始发地国家代码代码
|
|
|
masterItemXml.setOriginCountry(idXml4);
|
|
|
AssociatedUnitLoadTransportEquipmentXml equipmentXml = new AssociatedUnitLoadTransportEquipmentXml();
|
|
|
OperatingPartyXml operatingPartyXml = new OperatingPartyXml();
|
|
|
operatingPartyXml.setPrimaryID("");//ULD所属公司代码
|
|
|
equipmentXml.setOperatingParty(operatingPartyXml);
|
|
|
masterItemXml.setAssociatedUnitLoadTransportEquipment(equipmentXml);
|
|
|
|
|
|
TransportLogisticsPackageXml packageXml = new TransportLogisticsPackageXml();
|
|
|
packageXml.setItemQuantity("");//?
|
|
|
LinearSpatialDimensionXml dimensionXml = new LinearSpatialDimensionXml();
|
|
|
dimensionXml.setDescription(mawb.getPackingDimensions());
|
|
|
dimensionXml.setLengthMeasure("");//长?
|
|
|
dimensionXml.setWidthMeasure("");//宽?
|
|
|
dimensionXml.setHeightMeasure("");//高?
|
|
|
packageXml.setLinearSpatialDimension(dimensionXml);
|
|
|
masterItemXml.setTransportLogisticsPackage(packageXml);
|
|
|
|
|
|
//运价
|
|
|
ApplicableFreightRateServiceChargeXml chargeXml = new ApplicableFreightRateServiceChargeXml();
|
|
|
chargeXml.setCategoryCode(mawb.getFreightType());
|
|
|
chargeXml.setCommodityItemID(mawb.getGoodsCode());
|
|
|
chargeXml.setChargeableWeightMeasure(mawb.getWeightCharge()!=null?mawb.getFeeWeight().toString():"");
|
|
|
chargeXml.setAppliedRate(mawb.getRate()!=null?mawb.getRate().toString():"");
|
|
|
chargeXml.setAppliedAmount(mawb.getWeightCharge()!=null?mawb.getWeightCharge().toString():"");
|
|
|
masterItemXml.setApplicableFreightRateServiceCharge(chargeXml);
|
|
|
consignmentXml.setIncludedMasterConsignmentItem(masterItemXml);
|
|
|
|
|
|
ReportedStatusXml reportedStatusXml = new ReportedStatusXml();
|
|
|
reportedStatusXml.setReasonCode("");//?
|
|
|
EventTimeXml eventTimeXml = new EventTimeXml();
|
|
|
eventTimeXml.setDateTimeTypeCode("");//?
|
|
|
eventTimeXml.setOccurrenceDateTime("");//?
|
|
|
reportedStatusXml.setEventTime(eventTimeXml);
|
|
|
IDXml idXml5 = new IDXml();
|
|
|
idXml5.setId("");//?
|
|
|
reportedStatusXml.setSpecifiedLocation(idXml5);
|
|
|
consignmentXml.setReportedStatus(reportedStatusXml);
|
|
|
body.setMasterConsignment(consignmentXml);
|
|
|
|
|
|
String xml = XmlUtil.convertToXml2(body, path);
|
|
|
return xml;
|
|
|
}
|
|
|
} |
...
|
...
|
|