Browse Source

1.优化代码1.3

training
pref_mail@163.com 1 year ago
parent
commit
2ef2d25ea9
  1. 297
      blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java

297
blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java

@ -1,129 +1,168 @@
//package com.logpm.factory; package com.logpm.factory;
//
//import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpResponse;
//import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
//import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
//import com.alibaba.excel.EasyExcelFactory; import com.alibaba.excel.EasyExcelFactory;
//import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
//import com.alibaba.excel.metadata.BaseRowModel; import com.alibaba.excel.metadata.BaseRowModel;
//import com.alibaba.excel.metadata.Sheet; import com.alibaba.excel.metadata.Sheet;
//import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
//import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper; import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
//import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
//import com.logpm.factory.comfac.controller.FactoryCommonController; import com.logpm.factory.comfac.controller.FactoryCommonController;
//import com.logpm.factory.comfac.dto.UnloadCarDTO; import com.logpm.factory.comfac.dto.UnloadCarDTO;
//import com.logpm.factory.excel.ExcelMode; import com.logpm.factory.excel.ExcelMode;
//import com.logpm.factory.excel.JpDataMode; import com.logpm.factory.excel.JpDataMode;
//import com.logpm.factory.mt.entity.MtFactoryOrderMain; import com.logpm.factory.mt.entity.MtFactoryOrderMain;
//import com.logpm.factory.mt.entity.MtPushData; import com.logpm.factory.mt.entity.MtPushData;
//import com.logpm.factory.mt.service.IMtFactoryDataService; import com.logpm.factory.mt.service.IMtFactoryDataService;
//import com.logpm.factory.mt.service.IMtFactoryOrderMainService; import com.logpm.factory.mt.service.IMtFactoryOrderMainService;
//import com.logpm.factory.mt.service.IMtPushDataService; import com.logpm.factory.mt.service.IMtPushDataService;
//import com.logpm.factory.mt.service.impl.MtFactoryDataServiceImpl; import com.logpm.factory.mt.service.impl.MtFactoryDataServiceImpl;
//import com.logpm.factory.oupai.service.IOuPaiFactoryService; import com.logpm.factory.oupai.entity.OpOrderStatusLogEntity;
//import com.logpm.factory.snm.vo.MTOrderPackageRelationVO; import com.logpm.factory.oupai.service.IOuPaiFactoryService;
//import com.logpm.oldproject.entity.AdvanceDetailEntity; import com.logpm.factory.pan.service.IPanFactoryDataService;
//import com.logpm.oldproject.feign.IAdvanceDetailClient; import com.logpm.factory.snm.vo.MTOrderPackageRelationVO;
//import com.rabbitmq.client.Channel; import com.logpm.oldproject.entity.AdvanceDetailEntity;
//import lombok.Data; import com.logpm.oldproject.feign.IAdvanceDetailClient;
//import org.junit.jupiter.api.Test; import com.rabbitmq.client.Channel;
//import org.junit.jupiter.api.extension.ExtendWith; import lombok.Data;
//import org.springblade.core.test.BladeBootTest; import org.junit.jupiter.api.Test;
//import org.springblade.core.test.BladeSpringExtension; import org.junit.jupiter.api.extension.ExtendWith;
//import org.springblade.core.tool.api.R; import org.springblade.common.utils.CommonUtil;
//import org.springblade.core.tool.api.ResultCode; import org.springblade.core.test.BladeBootTest;
//import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.test.BladeSpringExtension;
//import org.springframework.amqp.core.Message; import org.springblade.core.tool.api.R;
//import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springblade.core.tool.api.ResultCode;
//import org.springframework.beans.factory.annotation.Autowired; import org.springblade.core.tool.utils.StringUtil;
// import org.springframework.amqp.core.Message;
//import java.io.*; import org.springframework.amqp.rabbit.annotation.RabbitHandler;
//import java.security.NoSuchAlgorithmException; import org.springframework.beans.factory.annotation.Autowired;
//import java.text.ParseException;
//import java.text.SimpleDateFormat; import java.io.*;
//import java.util.*; import java.security.NoSuchAlgorithmException;
//import java.util.stream.Collectors; import java.text.ParseException;
// import java.text.SimpleDateFormat;
//@ExtendWith(BladeSpringExtension.class) import java.util.*;
//@BladeBootTest(appName = "logpm-factory-pref", enableLoader = true) import java.util.stream.Collectors;
//public class TestService {
// @ExtendWith(BladeSpringExtension.class)
// @BladeBootTest(appName = "logpm-factory-pref", enableLoader = true)
//// @Autowired public class TestService {
//// private IOuPaiFactoryService ouPaiFactoryService;
////
//// @Autowired
//// private IPanFactoryDataService panFactoryDataService;
//
//
// @Test @Test
// public void test2() { public void test2() {
//// ouPaiFactoryService.findOuPaiFactoryOrderDTOByCarCarNumber("LCD230505047"); // ouPaiFactoryService.findOuPaiFactoryOrderDTOByCarCarNumber("LCD230505047");
//
// // 获取Excle // 获取Excle
//
// try { try {
//
// File file = new File("F://response.json"); File file = new File("F://response.json");
//
// BufferedReader reader = new BufferedReader(new FileReader(file)); BufferedReader reader = new BufferedReader(new FileReader(file));
//
// StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
//
// while (true) { while (true) {
// String ms = reader.readLine(); String ms = reader.readLine();
// if (StringUtil.isBlank(ms)) { if (StringUtil.isBlank(ms)) {
// break; break;
// } }
// sb.append(ms); sb.append(ms);
// } }
// JSONObject object = JSONObject.parseObject(sb.toString()); JSONObject object = JSONObject.parseObject(sb.toString());
//
// JSONArray jsonArray = object.getJSONArray("rows"); JSONArray jsonArray = object.getJSONArray("rows");
//
// List<JpDataMode> ls = new ArrayList<>(); List<JpDataMode> ls = new ArrayList<>();
// for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
// JpDataMode jpDataMode = new JpDataMode(); JpDataMode jpDataMode = new JpDataMode();
// JSONObject t = jsonArray.getJSONObject(i); JSONObject t = jsonArray.getJSONObject(i);
// String yjOrderNo =t.getString("yjOrderNo"); String yjOrderNo = t.getString("yjOrderNo");
// String omsExtYsId =t.getString("omsExtYsId"); String omsExtYsId = t.getString("omsExtYsId");
// String sendTime =t.getString("sendTime"); String sendTime = t.getString("sendTime");
// String goodsNumber =t.getString("goodsNumber"); String goodsNumber = t.getString("goodsNumber");
// String scanedNum =t.getString("scanedNum"); String scanedNum = t.getString("scanedNum");
// String handedNum =t.getString("handedNum"); String handedNum = t.getString("handedNum");
//
//
// jpDataMode.setOmsExtYsId(omsExtYsId); jpDataMode.setOmsExtYsId(omsExtYsId);
// jpDataMode.setOrderId(yjOrderNo); jpDataMode.setOrderId(yjOrderNo);
// jpDataMode.setGoodsNumber(goodsNumber); jpDataMode.setGoodsNumber(goodsNumber);
// jpDataMode.setSendTime(sendTime); jpDataMode.setSendTime(sendTime);
// jpDataMode.setScanedNum(scanedNum); jpDataMode.setScanedNum(scanedNum);
// jpDataMode.setHandedNum(handedNum); jpDataMode.setHandedNum(handedNum);
//
//
// ls.add(jpDataMode); ls.add(jpDataMode);
// } }
//
//
// EasyExcel.write("F:\\11.xlsx").sheet("sheet1").doWrite(ls);
//
// EasyExcel.write("F:\\11.xlsx").sheet("sheet1").doWrite(ls);
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (IOException e) {
// } catch (FileNotFoundException e) { e.printStackTrace();
// e.printStackTrace(); }
// } catch (IOException e) {
// e.printStackTrace();
// } }
//
// @Test
// } public void test3() throws IOException {
// // 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉
//
//} StringBuffer sb = new StringBuffer();
//
BufferedReader reader = new BufferedReader(new FileReader("F:\\json.txt"));
while(reader.ready()) {
String te =reader.readLine();
if(StringUtil.isBlank(te)){
break;
}
sb.append(te);
}
JSONObject jsonObject = JSONObject.parseObject(sb.toString());
JSONArray jsonArray = jsonObject.getJSONArray("value");
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject valueObject = jsonArray.getJSONObject(i);
JSONArray packages = valueObject.getJSONArray("Packages");
for (int j = 0; j < packages.size(); j++) {
JSONObject packageJSON = packages.getJSONObject(j);
String packageStatus = packageJSON.getString("PackageStatus");
String orderPackageCode = packageJSON.getString("Code");
String receivingTime = packageJSON.getString("CreateTime");
if ("已收货".equals(packageStatus)) {
//真正的处理需要的数据
try {
panFactoryDataService.handleDataToPlatform(orderPackageCode, receivingTime);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}

Loading…
Cancel
Save