InvokeHelper.java 65.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200
package com.huaheng.api.jindie;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.gson.Gson;
import com.huaheng.api.jindie.domain.WarehousePoint;
import com.huaheng.api.jindie.domain.allocate.Allocate;
import com.huaheng.api.jindie.domain.allocate.AllocateV;
import com.huaheng.api.jindie.domain.mes.MesPush;
import com.huaheng.api.jindie.domain.mes.MesPushData;
import com.huaheng.api.jindie.domain.position.Position;
import com.huaheng.api.jindie.domain.purchase.*;
import com.huaheng.api.jindie.domain.purchaseReturn.PurchaseReturnSave;
import com.huaheng.api.jindie.domain.purchaseReturn.PurchaseReturnSaveV;
import com.huaheng.api.jindie.domain.result.Results;
import com.huaheng.api.jindie.domain.uri.JinDieApiUri;
import com.huaheng.api.jindie.mapper.WarehousePointMapper;
import com.huaheng.api.jindie.service.WarehousePointService;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.DateUtils;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.aspectj.ApiLogAspect;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.location.domain.Location;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.config.supplier.domain.Supplier;
import com.huaheng.pc.config.supplier.service.SupplierService;
import com.huaheng.pc.monitor.apilog.domain.ApiLog;
import com.huaheng.pc.monitor.apilog.service.IApiLogService;
import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail;
import com.huaheng.pc.receipt.receiptDetail.service.ReceiptDetailService;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService;
import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailService;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
import com.huaheng.pc.system.config.service.IConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;


import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;

@Service
public class InvokeHelper {

    @Autowired
    private ReceiptHeaderService receiptHeaderService;
    @Autowired
    private ReceiptDetailService receiptDetailService;
    @Autowired
    private ShipmentHeaderService shipmentHeaderService;
    @Autowired
    private ShipmentDetailService shipmentDetailService;
    @Autowired
    private LocationService locationService;
    @Autowired
    private IConfigService configService;
    @Autowired
    private SupplierService supplierService;
    @Autowired
    private WarehousePointService warehousePointService;
    @Autowired
    private IApiLogService apiLogService;
    @Autowired
    private ApiLogAspect apiLogAspect;

    public static String POST_K3CloudURL = "http://219.137.250.36:8999/K3Cloud/";

    private ApiLog apiLog;

    // Cookie 值
    // private static String CookieVal = null;

    // HttpURLConnection
    public synchronized HttpURLConnection initUrlConn(String url, String paras)
            throws Exception {

        System.out.println(paras);
        URL postUrl = new URL(POST_K3CloudURL.concat(url));
        HttpURLConnection connection = (HttpURLConnection) postUrl
                .openConnection();
        String jindieCookie = configService.selectConfigByKey("jindieCookie");
        connection.setRequestProperty("Cookie", jindieCookie);
//        if (!connection.getDoOutput()) {
//            connection.setDoOutput(true);
//        }
//        connection.setRequestMethod("POST");
//        connection.setUseCaches(false);
//        connection.setInstanceFollowRedirects(true);
//        connection.setRequestProperty("Content-Type", "application/json");
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.setUseCaches(false);
        connection.setInstanceFollowRedirects(true);
        connection.setRequestMethod("POST");// 设置请求方式
        connection.setRequestProperty("Accept","application/json");// 设置接收数据的格式
        connection.setRequestProperty("Content-Type","application/json");// 设置发送数据的格式
        apiLog = ApiLogAspect.initApiLog(connection, paras, "ERP");
        DataOutputStream out = new DataOutputStream(connection.getOutputStream());
        out.writeBytes(paras);
        out.flush();
        out.close();
        return connection;
    }

    /**
     * 采购入库单操作
     * @throws Exception
     */

    // 收料通知单下推采购入库单
    public void pushPurchaseEnter(String billCode) throws Exception {
        PurchasePush purchasePush=new PurchasePush();
        PurchasePushData purchasePushData=new PurchasePushData();
        List<String> list=new ArrayList<>();
        list.add(billCode);
        purchasePushData.setNumbers(list);
        purchasePushData.setTargetOrgId(0);
        purchasePushData.setTargetFormId("STK_InStock");
        purchasePushData.setIsEnableDefaultRule("true");
        purchasePush.setData(purchasePushData);
        purchasePush.setFormid("PUR_ReceiveBill");
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Results.ResultDTO.ResponseStatusDTO responseStatusDTO = Invoke(JinDieApiUri.PURCHASE_PUSH.getApiUri(), s);
        receiptResultHandle(responseStatusDTO,billCode,"push");
    }

    // MES通过ERP叫料后,调拔申请单下推直接调拔单
    public void pushMesEnter(String billCode) throws Exception {
        MesPush push =new MesPush();
        MesPushData purchasePushData=new MesPushData();
        List<String> list=new ArrayList<>();
        list.add(billCode);
        purchasePushData.setNumbers(list);
        purchasePushData.setTargetFormId("STK_TransferDirect");
        purchasePushData.setIsEnableDefaultRule("true");
        purchasePushData.setIsDraftWhenSaveFail("true");
        push.setData(purchasePushData);
        push.setFormid("STK_TRANSFERAPPLY");
        Gson gson = new Gson();
        String s = gson.toJson(push);
        Results.ResultDTO.ResponseStatusDTO responseStatusDTO = Invoke(JinDieApiUri.MES_PUSH.getApiUri(), s);
        shipmentResultHandle4Mes(responseStatusDTO,billCode,"push");
    }

    // 收料通知单下推采购退料单
//    public void pushPurchaseOut(String billCode) throws Exception {
//        PurchasePush purchasePush=new PurchasePush();
//        PurchasePushData purchasePushData=new PurchasePushData();
//        List<String> list=new ArrayList<>();
//        list.add(billCode);
//        purchasePushData.setNumbers(list);
//        purchasePushData.setTargetOrgId(0);
//        purchasePushData.setTargetFormId("PUR_MRB");
//        purchasePushData.setIsEnableDefaultRule("true");
//        purchasePush.setData(purchasePushData);
//        purchasePush.setFormid("PUR_ReceiveBill");
//        JSONObject jsonObject = (JSONObject) JSONObject.toJSON(purchasePush);
//        Results.ResultDTO.ResponseStatusDTO responseStatusDTO = Invoke(JinDieApiUri.PURCHASE_PUSH.getApiUri(), jsonObject);
//        receiptResultHandle(responseStatusDTO,billCode,"push");
//    }

    @Transactional(rollbackFor = Exception.class)
    public void receiptResultHandle(Results.ResultDTO.ResponseStatusDTO responseStatusDTO,String billCode,String flag){
        List<Results.ResultDTO.ResponseStatusDTO.SuccessEntitys> successEntitys = responseStatusDTO.getSuccessEntitys();
        List<Results.ResultDTO.ResponseStatusDTO.ErrorsDTO> errors = responseStatusDTO.getErrors();
        Results.ResultDTO.ResponseStatusDTO.SuccessEntitys successEntity=null;
        Results.ResultDTO.ResponseStatusDTO.ErrorsDTO errorsDTO=null;
        ReceiptHeader receiptHeader = receiptHeaderService.getOne(new LambdaQueryWrapper<ReceiptHeader>().eq(ReceiptHeader::getReferCode, billCode));
        if(!CollectionUtils.isEmpty(successEntitys)){
            successEntity = successEntitys.get(0);
            if(flag.equals("push")){
                Integer id = successEntity.getId();
                String number = successEntity.getNumber();
                Integer dIndex = successEntity.getDIndex();
                receiptHeader.setUserDef1(id.toString());
                receiptHeader.setUserDef2(number);
                receiptHeader.setUserDef3("成功");
            }else if(flag.equals("save")){
                receiptHeader.setUserDef4("成功");
            }else if(flag.equals("submit")){
                receiptHeader.setUserDef5("成功");
            }else if(flag.equals("audit")){
                receiptHeader.setUserDef6("成功");
            }
            receiptHeaderService.updateById(receiptHeader);
        }else {
            errorsDTO = errors.get(0);
            String message = errorsDTO.getMessage();
            if(flag.equals("push")){
                receiptHeader.setUserDef3(message);
            }else if(flag.equals("save")){
                receiptHeader.setUserDef4(message);
            }else if(flag.equals("submit")){
                receiptHeader.setUserDef5(message);
            }else if(flag.equals("audit")){
                receiptHeader.setUserDef6(message);
            }
            receiptHeaderService.updateById(receiptHeader);
        }
    }


