作者 shenhailong

excel 导入 主单模七校验 添加针对主单操作工具类

... ... @@ -3,11 +3,13 @@ package com.agent.controller.agent;
import com.agent.controller.BasicController;
import com.agent.entity.Constant;
import com.agent.entity.agent.*;
import com.agent.entity.system.PermissionEntity;
import com.agent.entity.system.UserEntity;
import com.agent.service.agent.*;
import com.agent.service.system.*;
import com.agent.util.ExcelUtil;
import com.agent.util.HttpJsonMsg;
import com.agent.util.WaybillUtils;
import com.agent.vo.ResponseModel;
import com.agent.vo.agent.CommodityVo;
import com.agent.vo.agent.ManifestVo;
... ... @@ -27,10 +29,10 @@ import com.plugin.easyui.DataGrid;
import com.plugin.easyui.EasyPage;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -44,7 +46,6 @@ import tools.Tools;
import tools.oclass.FemyList;
import javax.annotation.Resource;
import javax.jnlp.PersistenceService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
... ... @@ -53,7 +54,6 @@ import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
... ... @@ -2469,6 +2469,311 @@ public class ManifestController extends BasicController {
* excel 导入
* @return
*/
// @RequestMapping(value = "/excelView")
// public String excelView(){
// return "manifest/excel_upload";
// }
//
// @RequestMapping(value = "/excelUpload")
// @ResponseBody
// public ResponseModel excelUpload(HttpServletRequest request,
// HttpServletResponse response,
// HttpSession session,
// @RequestParam MultipartFile file) throws IOException {
// ResponseModel model = new ResponseModel();
//
// //获取当前登录用户id
// UserEntity user = (UserEntity) session.getAttribute("user");
// Long userId = user.getId();
//
// List<ArrayList<String>> readResult = null;//总行记录
// try {
//
// //判断文件是否为空
// if (file.isEmpty()) {
// model.setStatus(500);
// model.setMsg("上传文件为空");
// }
// //判断文件大小
// long size = file.getSize();
// String name = file.getOriginalFilename();
// if (StringUtils.isBlank(name) || size == 0) {
// model.setStatus(500);
// model.setMsg("上传文件为空");
// }
// String postfix = ExcelUtil.getPostfix(name);
// //读取文件内容
// if (StringUtils.equals("xlsx", postfix)) {
// readResult = ExcelUtil.readXlsx(file);
// } else if (StringUtils.equals("xls", postfix)) {
// readResult = ExcelUtil.readXls(file);
// } else {
// model.setStatus(500);
// model.setMsg("文件类型错误");
// }
//
// if (readResult == null || readResult.size() == 0) {
// model.setStatus(500);
// model.setMsg("文件解析失败");
// }
//
//
// for (ArrayList<String> arr: readResult) {
// String wbm = "";
//
// if (!StringUtils.isBlank(arr.get(1)) && arr.get(1).length()== 12) {
//
// if (arr.get(1).contains("-")) {
// wbm = arr.get(1);
// } else {
// String s1 = arr.get(1);
// String substring = s1.substring(0, 3);
// String substring1 = s1.substring(3);
// wbm = substring + "-" + substring1;
// }
// // 如果分单不为空
// if (StringUtils.isBlank(arr.get(2))) {
// // 查询主单号是否存在
// ManifestEntity wbm1 = manifestService.findWbm(wbm);
// if (wbm1 == null) {
// ManifestEntity manifestEntity = new ManifestEntity();
// manifestEntity.setUSER_ID(userId);
// // 主单号
// manifestEntity.setWaybillnomaster(wbm);
// // 航班号
// manifestEntity.setFlightno(arr.get(3).substring(2));
// // 航班日期
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
// String s = arr.get(4);
// Date parse = simpleDateFormat.parse(s);
// manifestEntity.setFlightdate(parse);
// // 承运人代码
// manifestEntity.setCarrier(arr.get(3).substring(0, 2));
// // 运费支付方式
// manifestEntity.setPaymode(arr.get(5));
// // 装货地代码
// manifestEntity.setOriginatingstation(arr.get(6));
// // 卸货地代码
// manifestEntity.setDestinationstation(arr.get(7));
// // 货物装载运输时间
// manifestEntity.setStowagedate(new Date());
// // 海关关区代码
// manifestEntity.setCustomscode(arr.get(9));
// // 货物件数
// manifestEntity.setTotalpiece(arr.get(10));
// // 货物毛重
// manifestEntity.setTotalweight(arr.get(11));
// // 货物简要描述
// manifestEntity.setProductname(arr.get(12));
// // 发货人代码
// manifestEntity.setShpcusid(arr.get(13));
// // 发货人公司
// manifestEntity.setCo_company(arr.get(14));
// // 发货人地址
// manifestEntity.setCo_address(arr.get(15));
// // 发货人国家代码
// manifestEntity.setSh_country(arr.get(16));
// // 发货人传真
// manifestEntity.setSh_fax(arr.get(17));
// // 发货人联系号码
// manifestEntity.setCo_telephone(arr.get(18));
// // 收货人代码
// manifestEntity.setCnecusid(arr.get(19));
// // 收货人公司
// manifestEntity.setSh_company(arr.get(20));
// // 收货人地址
// manifestEntity.setSh_address(arr.get(21));
// // 收货人城市
// manifestEntity.setSh_city(arr.get(22));
// // 收货人国家代码
// manifestEntity.setSh_country(arr.get(23));
// // 收货人传真
// manifestEntity.setSh_fax(arr.get(24));
// // 收货人联系号码
// manifestEntity.setSh_telephone(arr.get(25));
//
// // 货物海关状态代码
// manifestEntity.setCustomsstatus(arr.get(26));
//
// // 安检申报
//
// if (StringUtils.isNotBlank(arr.get(27)) && StringUtils.isNotBlank(arr.get(28)) && StringUtils.isNotBlank(arr.get(29))
// && StringUtils.isNotBlank(arr.get(32)) && StringUtils.isNotBlank(arr.get(33))){
// SecurityDeclarationEntity sd = new SecurityDeclarationEntity();
// sd.setSd_waybill(wbm);
// // 航空货物托运人名称
// sd.setSd_cargo_shipper_name(arr.get(27));
// // 航空货物销售代理人名称
// sd.setSd_cargo_agent_name(arr.get(28));
// // 航协资质编号
// if (!StringUtils.isBlank(arr.get(29))) {
// sd.setSd_iata_number(arr.get(29));
// }
//
// sd.setSd_static("1");
// // 发布时间
// SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// String format = simpleDateFormat2.format(new Date());
// sd.setOperation_time(format);
//
// // 运输条件鉴定书
// if (!StringUtils.isBlank(arr.get(30))) {
//
// String certificate = arr.get(30);
// if (certificate != null) {
// String s2 = certificate.replaceAll(",", ",");
// sd.setSd_transport_certificate(s2);
// }
// }
//
// // 航空公司同意运输证明
// if (!StringUtils.isBlank(arr.get(31))) {
//
// String prove = arr.get(31);
// if (prove != null) {
// String s2 = prove.replaceAll(",", ",");
// sd.setSd_transportation_prove(s2);
// }
// }
//
// // 用户ID
// sd.setUSER_ID(userId);
//
// // 航空货物性质
// SDCargoTypeEntity sdCargoTypeEntity = new SDCargoTypeEntity();
// sdCargoTypeEntity.setSd_waybill(wbm);
// sdCargoTypeEntity.setSd_cargo_type(arr.get(32));
// sdCargoTypeService.save(sdCargoTypeEntity);
//
// // 航空货物品名
// String replace = arr.get(33).replace(",", ",");
//
// String[] cargoName = replace.split(",");
// for (int i = 0; i < cargoName.length; i++) {
// SDCargoNameEntity sdCargoNameEntity = new SDCargoNameEntity();
// sdCargoNameEntity.setSd_waybill(wbm);
// sdCargoNameEntity.setSd_cargo_name(cargoName[i]);
// sdCargoNameService.save(sdCargoNameEntity);
// }
// securityDeclarationService.save(sd);
// }
//
//
// manifestService.save(manifestEntity);
//
// model.setStatus(200);
//
// }else {
// model.setStatus(201);
// model.setMsg(wbm1.getWaybillnomaster() + "单号已存在");
// break;
// }
// }else {
//
// ManifestEntity wbm1 = manifestService.findWbm(wbm);
// if(wbm1 == null){
//
// model.setStatus(202);
// model.setMsg("请先添加主单号");
// break;
// }else {
// String waybill = preparesecondaryServer.findWaybill(arr.get(2));
//
// if (waybill != arr.get(2)) {
//
// PreparesecondaryEntity seconday = new PreparesecondaryEntity();
// seconday.setPreparemasterid(wbm1.getId());
// // 主单号
// seconday.setWaybillnomaster(wbm);
// // 分单号
// seconday.setWaybillnosecondary(arr.get(2));
// // 航班号
// seconday.setFlightno(arr.get(3).substring(2));
// // 航班日期
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
// String s = arr.get(4);
// Date parse = simpleDateFormat.parse(s);
// seconday.setFlightdate(parse);
// // 承运人代码
// seconday.setCarrier(arr.get(3).substring(0, 2));
// // 运费支付方式
// seconday.setPaymode(arr.get(5));
// // 装货地代码
// seconday.setOriginatingstation(arr.get(6));
// // 卸货地代码
// seconday.setDestinationstation(arr.get(7));
// // 货物装载运输时间
// SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss");
// seconday.setStowagedate(simpleDateFormat1.parse(arr.get(8)));
// // 海关关区代码
// seconday.setCustomscode(arr.get(9));
// // 货物件数
//// String s3 = arr.get(11);
// seconday.setTotalpiece(arr.get(10));
// // 货物毛重
//// String s1 = arr.get(12);
// seconday.setTotalweight(arr.get(11));
// // 货物简要描述
// seconday.setProductname(arr.get(12));
// // 发货人代码
// seconday.setShpcusid(arr.get(13));
// // 发货人公司
// seconday.setCo_company(arr.get(14));
// // 发货人地址
// seconday.setCo_address(arr.get(15));
// // 发货人国家代码
// seconday.setSh_country(arr.get(16));
// // 发货人传真
// seconday.setSh_fax(arr.get(17));
// // 发货人联系号码
// seconday.setCo_telephone(arr.get(18));
// // 收货人代码
// seconday.setCnecusid(arr.get(19));
// // 收货人公司
// seconday.setSh_company(arr.get(20));
// // 收货人地址
// seconday.setSh_address(arr.get(21));
// // 收货人城市
// seconday.setSh_city(arr.get(22));
// // 收货人国家代码
// seconday.setSh_country(arr.get(23));
// // 收货人传真
// seconday.setSh_fax(arr.get(24));
// // 收货人联系号码
// seconday.setSh_telephone(arr.get(25));
//
// // 货物海关状态代码
// seconday.setCustomsstatus(arr.get(26));
// seconday.setCreateDate(new Date());
// preparesecondaryServer.save(seconday);
// model.setStatus(200);
// } else {
// model.setStatus(201);
// model.setMsg(waybill + "分单号已存在");
// break;
// }
// }
// }
// }else {
//
// model.setStatus(300);
// model.setMsg("主单号格式有误");
// break;
// }
// }
// return model;
// } catch (Exception e) {
// model.setStatus(500);
// model.setMsg("格式有误");
// e.printStackTrace();
// }
// return model;
// }
/**
* excel 导入
* @return
*/
@RequestMapping(value = "/excelView")
public String excelView(){
return "manifest/excel_upload";
... ... @@ -2477,15 +2782,16 @@ public class ManifestController extends BasicController {
@RequestMapping(value = "/excelUpload")
@ResponseBody
public ResponseModel excelUpload(HttpServletRequest request,
HttpServletResponse response,
HttpSession session,
@RequestParam MultipartFile file) throws IOException {
HttpServletResponse response,
HttpSession session,
@RequestParam MultipartFile file) throws IOException {
ResponseModel model = new ResponseModel();
//获取当前登录用户id
UserEntity user = (UserEntity) session.getAttribute("user");
Long userId = user.getId();
UserEntity user = (UserEntity) session.getAttribute("user");
Long userId = user.getId();
List<ArrayList<String>> readResult = null;//总行记录
List<ArrayList<String>> readResult = null;//总行记录
try {
//判断文件是否为空
... ... @@ -2500,270 +2806,247 @@ public class ManifestController extends BasicController {
model.setStatus(500);
model.setMsg("上传文件为空");
}
String postfix = ExcelUtil.getPostfix(name);
//读取文件内容
if (StringUtils.equals("xlsx", postfix)) {
readResult = ExcelUtil.readXlsx(file);
} else if (StringUtils.equals("xls", postfix)) {
readResult = ExcelUtil.readXls(file);
} else {
model.setStatus(500);
model.setMsg("文件类型错误");
}
if (readResult == null || readResult.size() == 0) {
model.setStatus(500);
model.setMsg("文件解析失败");
}
for (ArrayList<String> arr: readResult) {
String postfix = ExcelUtil.getPostfix(name);
//读取文件内容
if (StringUtils.equals("xlsx", postfix)) {
readResult = ExcelUtil.readXlsx(file);
} else if (StringUtils.equals("xls", postfix)) {
readResult = ExcelUtil.readXls(file);
} else {
model.setStatus(500);
model.setMsg("文件类型错误");
}
if (readResult == null || readResult.size() == 0) {
model.setStatus(500);
model.setMsg("文件解析失败");
}
for (ArrayList<String> arr: readResult) {
String wbm = "";
if (!StringUtils.isBlank(arr.get(1))) {
if (arr.get(1).contains("-")) {
wbm = arr.get(1);
} else {
String s1 = arr.get(1);
String substring = s1.substring(0, 3);
String substring1 = s1.substring(3);
wbm = substring + "-" + substring1;
}
// 如果分单不为空
if (StringUtils.isBlank(arr.get(2))) {
// 查询主单号是否存在
ManifestEntity wbm1 = manifestService.findWbm(wbm);
if (wbm1 == null) {
ManifestEntity manifestEntity = new ManifestEntity();
manifestEntity.setUSER_ID(userId);
// 主单号
manifestEntity.setWaybillnomaster(wbm);
// 航班号
manifestEntity.setFlightno(arr.get(3).substring(2));
// 航班日期
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
String s = arr.get(4);
Date parse = simpleDateFormat.parse(s);
manifestEntity.setFlightdate(parse);
// 承运人代码
manifestEntity.setCarrier(arr.get(3).substring(0, 2));
// 运费支付方式
manifestEntity.setPaymode(arr.get(5));
// 装货地代码
manifestEntity.setOriginatingstation(arr.get(6));
// 卸货地代码
manifestEntity.setDestinationstation(arr.get(7));
// 货物装载运输时间
manifestEntity.setStowagedate(new Date());
// 海关关区代码
manifestEntity.setCustomscode(arr.get(9));
// 货物件数
manifestEntity.setTotalpiece(arr.get(10));
// 货物毛重
manifestEntity.setTotalweight(arr.get(11));
// 货物简要描述
manifestEntity.setProductname(arr.get(12));
// 发货人代码
manifestEntity.setShpcusid(arr.get(13));
// 发货人公司
manifestEntity.setCo_company(arr.get(14));
// 发货人地址
manifestEntity.setCo_address(arr.get(15));
// 发货人国家代码
manifestEntity.setSh_country(arr.get(16));
// 发货人传真
manifestEntity.setSh_fax(arr.get(17));
// 发货人联系号码
manifestEntity.setCo_telephone(arr.get(18));
// 收货人代码
manifestEntity.setCnecusid(arr.get(19));
// 收货人公司
manifestEntity.setSh_company(arr.get(20));
// 收货人地址
manifestEntity.setSh_address(arr.get(21));
// 收货人城市
manifestEntity.setSh_city(arr.get(22));
// 收货人国家代码
manifestEntity.setSh_country(arr.get(23));
// 收货人传真
manifestEntity.setSh_fax(arr.get(24));
// 收货人联系号码
manifestEntity.setSh_telephone(arr.get(25));
// 货物海关状态代码
manifestEntity.setCustomsstatus(arr.get(26));
// 安检申报
if (StringUtils.isNotBlank(arr.get(27)) && StringUtils.isNotBlank(arr.get(28)) && StringUtils.isNotBlank(arr.get(29))
&& StringUtils.isNotBlank(arr.get(32)) && StringUtils.isNotBlank(arr.get(33))){
SecurityDeclarationEntity sd = new SecurityDeclarationEntity();
sd.setSd_waybill(wbm);
// 航空货物托运人名称
sd.setSd_cargo_shipper_name(arr.get(27));
// 航空货物销售代理人名称
sd.setSd_cargo_agent_name(arr.get(28));
// 航协资质编号
if (!StringUtils.isBlank(arr.get(29))) {
sd.setSd_iata_number(arr.get(29));
}
sd.setSd_static("1");
// 发布时间
SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = simpleDateFormat2.format(new Date());
sd.setOperation_time(format);
// 运输条件鉴定书
if (!StringUtils.isBlank(arr.get(30))) {
String certificate = arr.get(30);
if (certificate != null) {
String s2 = certificate.replaceAll(",", ",");
sd.setSd_transport_certificate(s2);
}
}
// 航空公司同意运输证明
if (!StringUtils.isBlank(arr.get(31))) {
String prove = arr.get(31);
if (prove != null) {
String s2 = prove.replaceAll(",", ",");
sd.setSd_transportation_prove(s2);
}
}
// 用户ID
sd.setUSER_ID(userId);
// 航空货物性质
SDCargoTypeEntity sdCargoTypeEntity = new SDCargoTypeEntity();
sdCargoTypeEntity.setSd_waybill(wbm);
sdCargoTypeEntity.setSd_cargo_type(arr.get(32));
sdCargoTypeService.save(sdCargoTypeEntity);
// 航空货物品名
String replace = arr.get(33).replace(",", ",");
String[] cargoName = replace.split(",");
for (int i = 0; i < cargoName.length; i++) {
SDCargoNameEntity sdCargoNameEntity = new SDCargoNameEntity();
sdCargoNameEntity.setSd_waybill(wbm);
sdCargoNameEntity.setSd_cargo_name(cargoName[i]);
sdCargoNameService.save(sdCargoNameEntity);
}
securityDeclarationService.save(sd);
}
manifestService.save(manifestEntity);
model.setStatus(200);
}else {
model.setStatus(201);
model.setMsg(wbm1.getWaybillnomaster() + "单号已存在");
break;
}
}else {
ManifestEntity wbm1 = manifestService.findWbm(wbm);
if(wbm1 == null){
model.setStatus(202);
model.setMsg("请先添加主单号");
break;
}else {
String waybill = preparesecondaryServer.findWaybill(arr.get(2));
if (waybill != arr.get(2)) {
PreparesecondaryEntity seconday = new PreparesecondaryEntity();
seconday.setPreparemasterid(wbm1.getId());
// 判断非空 长度是否符合
if (!StringUtils.isBlank(arr.get(1)) && arr.get(1).length()== 12) {
WaybillUtils waybillUtils = new WaybillUtils();
wbm = waybillUtils.awb(arr.get(1));
// 是否符合摸七校验
if (waybillUtils.checkout(wbm)){
// 如果分单不为空
if (StringUtils.isBlank(arr.get(2))) {
// 查询主单号是否存在
ManifestEntity wbm1 = manifestService.findWbm(wbm);
if (wbm1 == null) {
ManifestEntity manifestEntity = new ManifestEntity();
manifestEntity.setUSER_ID(userId);
// 主单号
seconday.setWaybillnomaster(wbm);
// 分单号
seconday.setWaybillnosecondary(arr.get(2));
manifestEntity.setWaybillnomaster(wbm);
// 航班号
seconday.setFlightno(arr.get(3).substring(2));
manifestEntity.setFlightno(arr.get(3).substring(2));
// 航班日期
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
String s = arr.get(4);
Date parse = simpleDateFormat.parse(s);
seconday.setFlightdate(parse);
manifestEntity.setFlightdate(parse);
// 承运人代码
seconday.setCarrier(arr.get(3).substring(0, 2));
manifestEntity.setCarrier(arr.get(3).substring(0, 2));
// 运费支付方式
seconday.setPaymode(arr.get(5));
manifestEntity.setPaymode(arr.get(5));
// 装货地代码
seconday.setOriginatingstation(arr.get(6));
manifestEntity.setOriginatingstation(arr.get(6));
// 卸货地代码
seconday.setDestinationstation(arr.get(7));
manifestEntity.setDestinationstation(arr.get(7));
// 货物装载运输时间
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss");
seconday.setStowagedate(simpleDateFormat1.parse(arr.get(8)));
manifestEntity.setStowagedate(new Date());
// 海关关区代码
seconday.setCustomscode(arr.get(9));
manifestEntity.setCustomscode(arr.get(9));
// 货物件数
// String s3 = arr.get(11);
seconday.setTotalpiece(arr.get(10));
manifestEntity.setTotalpiece(arr.get(10));
// 货物毛重
// String s1 = arr.get(12);
seconday.setTotalweight(arr.get(11));
manifestEntity.setTotalweight(arr.get(11));
// 货物简要描述
seconday.setProductname(arr.get(12));
manifestEntity.setProductname(arr.get(12));
// 发货人代码
seconday.setShpcusid(arr.get(13));
manifestEntity.setShpcusid(arr.get(13));
// 发货人公司
seconday.setCo_company(arr.get(14));
manifestEntity.setCo_company(arr.get(14));
// 发货人地址
seconday.setCo_address(arr.get(15));
manifestEntity.setCo_address(arr.get(15));
// 发货人国家代码
seconday.setSh_country(arr.get(16));
manifestEntity.setSh_country(arr.get(16));
// 发货人传真
seconday.setSh_fax(arr.get(17));
manifestEntity.setSh_fax(arr.get(17));
// 发货人联系号码
seconday.setCo_telephone(arr.get(18));
manifestEntity.setCo_telephone(arr.get(18));
// 收货人代码
seconday.setCnecusid(arr.get(19));
manifestEntity.setCnecusid(arr.get(19));
// 收货人公司
seconday.setSh_company(arr.get(20));
manifestEntity.setSh_company(arr.get(20));
// 收货人地址
seconday.setSh_address(arr.get(21));
manifestEntity.setSh_address(arr.get(21));
// 收货人城市
seconday.setSh_city(arr.get(22));
manifestEntity.setSh_city(arr.get(22));
// 收货人国家代码
seconday.setSh_country(arr.get(23));
manifestEntity.setSh_country(arr.get(23));
// 收货人传真
seconday.setSh_fax(arr.get(24));
manifestEntity.setSh_fax(arr.get(24));
// 收货人联系号码
seconday.setSh_telephone(arr.get(25));
manifestEntity.setSh_telephone(arr.get(25));
// 货物海关状态代码
seconday.setCustomsstatus(arr.get(26));
seconday.setCreateDate(new Date());
preparesecondaryServer.save(seconday);
model.setStatus(200);
} else {
manifestEntity.setCustomsstatus(arr.get(26));
// 安检申报
if (StringUtils.isNotBlank(arr.get(27)) && StringUtils.isNotBlank(arr.get(28)) && StringUtils.isNotBlank(arr.get(29))
&& StringUtils.isNotBlank(arr.get(32)) && StringUtils.isNotBlank(arr.get(33))){
SecurityDeclarationEntity sd = new SecurityDeclarationEntity();
sd.setSd_waybill(wbm);
// 航空货物托运人名称
sd.setSd_cargo_shipper_name(arr.get(27));
// 航空货物销售代理人名称
sd.setSd_cargo_agent_name(arr.get(28));
// 航协资质编号
if (!StringUtils.isBlank(arr.get(29))) {
sd.setSd_iata_number(arr.get(29));
}
sd.setSd_static("1");
// 发布时间
SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = simpleDateFormat2.format(new Date());
sd.setOperation_time(format);
// 运输条件鉴定书
if (!StringUtils.isBlank(arr.get(30))) {
String certificate = arr.get(30);
if (certificate != null) {
String s2 = certificate.replaceAll(",", ",");
sd.setSd_transport_certificate(s2);
}
}
// 航空公司同意运输证明
if (!StringUtils.isBlank(arr.get(31))) {
String prove = arr.get(31);
if (prove != null) {
String s2 = prove.replaceAll(",", ",");
sd.setSd_transportation_prove(s2);
}
}
// 用户ID
sd.setUSER_ID(userId);
// 航空货物性质
SDCargoTypeEntity sdCargoTypeEntity = new SDCargoTypeEntity();
sdCargoTypeEntity.setSd_waybill(wbm);
sdCargoTypeEntity.setSd_cargo_type(arr.get(32));
sdCargoTypeService.save(sdCargoTypeEntity);
// 航空货物品名
String replace = arr.get(33).replace(",", ",");
String[] cargoName = replace.split(",");
for (int i = 0; i < cargoName.length; i++) {
SDCargoNameEntity sdCargoNameEntity = new SDCargoNameEntity();
sdCargoNameEntity.setSd_waybill(wbm);
sdCargoNameEntity.setSd_cargo_name(cargoName[i]);
sdCargoNameService.save(sdCargoNameEntity);
}
securityDeclarationService.save(sd);
}
manifestService.save(manifestEntity);
}else {
model.setStatus(201);
model.setMsg(waybill + "分单号已存在");
break;
model.setMsg(wbm1.getWaybillnomaster() + "单号已存在");
return model;
}
}else {
ManifestEntity wbm1 = manifestService.findWbm(wbm);
if(wbm1 == null){
model.setStatus(202);
model.setMsg(wbm+"请先添加主单号");
return model;
}else {
if (preparesecondaryServer.findWaybill(arr.get(2))==0) {
PreparesecondaryEntity seconday = new PreparesecondaryEntity();
seconday.setPreparemasterid(wbm1.getId());
// 主单号
seconday.setWaybillnomaster(wbm);
// 分单号
seconday.setWaybillnosecondary(arr.get(2));
// 航班号
seconday.setFlightno(arr.get(3).substring(2));
// 航班日期
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
String s = arr.get(4);
Date parse = simpleDateFormat.parse(s);
seconday.setFlightdate(parse);
// 承运人代码
seconday.setCarrier(arr.get(3).substring(0, 2));
// 运费支付方式
seconday.setPaymode(arr.get(5));
// 装货地代码
seconday.setOriginatingstation(arr.get(6));
// 卸货地代码
seconday.setDestinationstation(arr.get(7));
// 货物装载运输时间
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss");
seconday.setStowagedate(simpleDateFormat1.parse(arr.get(8)));
// 海关关区代码
seconday.setCustomscode(arr.get(9));
// 货物件数
seconday.setTotalpiece(arr.get(10));
// 货物毛重
seconday.setTotalweight(arr.get(11));
// 货物简要描述
seconday.setProductname(arr.get(12));
// 发货人代码
seconday.setShpcusid(arr.get(13));
// 发货人公司
seconday.setCo_company(arr.get(14));
// 发货人地址
seconday.setCo_address(arr.get(15));
// 发货人国家代码
seconday.setSh_country(arr.get(16));
// 发货人传真
seconday.setSh_fax(arr.get(17));
// 发货人联系号码
seconday.setCo_telephone(arr.get(18));
// 收货人代码
seconday.setCnecusid(arr.get(19));
// 收货人公司
seconday.setSh_company(arr.get(20));
// 收货人地址
seconday.setSh_address(arr.get(21));
// 收货人城市
seconday.setSh_city(arr.get(22));
// 收货人国家代码
seconday.setSh_country(arr.get(23));
// 收货人传真
seconday.setSh_fax(arr.get(24));
// 收货人联系号码
seconday.setSh_telephone(arr.get(25));
// 货物海关状态代码
seconday.setCustomsstatus(arr.get(26));
seconday.setCreateDate(new Date());
preparesecondaryServer.save(seconday);
} else {
model.setStatus(201);
model.setMsg(arr.get(2) + "分单号已存在");
return model;
}
}
}
}
}else {
break;
}
}
}else {
model.setStatus(301);
model.setMsg(wbm+"不符合模七校验");
return model;
}
}else {
model.setStatus(300);
model.setMsg("主单号格式有误");
return model;
}
}
model.setStatus(200);
return model;
} catch (Exception e) {
} catch (Exception e) {
model.setStatus(500);
model.setMsg("网络异常");
model.setMsg(e.getMessage());
e.printStackTrace();
}
return model;
return model;
}
}
... ...
... ... @@ -44,8 +44,8 @@ JpaSpecificationExecutor<PreparesecondaryEntity>{
@Query(value = "DELETE FROM PREPARESECONDARY WHERE PREPAREMASTERID = ?1", nativeQuery = true)
void deleteSub(Long id);
@Query(value = "SELECT WAYBILLNOSECONDARY FROM PREPARESECONDARY WHERE WAYBILLNOMASTER = ?1", nativeQuery = true)
String findWaybill(String wbm);
@Query(value = "SELECT count(*) FROM PREPARESECONDARY WHERE WAYBILLNOSECONDARY = ?1", nativeQuery = true)
int findWaybill(String wbm);
@Query(value = "select count(id) from PREPARESECONDARY where WAYBILLNOMASTER = ?1 and WAYBILLNOSECONDARY=?2", nativeQuery = true)
int findAwbAwbH(String awb, String awbh);
... ...
... ... @@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @Auther: shenhl
* @Date: 2019/4/24 16:38
... ... @@ -25,6 +27,6 @@ public interface SecurityDeclarationRepository extends PagingAndSortingRepositor
int findWaybill(String waybill);
@Query(value = "select * from SECURITY_DECLARATION where SD_WAYBILL = ?1", nativeQuery = true)
SecurityDeclarationEntity waybill(String waybill);
List<SecurityDeclarationEntity> waybill(String waybill);
}
... ...
... ... @@ -225,9 +225,13 @@ public class ManifestService extends BasicService<ManifestEntity> {
manifestEntity.setId(Long.valueOf(id));
manifestRepository.delete(manifestEntity);
//查看是否有安检申报 存在删除
SecurityDeclarationEntity waybill1 = securityDeclarationRepository.waybill(waybillnomaster);
List<SecurityDeclarationEntity> waybill1 = securityDeclarationRepository.waybill(waybillnomaster);
if (waybill1 != null){
securityDeclarationRepository.delete(waybill1.getId());
for (SecurityDeclarationEntity securityDeclarationEntity: waybill1){
securityDeclarationRepository.delete(securityDeclarationEntity.getId());
}
}
sdCargoNameRepository.deletes(waybillnomaster);
... ...
... ... @@ -96,9 +96,10 @@ public class PreparesecondaryService extends BasicService<PreparesecondaryEntity
return preparesecondaryRepository.queryByUserId(user_id);
}
public String findWaybill(String wbm){
public int findWaybill(String wbm){
int waybill = preparesecondaryRepository.findWaybill(wbm);
return preparesecondaryRepository.findWaybill(wbm);
return waybill;
}
... ...
package com.agent.util;
public class WaybillUtils {
// 主单添加 - 符号
public String awb(String waybill){
String awb = "";
if (waybill.contains("-")) {
awb = waybill;
} else {
String s1 = waybill;
String substring = s1.substring(0, 3);
String substring1 = s1.substring(3);
awb = substring + "-" + substring1;
}
return awb;
}
// 判断是否符合模七校验
public boolean checkout(String waybill){
String[] split = waybill.split("-");
int number = Integer.parseInt(split[1]);
int start = number/10;
int remainder = start % 7;
int last = number % 10;
if (remainder!=last){
return false;
}else {
return true;
}
}
}
... ...
... ... @@ -86,8 +86,12 @@
alert(data.msg);
}else if(data.status == 202){
alert(data.msg);
}else if (data.status == 300){
alert(data.msg);
}else if (data.status == 301){
alert(data.msg);
}else {
alert("网络异常");
alert(data.msg);
}
}
});
... ...
... ... @@ -238,8 +238,8 @@
}
//主单撤销按钮
function operatorFormat(val, row, index){
var html = "<a href='javascript:void(0)' onclick='backout("+row.id+")' style='text-decoration:none;color:blue;'><spring:message code='opt.backout'/></a>";
html+="<a href='javascript:void(0)' onclick='openReceipt(\""+row.waybillnomaster+"\")' style='text-decoration:none;color:blue;margin-left:20px;'><spring:message code='opt.open.receipt'/></a>";
<%--var html = "<a href='javascript:void(0)' onclick='backout("+row.id+")' style='text-decoration:none;color:blue;'><spring:message code='opt.backout'/></a>";--%>
var html ="<a href='javascript:void(0)' onclick='openReceipt(\""+row.waybillnomaster+"\")' style='text-decoration:none;color:blue;margin-left:20px;'><spring:message code='opt.open.receipt'/></a>";
html+="<a href='javascript:void(0)' onclick='security(\""+row.waybillnomaster+"\")' style='text-decoration:none;color:blue;margin-left:20px;'>添加安检申报</a>"
return html;
}
... ...