Commit bd990199 authored by 刘林's avatar 刘林

fix(jg):监管报错处理

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