@ -1,21 +1,30 @@
//package com.logpm.factory;
//
//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.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.snm.vo.MTOrderPackageRelationVO;
//import com.logpm.oldproject.entity.AdvanceDetailEntity;
//import com.logpm.oldproject.feign.IAdvanceDetailClient;
//import com.rabbitmq.client.Channel;
//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.security.NoSuchAlgorithmException;
@ -28,13 +37,11 @@
//import java.util.stream.Collectors;
//
//@ExtendWith(BladeSpringExtension.class)
//@BladeBootTest(appName = "logpm-factory-zhy ", enableLoader = true)
//@BladeBootTest(appName = "logpm-factory-pref ", enableLoader = true)
//public class TestService {
//
//
//
//
//
// @Autowired
// private IAdvanceDetailClient advanceDetailClient;
//
@ -45,102 +52,109 @@
// @Autowired
// private IMtFactoryDataService mtFactoryDataService;
//
// @Autowired
// private IMtPushDataService mtPushDataService;
//
//
//
// @Test
// public void testUpdate(){
//
//// UpdateChainWrapper<MtFactoryOrderMain> updateChainWrapper =new UpdateChainWrapper<MtFactoryOrderMain>(MtFactoryOrderMain.class);
//// updateChainWrapper.set("push_status","1");
//// updateChainWrapper.set("push_time",new Date());
//// updateChainWrapper.eq("invoice_order_code","HYLEJIA-230730");
//// mtFactoryOrderMainService.update(updateChainWrapper);
// }
//
//
// @Test
// public void contextLoads () {
// public void test2() {
//
///*
// /*
// 1.得到传递的车次
// 2. 需要判断这个车次是否市梦天的
// 3. 查询这个车次上的运单是否市梦天的
//
//// 4.查询包间对应的梦天发给我们的批次号
//// */
//// UnloadCarDTO unloadCarDTO = new UnloadCarDTO();
//// unloadCarDTO.setUnloadCarNum("LQGX230719001");
//// unloadCarDTO.setCompleteDate("2023-07-19 16:48:45");
////
//// /*
//// 2.通过车次查询来系统中车次绑定的运单
//// 3.通过运单查询货物上的包件
//// 4.需要过滤出来 只要梦天的
//// */
//// List<AdvanceDetailEntity> carNumList = advanceDetailClient.getByCarNum(unloadCarDTO.getUnloadCarNum());
////
////
//// /**
//// * 安装品类进行分组
//// */
//// Map<String, List<AdvanceDetailEntity>> carNumMapList = carNumList.stream().collect(Collectors.groupingBy(AdvanceDetailEntity::getType));
////
//// List<AdvanceDetailEntity> mtListdata = carNumMapList.get("梦天");
////
//// if (mtListdata == null || mtListdata.size() == 0) {
//// return;
//// }
////
//// // 得到车次下面梦天的包条码集合
//// List<String> mtStrs = mtListdata.stream().map(AdvanceDetailEntity::getUnitNo).collect(Collectors.toList());
//// if (mtStrs == null || mtStrs.size() == 0) {
//// return;
//// }
////
//// List<MTOrderPackageRelationVO> allMtData = mtFactoryOrderMainService.mtOrderPackageRelation();
//// // 对这个集合内进行分组
//// Map<String, List<MTOrderPackageRelationVO>> stringListMap = allMtData.stream().collect(Collectors.groupingBy(MTOrderPackageRelationVO::getInvoiceOrderCode));
//// Set<String> set = stringListMap.keySet();
//// boolean isPush = false;
//// for (String s : set) {
//// // 得到某个工厂运输批次的集合
//// List<MTOrderPackageRelationVO> t = stringListMap.get(s);
//// //得到这个批次下面所有的包间
//// List<String> strs = t.stream().map(MTOrderPackageRelationVO::getPackageCode).collect(Collectors.toList());
//// // 当前批次的包间 在 这个配载计划中存在一个 则进行通知
//// for (String mtStr : mtStrs) {
//// if (strs.contains(mtStr)) {
//// isPush = true;
//// break;
//// }
//// }
//// if (isPush) {
//// break;
//// }
//// }
//// if (isPush) {
//// try {
////
//// Date data = new SimpleDateFormat().parse(unloadCarDTO.getCompleteDate());
//// R r = mtFactoryDataService.sendUnloadCarNum(unloadCarDTO.getUnloadCarNum(), data);
//// // 更新订单状态
//// UpdateChainWrapper<MtFactoryOrderMain> updateChainWrapper =new UpdateChainWrapper<MtFactoryOrderMain>(MtFactoryOrderMain.class);
//// updateChainWrapper.set("push_status","1");
//// updateChainWrapper.set("push_time",data);
//// updateChainWrapper.eq("invoice_order_code",unloadCarDTO.getUnloadCarNum());
//// mtFactoryOrderMainService.update(updateChainWrapper);
////
//// } catch (ParseException e) {
//// e.printStackTrace();
//// } catch (JsonProcessingException e) {
//// e.printStackTrace();
//// } catch (NoSuchAlgorithmException e) {
//// e.printStackTrace();
//// }
////
////
//// }
// 4.查询包间对应的梦天发给我们的批次号
// */
// UnloadCarDTO unloadCarDTO = new UnloadCarDTO();
// unloadCarDTO.setCompleteDate("2023-08-08 15:39:40");
// unloadCarDTO.setUnloadCarNum("MTZX230808001");
//
// /*
// 2.通过车次查询来系统中车次绑定的运单
// 3.通过运单查询货物上的包件
// 4.需要过滤出来 只要梦天的
// */
//
// try {
// List<String> carNumList = advanceDetailClient.getByCarNum(unloadCarDTO.getUnloadCarNum());
// List<MTOrderPackageRelationVO> allMtData = mtFactoryOrderMainService.mtOrderPackageRelation();
// // 对这个集合内进行分组
// Map<String, List<MTOrderPackageRelationVO>> stringListMap = allMtData.stream().collect(Collectors.groupingBy(MTOrderPackageRelationVO::getInvoiceOrderCode));
// Set<String> set = stringListMap.keySet();
//
// for (String s : set) {
// String carNum = null;
// // 得到某个工厂运输批次的集合
// List<MTOrderPackageRelationVO> t = stringListMap.get(s);
// //得到这个批次下面所有的包间
// List<String> strs = t.stream().map(MTOrderPackageRelationVO::getPackageCode).collect(Collectors.toList());
// // 当前批次的包间 在 这个配载计划中存在一个 则进行通知
// for (String mtStr : carNumList) {
// if (strs.contains(mtStr)) {
// carNum = s;
// break;
// }
// }
//
// try {
// if (StringUtil.isNoneBlank(carNum)) {
// sendDataCarNum(carNum, unloadCarDTO.getCompleteDate());
// }
// } catch (ParseException e) {
// e.printStackTrace();
// } catch (NoSuchAlgorithmException e) {
// e.printStackTrace();
// } catch (JsonProcessingException e) {
// e.printStackTrace();
// }
//
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
//
//
// }
//
// /**
// * 根基匹配到的发货单编号 推送梦天
// *
// * @param carNum
// * @param completeDate
// * @throws ParseException
// * @throws NoSuchAlgorithmException
// * @throws JsonProcessingException
// */
// private void sendDataCarNum(String carNum, String completeDate) throws ParseException, NoSuchAlgorithmException, JsonProcessingException {
//
// // 需要判断这个发货单编号是否推送过
// QueryWrapper<MtPushData> lambdaQueryChainWrapper = new QueryWrapper<MtPushData>();
// lambdaQueryChainWrapper.eq("ref_code", carNum);
// MtPushData ms = mtPushDataService.getOne(lambdaQueryChainWrapper);
// if (ObjectUtils.isNotNull(ms)) {
// return;
// }
// R r = mtFactoryDataService.sendUnloadCarNum(carNum, completeDate);
// if (r.getCode() == ResultCode.SUCCESS.getCode()) {
// MtPushData mtPushData = new MtPushData();
// mtPushData.setPushTime(new Date());
// mtPushData.setPushStatus(1);// 推送状态
// mtPushData.setRefCode(carNum);
// mtPushData.setRefType(1);// 订单主表
// // todo 这里需要查询主推送单的 ID
// List<MtFactoryOrderMain> mtFactoryOrderMainList = mtFactoryOrderMainService.findMtFactoryOrderMainByInvoiceOrderCode(carNum);
// if (mtFactoryOrderMainList.size() > 0) {
// mtFactoryOrderMainList.get(0);
// mtPushData.setRefId(mtFactoryOrderMainList.get(0).getId());
// }
// // 插入推送数据
// mtPushDataService.save(mtPushData);
// }
// }
//
//}