|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.logpm.factorydata.mengtian.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
import cn.hutool.core.convert.Convert; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.http.HttpRequest; |
|
|
|
@ -15,6 +16,7 @@ import com.logpm.factorydata.mengtian.service.FactoryNodePushService;
|
|
|
|
|
import com.logpm.factorydata.mengtian.util.QueryUtil; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
@ -38,33 +40,44 @@ public class FactoryNodePushServiceImpl extends BaseServiceImpl<FactoryNodePushM
|
|
|
|
|
IPage<FactoryNodePushEntity> page = Condition.getPage(query); |
|
|
|
|
QueryWrapper<FactoryNodePushEntity> queryWrapper = QueryUtil.buildQueryWrapper(vo, FactoryNodePushEntity.class); |
|
|
|
|
List<FactoryNodePushEntity> deliveryTrainPage = baseMapper.pageNodePush(page, queryWrapper); |
|
|
|
|
return null; |
|
|
|
|
return page.setRecords(deliveryTrainPage); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Boolean cancel(String id) { |
|
|
|
|
return baseMapper.cancel(id); |
|
|
|
|
public Boolean cancel(List<String> ids) { |
|
|
|
|
if(CollUtil.isEmpty(ids)){ |
|
|
|
|
throw new ServiceException("参数为空"); |
|
|
|
|
} |
|
|
|
|
return baseMapper.cancel(ids); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Boolean rePush(String id) { |
|
|
|
|
FactoryNodePushEntity factoryNodePushEntity = baseMapper.selectById(id); |
|
|
|
|
if(ObjectUtil.isNotEmpty(factoryNodePushEntity)){ |
|
|
|
|
log.info("重新推送工厂:{}", JSONUtil.toJsonStr(factoryNodePushEntity)); |
|
|
|
|
HttpRequest post = HttpUtil.createPost(factoryNodePushEntity.getSendUrl()); |
|
|
|
|
post.header("ClientId", "mt.ht"); |
|
|
|
|
post.header("OperationCode", factoryNodePushEntity.getOperationCode()); |
|
|
|
|
post.body(factoryNodePushEntity.getContent()); |
|
|
|
|
HttpResponse execute = post.execute(); |
|
|
|
|
String resBody = execute.body(); |
|
|
|
|
log.info("重新推送工厂结果:{}", resBody); |
|
|
|
|
JSONObject entries = JSONUtil.parseObj(resBody); |
|
|
|
|
int resultCode = entries.getInt("Result"); |
|
|
|
|
// 存入日志表
|
|
|
|
|
factoryNodePushEntity.setSendStatus(Convert.toStr(resultCode)); |
|
|
|
|
baseMapper.updateById(factoryNodePushEntity); |
|
|
|
|
return Boolean.TRUE; |
|
|
|
|
public Boolean rePush(List<String> ids) { |
|
|
|
|
if(CollUtil.isEmpty(ids)){ |
|
|
|
|
throw new ServiceException("参数为空"); |
|
|
|
|
} |
|
|
|
|
List<FactoryNodePushEntity> factoryNodePushEntities = baseMapper.selectBatchIds(ids); |
|
|
|
|
if(CollUtil.isNotEmpty(factoryNodePushEntities)){ |
|
|
|
|
for (FactoryNodePushEntity factoryNodePushEntity : factoryNodePushEntities) { |
|
|
|
|
if(ObjectUtil.isNotEmpty(factoryNodePushEntity)){ |
|
|
|
|
log.info("重新推送工厂:{}", JSONUtil.toJsonStr(factoryNodePushEntity)); |
|
|
|
|
HttpRequest post = HttpUtil.createPost(factoryNodePushEntity.getSendUrl()); |
|
|
|
|
post.header("ClientId", "mt.ht"); |
|
|
|
|
post.header("OperationCode", factoryNodePushEntity.getOperationCode()); |
|
|
|
|
post.body(factoryNodePushEntity.getContent()); |
|
|
|
|
HttpResponse execute = post.execute(); |
|
|
|
|
String resBody = execute.body(); |
|
|
|
|
log.info("重新推送工厂结果:{}", resBody); |
|
|
|
|
JSONObject entries = JSONUtil.parseObj(resBody); |
|
|
|
|
int resultCode = entries.getInt("Result"); |
|
|
|
|
// 存入日志表
|
|
|
|
|
factoryNodePushEntity.setSendStatus(Convert.toStr(resultCode)); |
|
|
|
|
baseMapper.updateById(factoryNodePushEntity); |
|
|
|
|
return Boolean.TRUE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Boolean.FALSE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|