作者 shenhailong

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

@@ -3,11 +3,13 @@ package com.agent.controller.agent; @@ -3,11 +3,13 @@ package com.agent.controller.agent;
3 import com.agent.controller.BasicController; 3 import com.agent.controller.BasicController;
4 import com.agent.entity.Constant; 4 import com.agent.entity.Constant;
5 import com.agent.entity.agent.*; 5 import com.agent.entity.agent.*;
  6 +import com.agent.entity.system.PermissionEntity;
6 import com.agent.entity.system.UserEntity; 7 import com.agent.entity.system.UserEntity;
7 import com.agent.service.agent.*; 8 import com.agent.service.agent.*;
8 import com.agent.service.system.*; 9 import com.agent.service.system.*;
9 import com.agent.util.ExcelUtil; 10 import com.agent.util.ExcelUtil;
10 import com.agent.util.HttpJsonMsg; 11 import com.agent.util.HttpJsonMsg;
  12 +import com.agent.util.WaybillUtils;
11 import com.agent.vo.ResponseModel; 13 import com.agent.vo.ResponseModel;
12 import com.agent.vo.agent.CommodityVo; 14 import com.agent.vo.agent.CommodityVo;
13 import com.agent.vo.agent.ManifestVo; 15 import com.agent.vo.agent.ManifestVo;
@@ -27,10 +29,10 @@ import com.plugin.easyui.DataGrid; @@ -27,10 +29,10 @@ import com.plugin.easyui.DataGrid;
27 import com.plugin.easyui.EasyPage; 29 import com.plugin.easyui.EasyPage;
28 import org.apache.commons.collections.CollectionUtils; 30 import org.apache.commons.collections.CollectionUtils;
29 import org.apache.commons.lang.StringUtils; 31 import org.apache.commons.lang.StringUtils;
  32 +import org.apache.poi.ss.formula.functions.T;
