40 changed files with 1066 additions and 178 deletions
@ -0,0 +1,30 @@
|
||||
package com.logpm.factory.snm.feign; |
||||
|
||||
import com.logpm.factory.snm.entity.StationlinenumEntity; |
||||
import com.logpm.factory.snm.vo.MTOrderPackageRelationVO; |
||||
import org.springblade.common.constant.ModuleNameConstant; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
||||
import java.util.List; |
||||
|
||||
@FeignClient( |
||||
value = ModuleNameConstant.APPLICATION_FACTORY_NAME |
||||
) |
||||
public interface IMtOrderMainClinet { |
||||
|
||||
|
||||
String API_PREFIX = "/mtclient"; |
||||
String TOP = API_PREFIX + "/top"; |
||||
|
||||
|
||||
/** |
||||
* 获取梦天工厂订单 包间 主订单 的关系 |
||||
* |
||||
* @return |
||||
*/ |
||||
@GetMapping(TOP) |
||||
R<List<MTOrderPackageRelationVO>> mtOrderPackageRelation(); |
||||
|
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.logpm.factory.snm.vo; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
|
||||
/** |
||||
* 梦天 订单 主订单 包间 关系 用于判断车次中的订单是否包含 |
||||
*/ |
||||
@Data |
||||
public class MTOrderPackageRelationVO implements Serializable { |
||||
|
||||
|
||||
/** |
||||
* 包件码 |
||||
*/ |
||||
private String packageCode; |
||||
/** |
||||
* 订单号 |
||||
*/ |
||||
private String orderCode; |
||||
|
||||
/** |
||||
* 主订单号 |
||||
*/ |
||||
private String invoiceOrderCode; |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.logpm.factory.comfac.dto; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotEmpty; |
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 卸车完成推送 |
||||
*/ |
||||
@Data |
||||
public class UnloadCarDTO implements Serializable { |
||||
|
||||
@NotEmpty(message = "卸车车次号不能为空") |
||||
private String unloadCarNum; |
||||
|
||||
private String completeDate; |
||||
|
||||
|
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.logpm.factory.mt.dto; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
public class MtUnLoadCarNumDTO implements Serializable { |
||||
|
||||
|
||||
@JsonProperty("发货单编号") |
||||
private String invoiceOrderCode; |
||||
|
||||
|
||||
@JsonProperty("确认收货时间") |
||||
private Date invoiceTime; |
||||
|
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.logpm.factory.mt.feign; |
||||
|
||||
import com.logpm.factory.mt.service.IMtFactoryOrderMainService; |
||||
import com.logpm.factory.snm.feign.IMtOrderMainClinet; |
||||
import com.logpm.factory.snm.vo.MTOrderPackageRelationVO; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import java.util.List; |
||||
|
||||
@NonDS |
||||
@ApiIgnore |
||||
@RestController |
||||
@AllArgsConstructor |
||||
public class MtOrderMainClinet implements IMtOrderMainClinet { |
||||
|
||||
private final IMtFactoryOrderMainService mtFactoryOrderMainService; |
||||
|
||||
@Override |
||||
public R<List<MTOrderPackageRelationVO>> mtOrderPackageRelation() { |
||||
List<MTOrderPackageRelationVO> data =mtFactoryOrderMainService.mtOrderPackageRelation(); |
||||
return R.data(data); |
||||
} |
||||
} |
@ -1,8 +1,17 @@
|
||||
package com.logpm.factory.mt.service; |
||||
|
||||
import com.logpm.factory.snm.entity.MtFactoryOrderMain; |
||||
import com.logpm.factory.snm.vo.MTOrderPackageRelationVO; |
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.core.tool.api.R; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface IMtFactoryOrderMainService extends BaseService<MtFactoryOrderMain> { |
||||
|
||||
List<MTOrderPackageRelationVO> mtOrderPackageRelation(); |
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
|
@ -0,0 +1,139 @@
|
||||
package com.logpm.factory.receiver; |
||||
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper; |
||||
import com.fasterxml.jackson.core.JsonProcessingException; |
||||
import com.logpm.factory.comfac.dto.OrderInfoDTO; |
||||
import com.logpm.factory.comfac.dto.UnloadCarDTO; |
||||
import com.logpm.factory.mt.service.IMtFactoryDataService; |
||||
import com.logpm.factory.mt.service.IMtFactoryOrderMainService; |
||||
import com.logpm.factory.snm.entity.MtFactoryOrderMain; |
||||
import com.logpm.factory.snm.vo.MTOrderPackageRelationVO; |
||||
import com.logpm.oldproject.entity.AdvanceDetailEntity; |
||||
import com.logpm.oldproject.feign.IAdvanceClient; |
||||
import com.logpm.oldproject.feign.IAdvanceDetailClient; |
||||
import com.rabbitmq.client.Channel; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.common.constant.RabbitConstant; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.amqp.core.Message; |
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.security.NoSuchAlgorithmException; |
||||
import java.text.ParseException; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 卸车完成处理队列 |
||||
*/ |
||||
@Slf4j |
||||
@RabbitListener(queues = RabbitConstant.UNLOAD_CAR_COM_INFO_QUEUE) |
||||
@Component |
||||
public class UnloadCarComHandler { |
||||
|
||||
@Autowired |
||||
private IAdvanceDetailClient advanceDetailClient; |
||||
|
||||
|
||||
@Autowired |
||||
private IMtFactoryOrderMainService mtFactoryOrderMainService; |
||||
|
||||
@Autowired |
||||
private IMtFactoryDataService mtFactoryDataService; |
||||
|
||||
|
||||
@RabbitHandler |
||||
public void unloadCarComDataHandler(Map map, Message message, Channel channel) { |
||||
|
||||
/* |
||||
1.得到传递的车次 |
||||
2. 需要判断这个车次是否市梦天的 |
||||
3. 查询这个车次上的运单是否市梦天的 |
||||
|
||||
4.查询包间对应的梦天发给我们的批次号 |
||||
*/ |
||||
UnloadCarDTO unloadCarDTO = (UnloadCarDTO) map.get("messageData"); |
||||
/* |
||||
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) { |
||||
log.info("##################{} 车次 不存在梦天的数据 无需返回", unloadCarDTO.getUnloadCarNum()); |
||||
return; |
||||
} |
||||
|
||||
// 得到车次下面梦天的包条码集合
|
||||
List<String> mtStrs = mtListdata.stream().map(AdvanceDetailEntity::getUnitNo).collect(Collectors.toList()); |
||||
if (mtStrs == null || mtStrs.size() == 0) { |
||||
log.error("##################{} 车次 梦天的包条数据存在异常! 请联系管理员", unloadCarDTO.getUnloadCarNum()); |
||||
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); |
||||
if(r.isSuccess()){ |
||||
// 更新订单状态
|
||||
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(); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
} |
@ -1,17 +1,133 @@
|
||||
package com.logpm.factory; |
||||
|
||||
//@ExtendWith(BladeSpringExtension.class)
|
||||
//@BladeBootTest(appName = "logpm-factory", enableLoader = true)
|
||||
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.service.IMtFactoryDataService; |
||||
import com.logpm.factory.mt.service.IMtFactoryOrderMainService; |
||||
import com.logpm.factory.mt.service.impl.MtFactoryDataServiceImpl; |
||||
import com.logpm.factory.snm.entity.MtFactoryOrderMain; |
||||
import com.logpm.factory.snm.vo.MTOrderPackageRelationVO; |
||||
import com.logpm.oldproject.entity.AdvanceDetailEntity; |
||||
import com.logpm.oldproject.feign.IAdvanceDetailClient; |
||||
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.springframework.beans.factory.annotation.Autowired; |
||||
|
||||
import java.security.NoSuchAlgorithmException; |
||||
import java.text.ParseException; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
import java.util.stream.Collectors; |
||||
|
||||
@ExtendWith(BladeSpringExtension.class) |
||||
@BladeBootTest(appName = "logpm-factory-zhy", enableLoader = true) |
||||
public class TestService { |
||||
|
||||
// @Autowired
|
||||
// private MtFactoryDataServiceImpl mtFactoryDataService;
|
||||
// @Test
|
||||
// public void contextLoads() {
|
||||
//
|
||||
// String tolk =mtFactoryDataService.getMtToken();
|
||||
// System.out.println(tolk);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired |
||||
private IAdvanceDetailClient advanceDetailClient; |
||||
|
||||
|
||||
@Autowired |
||||
private IMtFactoryOrderMainService mtFactoryOrderMainService; |
||||
|
||||
@Autowired |
||||
private IMtFactoryDataService mtFactoryDataService; |
||||
@Test |
||||
public void contextLoads() { |
||||
|
||||
/* |
||||
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(); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
} |
||||
|
Loading…
Reference in new issue