    // 采购入库单查询
    @Transactional(rollbackFor = Exception.class)
    public void purchaseEnterSelect(String billCode) throws Exception {
        ReceiptHeader receiptHeader = receiptHeaderService.getOne(new LambdaQueryWrapper<ReceiptHeader>().eq(ReceiptHeader::getReferCode, billCode));
        List<ReceiptDetail> receiptDetails = receiptDetailService.list(new LambdaQueryWrapper<ReceiptDetail>().eq(ReceiptDetail::getReferCode, billCode));
        if(StringUtils.isNotEmpty(receiptHeader.getUserDef1())&&StringUtils.isNotEmpty(receiptHeader.getUserDef2())){
            PurchaseSelect purchaseSelect=new PurchaseSelect();
            Map map=new HashMap();
            purchaseSelect.setFormId("STK_InStock");
            purchaseSelect.setFieldKeys("FInStockEntry_FEntryID,FMATERIALID.FNUMBER");
            purchaseSelect.setFilterString("FBILLNO="+"'"+receiptHeader.getUserDef2()+"'");
            map.put("data",purchaseSelect);
            Gson gson = new Gson();
            String s = gson.toJson(map);
            purchaseSelectInvoke(JinDieApiUri.PURCHASE_SELECT.getApiUri(), s,receiptDetails);
        }
    }

    // 采购退料单查看
//    @Transactional(rollbackFor = Exception.class)
//    public void purchaseOutSee(String billCode) throws Exception {
//        ReceiptHeader receiptHeader = receiptHeaderService.getOne(new LambdaQueryWrapper<ReceiptHeader>().eq(ReceiptHeader::getReferCode, billCode));
//        List<ReceiptDetail> receiptDetails = receiptDetailService.list(new LambdaQueryWrapper<ReceiptDetail>().eq(ReceiptDetail::getReferCode, billCode));
//        if(StringUtils.isNotEmpty(receiptHeader.getUserDef1())&&StringUtils.isNotEmpty(receiptHeader.getUserDef2())){
//            PurchaseSee purchaseSee=new PurchaseSee();
//            PurchaseSeeData purchaseSeeData=new PurchaseSeeData();
//            Map map=new HashMap();
//            purchaseSee.setFormId("PUR_MRB");
//            purchaseSeeData.setCreateOrgId(0);
//            purchaseSeeData.setNumber(receiptHeader.getUserDef2());
//            purchaseSeeData.setId("");
//            purchaseSee.setData(purchaseSeeData);
//            map.put("data",purchaseSee);
//            JSONObject jsonObject = (JSONObject) JSONObject.toJSON(map);
//            purchaseOutSeeInvoke(JinDieApiUri.PURCHASE_OUT_SEE.getApiUri(), jsonObject,receiptDetails);
//        }
//    }

//    private void purchaseOutSeeInvoke(String apiUri, JSONObject jsonObject, List<ReceiptDetail> receiptDetails) throws Exception {
//        HttpURLConnection connectionInvoke = initUrlConn(apiUri, jsonObject);
//        BufferedReader reader = new BufferedReader(new InputStreamReader(connectionInvoke.getInputStream()));
//        String line;
//        String sResult=null;
//        while ((line = reader.readLine()) != null) {
//            sResult = new String(line.getBytes(), "utf-8");
//            System.out.println(sResult);
//        }
//        PurchaseReturnSee purchaseReturnSee = JSONObject.parseObject(sResult, PurchaseReturnSee.class);
//
//    }

