|
|
|
@ -17,6 +17,7 @@ import com.rabbitmq.client.Channel;
|
|
|
|
|
import jodd.util.StringUtil; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.common.constant.RabbitConstant; |
|
|
|
|
import org.springblade.core.redis.cache.BladeRedis; |
|
|
|
|
import org.springframework.amqp.core.Message; |
|
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
|
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
|
|
|
@ -51,6 +52,9 @@ public class OpOldReceivingDataHandler {
|
|
|
|
|
@Autowired |
|
|
|
|
private IFactoryPackageService factoryPackageService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private BladeRedis bladeRedis; |
|
|
|
|
|
|
|
|
|
@RabbitHandler |
|
|
|
|
public void opOldReceivingDataHandler(Map map, Message message, Channel channel) throws IOException { |
|
|
|
|
// 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉
|
|
|
|
@ -66,7 +70,6 @@ public class OpOldReceivingDataHandler {
|
|
|
|
|
|
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 查询包件数据 start >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); |
|
|
|
|
FactoryPackageEntity packageEntity = factoryPackageService.getOne(warehouseQueryWrapper); |
|
|
|
|
|
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 查询包件数据 end >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> packageEntity {}", packageEntity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -74,22 +77,29 @@ public class OpOldReceivingDataHandler {
|
|
|
|
|
try { |
|
|
|
|
// 保存数据
|
|
|
|
|
// 需要查询映射表 如果映射表没有值 这个字段为null
|
|
|
|
|
BasicdataTripartiteWarehouseEntity warehouse = basicdataTripartiteWarehouseClient.getWarehouse(warehouseName, null); |
|
|
|
|
BasicdataTripartiteWarehouseEntity warehouse = basicdataTripartiteWarehouseClient.getWarehouse(warehouseName, ""); |
|
|
|
|
if (ObjectUtils.isNotNull(warehouse)) { |
|
|
|
|
WarehouseEntity warehouseEntity = warehouseClient.findByCode(warehouse.getAssociationCode()); |
|
|
|
|
String warehouseCode = warehouse.getAssociationCode(); |
|
|
|
|
WarehouseEntity warehouseEntity = warehouseClient.findByCode(warehouseCode); |
|
|
|
|
// 请求老系统的登录接口
|
|
|
|
|
|
|
|
|
|
String authCode = oldLogin(warehouseEntity.getId()); |
|
|
|
|
// 推送数据
|
|
|
|
|
if (StringUtil.isNotBlank(authCode)) { |
|
|
|
|
boolean isSuccess = sendPackageData(authCode, orderPackageCode, warehouseName); |
|
|
|
|
if (isSuccess) { |
|
|
|
|
// 请求成功 修改推送数据的状态 修改未1
|
|
|
|
|
packageEntity.setOldPushStatus(1); |
|
|
|
|
} else { |
|
|
|
|
packageEntity.setOldPushStatus(2); |
|
|
|
|
if(!ObjectUtils.isNull(warehouseEntity)){ |
|
|
|
|
String authCode = oldLogin(warehouseEntity.getId()); |
|
|
|
|
// 推送数据
|
|
|
|
|
if (StringUtil.isNotBlank(authCode)) { |
|
|
|
|
boolean isSuccess = sendPackageData(authCode, orderPackageCode); |
|
|
|
|
if (isSuccess) { |
|
|
|
|
// 请求成功 修改推送数据的状态 修改未1
|
|
|
|
|
packageEntity.setOldPushStatus(1); |
|
|
|
|
} else { |
|
|
|
|
packageEntity.setOldPushStatus(2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
packageEntity.setOldPushStatus(2); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
@ -104,19 +114,28 @@ public class OpOldReceivingDataHandler {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean sendPackageData(String authCode, String orderPackageCode, String warehouseName) { |
|
|
|
|
private boolean sendPackageData(String authCode, String orderPackageCode) { |
|
|
|
|
// 构建请求头
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("type", "1"); |
|
|
|
|
map.put("unitNo", orderPackageCode); |
|
|
|
|
map.put("mctsTruckNo", ""); |
|
|
|
|
map.put("area", ""); |
|
|
|
|
map.put("user_id", ""); |
|
|
|
|
map.put("user_id", oldSystemProperties.getUserId()); |
|
|
|
|
map.put("pick_up_id", ""); |
|
|
|
|
map.put("origin", "按件入库"); |
|
|
|
|
|
|
|
|
|
String url = oldSystemProperties.getUrl() + "api/scan"; |
|
|
|
|
String body = HttpRequest.post(url).form(map).header("token",authCode).execute().body(); |
|
|
|
|
log.info("##################sendPackageData: 请求老系统接口,url:{},body:{}", url, body); |
|
|
|
|
if (StringUtil.isNotBlank(body)) { |
|
|
|
|
|
|
|
|
|
JSONObject res = JSON.parseObject(body); |
|
|
|
|
if("200".equals(res.getString("code"))){ |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -128,23 +147,28 @@ public class OpOldReceivingDataHandler {
|
|
|
|
|
* @return 成功token |
|
|
|
|
*/ |
|
|
|
|
private String oldLogin(Integer warhouseId) { |
|
|
|
|
String o = bladeRedis.get(oldSystemProperties.getUserId() + "_" + warhouseId); |
|
|
|
|
if(StringUtil.isBlank(o)){ |
|
|
|
|
String url = oldSystemProperties.getUrl() + "api/fakeLogin"; |
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("pwd", oldSystemProperties.getPwd()); |
|
|
|
|
map.put("user_id", oldSystemProperties.getUserId()); |
|
|
|
|
map.put("warehouse_id", warhouseId); |
|
|
|
|
String body = HttpRequest.post(url).form(map).execute().body(); |
|
|
|
|
log.info("##################opReceivingDataHandler: 请求老系统接口,url:{},body:{}", url, body); |
|
|
|
|
|
|
|
|
|
String url = oldSystemProperties.getUrl() + "api/fakeLogin"; |
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("pwd", oldSystemProperties.getPwd()); |
|
|
|
|
map.put("user_id", oldSystemProperties.getUserId()); |
|
|
|
|
map.put("warehouse_id", warhouseId); |
|
|
|
|
String body = HttpRequest.post(url).form(map).execute().body(); |
|
|
|
|
|
|
|
|
|
JSONObject authCode = JSON.parseObject(body); |
|
|
|
|
JSONObject authCode = JSON.parseObject(body); |
|
|
|
|
|
|
|
|
|
if ("200".equals(authCode.getString("code"))) { |
|
|
|
|
if ("200".equals(authCode.getString("code"))) { |
|
|
|
|
|
|
|
|
|
return authCode.getJSONObject("data").getJSONObject("token").getString("token"); |
|
|
|
|
o= authCode.getJSONObject("data").getJSONObject("token").getString("token"); |
|
|
|
|
bladeRedis.setEx(oldSystemProperties.getUserId() + "_" + warhouseId, o,30*60L); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
return o; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|