• Project background: The company has a new retail store, and the leaser needs to collect rent according to the daily sales quota, so it needs to push the daily order data of the background to the third party. The key point is that this data is not in our background, but in the background of Yuzan. Due to the shortage of staff in the company, the leader directly arranged me to do it. Android workload is not saturated, back end to gather!
  • throughHttpRequest the raw data from a third party and then splice the raw data into what you wantjson, and then useWebServicesPush to a third party! That’s the process.

1, docking wechat group, docking documents open

  • What the fuck?? Black question mark, the first time a WebServices backend code, you give me a WebServices, how do I play? Drink some water, calm down, here thank the company’s back end big guy macro true brother gave the idea!

  • Here is an episode, the docking document provided by others is wrong, really is to kill me this small white, here want to scold, love baby for a few seconds, who is not a baby!

  • Find the interface provided by the document, and if it’s accessible, that should be the first step

2. Generate the corresponding JAR package

  • WebServiceClient (WS client)
  • We got the address for the test. The access’s working. UseideGenerate the code to get started, as follows

  • I have a problem and thank you for the solution that junit. Framework does not exist
  • If all goes well, you’ll see this interface

3. The problem now is to jar this pile of code

  • Thanks for helping me with this blogIdea turns a Java file in a newly written project into a JAR package method

  • The following files are generated

  • Click on the Build

  • Next, go to the output directory to find the JAR package

  • This is the JAR I can use, and if I need to change to a formal address later, I need to generate a formal JAR

3, the generation ofjarIn theMaven Nexus3

  • I don’t have access! Ah ah

  • I’m glad our architect helped me upload it

  • Configuration of pom

< the dependency > < groupId >.net. Ticp. Asiatic < / groupId > < artifactId > FTP - pingan - SDK < / artifactId > < version > 1.0.0 < / version > </dependency>Copy the code
  • Start running the project,What the fuck??
  • This mistake is not recognized ah! Ask big guy, thank big guy again for help.

4. Write code logic

  • Thanks again to maomao, another big guy in the company, because this process is that I request the third party’s background and then get the key data, and then integrate the key data throughWebServicesPush to a third party. I am an Android in this area inexperienced, he finished a smallDemoHe didn’t ask me to look, I looked at his code, change the logic, aha
/** * author: Created by Shiming on 2018/9/30 17:14 * mailbox: [email protected] */ @service @ElasticJobConf(name="YouzanPushOrderPingAnSynJob",cron = "*/5 * * * *?") public class YouzanPushOrderPingAnSynJob implements SimpleJob { @Resource private YZClientService yzClientService; / / private static final Long PAGE_SIZE = 20L; private static final Logger logger = LoggerFactory.getLogger(YouzanPushOrderPingAnSynJob.class); @Override public void execute(ShardingContext shardingContext) { YouzanRetailOpenDeliveryorderQuery youzanRetailOpenDeliveryorderQuery = buildQueryApi(); YouzanRetailOpenDeliveryorderQueryResult result = yzClientService.invoke(youzanRetailOpenDeliveryorderQuery); Long pages = parsePages(result.getPaginator().getTotalCount()); int j=0; int k=0; OrderPushUtils.m=0; // Paging queryfor(long pageNo = 1; pageNo <= pages ; PageNo++) {// set paginationsetPage(youzanRetailOpenDeliveryorderQuery,pageNo); / / query result result = yzClientService. Invoke (youzanRetailOpenDeliveryorderQuery); / / handling the query results YouzanRetailOpenDeliveryorderQueryResult. OpenDeliveryOrderDTO [] deliveryOrders = result. GetDeliveryOrders ();if(deliveryOrders! =null&&deliveryOrders.length>0){for(int i=0; i<deliveryOrders.length; I++){// the data of ping an store can be correct and it is good to offline storeif(YouzanConst.ORDER_FORM_PINGANDIAN.equals(deliveryOrders[i].getWarehouseCode())&&YouzanConst.SALE_WAY_OFFLINE.equals(del IveryOrders [I].getSaleway ()) {orderpushutils. pushOrder(deliveryOrders[I]); j++; System.out.println("How many orders are there for The Safe shop?"+j);

                        if (i==2){
                            String s = new Gson().toJson(result);
                            System.out.println("result=="+s); }}if(YouzanConst.ORDER_FORM_CHEGONGMIAO.equals(deliveryOrders[i].getWarehouseCode())&&YouzanConst.SALE_WAY_OFFLINE.equals(de liveryOrders[i].getSaleWay())) { k++; System.out.println("There are altogether the single of chegong Temple..."+k);
                    }
                }
            }
        }
    }
    int i=1;

    private YouzanRetailOpenDeliveryorderQuery buildQueryApi() {// Date currentDate = new Date(system.currentTimemillis ()-86400*1000* I); i++; Date queryStart = dateutils.getDatestArt (currentDate); // queryEnd time Date queryEnd = dateutils.getdateend (currentDate); String queryEndTime = DateUtils.formatDateTime(queryEnd); String queryStartTime = DateUtils.formatDateTime(queryStart); logger.info("Query start time of liked background"+queryStartTime);
        logger.info("Query end time of liked background"+queryEndTime);
        Date date = new Date();
        String nowTime = DateUtils.formatDateTime(date);
        logger.info("Current query time"+nowTime);
        YouzanRetailOpenDeliveryorderQueryParams youzanRetailOpenDeliveryorderQueryParams = new YouzanRetailOpenDeliveryorderQueryParams();
        youzanRetailOpenDeliveryorderQueryParams.setPageNo(1L);
        youzanRetailOpenDeliveryorderQueryParams.setPageSize(1L);
        youzanRetailOpenDeliveryorderQueryParams.setCreateTimeStart(DateUtils.formatDate(queryStart));
        youzanRetailOpenDeliveryorderQueryParams.setCreateTimeEnd(DateUtils.formatDate(queryEnd));
        youzanRetailOpenDeliveryorderQueryParams.setCreateTimeStart(queryStartTime);
        youzanRetailOpenDeliveryorderQueryParams.setCreateTimeEnd(queryEndTime);
        YouzanRetailOpenDeliveryorderQuery youzanRetailOpenDeliveryorderQuery = new YouzanRetailOpenDeliveryorderQuery();
        youzanRetailOpenDeliveryorderQuery.setAPIParams(youzanRetailOpenDeliveryorderQueryParams);
       return youzanRetailOpenDeliveryorderQuery;
    }

    private void setPage(YouzanRetailOpenDeliveryorderQuery queryApi,Long pageNo){ YouzanRetailOpenDeliveryorderQueryParams queryAPIParams =  (YouzanRetailOpenDeliveryorderQueryParams)queryApi.getAPIParams(); queryAPIParams.setPageNo(pageNo); queryAPIParams.setPageSize(PAGE_SIZE); } private Long parsePages(long totalCount){if (totalCount == -1) {
            return 1L;
        }
        returntotalCount / PAGE_SIZE + ((totalCount % PAGE_SIZE == 0) ? 0:1); }}Copy the code
  • OrderPushUtils.pushOrder(deliveryOrders[i]);In this method, I’m going to distinguish which store the data is from, while assembling the JSON data, so I won’t post it

It never occurred to me

  • Third-party interfaces includebugAs a result, the total amount of data sent to the third party was incorrect, and I spat in your face.
  • The total sales collection for each order is actually not equal to the total of the sub-orders inside!

  • Finally get to this point and wait for their release

6. A few final notes

  • Thanks to the company’s big guy for helping me
  • Thank you very much for your support
  • Thanks to the blog for helping me
    • Solution that junit. Framework does not exist
    • Idea turns a Java file in a newly written project into a JAR package method
    • Creating WebServiceClient with Intellij Idea
  • Data generated in this paper
  • At the same time, I thank my good classmate Bo Ge for my great help, and also provideDemoThank you very much.
  • Bogo gave us the information