Commit bd990199 authored by 刘林's avatar 刘林

fix(jg):监管报错处理

parent 67ce2001
......@@ -65,7 +65,7 @@ public class CommonController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getChildren")
@ApiOperation(httpMethod = "GET", value = "通过设备种类code获取设备类别", notes = "通过设备种类code获取设备类别")
public ResponseModel<List<EquipmentCategory>> getChildren(@RequestParam(value = "code") String code,
public ResponseModel<List<EquipmentCategory>> getChildren(@RequestParam(value = "code", required = false) String code,
@RequestParam(value = "type", required = false) String type) {
return ResponseHelper.buildResponse(commonService.getEquipmentCategoryList(code, type));
}
......@@ -193,11 +193,11 @@ public class CommonController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getUserInfoSplit")
@ApiOperation(httpMethod = "GET", value = "查询安全管理员的基本信息", notes = "查询安全管理员的基本信息")
public ResponseModel<Map<String, Object>> getUserInfoSplit(@RequestParam(value = "sequenceNbr") String sequenceNbr) {
if (sequenceNbr.contains("_")) {
sequenceNbr = sequenceNbr.split("_")[0];
}
return ResponseHelper.buildResponse(commonService.getUserInfo(sequenceNbr));
public ResponseModel<Map<String, Object>> getUserInfoSplit(@RequestParam(value = "sequenceNbr", required = false) String sequenceNbr) {
return Optional.ofNullable(sequenceNbr)
.filter(s -> s.contains("_"))
.map(s -> ResponseHelper.buildResponse(commonService.getUserInfo(s.split("_")[0])))
.orElse(null);
}
/**
......
package com.yeejoin.amos.boot.module.jg.biz.listener;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.StartPlatformTokenService;
import lombok.extern.slf4j.Slf4j;
......@@ -13,59 +13,79 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.emq.EmqxListener;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.stream.Stream;
@Component
@Slf4j
public class PlatformUserTopicMessage extends EmqxListener {
private final String companyType = "行政审批局";
@Resource
protected EmqKeeper emqKeeper;
@Value("${amos.operation.log}")
private String amosOperationLog;
@PostConstruct
void init() throws Exception {
emqKeeper.subscript(amosOperationLog, 2, this);
}
@Value("${amos.agency.code}")
String amosAgencyCode;
private String amosAgencyCode;
@Autowired
RedisUtils redisUtil;
private StartPlatformTokenService platformTokenService;
@Autowired
StartPlatformTokenService platformTokenService;
@Autowired
ICommonService commonService;
private ICommonService commonService;
@PostConstruct
void init() throws Exception {
emqKeeper.subscript(amosOperationLog, 2, this);
}
@Override
public void processMessage(String topic, MqttMessage message) {
platformTokenService.getToken();
parseMessage(message)
.filter(jsonObject -> amosAgencyCode.equals(jsonObject.getString("agencyCode")))
.map(jsonObject -> jsonObject.getJSONObject("result"))
.filter(result -> StringUtils.isNotEmpty(result.getString("path")))
.map(result -> result.get("result"))
.flatMap(this::streamDataResult)
.forEach(this::processDataResult);
log.info("平台推送消息同步完成");
}
private Stream<JSONObject> streamDataResult(Object dataResult) {
if (dataResult instanceof JSONObject) {
return Stream.of((JSONObject) dataResult);
} else if (dataResult instanceof JSONArray) {
JSONArray dataResultArray = (JSONArray) dataResult;
return dataResultArray.stream()
.map(JSONObject.class::cast);
} else {
log.warn("未知的数据类型: {}", dataResult.getClass().getName());
return Stream.empty();
}
}
private Stream<JSONObject> parseMessage(MqttMessage message) {
try {
JSONObject jsonObject = JSON.parseObject(message.toString());
JSONObject result = jsonObject.getJSONObject("result");
JSONObject dataResult = result.getJSONObject("result");
String path = result.getString("path");
String agencyCode = jsonObject.getString("agencyCode");
if (!amosAgencyCode.equals(agencyCode)) {
return;
return Stream.of(jsonObject);
} catch (Exception e) {
log.error("消息解析失败: {}", message.toString(), e);
return Stream.empty();
}
}
private void processDataResult(JSONObject dataResultObject) {
try {
if (StringUtils.isNotEmpty(path)) {
if (dataResult.get("companyType").toString().contains(companyType)) {
String companyType = "行政审批局";
String companyTypeValue = dataResultObject.getString("companyType");
if (StringUtils.isNotEmpty(companyTypeValue) && companyTypeValue.contains(companyType)) {
commonService.creatApproveTree();
}
}
} catch (Exception e) {
log.info("平台同步消息失败:{}", e.getMessage());
log.error("平台同步消息处理失败: {}", dataResultObject, e);
}
log.info("平台推送消息同步完成");
}
}
......@@ -322,24 +322,18 @@ public class CommonServiceImpl implements ICommonService {
@Override
public List<EquipmentCategory> getEquipmentCategoryList(String code, String type) {
List<EquipmentCategory> result = new ArrayList<>();
if (StringUtils.isEmpty(code)) {
return Collections.emptyList();
}
LambdaQueryWrapper<EquipmentCategory> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EquipmentCategory::getCode, code);
EquipmentCategory equipmentCategory = equipmentCategoryMapper.selectOne(wrapper);
if (ObjectUtils.isEmpty(type)) {
if (!ValidationUtil.isEmpty(equipmentCategory)) {
result.add(equipmentCategory);
if (equipmentCategory == null) {
return Collections.emptyList();
}
} else {
LambdaQueryWrapper<EquipmentCategory> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.eq(EquipmentCategory::getParentId, equipmentCategory.getId());
List<EquipmentCategory> equipmentCategories = equipmentCategoryMapper.selectList(wrapper2);
if (!ValidationUtil.isEmpty(equipmentCategories)) {
result = equipmentCategories;
}
}
return result;
wrapper2.eq(!StringUtils.isEmpty(type), EquipmentCategory::getParentId, equipmentCategory.getId());
return equipmentCategoryMapper.selectList(wrapper2);
}
@Override
......
......@@ -1127,7 +1127,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 600000)
public void flowExecute(Long id, String instanceId, String operate, String comment, String carNumber, String manageType, String nextTaskId) {
String lockKey = CommonServiceImpl.buildJgExecuteLockKey(instanceId);
RLock lock = redissonClient.getLock(lockKey);
......
......@@ -54,6 +54,7 @@ client {
tm {
commitRetryCount = 5
rollbackRetryCount = 5
default-global-transaction-timeout = 600 # 600秒
}
undo {
dataValidation = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment