|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.logpm.factory.comfac.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataTrayEntity; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
|
|
|
|
import com.logpm.basicdata.feign.IBasicdataTrayClient; |
|
|
|
@ -18,13 +19,16 @@ import com.logpm.warehouse.feign.IWarehouseTrayTypeClient;
|
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.common.constant.OldSystemDataPushConfig; |
|
|
|
|
import org.springblade.common.constant.RedisKeyConstant; |
|
|
|
|
import org.springblade.common.exception.CustomerException; |
|
|
|
|
import org.springblade.core.redis.cache.BladeRedis; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.sql.Wrapper; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
@ -50,27 +54,27 @@ public class FactoryCommonServiceImpl implements IFactoryCommonService {
|
|
|
|
|
public void syncTrayTypeData(String unitNo, Integer trayId, String oldWarehouseId) { |
|
|
|
|
|
|
|
|
|
//先判断是否两个数据已经执行完成
|
|
|
|
|
String ruku = bladeRedis.get("arrive-"+unitNo); |
|
|
|
|
trayId = bladeRedis.get("tray-"+unitNo); |
|
|
|
|
String ruku = bladeRedis.get("arrive-" + unitNo); |
|
|
|
|
trayId = bladeRedis.get("tray-" + unitNo); |
|
|
|
|
|
|
|
|
|
if(StringUtil.isBlank(ruku) || Objects.isNull(trayId)){ |
|
|
|
|
log.error("###############syncTrayTypeData: 数据不完整,暂不打托 ruku={} trayId={}",ruku,trayId); |
|
|
|
|
throw new CustomerException(403,"数据不完整,暂不打托"); |
|
|
|
|
if (StringUtil.isBlank(ruku) || Objects.isNull(trayId)) { |
|
|
|
|
log.error("###############syncTrayTypeData: 数据不完整,暂不打托 ruku={} trayId={}", ruku, trayId); |
|
|
|
|
throw new CustomerException(403, "数据不完整,暂不打托"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("###############syncTrayTypeData: 包件打托开始 unitNo={} trayId={} oldWarehouseId={}",unitNo,trayId,oldWarehouseId); |
|
|
|
|
log.info("###############syncTrayTypeData: 包件打托开始 unitNo={} trayId={} oldWarehouseId={}", unitNo, trayId, oldWarehouseId); |
|
|
|
|
//先判断新系统仓库信息是否存在
|
|
|
|
|
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getWarehouseByOldId(Integer.parseInt(oldWarehouseId)); |
|
|
|
|
if(Objects.isNull(warehouseEntity)){ |
|
|
|
|
log.error("###############syncTrayTypeData: 仓库信息不存在 oldWarehouseId={}",oldWarehouseId); |
|
|
|
|
throw new CustomerException(403,"仓库信息不存在"); |
|
|
|
|
if (Objects.isNull(warehouseEntity)) { |
|
|
|
|
log.error("###############syncTrayTypeData: 仓库信息不存在 oldWarehouseId={}", oldWarehouseId); |
|
|
|
|
throw new CustomerException(403, "仓库信息不存在"); |
|
|
|
|
} |
|
|
|
|
Long newWarehouseId = warehouseEntity.getId(); |
|
|
|
|
|
|
|
|
|
//判断托盘是否已经存在
|
|
|
|
|
BasicdataTrayEntity basicdataTrayEntity = basicdataTrayClient.getTrayByTrayCode("T" + trayId); |
|
|
|
|
if(Objects.isNull(basicdataTrayEntity)){ |
|
|
|
|
if (Objects.isNull(basicdataTrayEntity)) { |
|
|
|
|
log.info("############syncTrayTypeData: 托盘信息不存在"); |
|
|
|
|
//如果托盘不存在就去同步该托盘
|
|
|
|
|
TrayEntity trayEntity = trayClient.getTrayById(trayId); |
|
|
|
@ -80,9 +84,9 @@ public class FactoryCommonServiceImpl implements IFactoryCommonService {
|
|
|
|
|
basicdataTrayEntity.setUpdateUser(1714696768639311873L); |
|
|
|
|
basicdataTrayEntity.setCreateDept(1649331096241836033L); |
|
|
|
|
basicdataTrayEntity.setPalletName(trayEntity.getTrayNo()); |
|
|
|
|
basicdataTrayEntity.setPalletCode("T"+trayEntity.getId()); |
|
|
|
|
basicdataTrayEntity.setPalletCode("T" + trayEntity.getId()); |
|
|
|
|
basicdataTrayEntity.setWarehouseId(newWarehouseId); |
|
|
|
|
basicdataTrayEntity.setTrayStatus(trayEntity.getStatus()+""); |
|
|
|
|
basicdataTrayEntity.setTrayStatus(trayEntity.getStatus() + ""); |
|
|
|
|
basicdataTrayEntity.setType(1); |
|
|
|
|
basicdataTrayEntity.setOldId(trayId); |
|
|
|
|
// basicdataTrayEntity.setNowWarehouseId(nowNewWarehouseId);
|
|
|
|
@ -90,40 +94,40 @@ public class FactoryCommonServiceImpl implements IFactoryCommonService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//把包件打托到托盘上
|
|
|
|
|
TrayScanEntity trayScanEntity = trayScanClient.getEntityByTrayIdAndOldWarehouseIdAndBindStatus(trayId,oldWarehouseId,1); |
|
|
|
|
TrayScanEntity trayScanEntity = trayScanClient.getEntityByTrayIdAndOldWarehouseIdAndBindStatus(trayId, oldWarehouseId, 1); |
|
|
|
|
String trayType = "100"; |
|
|
|
|
if(!Objects.isNull(trayScanEntity)){ |
|
|
|
|
if (!Objects.isNull(trayScanEntity)) { |
|
|
|
|
Integer type = trayScanEntity.getType(); |
|
|
|
|
if(1==type){ |
|
|
|
|
if (1 == type) { |
|
|
|
|
trayType = "60"; |
|
|
|
|
}else if(2==type){ |
|
|
|
|
} else if (2 == type) { |
|
|
|
|
trayType = "30"; |
|
|
|
|
}else if(3==type){ |
|
|
|
|
} else if (3 == type) { |
|
|
|
|
trayType = "50"; |
|
|
|
|
}else if(4==type){ |
|
|
|
|
} else if (4 == type) { |
|
|
|
|
trayType = "100"; |
|
|
|
|
}else if(5==type){ |
|
|
|
|
} else if (5 == type) { |
|
|
|
|
trayType = "10"; |
|
|
|
|
}else if(6==type){ |
|
|
|
|
} else if (6 == type) { |
|
|
|
|
trayType = "20"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
map.put("trayType",trayType); |
|
|
|
|
map.put("trayCode","T"+trayId); |
|
|
|
|
map.put("warehouseId",newWarehouseId); |
|
|
|
|
map.put("orderPackageCode",unitNo); |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("trayType", trayType); |
|
|
|
|
map.put("trayCode", "T" + trayId); |
|
|
|
|
map.put("warehouseId", newWarehouseId); |
|
|
|
|
map.put("orderPackageCode", unitNo); |
|
|
|
|
|
|
|
|
|
//新系统保存打托方式
|
|
|
|
|
boolean b = warehouseTrayTypeClient.orderScanOrderPackageCode(map); |
|
|
|
|
|
|
|
|
|
if(!b){ |
|
|
|
|
log.error("################syncTrayTypeData: 包件打托失败 unitNo={} trayCode={}",unitNo,"T"+trayId); |
|
|
|
|
throw new CustomerException(403,"包件打托失败"); |
|
|
|
|
if (!b) { |
|
|
|
|
log.error("################syncTrayTypeData: 包件打托失败 unitNo={} trayCode={}", unitNo, "T" + trayId); |
|
|
|
|
throw new CustomerException(403, "包件打托失败"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("################syncTrayTypeData: 包件打托成功 unitNo={}",unitNo); |
|
|
|
|
log.info("################syncTrayTypeData: 包件打托成功 unitNo={}", unitNo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -134,67 +138,69 @@ public class FactoryCommonServiceImpl implements IFactoryCommonService {
|
|
|
|
|
|
|
|
|
|
//查询destinationWarehouse logiBillNo plantId数据
|
|
|
|
|
Map<String, String> supplyData = advanceDetailClient.getSupplyData(unitNo); |
|
|
|
|
if (supplyData == null) { |
|
|
|
|
if (!supplyData.isEmpty()) { |
|
|
|
|
log.error("##############dealWithDataHandler: unitNo={} 没有查询到数据", unitNo); |
|
|
|
|
// 保存到数据库
|
|
|
|
|
|
|
|
|
|
// orderPackageStatusPushFailLogMapper.selectList()
|
|
|
|
|
|
|
|
|
|
OrderPackageStatusPushFailLogEntity orderPackageStatusPushFailLogEntity=new OrderPackageStatusPushFailLogEntity(); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setOrderPackageStatus(status); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setUnitNo(unitNo); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setWarehouseId(currentWarehouseId); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setOperationTime(operationTime); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setTrayId(trayId); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setDataStatus(0); |
|
|
|
|
|
|
|
|
|
// 插入之前判断这条数据是否存在系统中
|
|
|
|
|
|
|
|
|
|
orderPackageStatusPushFailLogMapper.insert(orderPackageStatusPushFailLogEntity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 执行定时任务
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
String destinationWarehouseId = supplyData.get("destinationWarehouseId");//目的仓id
|
|
|
|
|
if (StringUtil.isBlank(currentWarehouseId) || StringUtil.isBlank(destinationWarehouseId)) { |
|
|
|
|
log.warn("##############dealWithDataHandler: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId); |
|
|
|
|
throw new CustomerException(405, "仓库数据有误"); |
|
|
|
|
} else { |
|
|
|
|
if (!currentWarehouseId.equals(destinationWarehouseId)) { |
|
|
|
|
log.info("##############dealWithDataHandler: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId); |
|
|
|
|
// channel.basicAck(deliveryTag,false);
|
|
|
|
|
String destinationWarehouseId = supplyData.get("destinationWarehouseId");//目的仓id
|
|
|
|
|
if (StringUtil.isBlank(currentWarehouseId) || StringUtil.isBlank(destinationWarehouseId)) { |
|
|
|
|
log.warn("##############dealWithDataHandler: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId); |
|
|
|
|
throw new CustomerException(405, "仓库数据有误"); |
|
|
|
|
} else { |
|
|
|
|
//真正的处理需要的数据
|
|
|
|
|
|
|
|
|
|
if(OldSystemDataPushConfig.getWarehourseIdList().contains(currentWarehouseId)){ |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if ("1".equals(status)) { |
|
|
|
|
|
|
|
|
|
// 始发仓和目的仓入库
|
|
|
|
|
panFactoryDataService.handleDataToPlatform(unitNo, operationTime); |
|
|
|
|
bladeRedis.setEx("tray-" + unitNo, trayId, 30L); |
|
|
|
|
|
|
|
|
|
} else if ("4".equals(status)) { |
|
|
|
|
panFactoryDataService.handleDataToPlatform(unitNo, operationTime); |
|
|
|
|
} else if ("2".equals(status)) { |
|
|
|
|
bladeRedis.setEx("tray-" + unitNo, trayId, 30L); |
|
|
|
|
} else { |
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>> 错误的状态"); |
|
|
|
|
if (!currentWarehouseId.equals(destinationWarehouseId)) { |
|
|
|
|
log.info("##############dealWithDataHandler: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId); |
|
|
|
|
// channel.basicAck(deliveryTag,false);
|
|
|
|
|
} else { |
|
|
|
|
//真正的处理需要的数据
|
|
|
|
|
if (OldSystemDataPushConfig.getWarehourseIdList().contains(currentWarehouseId)) { |
|
|
|
|
try { |
|
|
|
|
if ("1".equals(status)) { |
|
|
|
|
|
|
|
|
|
// 始发仓和目的仓入库
|
|
|
|
|
panFactoryDataService.handleDataToPlatform(unitNo, operationTime); |
|
|
|
|
bladeRedis.setEx("tray-" + unitNo, trayId, 30L); |
|
|
|
|
|
|
|
|
|
} else if ("4".equals(status)) { |
|
|
|
|
panFactoryDataService.handleDataToPlatform(unitNo, operationTime); |
|
|
|
|
} else if ("2".equals(status)) { |
|
|
|
|
bladeRedis.setEx("tray-" + unitNo, trayId, 30L); |
|
|
|
|
} else { |
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>> 错误的状态"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//同步打托数据
|
|
|
|
|
syncTrayTypeData(unitNo, trayId, currentWarehouseId); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//同步打托数据
|
|
|
|
|
syncTrayTypeData(unitNo, trayId, currentWarehouseId); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
QueryWrapper queryWrapper = new QueryWrapper(); |
|
|
|
|
queryWrapper.eq("unit_no", unitNo); |
|
|
|
|
queryWrapper.eq("warehouse_id", currentWarehouseId); |
|
|
|
|
|
|
|
|
|
List list = orderPackageStatusPushFailLogMapper.selectList(queryWrapper); |
|
|
|
|
|
|
|
|
|
if (list == null || list.isEmpty()) { |
|
|
|
|
OrderPackageStatusPushFailLogEntity orderPackageStatusPushFailLogEntity = new OrderPackageStatusPushFailLogEntity(); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setOrderPackageStatus(status); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setUnitNo(unitNo); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setWarehouseId(currentWarehouseId); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setOperationTime(operationTime); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setTrayId(trayId); |
|
|
|
|
orderPackageStatusPushFailLogEntity.setDataStatus(0); |
|
|
|
|
|
|
|
|
|
// 插入之前判断这条数据是否存在系统中
|
|
|
|
|
log.info(">>>>>>>>>>>>>>>> 保存到定时任务队列"); |
|
|
|
|
orderPackageStatusPushFailLogMapper.insert(orderPackageStatusPushFailLogEntity); |
|
|
|
|
}else{ |
|
|
|
|
throw new CustomerException(405, "失败的包件数据状态记录已存在"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
log.info("##############dealWithDataHandler: 不用处理的状态 status={}", status); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|