Browse Source

feat(all): 修改梦天回传逻辑

dist.1.3.0
zhaoqiaobo 8 months ago
parent
commit
a6335cda4a
  1. 33
      blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/controller/OrderController.java
  2. 2
      blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/entity/FactoryNodePushEntity.java
  3. 8
      blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/mapper/FactoryNodePushMapper.java
  4. 7
      blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/mapper/FactoryNodePushMapper.xml
  5. 4
      blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/mq/NodeDataPushListener.java
  6. 7
      blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/service/FactoryNodePushService.java
  7. 48
      blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/service/impl/FactoryNodePushServiceImpl.java
  8. 29
      blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/util/QueryUtil.java

33
blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/controller/OrderController.java

@ -1,14 +1,21 @@
package com.logpm.factorydata.mengtian.controller;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.factorydata.mengtian.entity.FactoryNodePushEntity;
import com.logpm.factorydata.mengtian.service.FactoryNodePushService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@ -31,6 +38,7 @@ import java.util.Map;
public class OrderController {
private final RabbitTemplate rabbitTemplate;
private final FactoryNodePushService nodePushService;
@ResponseBody
@PostMapping("sendMsg")
@ -43,6 +51,31 @@ public class OrderController {
return R.success("成功");
}
@GetMapping
@ApiOperationSupport(order = 2)
@ApiOperation(value = "推送记录", notes = "推送记录")
public R<IPage<FactoryNodePushEntity>> pageNodePush(FactoryNodePushEntity vo, Query query) {
IPage<FactoryNodePushEntity> pages = nodePushService.pageNodePush(vo, query);
return R.data(pages);
}
@PostMapping("rePush/{id}")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "重新推送", notes = "重新推送")
public R<Boolean> rePush(@PathVariable("id") String id) {
Boolean flag = nodePushService.rePush(id);
return R.data(flag);
}
@PatchMapping("cancel/{id}")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "取消", notes = "取消")
public R<Boolean> cancel(@PathVariable("id") String id) {
Boolean flag = nodePushService.cancel(id);
return R.data(flag);
}
}

2
blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/entity/FactoryNodePushEntity.java

@ -78,7 +78,7 @@ public class FactoryNodePushEntity extends BaseEntity {
/**
* 发送状态
*/
@ApiModelProperty(name = "发送状态", notes = "")
@ApiModelProperty(name = "发送状态(0:成功,-1:失败,1:取消)", notes = "")
private String sendStatus;
/**
* 操作码

8
blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/mapper/FactoryNodePushMapper.java

@ -1,8 +1,13 @@
package com.logpm.factorydata.mengtian.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.factorydata.mengtian.entity.FactoryNodePushEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 装箱包信息 mapper
@ -13,4 +18,7 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface FactoryNodePushMapper extends BaseMapper<FactoryNodePushEntity> {
List<FactoryNodePushEntity> pageNodePush(IPage<FactoryNodePushEntity> page, @Param("ew") Wrapper queryWrapper);
Boolean cancel(@Param("id") String id);
}

7
blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/mapper/FactoryNodePushMapper.xml

@ -2,4 +2,11 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.logpm.factorydata.mengtian.mapper.FactoryNodePushMapper">
<select id="pageNodePush" resultType="com.logpm.factorydata.mengtian.entity.FactoryNodePushEntity">
select * from mt_factory_node_push #{ew.customSqlSegment}
</select>
<update id="cancel">
update mt_factory_node_push set send_status = 1 where id = #{id}
</update>
</mapper>

4
blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/mq/NodeDataPushListener.java

@ -1,6 +1,7 @@
package com.logpm.factorydata.mengtian.mq;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.EnumUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@ -313,11 +314,14 @@ public class NodeDataPushListener {
HttpResponse execute = post.execute();
String resBody = execute.body();
log.info("推送工厂结果:{}", resBody);
JSONObject entries = JSONUtil.parseObj(resBody);
int resultCode = entries.getInt("Result");
// 存入日志表
entity.setContent(body);
entity.setOperationCode(operationCode);
entity.setSendUrl(mengTianProperties.getHost() + url);
entity.setResultContent(resBody);
entity.setSendStatus(Convert.toStr(resultCode));
factoryNodePushService.save(entity);
}

7
blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/service/FactoryNodePushService.java

@ -1,7 +1,9 @@
package com.logpm.factorydata.mengtian.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.factorydata.mengtian.entity.FactoryNodePushEntity;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query;
/**
* 推送工厂节点数据 服务类
@ -11,4 +13,9 @@ import org.springblade.core.mp.base.BaseService;
**/
public interface FactoryNodePushService extends BaseService<FactoryNodePushEntity> {
IPage<FactoryNodePushEntity> pageNodePush(FactoryNodePushEntity vo, Query query);
Boolean cancel(String id);
Boolean rePush(String id);
}

48
blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/service/impl/FactoryNodePushServiceImpl.java

@ -1,13 +1,27 @@
package com.logpm.factorydata.mengtian.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.factorydata.mengtian.entity.FactoryNodePushEntity;
import com.logpm.factorydata.mengtian.mapper.FactoryNodePushMapper;
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.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 装箱包信息 业务实现类
*
@ -19,4 +33,38 @@ import org.springframework.stereotype.Service;
@AllArgsConstructor
public class FactoryNodePushServiceImpl extends BaseServiceImpl<FactoryNodePushMapper, FactoryNodePushEntity> implements FactoryNodePushService {
@Override
public IPage<FactoryNodePushEntity> pageNodePush(FactoryNodePushEntity vo, Query query) {
IPage<FactoryNodePushEntity> page = Condition.getPage(query);
QueryWrapper<FactoryNodePushEntity> queryWrapper = QueryUtil.buildQueryWrapper(vo, FactoryNodePushEntity.class);
List<FactoryNodePushEntity> deliveryTrainPage = baseMapper.pageNodePush(page, queryWrapper);
return null;
}
@Override
public Boolean cancel(String id) {
return baseMapper.cancel(id);
}
@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;
}
return Boolean.FALSE;
}
}

29
blade-service/logpm-factory-data/logpm-factory-data-mengtian/src/main/java/com/logpm/factorydata/mengtian/util/QueryUtil.java

@ -0,0 +1,29 @@
package com.logpm.factorydata.mengtian.util;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springblade.core.mp.support.Condition;
import java.util.Map;
/**
* QueryWrapper查询对象工具类
*
* @author zhaoqiaobo
* @create 2024-03-13 15:43
*/
public class QueryUtil {
/**
* vo 对象构建成指定类型的 QueryWrapper 对象
*
* @param vo
* @param classz
* @return
*/
public static QueryWrapper buildQueryWrapper(Object vo, Class classz) {
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(vo);
return Condition.getQueryWrapper(stringObjectMap, classz);
}
}
Loading…
Cancel
Save