From 2ef2d25ea97e48ee8587add6d58a09cf5174a328 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" <123456> Date: Fri, 8 Sep 2023 15:59:01 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=811.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/logpm/factory/TestService.java | 297 ++++++++++-------- 1 file changed, 168 insertions(+), 129 deletions(-) diff --git a/blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java b/blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java index f407deee6..0610e248d 100644 --- a/blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java +++ b/blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java @@ -1,129 +1,168 @@ -//package com.logpm.factory; -// -//import cn.hutool.http.HttpResponse; -//import cn.hutool.http.HttpUtil; -//import com.alibaba.excel.EasyExcel; -//import com.alibaba.excel.EasyExcelFactory; -//import com.alibaba.excel.annotation.ExcelProperty; -//import com.alibaba.excel.metadata.BaseRowModel; -//import com.alibaba.excel.metadata.Sheet; -//import com.alibaba.fastjson.JSON; -//import com.alibaba.fastjson.JSONArray; -//import com.alibaba.fastjson.JSONObject; -//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -//import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -//import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper; -//import com.fasterxml.jackson.core.JsonProcessingException; -//import com.logpm.factory.comfac.controller.FactoryCommonController; -//import com.logpm.factory.comfac.dto.UnloadCarDTO; -//import com.logpm.factory.excel.ExcelMode; -//import com.logpm.factory.excel.JpDataMode; -//import com.logpm.factory.mt.entity.MtFactoryOrderMain; -//import com.logpm.factory.mt.entity.MtPushData; -//import com.logpm.factory.mt.service.IMtFactoryDataService; -//import com.logpm.factory.mt.service.IMtFactoryOrderMainService; -//import com.logpm.factory.mt.service.IMtPushDataService; -//import com.logpm.factory.mt.service.impl.MtFactoryDataServiceImpl; -//import com.logpm.factory.oupai.service.IOuPaiFactoryService; -//import com.logpm.factory.snm.vo.MTOrderPackageRelationVO; -//import com.logpm.oldproject.entity.AdvanceDetailEntity; -//import com.logpm.oldproject.feign.IAdvanceDetailClient; -//import com.rabbitmq.client.Channel; -//import lombok.Data; -//import org.junit.jupiter.api.Test; -//import org.junit.jupiter.api.extension.ExtendWith; -//import org.springblade.core.test.BladeBootTest; -//import org.springblade.core.test.BladeSpringExtension; -//import org.springblade.core.tool.api.R; -//import org.springblade.core.tool.api.ResultCode; -//import org.springblade.core.tool.utils.StringUtil; -//import org.springframework.amqp.core.Message; -//import org.springframework.amqp.rabbit.annotation.RabbitHandler; -//import org.springframework.beans.factory.annotation.Autowired; -// -//import java.io.*; -//import java.security.NoSuchAlgorithmException; -//import java.text.ParseException; -//import java.text.SimpleDateFormat; -//import java.util.*; -//import java.util.stream.Collectors; -// -//@ExtendWith(BladeSpringExtension.class) -//@BladeBootTest(appName = "logpm-factory-pref", enableLoader = true) -//public class TestService { -// -// -//// @Autowired -//// private IOuPaiFactoryService ouPaiFactoryService; -//// -//// -//// -// -// -// @Test -// public void test2() { -//// ouPaiFactoryService.findOuPaiFactoryOrderDTOByCarCarNumber("LCD230505047"); -// -// // 获取Excle -// -// try { -// -// File file = new File("F://response.json"); -// -// BufferedReader reader = new BufferedReader(new FileReader(file)); -// -// StringBuffer sb = new StringBuffer(); -// -// while (true) { -// String ms = reader.readLine(); -// if (StringUtil.isBlank(ms)) { -// break; -// } -// sb.append(ms); -// } -// JSONObject object = JSONObject.parseObject(sb.toString()); -// -// JSONArray jsonArray = object.getJSONArray("rows"); -// -// List ls = new ArrayList<>(); -// for (int i = 0; i < jsonArray.size(); i++) { -// JpDataMode jpDataMode = new JpDataMode(); -// JSONObject t = jsonArray.getJSONObject(i); -// String yjOrderNo =t.getString("yjOrderNo"); -// String omsExtYsId =t.getString("omsExtYsId"); -// String sendTime =t.getString("sendTime"); -// String goodsNumber =t.getString("goodsNumber"); -// String scanedNum =t.getString("scanedNum"); -// String handedNum =t.getString("handedNum"); -// -// -// jpDataMode.setOmsExtYsId(omsExtYsId); -// jpDataMode.setOrderId(yjOrderNo); -// jpDataMode.setGoodsNumber(goodsNumber); -// jpDataMode.setSendTime(sendTime); -// jpDataMode.setScanedNum(scanedNum); -// jpDataMode.setHandedNum(handedNum); -// -// -// ls.add(jpDataMode); -// } -// -// -// -// -// EasyExcel.write("F:\\11.xlsx").sheet("sheet1").doWrite(ls); -// -// -// -// } catch (FileNotFoundException e) { -// e.printStackTrace(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// -// -// } -// -// -//} -// +package com.logpm.factory; + +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.EasyExcelFactory; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.metadata.BaseRowModel; +import com.alibaba.excel.metadata.Sheet; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.logpm.factory.comfac.controller.FactoryCommonController; +import com.logpm.factory.comfac.dto.UnloadCarDTO; +import com.logpm.factory.excel.ExcelMode; +import com.logpm.factory.excel.JpDataMode; +import com.logpm.factory.mt.entity.MtFactoryOrderMain; +import com.logpm.factory.mt.entity.MtPushData; +import com.logpm.factory.mt.service.IMtFactoryDataService; +import com.logpm.factory.mt.service.IMtFactoryOrderMainService; +import com.logpm.factory.mt.service.IMtPushDataService; +import com.logpm.factory.mt.service.impl.MtFactoryDataServiceImpl; +import com.logpm.factory.oupai.entity.OpOrderStatusLogEntity; +import com.logpm.factory.oupai.service.IOuPaiFactoryService; +import com.logpm.factory.pan.service.IPanFactoryDataService; +import com.logpm.factory.snm.vo.MTOrderPackageRelationVO; +import com.logpm.oldproject.entity.AdvanceDetailEntity; +import com.logpm.oldproject.feign.IAdvanceDetailClient; +import com.rabbitmq.client.Channel; +import lombok.Data; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springblade.common.utils.CommonUtil; +import org.springblade.core.test.BladeBootTest; +import org.springblade.core.test.BladeSpringExtension; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.api.ResultCode; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.rabbit.annotation.RabbitHandler; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.*; +import java.security.NoSuchAlgorithmException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +@ExtendWith(BladeSpringExtension.class) +@BladeBootTest(appName = "logpm-factory-pref", enableLoader = true) +public class TestService { + + + @Autowired + private IPanFactoryDataService panFactoryDataService; + + + @Test + public void test2() { +// ouPaiFactoryService.findOuPaiFactoryOrderDTOByCarCarNumber("LCD230505047"); + + // 获取Excle + + try { + + File file = new File("F://response.json"); + + BufferedReader reader = new BufferedReader(new FileReader(file)); + + StringBuffer sb = new StringBuffer(); + + while (true) { + String ms = reader.readLine(); + if (StringUtil.isBlank(ms)) { + break; + } + sb.append(ms); + } + JSONObject object = JSONObject.parseObject(sb.toString()); + + JSONArray jsonArray = object.getJSONArray("rows"); + + List ls = new ArrayList<>(); + for (int i = 0; i < jsonArray.size(); i++) { + JpDataMode jpDataMode = new JpDataMode(); + JSONObject t = jsonArray.getJSONObject(i); + String yjOrderNo = t.getString("yjOrderNo"); + String omsExtYsId = t.getString("omsExtYsId"); + String sendTime = t.getString("sendTime"); + String goodsNumber = t.getString("goodsNumber"); + String scanedNum = t.getString("scanedNum"); + String handedNum = t.getString("handedNum"); + + + jpDataMode.setOmsExtYsId(omsExtYsId); + jpDataMode.setOrderId(yjOrderNo); + jpDataMode.setGoodsNumber(goodsNumber); + jpDataMode.setSendTime(sendTime); + jpDataMode.setScanedNum(scanedNum); + jpDataMode.setHandedNum(handedNum); + + + ls.add(jpDataMode); + } + + + EasyExcel.write("F:\\11.xlsx").sheet("sheet1").doWrite(ls); + + + } catch (FileNotFoundException e) { + 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(); + } + } + } + } + } + + +} +