    // 采购入库单保存
    public void save(String billCode) throws Exception {
        ReceiptHeader receiptHeader = receiptHeaderService.getOne(new LambdaQueryWrapper<ReceiptHeader>().eq(ReceiptHeader::getReferCode, billCode));
        List<ReceiptDetail> receiptDetails = receiptDetailService.list(new LambdaQueryWrapper<ReceiptDetail>().eq(ReceiptDetail::getReferCode, billCode));

        PurchaseBatchSave purchaseBatchSave = newInstancePurchaseBatchSave();

        List<PurchaseBatchSave.DataDTO.ModelDTO.FInStockEntryDTO> fInStockEntryDTOList=new ArrayList<>();

        purchaseBatchSave.setFormid("STK_InStock");
        purchaseBatchSave.getData().getModel().setFId(receiptHeader.getUserDef1());

        receiptDetails.forEach((receiptDetail)->{
            if(StringUtils.isNotEmpty(receiptHeader.getUserDef1())&&StringUtils.isNotEmpty(receiptHeader.getUserDef2())&&StringUtils.isNotEmpty(receiptDetail.getUserDef1())){
                PurchaseBatchSave.DataDTO.ModelDTO.FInStockEntryDTO fInStockEntryDTO = new PurchaseBatchSave.DataDTO.ModelDTO.FInStockEntryDTO();
                fInStockEntryDTO.setFEntryID(receiptDetail.getUserDef1());
                fInStockEntryDTO.setFRealQty(receiptDetail.getTotalQty());
                fInStockEntryDTOList.add(fInStockEntryDTO);
                purchaseBatchSave.getData().getModel().setFInStockEntry(fInStockEntryDTOList);
            }
        });
        Gson gson = new Gson();
        String s = gson.toJson(purchaseBatchSave);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.PURCHASE_SAVE.getApiUri(), s);
        receiptResultHandle(invoke,billCode,"save");
        System.out.println("Save:"+"单号"+billCode+"成功!");
    }

    // 采购入库单提交
    public void submit(String billCode) throws Exception {
        ReceiptHeader receiptHeader = receiptHeaderService.getOne(new LambdaQueryWrapper<ReceiptHeader>().eq(ReceiptHeader::getReferCode, billCode));
        PurchasePush purchasePush=new PurchasePush();
        purchasePush.setFormid("STK_InStock");
        PurchasePushData purchasePushData = new PurchasePushData();
        purchasePush.setData(purchasePushData);
        purchasePush.getData().setIds(receiptHeader.getUserDef1());
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.PURCHASE_SUBMIT.getApiUri(), s);
        receiptResultHandle(invoke,billCode,"submit");
        System.out.println("Submit:"+"单号"+billCode+"成功!");
    }

    // 采购入库单审核
    public void audit(String  billCode) throws Exception {
        ReceiptHeader receiptHeader = receiptHeaderService.getOne(new LambdaQueryWrapper<ReceiptHeader>().eq(ReceiptHeader::getReferCode, billCode));
        PurchasePush purchasePush=new PurchasePush();
        purchasePush.setFormid("STK_InStock");
        PurchasePushData purchasePushData = new PurchasePushData();
        purchasePush.setData(purchasePushData);
        purchasePush.getData().setIds(receiptHeader.getUserDef1());
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.PURCHASE_AUDIT.getApiUri(), s);
        receiptResultHandle(invoke,billCode,"audit");
        System.out.println("Audit:"+"单号"+billCode+"成功!");
    }

    //delete删除回传数据
    public void delete(String billCode) throws Exception {
        PurchasePush purchasePush=new PurchasePush();
        purchasePush.setFormid("STK_InStock");
        List<String> list=new ArrayList();
        list.add(billCode);
        PurchasePushData purchasePushData=new PurchasePushData();
        purchasePushData.setNumbers(list);
        purchasePush.setData(purchasePushData);
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Invoke(JinDieApiUri.DELETE_RETURN.getApiUri(), s);
        System.out.println("Delete:"+"单号"+billCode+"成功!");
    }

    /**
     * 直接调拨单操作
     * @throws Exception
     */

    /**
     * 直接调拨单保存
     * @param referCode  ERP单号
     * @param FSrcStockId   调出仓库编码
     * @param FDestStockId    调入仓库编码
     * @throws Exception
     */
    public void allocateSave(String referCode,String FSrcStockId,String FDestStockId) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getReferCode, referCode));
        List<ShipmentDetail> shipmentDetails = shipmentDetailService.list(new LambdaQueryWrapper<ShipmentDetail>().eq(ShipmentDetail::getReferCode, referCode));

        Allocate allocate = newInstanceAllocateBatchSave();

        allocate.setFormid("STK_TransferDirect");
        allocate.getData().getModel().setFid(shipmentHeader.getReferLineId());
        //allocate.getData().getModel().getF_aro_Base().setFstaffnumber("006034_GW000039_100069");
        allocate.getData().getModel().setFDate(DateUtils.parseDateToStr("yyyy-MM-dd",new Date()));

        ArrayList<Allocate.DataDTO.ModelDTO.FBillEntryDTO> fBillEntryDTOS=new ArrayList<>();

        shipmentDetails.forEach((shipmentDetail -> {
            Allocate.DataDTO.ModelDTO.FBillEntryDTO fBillEntryDTO = new Allocate.DataDTO.ModelDTO.FBillEntryDTO();
            newInstanceAllocateBatchSave2(fBillEntryDTO);
//            fBillEntryDTO.getFMaterialId().setFNumber(shipmentDetail.getMaterialCode());
            fBillEntryDTO.setFQty(shipmentDetail.getShipQty());
            fBillEntryDTO.setFEntryID(shipmentDetail.getLineId());
//            fBillEntryDTO.getFLot().setFNumber(shipmentDetail.getBatch());
//            fBillEntryDTO.getFSrcStockId().setFNumber(FSrcStockId);
//            fBillEntryDTO.getFDestStockId().setFNumber(FDestStockId);
            try {
//                String s1 = position_select(FSrcStockId);
//                bindFsrcStockLocIdData(s1,fBillEntryDTO);
//                String s2 = position_select(FDestStockId);
//                bindFDestStockLocIdData(s2,fBillEntryDTO);
            } catch (Exception e) {
                e.printStackTrace();
            }

            fBillEntryDTOS.add(fBillEntryDTO);
            allocate.getData().getModel().setFBillEntry(fBillEntryDTOS);
        }));
        Gson gson = new Gson();
        String s = gson.toJson(allocate);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.ALLOCATE_SAVE.getApiUri(), s);
        shipmentResultHandle(invoke,referCode,"save");
        System.out.println("allocateSave:"+"单号"+referCode+"成功!");
    }

    public void allocateSaveV(String referCode,String FSrcStockId,String FDestStockId) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getReferCode, referCode));
        List<ShipmentDetail> shipmentDetails = shipmentDetailService.list(new LambdaQueryWrapper<ShipmentDetail>().eq(ShipmentDetail::getReferCode, referCode));

        AllocateV allocateV = newInstanceAllocateBatchSaveV();

        ArrayList<AllocateV.DataDTO.ModelDTO.FBillEntryDTO> fBillEntryDTOS=new ArrayList<>();

        shipmentDetails.forEach((shipmentDetail -> {
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO fBillEntryDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO();
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FMaterialIdDTO fMaterialIdDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FMaterialIdDTO();
            fMaterialIdDTO.setFNumber(shipmentDetail.getMaterialCode());
            fBillEntryDTO.setFMaterialId(fMaterialIdDTO);
            fBillEntryDTO.setFQty(shipmentDetail.getShipQty().intValue());
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FLotDTO fLotDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FLotDTO();
            fLotDTO.setFNumber(shipmentDetail.getBatch());
            fBillEntryDTO.setFLot(fLotDTO);
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockIdDTO fSrcStockIdDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockIdDTO();
            fSrcStockIdDTO.setFNumber("CK621001");
            fBillEntryDTO.setFSrcStockId(fSrcStockIdDTO);
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockIdDTO fDestStockIdDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockIdDTO();
            fDestStockIdDTO.setFNumber("CK621002");
            fBillEntryDTO.setFDestStockId(fDestStockIdDTO);
            fBillEntryDTO.setFBusinessDate(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",new Date()));
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100001DTO fsrcstocklocidff100001DTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100001DTO();
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100001DTO fdeststocklocidff100001DTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100001DTO();
            fsrcstocklocidff100001DTO.setFNumber("1001");
            fdeststocklocidff100001DTO.setFNumber("1001");
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO fSrcStockLocIdDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO();
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO fdestStockLocIdDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO();
            fSrcStockLocIdDTO.setFsrcstocklocid__Ff100001(fsrcstocklocidff100001DTO);
            fBillEntryDTO.setFSrcStockLocId(fSrcStockLocIdDTO);
            fdestStockLocIdDTO.setFdeststocklocid__Ff100001(fdeststocklocidff100001DTO);
            fBillEntryDTO.setFDestStockLocId(fdestStockLocIdDTO);
            fBillEntryDTOS.add(fBillEntryDTO);
        }));
        allocateV.getData().getModel().setFBillEntry(fBillEntryDTOS);
        Gson gson = new Gson();
        String s = gson.toJson(allocateV);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.ALLOCATE_SAVE.getApiUri(), s);
        shipmentResultHandle(invoke,referCode,"save");
        System.out.println("allocateSave:"+"单号"+referCode+"成功!");
    }

    public void allocateSaveV2(String code,String FSrcStockId,String FDestStockId) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getCode, code));
        List<ShipmentDetail> shipmentDetails = shipmentDetailService.list(new LambdaQueryWrapper<ShipmentDetail>().eq(ShipmentDetail::getShipmentCode, code));

        AllocateV allocateV = newInstanceAllocateBatchSaveV();

        ArrayList<AllocateV.DataDTO.ModelDTO.FBillEntryDTO> fBillEntryDTOS=new ArrayList<>();

        shipmentDetails.forEach((shipmentDetail -> {
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO fBillEntryDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO();
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FMaterialIdDTO fMaterialIdDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FMaterialIdDTO();
            fMaterialIdDTO.setFNumber(shipmentDetail.getMaterialCode());
            fBillEntryDTO.setFMaterialId(fMaterialIdDTO);
            fBillEntryDTO.setFQty(shipmentDetail.getShipQty().intValue());
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FLotDTO fLotDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FLotDTO();
            fLotDTO.setFNumber(shipmentDetail.getBatch());
            fBillEntryDTO.setFLot(fLotDTO);
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockIdDTO fSrcStockIdDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockIdDTO();
            fSrcStockIdDTO.setFNumber(shipmentDetail.getfSrcStockId());
            fBillEntryDTO.setFSrcStockId(fSrcStockIdDTO);
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockIdDTO fDestStockIdDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockIdDTO();
            fDestStockIdDTO.setFNumber(shipmentDetail.getfDestStockId());
            fBillEntryDTO.setFDestStockId(fDestStockIdDTO);
            fBillEntryDTO.setFBusinessDate(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",new Date()));
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100001DTO fsrcstocklocidff100001DTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100001DTO();
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100001DTO fdeststocklocidff100001DTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100001DTO();
            fsrcstocklocidff100001DTO.setFNumber(shipmentDetail.getfSrcStockLocId());
            fdeststocklocidff100001DTO.setFNumber(shipmentDetail.getfDestStockLocId());
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO fSrcStockLocIdDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO();
            AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO fdestStockLocIdDTO=new AllocateV.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO();
            fSrcStockLocIdDTO.setFsrcstocklocid__Ff100001(fsrcstocklocidff100001DTO);
            fBillEntryDTO.setFSrcStockLocId(fSrcStockLocIdDTO);
            fdestStockLocIdDTO.setFdeststocklocid__Ff100001(fdeststocklocidff100001DTO);
            fBillEntryDTO.setFDestStockLocId(fdestStockLocIdDTO);
            fBillEntryDTOS.add(fBillEntryDTO);
        }));
        allocateV.getData().getModel().setFBillEntry(fBillEntryDTOS);
        Gson gson = new Gson();
        String s = gson.toJson(allocateV);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.ALLOCATE_SAVE.getApiUri(), s);
        shipmentResultHandle2(invoke,code,"save");
        System.out.println("allocateSave:"+"单号"+code+"成功!");
    }

    @Transactional(rollbackFor = Exception.class)
    public void shipmentResultHandle(Results.ResultDTO.ResponseStatusDTO responseStatusDTO,String billCode,String flag){
        List<Results.ResultDTO.ResponseStatusDTO.SuccessEntitys> successEntitys = responseStatusDTO.getSuccessEntitys();
        List<Results.ResultDTO.ResponseStatusDTO.ErrorsDTO> errors = responseStatusDTO.getErrors();
        Results.ResultDTO.ResponseStatusDTO.SuccessEntitys successEntity=null;
        Results.ResultDTO.ResponseStatusDTO.ErrorsDTO errorsDTO=null;
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getReferCode, billCode));
        if(!CollectionUtils.isEmpty(successEntitys)){
            successEntity = successEntitys.get(0);
            if(flag.equals("save")){
                Integer id = successEntity.getId();
                String number = successEntity.getNumber();
                shipmentHeader.setUserDef1(id.toString());
                shipmentHeader.setUserDef2(number);
                shipmentHeader.setUserDef4("成功");
            }else if(flag.equals("submit")){
                shipmentHeader.setUserDef5("成功");
            }else if(flag.equals("audit")){
                shipmentHeader.setUserDef6("成功");
            }
            shipmentHeaderService.updateById(shipmentHeader);
        }else {
            errorsDTO = errors.get(0);
            String message = errorsDTO.getMessage();
            if(flag.equals("save")){
                shipmentHeader.setUserDef4(message);
            }else if(flag.equals("submit")){
                shipmentHeader.setUserDef5(message);
            }else if(flag.equals("audit")){
                shipmentHeader.setUserDef6(message);
            }
            shipmentHeaderService.updateById(shipmentHeader);
        }
    }

    @Transactional(rollbackFor = Exception.class)
    public void shipmentResultHandle2(Results.ResultDTO.ResponseStatusDTO responseStatusDTO,String billCode,String flag){
        List<Results.ResultDTO.ResponseStatusDTO.SuccessEntitys> successEntitys = responseStatusDTO.getSuccessEntitys();
        List<Results.ResultDTO.ResponseStatusDTO.ErrorsDTO> errors = responseStatusDTO.getErrors();
        Results.ResultDTO.ResponseStatusDTO.SuccessEntitys successEntity=null;
        Results.ResultDTO.ResponseStatusDTO.ErrorsDTO errorsDTO=null;
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getCode, billCode));
        if(!CollectionUtils.isEmpty(successEntitys)){
            successEntity = successEntitys.get(0);
            if(flag.equals("save")){
                Integer id = successEntity.getId();
                String number = successEntity.getNumber();
                shipmentHeader.setUserDef1(id.toString());
                shipmentHeader.setUserDef2(number);
                shipmentHeader.setUserDef4("成功");
            }else if(flag.equals("submit")){
                shipmentHeader.setUserDef5("成功");
            }else if(flag.equals("audit")){
                shipmentHeader.setUserDef6("成功");
            }
            shipmentHeaderService.updateById(shipmentHeader);
        }else {
            errorsDTO = errors.get(0);
            String message = errorsDTO.getMessage();
            if(flag.equals("save")){
                shipmentHeader.setUserDef4(message);
            }else if(flag.equals("submit")){
                shipmentHeader.setUserDef5(message);
            }else if(flag.equals("audit")){
                shipmentHeader.setUserDef6(message);
            }
            shipmentHeaderService.updateById(shipmentHeader);
        }
    }

    @Transactional(rollbackFor = Exception.class)
    public void shipmentResultHandle4Mes(Results.ResultDTO.ResponseStatusDTO responseStatusDTO,String billCode,String flag){
        List<Results.ResultDTO.ResponseStatusDTO.SuccessEntitys> successEntitys = responseStatusDTO.getSuccessEntitys();
        List<Results.ResultDTO.ResponseStatusDTO.ErrorsDTO> errors = responseStatusDTO.getErrors();
        Results.ResultDTO.ResponseStatusDTO.SuccessEntitys successEntity=null;
        Results.ResultDTO.ResponseStatusDTO.ErrorsDTO errorsDTO=null;
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getCode, billCode));
        if(!CollectionUtils.isEmpty(successEntitys)){
            successEntity = successEntitys.get(0);
            if(flag.equals("push")){
                Integer id = successEntity.getId();
                String number = successEntity.getNumber();
                Integer dIndex = successEntity.getDIndex();
                shipmentHeader.setUserDef1(id.toString());
                shipmentHeader.setUserDef2(number);
                shipmentHeader.setUserDef3("成功");
            }else if(flag.equals("save")){
                shipmentHeader.setUserDef4("成功");
            }else if(flag.equals("submit")){
                shipmentHeader.setUserDef5("成功");
            }else if(flag.equals("audit")){
                shipmentHeader.setUserDef6("成功");
            }
            shipmentHeaderService.updateById(shipmentHeader);
        }else {
            errorsDTO = errors.get(0);
            String message = errorsDTO.getMessage();
            if(flag.equals("push")){
                shipmentHeader.setUserDef3(message);
            }else if(flag.equals("save")){
                shipmentHeader.setUserDef4(message);
            }else if(flag.equals("submit")){
                shipmentHeader.setUserDef5(message);
            }else if(flag.equals("audit")){
                shipmentHeader.setUserDef6(message);
            }
            shipmentHeaderService.updateById(shipmentHeader);
        }
    }

    //直接调拨单提交
    public void allocateSubmit(String referCode) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getReferCode, referCode));
        PurchasePush purchasePush=new PurchasePush();
        purchasePush.setFormid("STK_TransferDirect");
        PurchasePushData purchasePushData = new PurchasePushData();
        purchasePush.setData(purchasePushData);
        purchasePush.getData().setIds(shipmentHeader.getUserDef1());
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.ALLOCATE_SUBMIT.getApiUri(), s);
        shipmentResultHandle(invoke,referCode,"submit");
        System.out.println("allocateSubmit:"+"单号"+referCode+"成功!");
    }
    public void allocateSubmit2(String code) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getCode, code));
        PurchasePush purchasePush=new PurchasePush();
        purchasePush.setFormid("STK_TransferDirect");
        PurchasePushData purchasePushData = new PurchasePushData();
        purchasePush.setData(purchasePushData);
        purchasePush.getData().setIds(shipmentHeader.getUserDef1());
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.ALLOCATE_SUBMIT.getApiUri(), s);
        shipmentResultHandle2(invoke,code,"submit");
        System.out.println("allocateSubmit:"+"单号"+code+"成功!");
    }

    //直接调拨单审核
    public void allocateAudit(String referCode) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getReferCode, referCode));
        PurchasePush purchasePush=new PurchasePush();
        purchasePush.setFormid("STK_TransferDirect");
        PurchasePushData purchasePushData = new PurchasePushData();
        purchasePush.setData(purchasePushData);
        purchasePush.getData().setIds(shipmentHeader.getUserDef1());
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.ALLOCATE_AUDIT.getApiUri(), s);
        shipmentResultHandle(invoke,referCode,"audit");
        System.out.println("allocateAudit:"+"单号"+referCode+"成功!");
    }

    public void allocateAudit2(String code) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getCode, code));
        PurchasePush purchasePush=new PurchasePush();
        purchasePush.setFormid("STK_TransferDirect");
        PurchasePushData purchasePushData = new PurchasePushData();
        purchasePush.setData(purchasePushData);
        purchasePush.getData().setIds(shipmentHeader.getUserDef1());
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.ALLOCATE_AUDIT.getApiUri(), s);
        shipmentResultHandle2(invoke,code,"audit");
        System.out.println("allocateAudit:"+"单号"+code+"成功!");
    }

    /**
     * 采购退料单操作
     * @throws Exception
     */

    //采购退货单保存
    public void purchase_return_save(String referCode) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getReferCode, referCode));
        List<ShipmentDetail> shipmentDetails = shipmentDetailService.list(new LambdaQueryWrapper<ShipmentDetail>().eq(ShipmentDetail::getReferCode, referCode));

        PurchaseReturnSave purchaseReturnSave = newInstancePurchaseReturnSave();

        List<PurchaseReturnSave.DataDTO.ModelDTO.FPURMRBENTRYDTO> fpurmrbentrydtos=new ArrayList<>();

        purchaseReturnSave.setFormid("PUR_MRB");
        purchaseReturnSave.getData().getModel().setFId(shipmentHeader.getReferLineId().toString());

        shipmentDetails.forEach((shipmentDetail)->{
            //if(StringUtils.isNotEmpty(shipmentHeader.getUserDef1())&&StringUtils.isNotEmpty(shipmentHeader.getUserDef2())&&StringUtils.isNotEmpty(shipmentDetail.getUserDef1())){
                PurchaseReturnSave.DataDTO.ModelDTO.FPURMRBENTRYDTO fpurmrbentrydto = new PurchaseReturnSave.DataDTO.ModelDTO.FPURMRBENTRYDTO();
                //PurchaseReturnSave.DataDTO.ModelDTO.FPURMRBENTRYDTO.FMaterialIdDTO fMaterialIdDTO = new PurchaseReturnSave.DataDTO.ModelDTO.FPURMRBENTRYDTO.FMaterialIdDTO();
                fpurmrbentrydto.setFEntryID(shipmentDetail.getLineId());
                fpurmrbentrydto.setFrmrealqty(shipmentDetail.getShipQty());
                //fMaterialIdDTO.setFNumber(shipmentDetail.getMaterialCode());
                //fpurmrbentrydto.setFMaterialId(fMaterialIdDTO);
                fpurmrbentrydtos.add(fpurmrbentrydto);
                purchaseReturnSave.getData().getModel().setFpurmrbentry(fpurmrbentrydtos);
           // }
        });
        Gson gson = new Gson();
        String s = gson.toJson(purchaseReturnSave);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.PURCHASE_RETURN_SAVE.getApiUri(), s);
        shipmentResultHandle(invoke,referCode,"save");
        System.out.println("PURCHASE_RETURN_SAVE:"+"单号"+referCode+"成功!");
    }

    //采购退货单保存
    public void purchase_return_save_V(String referCode) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getReferCode, referCode));
        List<ShipmentDetail> shipmentDetails = shipmentDetailService.list(new LambdaQueryWrapper<ShipmentDetail>().eq(ShipmentDetail::getReferCode, referCode));

        PurchaseReturnSaveV purchaseReturnSaveV = newInstancePurchaseReturnSaveV();

        List<PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO> fpurmrbentrydtos=new ArrayList<>();

        shipmentDetails.forEach((shipmentDetail)->{
            PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO fpurmrbentrydto=new PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO();
            PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FMATERIALIDDTO fmaterialiddto=new  PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FMATERIALIDDTO();
            fmaterialiddto.setFNumber(shipmentDetail.getMaterialCode());
            fpurmrbentrydto.setFmaterialid(fmaterialiddto);

            fpurmrbentrydto.setFrmrealqty(shipmentDetail.getShipQty().intValue());

            PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FSTOCKIDDTO fstockiddto=new  PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FSTOCKIDDTO();
            fstockiddto.setFNumber("CK621001");
            fpurmrbentrydto.setFstockid(fstockiddto);

            PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FSTOCKLOCIDDTO fstocklociddto =new PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FSTOCKLOCIDDTO();
            PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FSTOCKLOCIDDTO.FSTOCKLOCID__FF100001DTO fstocklocidff100001DTO=new PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FSTOCKLOCIDDTO.FSTOCKLOCID__FF100001DTO();
            fstocklocidff100001DTO.setFNumber("1001");
            fstocklociddto.setFstocklocid__Ff100001(fstocklocidff100001DTO);
            fpurmrbentrydto.setFstocklocid(fstocklociddto);

            PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FLOTDTO flotdto=new PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FLOTDTO();
            flotdto.setFNumber(shipmentDetail.getBatch());
            fpurmrbentrydto.setFlot(flotdto);

            fpurmrbentrydto.setFSRCBillTypeId("PUR_ReceiveBill");

            List<PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FPURMRBENTRYLinkDTO> fpurmrbentryLinkDTOS=new ArrayList<>();
            PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FPURMRBENTRYLinkDTO fpurmrbentryLinkDTO=new PurchaseReturnSaveV.DataDTO.ModelDTO.FPURMRBENTRYDTO.FPURMRBENTRYLinkDTO();
            fpurmrbentryLinkDTO.setFpurmrbentryLinkFruleid("PUR_ReceiveBill-PUR_MRB");
            fpurmrbentryLinkDTO.setFpurmrbentryLinkFstablename("T_PUR_ReceiveEntry");
            fpurmrbentryLinkDTO.setFpurmrbentryLinkFsbillid(shipmentHeader.getReferLineId().toString());
            fpurmrbentryLinkDTO.setFpurmrbentryLinkFsid(shipmentDetail.getLineId().toString());
            fpurmrbentryLinkDTO.setFpurmrbentryLinkFcarrybaseqtyold(shipmentDetail.getShipQty().intValue());
            fpurmrbentryLinkDTO.setFpurmrbentryLinkFcarrybaseqty(shipmentDetail.getShipQty().intValue());
            fpurmrbentryLinkDTO.setFpurmrbentryLinkFbaseunitqtyold(shipmentDetail.getShipQty().intValue());
            fpurmrbentryLinkDTO.setFpurmrbentryLinkFbaseunitqty(shipmentDetail.getShipQty().intValue());
            fpurmrbentryLinkDTOS.add(fpurmrbentryLinkDTO);
            fpurmrbentrydto.setFpurmrbentryLink(fpurmrbentryLinkDTOS);
            fpurmrbentrydtos.add(fpurmrbentrydto);
        });
        purchaseReturnSaveV.getData().getModel().setFpurmrbentry(fpurmrbentrydtos);
        Gson gson=new Gson();
        String s = gson.toJson(purchaseReturnSaveV);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.PURCHASE_RETURN_SAVE.getApiUri(), s);
        shipmentResultHandle(invoke,referCode,"save");
        System.out.println("PURCHASE_RETURN_SAVE_V:"+"单号"+referCode+"成功!");
    }

    //采购退货单提交
    public void purchase_return_submit(String referCode) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getReferCode, referCode));
        PurchasePush purchasePush=new PurchasePush();
        purchasePush.setFormid("PUR_MRB");
        PurchasePushData purchasePushData = new PurchasePushData();
        purchasePush.setData(purchasePushData);
        purchasePush.getData().setIds(shipmentHeader.getReferLineId().toString());
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.PURCHASE_RETURN_SUBMIT.getApiUri(), s);
        shipmentResultHandle(invoke,referCode,"submit");
        System.out.println("PURCHASE_RETURN_SUBMIT:"+"单号"+referCode+"成功!");
    }

    public void purchase_return_submit_V(String referCode) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getReferCode, referCode));
        PurchasePush purchasePush=new PurchasePush();
        purchasePush.setFormid("PUR_MRB");
        PurchasePushData purchasePushData = new PurchasePushData();
        purchasePush.setData(purchasePushData);
        purchasePush.getData().setIds(shipmentHeader.getUserDef1().toString());
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.PURCHASE_RETURN_SUBMIT.getApiUri(), s);
        shipmentResultHandle(invoke,referCode,"submit");
        System.out.println("PURCHASE_RETURN_SUBMIT:"+"单号"+referCode+"成功!");
    }

    //采购退货单审核
    public void purchase_return_audit(String referCode) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getReferCode, referCode));
        PurchasePush purchasePush=new PurchasePush();
        purchasePush.setFormid("PUR_MRB");
        PurchasePushData purchasePushData = new PurchasePushData();
        purchasePush.setData(purchasePushData);
        purchasePush.getData().setIds(shipmentHeader.getReferLineId().toString());
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.PURCHASE_RETURN_AUDIT.getApiUri(), s);
        shipmentResultHandle(invoke,referCode,"audit");
        System.out.println("PURCHASE_RETURN_AUDIT:"+"单号"+referCode+"成功!");
    }

    public void purchase_return_audit_V(String referCode) throws Exception {
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>().eq(ShipmentHeader::getReferCode, referCode));
        PurchasePush purchasePush=new PurchasePush();
        purchasePush.setFormid("PUR_MRB");
        PurchasePushData purchasePushData = new PurchasePushData();
        purchasePush.setData(purchasePushData);
        purchasePush.getData().setIds(shipmentHeader.getUserDef1().toString());
        Gson gson = new Gson();
        String s = gson.toJson(purchasePush);
        Results.ResultDTO.ResponseStatusDTO invoke = Invoke(JinDieApiUri.PURCHASE_RETURN_AUDIT.getApiUri(), s);
        shipmentResultHandle(invoke,referCode,"audit");
        System.out.println("PURCHASE_RETURN_AUDIT:"+"单号"+referCode+"成功!");
    }

    //仓位值查询:用于直接调拨单
    public String position_select(String warehouseCode) throws Exception {
        PurchaseSelect purchaseSelect=new PurchaseSelect();
        Map map=new HashMap();
        purchaseSelect.setFormId("BD_STOCK");
        purchaseSelect.setFieldKeys("FFlexNumber");
        purchaseSelect.setFilterString("FNumber="+"'"+warehouseCode+"'");
        map.put("data",purchaseSelect);
        Gson gson = new Gson();
        String s = gson.toJson(map);
        return positionSelectInvoke(JinDieApiUri.POSITION_SELECT.getApiUri(), s);
    }

    //仓位值提交到金蝶  已经提交到测试环境一次了 别再次提交了
    public void position_save() throws Exception {
        LambdaQueryWrapper<Location> lambdaQueryWrapper= Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(Location::getLocationType,"L");
        List<Location> list = locationService.list();
        ArrayList<Position.DataDTO.ModelDTO.FEntityDTO> fEntityDTOS=new ArrayList<>();
        list.forEach(location -> {
            Position.DataDTO.ModelDTO.FEntityDTO fEntityDTO = new Position.DataDTO.ModelDTO.FEntityDTO();
            fEntityDTO.setFFlexValueName(location.getCode());
            fEntityDTO.setFFlexValueNumber(location.getCode());
            fEntityDTOS.add(fEntityDTO);
        });
        Position.DataDTO.ModelDTO modelDTO = new Position.DataDTO.ModelDTO();
        modelDTO.setFid(100001);
        modelDTO.setFEntity(fEntityDTOS);
        Position.DataDTO dataDTO = new Position.DataDTO();
        dataDTO.setIsDeleteEntry("false");
        dataDTO.setModel(modelDTO);
        Position position=new Position();
        position.setData(dataDTO);
        position.setFormid("BD_FLEXVALUES");
        Gson gson = new Gson();
        String s = gson.toJson(position);
        Invoke(JinDieApiUri.POISTTION_SAVE.getApiUri(),s);
    }


    /**
     * 通用参数推送
     * @param uri
     * @param jParas  参数
     * @return  Results.ResultDTO.ResponseStatusDTO.SuccessEntitys
     * @throws Exception
     */
    public  Results.ResultDTO.ResponseStatusDTO Invoke(String uri,String jParas)
            throws Exception {
        HttpURLConnection connectionInvoke = initUrlConn(uri, jParas);
        BufferedReader reader = new BufferedReader(new InputStreamReader(connectionInvoke.getInputStream()));
        String line;
        String sResult=null;
        while ((line = reader.readLine()) != null) {
            sResult = new String(line.getBytes(), "utf-8");
            System.out.println(sResult);
        }
        ApiLogAspect.finishApiLog(apiLog,connectionInvoke,AjaxResult.success(sResult).toString());
        Results results = JSONObject.parseObject(sResult, Results.class);
//        List<Results.ResultDTO.ResponseStatusDTO.SuccessEntitys> successEntitys = results.getResult().getResponseStatus().getSuccessEntitys();
//        List<Results.ResultDTO.ResponseStatusDTO.ErrorsDTO> errors = results.getResult().getResponseStatus().getErrors();
//        Results.ResultDTO.ResponseStatusDTO.SuccessEntitys successEntity=null;
//        Results.ResultDTO.ResponseStatusDTO.ErrorsDTO errorsDTO=null;
//        if(!CollectionUtils.isEmpty(successEntitys)){
//            successEntity = successEntitys.get(0);
//        }else {
//            errorsDTO = errors.get(0);
//        }
        reader.close();
        connectionInvoke.disconnect();
//        if(StringUtils.isNotNull(successEntity)){
//            return successEntity;
//        }else {
//            throw new ServiceException(errorsDTO.getMessage());
//        }
        return results.getResult().getResponseStatus();
    }


    /**
     * 采购入库单查询参数推送
     * @param uri   JinDieApiUri.PURCHASE_SELECT
     * @param
     * @param receiptDetails   入库单明细集合
     * @throws Exception
     */
    public void purchaseSelectInvoke(String uri,String s,List<ReceiptDetail> receiptDetails) throws Exception {
        HttpURLConnection connectionInvoke = initUrlConn(uri, s);
        BufferedReader reader = new BufferedReader(new InputStreamReader(connectionInvoke.getInputStream()));
        String line;
        String sResult=null;
        while ((line = reader.readLine()) != null) {
            sResult = new String(line.getBytes(), "utf-8");
            System.out.println(sResult);
        }
        List<List<Object>> results = JSONObject.parseObject(sResult, ArrayList.class);
        results.forEach((list)->{
            Integer purchaseLineId = (Integer) list.get(0);
            String materialCode = (String) list.get(1);
            receiptDetails.forEach((receiptDetail)->{
                if(receiptDetail.getMaterialCode().trim().equals(materialCode)){
                     receiptDetail.setUserDef1(purchaseLineId.toString());
                     receiptDetailService.updateById(receiptDetail);
                }
            });
        });
        reader.close();
        connectionInvoke.disconnect();
    }

    /**
     * 仓位值集查询参数推送
     * @param uri   JinDieApiUri.POSITION_SELECT
     * @param
     * @return   仓位值集字符串
     * @throws Exception
     */
    public String positionSelectInvoke(String uri, String s) throws Exception {
        HttpURLConnection connectionInvoke = initUrlConn(uri, s);
        BufferedReader reader = new BufferedReader(new InputStreamReader(connectionInvoke.getInputStream()));
        String line;
        String sResult=null;
        while ((line = reader.readLine()) != null) {
            sResult = new String(line.getBytes(), "utf-8");
            System.out.println(sResult);
        }
        List<List<Object>> results = JSONObject.parseObject(sResult, ArrayList.class);
        StringBuilder stringBuilder=new StringBuilder();
        results.forEach((list)->{
            stringBuilder.append(list.get(0).toString()+",");
        });
        reader.close();
        connectionInvoke.disconnect();
        return stringBuilder.toString();
    }

    public void selectSupplier(String uri, String s) throws Exception {
        HttpURLConnection connectionInvoke = initUrlConn(uri, s);
        BufferedReader reader = new BufferedReader(new InputStreamReader(connectionInvoke.getInputStream()));
        String line;
        String sResult=null;
        while ((line = reader.readLine()) != null) {
            sResult = new String(line.getBytes(), "utf-8");
            System.out.println(sResult);
        }
        List<List<Object>> results = JSONObject.parseObject(sResult, ArrayList.class);
        List<Supplier> supplierList=new ArrayList<>();
        results.forEach((list)->{
            String supplierCode = (String)list.get(0);
            String supplierName = (String)list.get(1);
            Supplier supplier=new Supplier();
            supplier.setCode(supplierCode);
            supplier.setName(supplierName);
            supplier.setWarehouseCode("CS0001");
            supplier.setCompanyCode("WB");
            supplierList.add(supplier);
        });
        try {
            supplierService.saveBatch(supplierList);
        }catch (Exception  e){
            e.printStackTrace();
        }
        reader.close();
        connectionInvoke.disconnect();
    }
    public void selectWarehouseAndPoint(String uri, String s) throws Exception {
        HttpURLConnection connectionInvoke = initUrlConn(uri, s);
        BufferedReader reader = new BufferedReader(new InputStreamReader(connectionInvoke.getInputStream()));
        String line;
        String sResult=null;
        while ((line = reader.readLine()) != null) {
            sResult = new String(line.getBytes(), "utf-8");
            System.out.println(sResult);
        }
        List<List<Object>> results = JSONObject.parseObject(sResult, ArrayList.class);
        List<WarehousePoint> warehousePointList=new ArrayList<>();
        results.forEach((list)->{
            String fNumber = String.valueOf(list.get(0));
            String fName = String.valueOf(list.get(1));
            String fStockProperty = String.valueOf(list.get(2));
            String fFlexEntryId =String.valueOf(list.get(3));
            WarehousePoint warehousePoint=new WarehousePoint();
            warehousePoint.setFNumber(fNumber);
            warehousePoint.setFName(fName);
            warehousePoint.setFStockProperty(fStockProperty);
            warehousePoint.setFFlexEntryId(fFlexEntryId);
            warehousePointList.add(warehousePoint);
        });
        try {
            warehousePointService.remove(Wrappers.lambdaQuery());
            warehousePointService.saveBatch(warehousePointList);
        }catch (Exception  e){
            e.printStackTrace();
        }
        reader.close();
        connectionInvoke.disconnect();
    }
    /**
     * 把中文转成Unicode码
     *
     * @param str
     * @return
     */
    public  String chinaToUnicode(String str) {
        String result = "";
        for (int i = 0; i < str.length(); i++) {
            int chr1 = (char) str.charAt(i);
            if (chr1 >= 19968 && chr1 <= 171941) {// 汉字范围 \u4e00-\u9fa5 (中文)
                result += "\\u" + Integer.toHexString(chr1);
            } else {
                result += str.charAt(i);
            }
        }
        return result;
    }

    //初始化采购入库单保存实体
    public  PurchaseBatchSave newInstancePurchaseBatchSave(){
        PurchaseBatchSave purchaseBatchSave=new PurchaseBatchSave();
        PurchaseBatchSave.DataDTO dataDTO = new PurchaseBatchSave.DataDTO();
        PurchaseBatchSave.DataDTO.ModelDTO modelDTO = new PurchaseBatchSave.DataDTO.ModelDTO();
        purchaseBatchSave.setData(dataDTO);
        purchaseBatchSave.getData().setModel(modelDTO);
        return purchaseBatchSave;
    }

    //初始化直接调拨单保存实体
    public  Allocate newInstanceAllocateBatchSave(){
        Allocate allocate=new Allocate();

        Allocate.DataDTO dataDTO = new Allocate.DataDTO();
        Allocate.DataDTO.ModelDTO modelDTO = new Allocate.DataDTO.ModelDTO();
//        Allocate.DataDTO.ModelDTO.FAroBaseDTO fAroBaseDTO = new Allocate.DataDTO.ModelDTO.FAroBaseDTO();

        allocate.setData(dataDTO);
        allocate.getData().setModel(modelDTO);
//        allocate.getData().getModel().setF_aro_Base(fAroBaseDTO);

        return allocate;
    }

    public  AllocateV newInstanceAllocateBatchSaveV(){
        AllocateV allocateV=new AllocateV();
        allocateV.setFormid("STK_TransferDirect");
        AllocateV.DataDTO dataDTO = new AllocateV.DataDTO();
        AllocateV.DataDTO.ModelDTO modelDTO = new AllocateV.DataDTO.ModelDTO();
        modelDTO.setFid(0);
        AllocateV.DataDTO.ModelDTO.FBillTypeIDDTO fBillTypeIDDTO=new AllocateV.DataDTO.ModelDTO.FBillTypeIDDTO();
        AllocateV.DataDTO.ModelDTO.FStockOutOrgIdDTO fStockOutOrgIdDTO=new AllocateV.DataDTO.ModelDTO.FStockOutOrgIdDTO();
        AllocateV.DataDTO.ModelDTO.F_aro_AssistantDTO f_aro_assistantDTO=new AllocateV.DataDTO.ModelDTO.F_aro_AssistantDTO();
        f_aro_assistantDTO.setFnumber("11");
        fBillTypeIDDTO.setFnumber("ZJDB01_SYS");
        fStockOutOrgIdDTO.setFnumber("62");
        modelDTO.setFBillTypeID(fBillTypeIDDTO);
        modelDTO.setFTransferDirect("GENERAL");
        modelDTO.setFTransferBizType("InnerOrgTransfer");
        modelDTO.setFStockOutOrgId(fStockOutOrgIdDTO);
        modelDTO.setF_aro_Assistant(f_aro_assistantDTO);
        modelDTO.setFDate(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",new Date()));
        AllocateV.DataDTO.ModelDTO.F_aro_BaseDTO f_aro_BaseDTO=new AllocateV.DataDTO.ModelDTO.F_aro_BaseDTO();
        f_aro_BaseDTO.setFSTAFFNUMBER("YG000108_GW000019_100069");
        modelDTO.setF_aro_Base(f_aro_BaseDTO);
        dataDTO.setModel(modelDTO);
        allocateV.setData(dataDTO);
        return allocateV;
    }

    //初始化直接调拨单内部类(传输model)
    public  void newInstanceAllocateBatchSave2(Allocate.DataDTO.ModelDTO.FBillEntryDTO fBillEntryDTO){
//        Allocate.DataDTO.ModelDTO.FBillEntryDTO.FMaterialIdDTO fMaterialIdDTO = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FMaterialIdDTO();
//        Allocate.DataDTO.ModelDTO.FBillEntryDTO.FUnitIDDTO fUnitIDDTO = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FUnitIDDTO();
//        Allocate.DataDTO.ModelDTO.FBillEntryDTO.FLotDTO fLotDTO = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FLotDTO();
//        Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockIdDTO fSrcStockIdDTO = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockIdDTO();
//        Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO fSrcStockLocIdDTO = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO();
//        Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockIdDTO fDestStockIdDTO = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockIdDTO();
//        Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO fDestStockLocIdDTO = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO();

//        fBillEntryDTO.setFMaterialId(fMaterialIdDTO);
//        fBillEntryDTO.setFUnitID(fUnitIDDTO);
//        fBillEntryDTO.setFLot(fLotDTO);
//        fBillEntryDTO.setFSrcStockId(fSrcStockIdDTO);
//        fBillEntryDTO.setFSrcStockLocId(fSrcStockLocIdDTO);
//        fBillEntryDTO.setFDestStockId(fDestStockIdDTO);
//        fBillEntryDTO.setFDestStockLocId(fDestStockLocIdDTO);
    }

    //初始化采购退料单保存实体
    public  PurchaseReturnSave newInstancePurchaseReturnSave(){
        PurchaseReturnSave purchaseReturnSave=new PurchaseReturnSave();
        PurchaseReturnSave.DataDTO dataDTO = new PurchaseReturnSave.DataDTO();
        PurchaseReturnSave.DataDTO.ModelDTO modelDTO = new PurchaseReturnSave.DataDTO.ModelDTO();

        purchaseReturnSave.setData(dataDTO);
        purchaseReturnSave.getData().setModel(modelDTO);
        return purchaseReturnSave;
    }

    //初始化采购退料单保存实体V
    public PurchaseReturnSaveV newInstancePurchaseReturnSaveV(){
        PurchaseReturnSaveV purchaseReturnSaveV=new PurchaseReturnSaveV();
        purchaseReturnSaveV.setFormId("PUR_MRB");
        PurchaseReturnSaveV.DataDTO dataDTO=new PurchaseReturnSaveV.DataDTO();
        PurchaseReturnSaveV.DataDTO.ModelDTO modelDTO=new PurchaseReturnSaveV.DataDTO.ModelDTO();

        PurchaseReturnSaveV.DataDTO.ModelDTO.FBillTypeIDDTO fBillTypeIDDTO=new PurchaseReturnSaveV.DataDTO.ModelDTO.FBillTypeIDDTO();
        fBillTypeIDDTO.setFnumber("TLD01_SYS");

        PurchaseReturnSaveV.DataDTO.ModelDTO.FSupplierIDDTO fSupplierIDDTO=new PurchaseReturnSaveV.DataDTO.ModelDTO.FSupplierIDDTO();
        fSupplierIDDTO.setFnumber("004");
        PurchaseReturnSaveV.DataDTO.ModelDTO.FStockOrgIdDTIO fStockOrgIdDTIO=new PurchaseReturnSaveV.DataDTO.ModelDTO.FStockOrgIdDTIO();
        fStockOrgIdDTIO.setFnumber("62");
        modelDTO.setFid(0);
        modelDTO.setFBillTypeID(fBillTypeIDDTO);
        modelDTO.setFDate(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",new Date()));
        modelDTO.setFSupplierID(fSupplierIDDTO);
        modelDTO.setFStockOrgId(fStockOrgIdDTIO);

        dataDTO.setModel(modelDTO);
        purchaseReturnSaveV.setData(dataDTO);
        return purchaseReturnSaveV;
    }

    /**
     * 初始化上游仓位维度值,绑定上游仓位编码
     * @param s  仓位维度值
     * @param fBillEntryDTO  直接调拨单保存实体类—>内部类
     */
    public   void  bindFsrcStockLocIdData(String s,Allocate.DataDTO.ModelDTO.FBillEntryDTO fBillEntryDTO){
         String[] strings = Convert.toStrArray(s);
         for (String string : strings) {
             if(string.trim().equals("FF100001")){
                 Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100001 fsrcstocklocid__ff100001 = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100001();
                 fBillEntryDTO.getFSrcStockLocId().setFSRCSTOCKLOCID__FF100001(fsrcstocklocid__ff100001);
                 fBillEntryDTO.getFSrcStockLocId().getFSRCSTOCKLOCID__FF100001().setFNumber("L010102");
             }
             if(string.trim().equals("FF100011")){
                 Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100011 fsrcstocklocid__ff100011 = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100011();
                 fBillEntryDTO.getFSrcStockLocId().setFSRCSTOCKLOCID__FF100011(fsrcstocklocid__ff100011);
                 fBillEntryDTO.getFSrcStockLocId().getFSRCSTOCKLOCID__FF100011().setFNumber("");
             }
             if(string.trim().equals("FF100015")){
                 Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100015 fsrcstocklocid__ff100015 = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100015();
                 fBillEntryDTO.getFSrcStockLocId().setFSRCSTOCKLOCID__FF100015(fsrcstocklocid__ff100015);
                 fBillEntryDTO.getFSrcStockLocId().getFSRCSTOCKLOCID__FF100015().setFNumber("");
             }
             if(string.trim().equals("FF100022")){
                 Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100022 fsrcstocklocid__ff100022 = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100022();
                 fBillEntryDTO.getFSrcStockLocId().setFSRCSTOCKLOCID__FF100022(fsrcstocklocid__ff100022);
                 fBillEntryDTO.getFSrcStockLocId().getFSRCSTOCKLOCID__FF100022().setFNumber("");
             }
             if(string.trim().equals("FF100026")){
                 Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100026 fsrcstocklocid__ff100026 = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FSrcStockLocIdDTO.FSRCSTOCKLOCID__FF100026();
                 fBillEntryDTO.getFSrcStockLocId().setFSRCSTOCKLOCID__FF100026(fsrcstocklocid__ff100026);
                 fBillEntryDTO.getFSrcStockLocId().getFSRCSTOCKLOCID__FF100026().setFNumber("");
             }
         }
    }

    /**
     * 初始化下游仓位维度值,绑定下游仓位编码
     * @param s  仓位维度值
     * @param fBillEntryDTO  直接调拨单保存实体类—>内部类
     */
    public   void  bindFDestStockLocIdData(String s,Allocate.DataDTO.ModelDTO.FBillEntryDTO fBillEntryDTO){
        String[] strings = Convert.toStrArray(s);
        for (String string : strings) {
            if(string.trim().equals("FF100001")){
                Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100001 fdeststocklocid__ff100001 = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100001();
                fBillEntryDTO.getFDestStockLocId().setFDESTSTOCKLOCID__FF100001(fdeststocklocid__ff100001);
                fBillEntryDTO.getFDestStockLocId().getFDESTSTOCKLOCID__FF100001().setFNumber("1001");
            }
            if(string.trim().equals("FF100011")){
                Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100011 fdeststocklocid__ff100011 = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100011();
                fBillEntryDTO.getFDestStockLocId().setFDESTSTOCKLOCID__FF100011(fdeststocklocid__ff100011);
                fBillEntryDTO.getFDestStockLocId().getFDESTSTOCKLOCID__FF100011().setFNumber("");
            }
            if(string.trim().equals("FF100015")){
                Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100015 fdeststocklocid__ff100015 = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100015();
                fBillEntryDTO.getFDestStockLocId().setFDESTSTOCKLOCID__FF100015(fdeststocklocid__ff100015);
                fBillEntryDTO.getFDestStockLocId().getFDESTSTOCKLOCID__FF100015().setFNumber("");
            }
            if(string.trim().equals("FF100022")){
                Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100022 fdeststocklocid__ff100022 = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100022();
                fBillEntryDTO.getFDestStockLocId().setFDESTSTOCKLOCID__FF100022(fdeststocklocid__ff100022);
                fBillEntryDTO.getFDestStockLocId().getFDESTSTOCKLOCID__FF100022().setFNumber("");
            }
            if(string.trim().equals("FF100026")){
                Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100026 fdeststocklocid__ff100026 = new Allocate.DataDTO.ModelDTO.FBillEntryDTO.FDestStockLocIdDTO.FDESTSTOCKLOCID__FF100026();
                fBillEntryDTO.getFDestStockLocId().setFDESTSTOCKLOCID__FF100026(fdeststocklocid__ff100026);
                fBillEntryDTO.getFDestStockLocId().getFDESTSTOCKLOCID__FF100026().setFNumber("");

            }
        }
    }

    //根据仓库编码,找仓位编码
    public  void bingStockLocIdFnumberData(String s,Allocate.DataDTO.ModelDTO.FBillEntryDTO fBillEntryDTO){
        //这里会有获取仓位值的逻辑
        //...
    }


}