30 import org.apache.shiro.SecurityUtils; 33 import org.apache.shiro.SecurityUtils;
31 import org.slf4j.Logger; 34 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory; 35 import org.slf4j.LoggerFactory;
33 -import org.springframework.beans.factory.annotation.Autowired;  
34 import org.springframework.stereotype.Controller; 36 import org.springframework.stereotype.Controller;
35 import org.springframework.ui.Model; 37 import org.springframework.ui.Model;
36 import org.springframework.web.bind.annotation.RequestMapping; 38 import org.springframework.web.bind.annotation.RequestMapping;
@@ -44,7 +46,6 @@ import tools.Tools; @@ -44,7 +46,6 @@ import tools.Tools;
44 import tools.oclass.FemyList; 46 import tools.oclass.FemyList;
45 47
46 import javax.annotation.Resource; 48 import javax.annotation.Resource;
47 -import javax.jnlp.PersistenceService;  
48 import javax.servlet.http.HttpServletRequest; 49 import javax.servlet.http.HttpServletRequest;
49 import javax.servlet.http.HttpServletResponse; 50 import javax.servlet.http.HttpServletResponse;
50 import javax.servlet.http.HttpSession; 51 import javax.servlet.http.HttpSession;
@@ -53,7 +54,6 @@ import java.sql.Connection; @@ -53,7 +54,6 @@ import java.sql.Connection;
53 import java.sql.ResultSet; 54 import java.sql.ResultSet;
54 import java.sql.SQLException; 55 import java.sql.SQLException;
55 import java.sql.Statement; 56 import java.sql.Statement;
56 -import java.text.ParseException;  
57 import java.text.SimpleDateFormat; 57 import java.text.SimpleDateFormat;
58 import java.util.*; 58 import java.util.*;
59 59
@@ -2469,6 +2469,311 @@ public class ManifestController extends BasicController { @@ -2469,6 +2469,311 @@ public class ManifestController extends BasicController {
2469 * excel 导入 2469 * excel 导入
2470 * @return 2470 * @return
2471 */ 2471 */
  2472 +// @RequestMapping(value = "/excelView")
  2473 +// public String excelView(){
  2474 +// return "manifest/excel_upload";
  2475 +// }
  2476 +//
  2477 +// @RequestMapping(value = "/excelUpload")
  2478 +// @ResponseBody
  2479 +// public ResponseModel excelUpload(HttpServletRequest request,
  2480 +// HttpServletResponse response,
  2481 +// HttpSession session,
  2482 +// @RequestParam MultipartFile file) throws IOException {
  2483 +// ResponseModel model = new ResponseModel();
  2484 +//
  2485 +// //获取当前登录用户id
  2486 +// UserEntity user = (UserEntity) session.getAttribute("user");
  2487 +// Long userId = user.getId();
  2488 +//
  2489 +// List<ArrayList<String>> readResult = null;//总行记录
  2490 +// try {
  2491 +//
  2492 +// //判断文件是否为空
  2493 +// if (file.isEmpty()) {
  2494 +// model.setStatus(500);
  2495 +// model.setMsg("上传文件为空");
  2496 +// }
  2497 +// //判断文件大小
  2498 +// long size = file.getSize();
  2499 +// String name = file.getOriginalFilename();
  2500 +// if (StringUtils.isBlank(name) || size == 0) {
  2501 +// model.setStatus(500);
  2502 +// model.setMsg("上传文件为空");
  2503 +// }
  2504 +// String postfix = ExcelUtil.getPostfix(name);
  2505 +// //读取文件内容
  2506 +// if (StringUtils.equals("xlsx", postfix)) {
  2507 +// readResult = ExcelUtil.readXlsx(file);
  2508 +// } else if (StringUtils.equals("xls", postfix)) {
  2509 +// readResult = ExcelUtil.readXls(file);
  2510 +// } else {
  2511 +// model.setStatus(500);
  2512 +// model.setMsg("文件类型错误");
  2513 +// }
  2514 +//
  2515 +// if (readResult == null || readResult.size() == 0) {
  2516 +// model.setStatus(500);
  2517 +// model.setMsg("文件解析失败");
  2518 +// }
  2519 +//
  2520 +//
  2521 +// for (ArrayList<String> arr: readResult) {
  2522 +// String wbm = "";
  2523 +//
  2524 +// if (!StringUtils.isBlank(arr.get(1)) && arr.get(1).length()== 12) {
  2525 +//
  2526 +// if (arr.get(1).contains("-")) {
  2527 +// wbm = arr.get(1);
  2528 +// } else {
  2529 +// String s1 = arr.get(1);
  2530 +// String substring = s1.substring(0, 3);
  2531 +// String substring1 = s1.substring(3);
  2532 +// wbm = substring + "-" + substring1;
  2533 +// }
  2534 +// // 如果分单不为空
  2535 +// if (StringUtils.isBlank(arr.get(2))) {
  2536 +// // 查询主单号是否存在
  2537 +// ManifestEntity wbm1 = manifestService.findWbm(wbm);
  2538 +// if (wbm1 == null) {
  2539 +// ManifestEntity manifestEntity = new ManifestEntity();
  2540 +// manifestEntity.setUSER_ID(userId);
  2541 +// // 主单号
  2542 +// manifestEntity.setWaybillnomaster(wbm);
  2543 +// // 航班号
  2544 +// manifestEntity.setFlightno(arr.get(3).substring(2));
  2545 +// // 航班日期
  2546 +// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
  2547 +// String s = arr.get(4);
  2548 +// Date parse = simpleDateFormat.parse(s);
  2549 +// manifestEntity.setFlightdate(parse);
  2550 +// // 承运人代码
  2551 +// manifestEntity.setCarrier(arr.get(3).substring(0, 2));
  2552 +// // 运费支付方式
  2553 +// manifestEntity.setPaymode(arr.get(5));
  2554 +// // 装货地代码
  2555 +// manifestEntity.setOriginatingstation(arr.get(6));
  2556 +// // 卸货地代码
  2557 +// manifestEntity.setDestinationstation(arr.get(7));
  2558 +// // 货物装载运输时间
  2559 +// manifestEntity.setStowagedate(new Date());
  2560 +// // 海关关区代码
  2561 +// manifestEntity.setCustomscode(arr.get(9));
  2562 +// // 货物件数
  2563 +// manifestEntity.setTotalpiece(arr.get(10));
  2564 +// // 货物毛重
  2565 +// manifestEntity.setTotalweight(arr.get(11));
  2566 +// // 货物简要描述
  2567 +// manifestEntity.setProductname(arr.get(12));
  2568 +// // 发货人代码
  2569 +// manifestEntity.setShpcusid(arr.get(13));
  2570 +// // 发货人公司
  2571 +// manifestEntity.setCo_company(arr.get(14));
  2572 +// // 发货人地址
  2573 +// manifestEntity.setCo_address(arr.get(15));
  2574 +// // 发货人国家代码
  2575 +// manifestEntity.setSh_country(arr.get(16));
  2576 +// // 发货人传真
  2577 +// manifestEntity.setSh_fax(arr.get(17));
  2578 +// // 发货人联系号码
  2579 +// manifestEntity.setCo_telephone(arr.get(18));
  2580 +// // 收货人代码
  2581 +// manifestEntity.setCnecusid(arr.get(19));
  2582 +// // 收货人公司
  2583 +// manifestEntity.setSh_company(arr.get(20));
  2584 +// // 收货人地址
  2585 +// manifestEntity.setSh_address(arr.get(21));
  2586 +// // 收货人城市
  2587 +// manifestEntity.setSh_city(arr.get(22));
  2588 +// // 收货人国家代码
  2589 +// manifestEntity.setSh_country(arr.get(23));
  2590 +// // 收货人传真
  2591 +// manifestEntity.setSh_fax(arr.get(24));
  2592 +// // 收货人联系号码
  2593 +// manifestEntity.setSh_telephone(arr.get(25));
  2594 +//
  2595 +// // 货物海关状态代码
  2596 +// manifestEntity.setCustomsstatus(arr.get(26));
  2597 +//
  2598 +// // 安检申报
  2599 +//
  2600 +// if (StringUtils.isNotBlank(arr.get(27)) && StringUtils.isNotBlank(arr.get(28)) && StringUtils.isNotBlank(arr.get(29))
  2601 +// && StringUtils.isNotBlank(arr.get(32)) && StringUtils.isNotBlank(arr.get(33))){
  2602 +// SecurityDeclarationEntity sd = new SecurityDeclarationEntity();
  2603 +// sd.setSd_waybill(wbm);
  2604 +// // 航空货物托运人名称
  2605 +// sd.setSd_cargo_shipper_name(arr.get(27));
  2606 +// // 航空货物销售代理人名称
  2607 +// sd.setSd_cargo_agent_name(arr.get(28));
  2608 +// // 航协资质编号
  2609 +// if (!StringUtils.isBlank(arr.get(29))) {
  2610 +// sd.setSd_iata_number(arr.get(29));
  2611 +// }
  2612 +//
  2613 +// sd.setSd_static("1");
  2614 +// // 发布时间
  2615 +// SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  2616 +// String format = simpleDateFormat2.format(new Date());
  2617 +// sd.setOperation_time(format);
  2618 +//
  2619 +// // 运输条件鉴定书
  2620 +// if (!StringUtils.isBlank(arr.get(30))) {
  2621 +//
  2622 +// String certificate = arr.get(30);
  2623 +// if (certificate != null) {
  2624 +// String s2 = certificate.replaceAll(",", ",");
  2625 +// sd.setSd_transport_certificate(s2);
  2626 +// }
  2627 +// }
  2628 +//
  2629 +// // 航空公司同意运输证明
  2630 +// if (!StringUtils.isBlank(arr.get(31))) {
  2631 +//
  2632 +// String prove = arr.get(31);
  2633 +// if (prove != null) {
  2634 +// String s2 = prove.replaceAll(",", ",");
  2635 +// sd.setSd_transportation_prove(s2);
  2636 +// }
  2637 +// }
  2638 +//
  2639 +// // 用户ID
  2640 +// sd.setUSER_ID(userId);
  2641 +//
  2642 +// // 航空货物性质
  2643 +// SDCargoTypeEntity sdCargoTypeEntity = new SDCargoTypeEntity();
  2644 +// sdCargoTypeEntity.setSd_waybill(wbm);
  2645 +// sdCargoTypeEntity.setSd_cargo_type(arr.get(32));
  2646 +// sdCargoTypeService.save(sdCargoTypeEntity);
  2647 +//
  2648 +// // 航空货物品名
  2649 +// String replace = arr.get(33).replace(",", ",");
  2650 +//
  2651 +// String[] cargoName = replace.split(",");
  2652 +// for (int i = 0; i < cargoName.length; i++) {
  2653 +// SDCargoNameEntity sdCargoNameEntity = new SDCargoNameEntity();
  2654 +// sdCargoNameEntity.setSd_waybill(wbm);
  2655 +// sdCargoNameEntity.setSd_cargo_name(cargoName[i]);
  2656 +// sdCargoNameService.save(sdCargoNameEntity);
  2657 +// }
  2658 +// securityDeclarationService.save(sd);
  2659 +// }
  2660 +//
  2661 +//
  2662 +// manifestService.save(manifestEntity);
  2663 +//
  2664 +// model.setStatus(200);
  2665 +//
  2666 +// }else {
  2667 +// model.setStatus(201);
  2668 +// model.setMsg(wbm1.getWaybillnomaster() + "单号已存在");
  2669 +// break;
  2670 +// }
  2671 +// }else {
  2672 +//
  2673 +// ManifestEntity wbm1 = manifestService.findWbm(wbm);
  2674 +// if(wbm1 == null){
  2675 +//
  2676 +// model.setStatus(202);
  2677 +// model.setMsg("请先添加主单号");
  2678 +// break;
  2679 +// }else {
  2680 +// String waybill = preparesecondaryServer.findWaybill(arr.get(2));
  2681 +//
  2682 +// if (waybill != arr.get(2)) {
  2683 +//
  2684 +// PreparesecondaryEntity seconday = new PreparesecondaryEntity();
  2685 +// seconday.setPreparemasterid(wbm1.getId());
  2686 +// // 主单号
  2687 +// seconday.setWaybillnomaster(wbm);
  2688 +// // 分单号
  2689 +// seconday.setWaybillnosecondary(arr.get(2));
  2690 +// // 航班号
  2691 +// seconday.setFlightno(arr.get(3).substring(2));
  2692 +// // 航班日期
  2693 +// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
  2694 +// String s = arr.get(4);
  2695 +// Date parse = simpleDateFormat.parse(s);
  2696 +// seconday.setFlightdate(parse);
  2697 +// // 承运人代码
  2698 +// seconday.setCarrier(arr.get(3).substring(0, 2));
  2699 +// // 运费支付方式
  2700 +// seconday.setPaymode(arr.get(5));
  2701 +// // 装货地代码
  2702 +// seconday.setOriginatingstation(arr.get(6));
  2703 +// // 卸货地代码
  2704 +// seconday.setDestinationstation(arr.get(7));
  2705 +// // 货物装载运输时间
  2706 +// SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss");
  2707 +// seconday.setStowagedate(simpleDateFormat1.parse(arr.get(8)));
  2708 +// // 海关关区代码
  2709 +// seconday.setCustomscode(arr.get(9));
  2710 +// // 货物件数
  2711 +//// String s3 = arr.get(11);
  2712 +// seconday.setTotalpiece(arr.get(10));
  2713 +// // 货物毛重
  2714 +//// String s1 = arr.get(12);
  2715 +// seconday.setTotalweight(arr.get(11));
  2716 +// // 货物简要描述
  2717 +// seconday.setProductname(arr.get(12));
  2718 +// // 发货人代码
  2719 +// seconday.setShpcusid(arr.get(13));
  2720 +// // 发货人公司
  2721 +// seconday.setCo_company(arr.get(14));
  2722 +// // 发货人地址
  2723 +// seconday.setCo_address(arr.get(15));
  2724 +// // 发货人国家代码
  2725 +// seconday.setSh_country(arr.get(16));
  2726 +// // 发货人传真
  2727 +// seconday.setSh_fax(arr.get(17));
  2728 +// // 发货人联系号码
  2729 +// seconday.setCo_telephone(arr.get(18));
  2730 +// // 收货人代码
  2731 +// seconday.setCnecusid(arr.get(19));
  2732 +// // 收货人公司
  2733 +// seconday.setSh_company(arr.get(20));
  2734 +// // 收货人地址
  2735 +// seconday.setSh_address(arr.get(21));
  2736 +// // 收货人城市
  2737 +// seconday.setSh_city(arr.get(22));
  2738 +// // 收货人国家代码
  2739 +// seconday.setSh_country(arr.get(23));
  2740 +// // 收货人传真
  2741 +// seconday.setSh_fax(arr.get(24));
  2742 +// // 收货人联系号码
  2743 +// seconday.setSh_telephone(arr.get(25));
  2744 +//
  2745 +// // 货物海关状态代码
  2746 +// seconday.setCustomsstatus(arr.get(26));
  2747 +// seconday.setCreateDate(new Date());
  2748 +// preparesecondaryServer.save(seconday);
  2749 +// model.setStatus(200);
  2750 +// } else {
  2751 +// model.setStatus(201);
  2752 +// model.setMsg(waybill + "分单号已存在");
  2753 +// break;
  2754 +// }
  2755 +// }
  2756 +// }
  2757 +// }else {
  2758 +//
  2759 +// model.setStatus(300);
  2760 +// model.setMsg("主单号格式有误");
  2761 +// break;
  2762 +// }
  2763 +// }
  2764 +// return model;
  2765 +// } catch (Exception e) {
  2766 +// model.setStatus(500);
  2767 +// model.setMsg("格式有误");
  2768 +// e.printStackTrace();
  2769 +// }
  2770 +// return model;
  2771 +// }
  2772 +
  2773 + /**
  2774 + * excel 导入
  2775 + * @return
  2776 + */
2472 @RequestMapping(value = "/excelView") 2777 @RequestMapping(value = "/excelView")
2473 public String excelView(){ 2778 public String excelView(){
2474 return "manifest/excel_upload"; 2779 return "manifest/excel_upload";
@@ -2481,6 +2786,7 @@ public class ManifestController extends BasicController { @@ -2481,6 +2786,7 @@ public class ManifestController extends BasicController {
2481 HttpSession session, 2786 HttpSession session,
2482 @RequestParam MultipartFile file) throws IOException { 2787 @RequestParam MultipartFile file) throws IOException {
2483 ResponseModel model = new ResponseModel(); 2788 ResponseModel model = new ResponseModel();
  2789 +
2484 //获取当前登录用户id 2790 //获取当前登录用户id
2485 UserEntity user = (UserEntity) session.getAttribute("user"); 2791 UserEntity user = (UserEntity) session.getAttribute("user");
2486 Long userId = user.getId(); 2792 Long userId = user.getId();
@@ -2510,25 +2816,18 @@ public class ManifestController extends BasicController { @@ -2510,25 +2816,18 @@ public class ManifestController extends BasicController {
2510 model.setStatus(500); 2816 model.setStatus(500);
2511 model.setMsg("文件类型错误"); 2817 model.setMsg("文件类型错误");
2512 } 2818 }
2513 -  
2514 if (readResult == null || readResult.size() == 0) { 2819 if (readResult == null || readResult.size() == 0) {
2515 model.setStatus(500); 2820 model.setStatus(500);
2516 model.setMsg("文件解析失败"); 2821 model.setMsg("文件解析失败");
2517 } 2822 }
2518 -  
2519 -  
2520 for (ArrayList<String> arr: readResult) { 2823 for (ArrayList<String> arr: readResult) {
2521 String wbm = ""; 2824 String wbm = "";
2522 - if (!StringUtils.isBlank(arr.get(1))) {  
2523 -  
2524 - if (arr.get(1).contains("-")) {  
2525 - wbm = arr.get(1);  
2526 - } else {  
2527 - String s1 = arr.get(1);  
2528 - String substring = s1.substring(0, 3);  
2529 - String substring1 = s1.substring(3);  
2530 - wbm = substring + "-" + substring1;  
2531 - } 2825 + // 判断非空 长度是否符合
  2826 + if (!StringUtils.isBlank(arr.get(1)) && arr.get(1).length()== 12) {
  2827 + WaybillUtils waybillUtils = new WaybillUtils();
  2828 + wbm = waybillUtils.awb(arr.get(1));
  2829 + // 是否符合摸七校验
  2830 + if (waybillUtils.checkout(wbm)){
2532 // 如果分单不为空 2831 // 如果分单不为空
2533 if (StringUtils.isBlank(arr.get(2))) { 2832 if (StringUtils.isBlank(arr.get(2))) {
2534 // 查询主单号是否存在 2833 // 查询主单号是否存在
@@ -2589,12 +2888,9 @@ public class ManifestController extends BasicController { @@ -2589,12 +2888,9 @@ public class ManifestController extends BasicController {
2589 manifestEntity.setSh_fax(arr.get(24)); 2888 manifestEntity.setSh_fax(arr.get(24));
2590 // 收货人联系号码 2889 // 收货人联系号码
2591 manifestEntity.setSh_telephone(arr.get(25)); 2890 manifestEntity.setSh_telephone(arr.get(25));
2592 -  
2593 // 货物海关状态代码 2891 // 货物海关状态代码
2594 manifestEntity.setCustomsstatus(arr.get(26)); 2892 manifestEntity.setCustomsstatus(arr.get(26));
2595 -  
2596 // 安检申报 2893 // 安检申报
2597 -  
2598 if (StringUtils.isNotBlank(arr.get(27)) && StringUtils.isNotBlank(arr.get(28)) && StringUtils.isNotBlank(arr.get(29)) 2894 if (StringUtils.isNotBlank(arr.get(27)) && StringUtils.isNotBlank(arr.get(28)) && StringUtils.isNotBlank(arr.get(29))
2599 && StringUtils.isNotBlank(arr.get(32)) && StringUtils.isNotBlank(arr.get(33))){ 2895 && StringUtils.isNotBlank(arr.get(32)) && StringUtils.isNotBlank(arr.get(33))){
2600 SecurityDeclarationEntity sd = new SecurityDeclarationEntity(); 2896 SecurityDeclarationEntity sd = new SecurityDeclarationEntity();
@@ -2607,23 +2903,19 @@ public class ManifestController extends BasicController { @@ -2607,23 +2903,19 @@ public class ManifestController extends BasicController {
2607 if (!StringUtils.isBlank(arr.get(29))) { 2903 if (!StringUtils.isBlank(arr.get(29))) {
2608 sd.setSd_iata_number(arr.get(29)); 2904 sd.setSd_iata_number(arr.get(29));
2609 } 2905 }
2610 -  
2611 sd.setSd_static("1"); 2906 sd.setSd_static("1");
2612 // 发布时间 2907 // 发布时间
2613 SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 2908 SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
2614 String format = simpleDateFormat2.format(new Date()); 2909 String format = simpleDateFormat2.format(new Date());
2615 sd.setOperation_time(format); 2910 sd.setOperation_time(format);
2616 -  
2617 // 运输条件鉴定书 2911 // 运输条件鉴定书
2618 if (!StringUtils.isBlank(arr.get(30))) { 2912 if (!StringUtils.isBlank(arr.get(30))) {
2619 -  
2620 String certificate = arr.get(30); 2913 String certificate = arr.get(30);
2621 if (certificate != null) { 2914 if (certificate != null) {
2622 String s2 = certificate.replaceAll(",", ","); 2915 String s2 = certificate.replaceAll(",", ",");
2623 sd.setSd_transport_certificate(s2); 2916 sd.setSd_transport_certificate(s2);
2624 } 2917 }
2625 } 2918 }
2626 -  
2627 // 航空公司同意运输证明 2919 // 航空公司同意运输证明
2628 if (!StringUtils.isBlank(arr.get(31))) { 2920 if (!StringUtils.isBlank(arr.get(31))) {
2629 2921
@@ -2633,16 +2925,13 @@ public class ManifestController extends BasicController { @@ -2633,16 +2925,13 @@ public class ManifestController extends BasicController {
2633 sd.setSd_transportation_prove(s2); 2925 sd.setSd_transportation_prove(s2);
2634 } 2926 }
2635 } 2927 }
2636 -  
2637 // 用户ID 2928 // 用户ID
2638 sd.setUSER_ID(userId); 2929 sd.setUSER_ID(userId);
2639 -  
2640 // 航空货物性质 2930 // 航空货物性质
2641 SDCargoTypeEntity sdCargoTypeEntity = new SDCargoTypeEntity(); 2931 SDCargoTypeEntity sdCargoTypeEntity = new SDCargoTypeEntity();
2642 sdCargoTypeEntity.setSd_waybill(wbm); 2932 sdCargoTypeEntity.setSd_waybill(wbm);
2643 sdCargoTypeEntity.setSd_cargo_type(arr.get(32)); 2933 sdCargoTypeEntity.setSd_cargo_type(arr.get(32));
2644 sdCargoTypeService.save(sdCargoTypeEntity); 2934 sdCargoTypeService.save(sdCargoTypeEntity);
2645 -  
2646 // 航空货物品名 2935 // 航空货物品名
2647 String replace = arr.get(33).replace(",", ","); 2936 String replace = arr.get(33).replace(",", ",");
2648 2937
@@ -2655,30 +2944,20 @@ public class ManifestController extends BasicController { @@ -2655,30 +2944,20 @@ public class ManifestController extends BasicController {
2655 } 2944 }
2656 securityDeclarationService.save(sd); 2945 securityDeclarationService.save(sd);
2657 } 2946 }
2658 -  
2659 -  
2660 manifestService.save(manifestEntity); 2947 manifestService.save(manifestEntity);
2661 -  
2662 - model.setStatus(200);  
2663 -  
2664 }else { 2948 }else {
2665 model.setStatus(201); 2949 model.setStatus(201);
2666 model.setMsg(wbm1.getWaybillnomaster() + "单号已存在"); 2950 model.setMsg(wbm1.getWaybillnomaster() + "单号已存在");
2667 - break; 2951 + return model;
2668 } 2952 }
2669 }else { 2953 }else {
2670 -  
2671 ManifestEntity wbm1 = manifestService.findWbm(wbm); 2954 ManifestEntity wbm1 = manifestService.findWbm(wbm);
2672 if(wbm1 == null){ 2955 if(wbm1 == null){
2673 -  
2674 model.setStatus(202); 2956 model.setStatus(202);
2675 - model.setMsg("请先添加主单号");  
2676 - break; 2957 + model.setMsg(wbm+"请先添加主单号");
  2958 + return model;
2677 }else { 2959 }else {
2678 - String waybill = preparesecondaryServer.findWaybill(arr.get(2));  
2679 -  
2680 - if (waybill != arr.get(2)) {  
2681 - 2960 + if (preparesecondaryServer.findWaybill(arr.get(2))==0) {
2682 PreparesecondaryEntity seconday = new PreparesecondaryEntity(); 2961 PreparesecondaryEntity seconday = new PreparesecondaryEntity();
2683 seconday.setPreparemasterid(wbm1.getId()); 2962 seconday.setPreparemasterid(wbm1.getId());
2684 // 主单号 2963 // 主单号
@@ -2706,10 +2985,8 @@ public class ManifestController extends BasicController { @@ -2706,10 +2985,8 @@ public class ManifestController extends BasicController {
2706 // 海关关区代码 2985 // 海关关区代码
2707 seconday.setCustomscode(arr.get(9)); 2986 seconday.setCustomscode(arr.get(9));
2708 // 货物件数 2987 // 货物件数
2709 -// String s3 = arr.get(11);  
2710 seconday.setTotalpiece(arr.get(10)); 2988 seconday.setTotalpiece(arr.get(10));
2711 // 货物毛重 2989 // 货物毛重
2712 -// String s1 = arr.get(12);  
2713 seconday.setTotalweight(arr.get(11)); 2990 seconday.setTotalweight(arr.get(11));
2714 // 货物简要描述 2991 // 货物简要描述
2715 seconday.setProductname(arr.get(12)); 2992 seconday.setProductname(arr.get(12));
@@ -2739,31 +3016,37 @@ public class ManifestController extends BasicController { @@ -2739,31 +3016,37 @@ public class ManifestController extends BasicController {
2739 seconday.setSh_fax(arr.get(24)); 3016 seconday.setSh_fax(arr.get(24));
2740 // 收货人联系号码 3017 // 收货人联系号码
2741 seconday.setSh_telephone(arr.get(25)); 3018 seconday.setSh_telephone(arr.get(25));
2742 -  
2743 // 货物海关状态代码 3019 // 货物海关状态代码
2744 seconday.setCustomsstatus(arr.get(26)); 3020 seconday.setCustomsstatus(arr.get(26));
2745 seconday.setCreateDate(new Date()); 3021 seconday.setCreateDate(new Date());
2746 preparesecondaryServer.save(seconday); 3022 preparesecondaryServer.save(seconday);
2747 - model.setStatus(200);  
2748 } else { 3023 } else {
2749 model.setStatus(201); 3024 model.setStatus(201);
2750 - model.setMsg(waybill + "分单号已存在");  
2751 - break; 3025 + model.setMsg(arr.get(2) + "分单号已存在");
  3026 + return model;
2752 } 3027 }
2753 } 3028 }
2754 } 3029 }
2755 }else { 3030 }else {
2756 - break; 3031 + model.setStatus(301);
  3032 + model.setMsg(wbm+"不符合模七校验");
  3033 + return model;
  3034 + }
  3035 + }else {
  3036 +
  3037 + model.setStatus(300);
  3038 + model.setMsg("主单号格式有误");
  3039 + return model;
2757 } 3040 }
2758 } 3041 }
  3042 + model.setStatus(200);
2759 return model; 3043 return model;
2760 } catch (Exception e) { 3044 } catch (Exception e) {
2761 model.setStatus(500); 3045 model.setStatus(500);
2762 - model.setMsg("网络异常"); 3046 + model.setMsg(e.getMessage());
2763 e.printStackTrace(); 3047 e.printStackTrace();
2764 } 3048 }
2765 return model; 3049 return model;
2766 } 3050 }
2767 3051
2768 -  
2769 } 3052 }
@@ -44,8 +44,8 @@ JpaSpecificationExecutor<PreparesecondaryEntity>{ @@ -44,8 +44,8 @@ JpaSpecificationExecutor<PreparesecondaryEntity>{
44 @Query(value = "DELETE FROM PREPARESECONDARY WHERE PREPAREMASTERID = ?1", nativeQuery = true) 44 @Query(value = "DELETE FROM PREPARESECONDARY WHERE PREPAREMASTERID = ?1", nativeQuery = true)
45 void deleteSub(Long id); 45 void deleteSub(Long id);
46 46
47 - @Query(value = "SELECT WAYBILLNOSECONDARY FROM PREPARESECONDARY WHERE WAYBILLNOMASTER = ?1", nativeQuery = true)  
48 - String findWaybill(String wbm); 47 + @Query(value = "SELECT count(*) FROM PREPARESECONDARY WHERE WAYBILLNOSECONDARY = ?1", nativeQuery = true)
  48 + int findWaybill(String wbm);
49 49
50 @Query(value = "select count(id) from PREPARESECONDARY where WAYBILLNOMASTER = ?1 and WAYBILLNOSECONDARY=?2", nativeQuery = true) 50 @Query(value = "select count(id) from PREPARESECONDARY where WAYBILLNOMASTER = ?1 and WAYBILLNOSECONDARY=?2", nativeQuery = true)
51 int findAwbAwbH(String awb, String awbh); 51 int findAwbAwbH(String awb, String awbh);
@@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Query; @@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Query;
7 import org.springframework.data.repository.PagingAndSortingRepository; 7 import org.springframework.data.repository.PagingAndSortingRepository;
8 import org.springframework.transaction.annotation.Transactional; 8 import org.springframework.transaction.annotation.Transactional;
9 9
  10 +import java.util.List;
  11 +
10 /** 12 /**
11 * @Auther: shenhl 13 * @Auther: shenhl
12 * @Date: 2019/4/24 16:38 14 * @Date: 2019/4/24 16:38
@@ -25,6 +27,6 @@ public interface SecurityDeclarationRepository extends PagingAndSortingRepositor @@ -25,6 +27,6 @@ public interface SecurityDeclarationRepository extends PagingAndSortingRepositor
25 int findWaybill(String waybill); 27 int findWaybill(String waybill);
26 28
27 @Query(value = "select * from SECURITY_DECLARATION where SD_WAYBILL = ?1", nativeQuery = true) 29 @Query(value = "select * from SECURITY_DECLARATION where SD_WAYBILL = ?1", nativeQuery = true)
28 - SecurityDeclarationEntity waybill(String waybill); 30 + List<SecurityDeclarationEntity> waybill(String waybill);
29 31
30 } 32 }
@@ -225,9 +225,13 @@ public class ManifestService extends BasicService<ManifestEntity> { @@ -225,9 +225,13 @@ public class ManifestService extends BasicService<ManifestEntity> {
225 manifestEntity.setId(Long.valueOf(id)); 225 manifestEntity.setId(Long.valueOf(id));
226 manifestRepository.delete(manifestEntity); 226 manifestRepository.delete(manifestEntity);
227 //查看是否有安检申报 存在删除 227 //查看是否有安检申报 存在删除
228 - SecurityDeclarationEntity waybill1 = securityDeclarationRepository.waybill(waybillnomaster); 228 + List<SecurityDeclarationEntity> waybill1 = securityDeclarationRepository.waybill(waybillnomaster);
229 if (waybill1 != null){ 229 if (waybill1 != null){
230 - securityDeclarationRepository.delete(waybill1.getId()); 230 +
  231 + for (SecurityDeclarationEntity securityDeclarationEntity: waybill1){
  232 +
  233 + securityDeclarationRepository.delete(securityDeclarationEntity.getId());
  234 + }
231 } 235 }
232 236
233 sdCargoNameRepository.deletes(waybillnomaster); 237 sdCargoNameRepository.deletes(waybillnomaster);
@@ -96,9 +96,10 @@ public class PreparesecondaryService extends BasicService<PreparesecondaryEntity @@ -96,9 +96,10 @@ public class PreparesecondaryService extends BasicService<PreparesecondaryEntity
96 return preparesecondaryRepository.queryByUserId(user_id); 96 return preparesecondaryRepository.queryByUserId(user_id);
97 } 97 }
98 98
99 - public String findWaybill(String wbm){ 99 + public int findWaybill(String wbm){
  100 + int waybill = preparesecondaryRepository.findWaybill(wbm);
100 101
101 - return preparesecondaryRepository.findWaybill(wbm); 102 + return waybill;
102 } 103 }
103 104
104 105
  1 +package com.agent.util;
  2 +
  3 +public class WaybillUtils {
  4 +
  5 +
  6 + // 主单添加 - 符号
  7 + public String awb(String waybill){
  8 + String awb = "";
  9 + if (waybill.contains("-")) {
  10 + awb = waybill;
  11 + } else {
  12 + String s1 = waybill;
  13 + String substring = s1.substring(0, 3);
  14 + String substring1 = s1.substring(3);
  15 + awb = substring + "-" + substring1;
  16 + }
  17 + return awb;
  18 + }
  19 +
  20 + // 判断是否符合模七校验
  21 + public boolean checkout(String waybill){
  22 +
  23 + String[] split = waybill.split("-");
  24 +
  25 + int number = Integer.parseInt(split[1]);
  26 +
  27 + int start = number/10;
  28 +
  29 + int remainder = start % 7;
  30 +
  31 + int last = number % 10;
  32 +
  33 + if (remainder!=last){
  34 + return false;
  35 + }else {
  36 + return true;
  37 + }
  38 +
  39 + }
  40 +
  41 +}
@@ -86,8 +86,12 @@ @@ -86,8 +86,12 @@
86 alert(data.msg); 86 alert(data.msg);
87 }else if(data.status == 202){ 87 }else if(data.status == 202){
88 alert(data.msg); 88 alert(data.msg);
  89 + }else if (data.status == 300){
  90 + alert(data.msg);
  91 + }else if (data.status == 301){
  92 + alert(data.msg);
89 }else { 93 }else {
90 - alert("网络异常"); 94 + alert(data.msg);
91 } 95 }
92 } 96 }
93 }); 97 });
@@ -238,8 +238,8 @@ @@ -238,8 +238,8 @@
238 } 238 }
239 //主单撤销按钮 239 //主单撤销按钮
240 function operatorFormat(val, row, index){ 240 function operatorFormat(val, row, index){
241 - var html = "<a href='javascript:void(0)' onclick='backout("+row.id+")' style='text-decoration:none;color:blue;'><spring:message code='opt.backout'/></a>";  
242 - 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>"; 241 + <%--var html = "<a href='javascript:void(0)' onclick='backout("+row.id+")' style='text-decoration:none;color:blue;'><spring:message code='opt.backout'/></a>";--%>
  242 + 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>";
243 html+="<a href='javascript:void(0)' onclick='security(\""+row.waybillnomaster+"\")' style='text-decoration:none;color:blue;margin-left:20px;'>添加安检申报</a>" 243 html+="<a href='javascript:void(0)' onclick='security(\""+row.waybillnomaster+"\")' style='text-decoration:none;color:blue;margin-left:20px;'>添加安检申报</a>"
244 return html; 244 return html;
245 } 245 }