diff --git a/hzims-service/assets/src/main/resources/template/template.yml b/hzims-service/assets/src/main/resources/template/template.yml index 8aaa1ea..3a4fb6f 100644 --- a/hzims-service/assets/src/main/resources/template/template.yml +++ b/hzims-service/assets/src/main/resources/template/template.yml @@ -13,7 +13,7 @@ spring: autoconfigure: exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure datasource: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_assets?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-assets?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} #swagger扫描路径配置 diff --git a/hzims-service/equipment/src/main/resources/template/template.yml b/hzims-service/equipment/src/main/resources/template/template.yml index b99b6b0..959a4b4 100644 --- a/hzims-service/equipment/src/main/resources/template/template.yml +++ b/hzims-service/equipment/src/main/resources/template/template.yml @@ -12,23 +12,23 @@ spring: primary: master datasource: master: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} slave: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} inspect: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} hzims: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} bladex: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} @@ -89,9 +89,14 @@ blade: data: sdk: enabled: true - url: http://${hzims.sdk.ip}/api/hzinfo-data-config - appId: ${hzims.sdk.appId} - appSecret: ${hzims.sdk.appSecret} + url: "http://${hzims.sdk.ip}/api/hzinfo-data-config" + ctrlUrl: "http://${hzims.sdk.ip}/api/hzinfo-data-handler" + appId: "${hzims.sdk.appId}" + appSecret: "${hzims.sdk.appSecret}" + redisIp: "${hzinfo.redis.ip}" + redisPort: ${hzinfo.redis.port} + password: "${hzinfo.redis.password}" + maxKeys: 1000 data-scope: enabled: false diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java index 700ca5f..2d3090e 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleFlowServiceImpl.java @@ -2,6 +2,8 @@ package com.hnac.hzims.alarm.show.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant; @@ -13,6 +15,7 @@ import com.hnac.hzims.alarm.show.service.AlarmHandleFlowService; import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.fdp.feign.IFdpDiagnoseClient; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; @@ -63,6 +66,9 @@ public class AlarmHandleFlowServiceImpl extends ServiceImpl() {{ + eq(AlarmHandleFlowEntity::getId, split[1]); + }}); + alarmHandleFlowEntity.setIsNormal(false); + alarmHandleFlowEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId()); + alarmHandleFlowEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); + alarmHandleFlowEntity.setCurrentOperator(processWorkFlowResponse.getTaskName()); + alarmHandleFlowEntity.setCurrentLinkHandler(""); + this.baseMapper.updateById(alarmHandleFlowEntity); + log.info("补偿流程消息转换结束"+ processWorkFlowResponse); + return R.success("补偿流程消息保存成功"); + } private void sendMessage(ProcessWorkFlowResponse processWorkFlowResponse, AlarmHandleFlowEntity alarmHandleFlowEntity, Long taskId) { //推送消息 if (processWorkFlowResponse.getTaskId() != null) { diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java index 14f7b9f..769e53e 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java @@ -159,9 +159,9 @@ public class AlarmHandleServiceImpl extends ServiceImpl variables) { - return processService.startFlow(userId,dictValue,taskId,processName,variables); + return processService.startFlow(userId,dictValue,businessKey,processName,variables); } } \ No newline at end of file diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java index 9952839..b7014fb 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/abstracts/ProcessAbstractService.java @@ -4,13 +4,14 @@ import com.hnac.hzims.middle.processflow.entity.ProcessDict; import com.hnac.hzims.middle.processflow.service.ProcessDictService; import com.hnac.hzims.middle.processflow.strategy.service.ProcessService; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; import org.springblade.message.MessageConstants; -import org.springblade.message.dto.BusinessMessageDTO; +import org.springblade.message.dto.BusinessMessageFlowDTO; import org.springblade.message.fegin.IMessageClient; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.entity.User; @@ -43,11 +44,11 @@ public abstract class ProcessAbstractService implements ProcessService { private ProcessDictService processDictService; @Override - public R startFlow(String userId, String dictValue, String taskId, String processName, Map variables) { + public R startFlow(String userId, String dictValue, String businessKey, String processName, Map variables) { log.info("开启流程....."); R r = new R(); try { - R result = flowClient.startProcessInstanceContainNameByKey(dictValue, taskId, processName, variables); + R result = flowClient.startProcessInstanceContainNameByKey(dictValue, businessKey, processName, variables); r.setSuccess(result.isSuccess()); r.setCode(result.getCode()); r.setMsg(result.getMsg()); @@ -60,7 +61,7 @@ public abstract class ProcessAbstractService implements ProcessService { log.error("开启流程失败:{}",result); log.error("流程信息为{}",variables); r.setData(variables); - pushStartFailMessage(dictValue,Long.valueOf(taskId),userId,processName,result.getMsg()); + pushStartFailMessage(dictValue,businessKey,userId,processName,result.getMsg()); } return r; }catch (Exception e){ @@ -85,11 +86,11 @@ public abstract class ProcessAbstractService implements ProcessService { // return r; // } - public void pushStartFailMessage(String dictValue,Long taskId, String userId, String content,String reason) { + public void pushStartFailMessage(String dictValue,String businessKey, String userId, String content,String reason) { ProcessDict processDict = processDictService.selectDictLabelByKey(dictValue); - BusinessMessageDTO message = new BusinessMessageDTO(); + BusinessMessageFlowDTO message = new BusinessMessageFlowDTO(); // 计划Id - message.setTaskId(taskId); + message.setTaskId(businessKey); message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); message.setBusinessKey(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); // 主题 @@ -108,36 +109,46 @@ public abstract class ProcessAbstractService implements ProcessService { } message.setCreateUser(admin.getId()); message.setUserIds(userId); - messageClient.sendAppAndWsMsgByUsers(message); + messageClient.sendAppAndWsMsgByUsersFlow(message); } @Override - public void pushFailMessage(Long taskId, String proessKey, String userId, String content,String reason,String deptId) { + public void pushFailMessage(String businessKey, String proessKey, String content,String reason,String deptId) { ProcessDict processDict = processDictService.selectDictLabelByKey(proessKey); - BusinessMessageDTO message = new BusinessMessageDTO(); + BusinessMessageFlowDTO message = new BusinessMessageFlowDTO(); +// BusinessMessageDTO message = new BusinessMessageDTO(); // 计划Id - message.setTaskId(taskId); + message.setTaskId(businessKey); message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); message.setBusinessKey(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); // 主题 message.setSubject(MessageConstants.BusinessClassifyEnum.BUSINESS.getDescription()); // 内容 - String res= StringUtil.format("你有一个{}的{}流程流转失败,失败原因为:{}",content, + String res= StringUtil.format("你有一个流程环节为{}的{}流转失败,失败原因为:{}",content, processDict.getDictLabel(), reason); message.setContent(res); message.setTenantId("200000"); - R> userListR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), Long.valueOf(deptId), PROJECT_MANAGER); + R> userListR = userClient.queryUserByRoleAlias("200000", Long.valueOf(deptId), PROJECT_MANAGER); User admin = userClient.userByAccount("200000", "admin").getData(); - User createUser = userClient.userInfoById(Long.valueOf(userId)).getData(); - message.setDeptId(createUser.getCreateDept()); - R result = sysClient.getDeptName(createUser.getCreateDept()); + message.setDeptId(Long.valueOf(deptId)); + R result = sysClient.getDeptName(Long.valueOf(deptId)); if (result.isSuccess()) { message.setDeptName(result.getData()); } - List data = userListR.getData(); - String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(",")); + if (CollectionUtil.isNotEmpty(userListR.getData())){ + List data = userListR.getData(); + String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(",")); + message.setUserIds(userIds); + }else { + R> listR = userClient.queryUserByRoleAlias("200000", Long.valueOf(20000001), PROJECT_MANAGER); + if (ObjectUtil.isEmpty(listR)||CollectionUtil.isEmpty(listR.getData())){ + return; + } + List data =listR.getData(); + String userIds = data.stream().map(user -> user.getId().toString()).collect(Collectors.joining(",")); + message.setUserIds(userIds); + } message.setCreateUser(admin.getId()); - message.setUserIds(userIds); - messageClient.sendAppAndWsMsgByUsers(message); + messageClient.sendAppAndWsMsgByUsersFlow(message); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java index 7869a16..68ab7f0 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/service/ProcessService.java @@ -14,9 +14,9 @@ import java.util.Map; */ public interface ProcessService { - R startFlow(String userId, String dictValue, String taskId, String processName, Map variables) ; + R startFlow(String userId, String dictValue, String businessKey, String processName, Map variables) ; - void pushFailMessage(Long taskId, String proessKey, String userId, String content,String reason,String deptId); + void pushFailMessage(String taskId, String proessKey, String content,String reason,String deptId); /** * 设置执行那种实现类 * @param flowQueue diff --git a/hzims-service/hzims-middle/src/main/resources/template/template.yml b/hzims-service/hzims-middle/src/main/resources/template/template.yml index 1746921..36a8370 100644 --- a/hzims-service/hzims-middle/src/main/resources/template/template.yml +++ b/hzims-service/hzims-middle/src/main/resources/template/template.yml @@ -8,7 +8,7 @@ spring: autoconfigure: exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure datasource: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_middle?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-middle?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} diff --git a/hzims-service/hzims-scheduled/src/main/resources/template/template.yml b/hzims-service/hzims-scheduled/src/main/resources/template/template.yml index cf19301..fc8cd35 100644 --- a/hzims-service/hzims-scheduled/src/main/resources/template/template.yml +++ b/hzims-service/hzims-scheduled/src/main/resources/template/template.yml @@ -14,31 +14,31 @@ spring: primary: master datasource: master: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} equipment: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} ticket: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} safeproduct: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} inspect: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} basic: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_basic?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-basic?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} alarm: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_alarm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_alarm?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} diff --git a/hzims-service/inspect/src/main/resources/template/template.yml b/hzims-service/inspect/src/main/resources/template/template.yml index f53c3bd..77f2f0d 100644 --- a/hzims-service/inspect/src/main/resources/template/template.yml +++ b/hzims-service/inspect/src/main/resources/template/template.yml @@ -18,7 +18,7 @@ spring: autoconfigure: exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure datasource: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java index cc715ff..e2cc2da 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java @@ -121,7 +121,6 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces private final TransactionTemplate transactionTemplate; @Override public String saveEntity(String entity) { - transactionTemplate.setTransactionManager(transactionManager); String res = transactionTemplate.execute(status -> { AccessPlanV4DTO accessPlanV4DTO = JSONObject.parseObject(entity, AccessPlanV4DTO.class); @@ -289,8 +288,8 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator()); entity.setIsNormal(true); if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){ - entity.setIsNormal(false); - entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); + handException(processWorkFlowResponse); + return false; } if(ObjectUtil.isNotEmpty(variables.get("examine")) && (Boolean) variables.get("examine")){ entity.setTaskName("流程结束"); @@ -322,7 +321,27 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces } return true; } - + private R handException(ProcessWorkFlowResponse processWorkFlowResponse) { + String[] split = processWorkFlowResponse.getBusinessKey().split(":"); + if (StringUtils.isBlank(split[1])){ + log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse); + return R.fail("异常消息处理失败"); + } + OperAccessPlanEntity operAccessPlanEntity = planService.getOne(new LambdaQueryWrapper() {{ + eq(OperAccessPlanEntity::getId, split[1]); + }}); + operAccessPlanEntity.setIsNormal(false); + operAccessPlanEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); + operAccessPlanEntity.setTaskName(processWorkFlowResponse.getTaskName()); + operAccessPlanEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId()); + operAccessPlanEntity.setNextStepOperator(""); + boolean flag = planService.updateById(operAccessPlanEntity); + if (!flag){ + log.info("异常状态消息保存失败"+ processWorkFlowResponse); + return R.success("消息保存失败"); + } + return R.fail("消息保存成功"); + } /** * 开启检修任务 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java index 675064c..90ba737 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java @@ -131,7 +131,7 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service, StartProces String.valueOf(accessTaskV4DTO.getId())), accessTaskV4DTO.getName(),variables); log.error("开启检修任务流程失败{}" + result); // 更新任务流程Id - if (200==result.getCode()) { + if (200==result.getCode()&&ObjectUtil.isNotEmpty(result.getData())) { accessTaskV4DTO.setProcessInstanceId(result.getData().toString()); accessTaskV4DTO.setIsNormal(true); taskService.updateById(accessTaskV4DTO); @@ -237,8 +237,8 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service, StartProces AccessTaskV4DTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference(){}); entity.setIsNormal(true); if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){ - entity.setIsNormal(false); - entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); + handException(processWorkFlowResponse); + return false; } // 当前流程名称 entity.setTaskName(processWorkFlowResponse.getTaskName()); @@ -266,12 +266,31 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service, StartProces String content = "您有一条检修任务待处理/审核,检修任务名称:".concat(entity.getName()) .concat(",当前环节:") .concat(processWorkFlowResponse.getTaskName()); - if(ObjectUtils.isEmpty(processWorkFlowResponse.getCode())||700!=processWorkFlowResponse.getCode()){ - this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); - } + this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); return true; } + private R handException(ProcessWorkFlowResponse processWorkFlowResponse) { + String[] split = processWorkFlowResponse.getBusinessKey().split(":"); + if (StringUtils.isBlank(split[1])){ + log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse); + return R.fail("异常消息处理失败"); + } + OperAccessTaskEntity operAccessTaskEntity = taskService.getOne(new LambdaQueryWrapper() {{ + eq(OperAccessTaskEntity::getId, split[1]); + }}); + operAccessTaskEntity.setIsNormal(false); + operAccessTaskEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); + operAccessTaskEntity.setTaskName(processWorkFlowResponse.getTaskName()); + operAccessTaskEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId()); + operAccessTaskEntity.setNextStepOperator(""); + boolean flag = taskService.updateById(operAccessTaskEntity); + if (!flag){ + log.info("异常状态消息保存失败"+ processWorkFlowResponse); + return R.success("消息保存失败"); + } + return R.fail("消息保存成功"); + } /** * 推送业务流程消息 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java index 2670106..0e16ddf 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java @@ -26,13 +26,7 @@ public class HzimsDataController { private final HzimsDataService service; - - @GetMapping("/saveArea") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "获取区域列表数据", notes = "无需传入参数") - public R saveArea() { - return R.data(service.saveArea()); - } + @GetMapping("/stationNumber") @@ -42,7 +36,7 @@ public class HzimsDataController { return R.data(service.stationNumber()); } - + @GetMapping("/station") @ApiOperationSupport(order = 3) @ApiOperation(value = "站点数据获取", notes = "传入站点code") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java index 5974bd1..a10edbb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java @@ -15,11 +15,6 @@ import java.util.List; */ public interface HzimsDataService { - /** - * 获取区域列表数据 - * @return - */ - boolean saveArea(); List stationNumber(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java index b239d27..296612c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java @@ -85,10 +85,7 @@ public class HzimsDataServiceImpl implements HzimsDataService { private final RedisTemplate redisTemplate; - @Value("${hzims.operation.save.area.url}") - public String AREA_URL; - @Value("${hzims.operation.save.station.url}") - public String STATION_URL; + private final static String charge = "hzims:operation:key:charge"; @@ -105,41 +102,7 @@ public class HzimsDataServiceImpl implements HzimsDataService { private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; - @Override - public boolean saveArea() { - R> result = sysClient.getDeptList(); - if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { - throw new ServiceException("暂无区域数据!"); - } - List types = Arrays.asList(HomePageConstant.HYDROPOWER, HomePageConstant.WATER_CONSERVANCY, HomePageConstant.PUMPING, HomePageConstant.GATE); - Map> map = areaService.getAuthArea(result.getData(), null, types, HomePageConstant.HYDROPOWER_SERVETYPE,true); - if (MapUtils.isEmpty(map)) { - throw new ServiceException("暂无区域数据!"); - - } - List deviceList = emService.getEmInfoList(); - // 获取区域列表数据 - List list = map.entrySet().stream().map(entry->{ - AreaVo vo = new AreaVo(); - vo.setDeptId(entry.getKey().getId()); - vo.setDeptName(entry.getKey().getDeptName()); - int hydropowerCount = (int) entry.getValue().stream().filter(o->HomePageConstant.HYDROPOWER.equals(o.getType())).count(); - vo.setHydropowerStationCount(hydropowerCount); - int waterCount = entry.getValue().size() - hydropowerCount; - vo.setWaterStationCount(waterCount); - List value = entry.getValue().stream().filter(o->HomePageConstant.HYDROPOWER.equals(o.getType())).map(StationEntity::getRefDept).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(value)){ - vo.setInstalledCapacity(0.0); - }else{ - double installedCapacity = deviceList.stream().filter(o-> null != o.getInstalledCapacity() && value.contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum(); - vo.setInstalledCapacity(installedCapacity); - } - return vo; - }).collect(Collectors.toList()); - // 调用Http请求 - return this.sendMessage(JSONObject.toJSONBytes(list),AREA_URL); - } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java index f0355a4..1247345 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java @@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -335,6 +337,10 @@ public class DefectCheckServiceImpl extends ServiceImpl variables = (Map) processWorkFlowResponse.getVariables(); //现象缺陷全表更新 @@ -368,7 +374,6 @@ public class DefectCheckServiceImpl extends ServiceImpl() {{ + eq(OperPhenomenonEntity::getId, split[1]); + }}); + operPhenomenonEntity.setIsNormal(false); + operPhenomenonEntity.setCheckProcessInstanceId(processWorkFlowResponse.getTaskId()); + operPhenomenonEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); + operPhenomenonEntity.setCurrentOperator(processWorkFlowResponse.getTaskName()); + operPhenomenonEntity.setCurrentLinkHandler(""); + this.baseMapper.update(operPhenomenonEntity, new LambdaUpdateWrapper() {{ + eq(OperPhenomenonEntity::getDefectCode, operPhenomenonEntity.getDefectCode()); + }}); + log.info("消缺消息转换结束"+ processWorkFlowResponse); return R.success("消息保存成功"); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java index eab7449..7df8870 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/feign/DutyRecClient.java @@ -32,18 +32,6 @@ public class DutyRecClient implements IDutyRecClient { @Override public R dealDutyRecFlow(ProcessWorkFlowResponse processWorkFlowResponse) { - log.info("operational:duty:rec:dealDutyRecFlow","接受到消息:消息内容为:"+ JSON.toJSONString(processWorkFlowResponse)); - //ImsDutyRecDTO recDTO = BeanUtil.copy(processWorkFlowResponse.getVariables(),ImsDutyRecDTO.class); - ImsDutyRecDTO recDTO = JSONObject.parseObject(JSON.toJSONString(processWorkFlowResponse.getVariables()),ImsDutyRecDTO.class); - Assert.isTrue(ObjectUtil.isNotEmpty(recDTO),() -> { - throw new RuntimeException("未接收到交接班信息!"); - }); - recDTO.setDealChain(processWorkFlowResponse.getTaskName()); - recDTO.setIsNormal(true); - if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){ - recDTO.setIsNormal(false); - recDTO.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); - } - return R.status(service.dealDutyRecFlow(recDTO)); + return service.dealDutyRecFlow(processWorkFlowResponse); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyRecQRRecordMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyRecQRRecordMapper.java index 1699cc7..00c0f62 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyRecQRRecordMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyRecQRRecordMapper.java @@ -25,7 +25,6 @@ public interface ImsDutyRecQRRecordMapper extends UserDataScopeBaseMapper selectPageList(IPage page,@Param(value = "vo") ImsDutyRecQRRecordVo vo); + List selectPageList(@Param(value = "page")IPage page,@Param(value = "vo") ImsDutyRecQRRecordVo vo); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java index a217f4c..1d0461f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java @@ -2,6 +2,7 @@ package com.hnac.hzims.operational.duty.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; import com.hnac.hzims.operational.duty.dto.ImsDutyRecDTO; @@ -130,7 +131,7 @@ public interface IImsDutyRecService extends IService { * @param recDTO 交接班信息 * @return */ - Boolean dealDutyRecFlow(ImsDutyRecDTO recDTO); + R dealDutyRecFlow(ProcessWorkFlowResponse processWorkFlowResponse); R getDutyLog(ImsDutyLogEntity imsDutyLogEntity); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java index c88e34e..89284c7 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java @@ -10,10 +10,13 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Lists; import com.hnac.hzims.common.flow.StartProcessService; +import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.middle.process.feign.ICompensateProcessClient; +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.monitor.utils.DateUtils; import com.hnac.hzims.operational.OperationalConstants; import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO; +import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; import com.hnac.hzims.operational.defect.constants.TreatMethodConstant; import com.hnac.hzims.operational.defect.entity.OperAppearanceEntity; import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity; @@ -1321,8 +1324,19 @@ public class ImsDutyRecServiceImpl extends ServiceImpl { + throw new RuntimeException("未接收到交接班信息!"); + }); + recDTO.setDealChain(processWorkFlowResponse.getTaskName()); + recDTO.setIsNormal(true); + if(ObjectUtil.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){ + handException(processWorkFlowResponse); + + } ImsDutyMainEntity headDutyMain = BeanUtil.copy(recDTO.getHeadDutyMainVo(), ImsDutyMainEntity.class); ImsDutyMainEntity carryDutyMain = BeanUtil.copy(recDTO.getCarryDutyMainVo(), ImsDutyMainEntity.class); if(StringUtil.isBlank(recDTO.getDealChain())) { @@ -1366,13 +1380,36 @@ public class ImsDutyRecServiceImpl extends ServiceImpl() {{ + eq(ImsDutyRecEntity::getId, split[1]); + }}); + imsDutyRecEntity.setIsNormal(false); + imsDutyRecEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); + imsDutyRecEntity.setDealChain(processWorkFlowResponse.getTaskName()); + imsDutyRecEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId()); + boolean flag = this.updateById(imsDutyRecEntity); + if (!flag){ + log.info("异常状态消息保存失败"+ processWorkFlowResponse); + return R.success("消息保存失败"); + } + return R.fail("消息保存成功"); + } /** * 计算交接班状态 * @param duty 值班信息 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java index c40702b..5228a86 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java @@ -1,12 +1,17 @@ package com.hnac.hzims.operational.maintenance.scheduled; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant; +import com.hnac.hzims.alarm.config.entity.AlarmHandleFlowEntity; import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.middle.process.feign.ICompensateProcessClient; import com.hnac.hzims.operational.constants.FlowKeyConstants; import com.hnac.hzims.operational.constants.RedisKeyConstants; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; @@ -28,6 +33,7 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; +import org.springblade.flow.core.utils.FlowUtil; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springframework.data.redis.core.RedisTemplate; @@ -41,6 +47,7 @@ import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.hnac.hzims.operational.constants.FlowKeyConstants.MAINTENANCE_TASK_FLOW_KEY; import static com.hnac.hzims.operational.maintenance.constants.ScheduledConstant.GENERATE_MAINTENANCE_TASK_SCHEDULE; /** @@ -57,6 +64,7 @@ public class MaintenanceTaskSchedule implements StartProcessService { private final IImsDutyMainService dutyMainService; private final RedisTemplate redisTemplate; private final IEmInfoClient emInfoClient; + private final ICompensateProcessClient compensateProcessClient; @XxlJob(GENERATE_MAINTENANCE_TASK_SCHEDULE) public ReturnT execute(String param) throws Exception { @@ -173,10 +181,11 @@ public class MaintenanceTaskSchedule implements StartProcessService { */ private void startProcessInstance(OperMaintenanceTaskEntity task) { String s = saveEntity(JSONObject.toJSONString(task)); - startProcess(s,FlowKeyConstants.MAINTENANCE_TASK_FLOW_KEY,null); + startProcess(s, MAINTENANCE_TASK_FLOW_KEY,null); } @Override + //没有保存多张表,不单独开启事务 public String saveEntity(String entity) { return entity; } @@ -202,8 +211,13 @@ public class MaintenanceTaskSchedule implements StartProcessService { }); put("operMaintenanceTaskEntityVo",vo); }}; - R flowResult = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(task.getId()), task.getTitle(), params); - if (!flowResult.isSuccess()){ + if (StringUtils.isNotBlank(param)){ + params=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class); + } + String businessKey = FlowUtil.getBusinessKey("hzims_oper_maintenance_task", "" +task.getId()); + R flowResult = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(), dictValue, businessKey, task.getTitle(), params); +// R flowResult = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(task.getId()), task.getTitle(), params); + if (200!=flowResult.getCode()){ task.setIsNormal(false); task.setRemark(JSONObject.toJSONString(params)); taskService.updateById(task); @@ -213,14 +227,22 @@ public class MaintenanceTaskSchedule implements StartProcessService { r.setData(params); log.error(task.getId()+"日常维护任务启动流程失败{}", task); return r; + }else { + task.setIsNormal(true); + task.setProcessInstanceId(flowResult.getData().toString()); + taskService.updateById(task); } - String s = Optional.ofNullable(flowResult).filter(r -> r.isSuccess()).map(R::getData).map(BladeFlow::getProcessInstanceId).orElse(null); + String s = flowResult.getData().toString(); log.info(task.getId()+"日常维护任务启动成功{}", s); return R.success("启动流程成功"); } @Override public R compensationProcess(String id) { - return null; + OperMaintenanceTaskEntity operMaintenanceTaskEntity = taskService.getById(id); + if (ObjectUtils.isNotEmpty(operMaintenanceTaskEntity)){ + return this.startProcess(JSON.toJSONString(operMaintenanceTaskEntity), MAINTENANCE_TASK_FLOW_KEY,operMaintenanceTaskEntity.getRemark()); + } + return R.fail("找不到对应流程数据,请稍后重试!"); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java index 5c0b65e..a786d50 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.utils.DateUtil; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity; @@ -125,12 +126,17 @@ public class MaintenanceServiceImpl implements MaintenanceService { log.error("获取表单出现异常了~~~~"+response); throw new IllegalArgumentException(e.getMessage()); } + if(ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){ + handException(response); + return; + } OperMaintenanceTaskEntity entity = new OperMaintenanceTaskEntity(); BeanUtils.copyProperties(standardTicketInfoVo, entity); //1.查询日常维护信息 //有Id才进行生成操作 if (StringUtils.isNotBlank(response.getBusinessKey())) { - Long id = NumberUtils.toLong(response.getBusinessKey()); + String str = response.getBusinessKey().split(":")[1]; + Long id = NumberUtils.toLong(str); OperMaintenanceTaskEntity dbOperMaintenanceTaskEntity = taskService.getById(id); if (ObjectUtils.isEmpty(dbOperMaintenanceTaskEntity)) { log.error("获取日常维护数据不存在" + response); @@ -178,6 +184,28 @@ public class MaintenanceServiceImpl implements MaintenanceService { } } + private R handException(ProcessWorkFlowResponse response) { + String[] split = response.getBusinessKey().split(":"); + if (StringUtils.isBlank(split[1])){ + log.error("异常消息转换失败,未找到BusinessKey:"+ response); + return R.fail("异常消息处理失败"); + } + OperMaintenanceTaskEntity entity = taskService.getOne(new LambdaQueryWrapper() {{ + eq(OperMaintenanceTaskEntity::getId, split[1]); + }}); + entity.setIsNormal(false); + entity.setRemark(JSONObject.toJSONString(response.getVariables())); + entity.setFlowTaskName(response.getTaskName()); + entity.setProcessInstanceId(response.getTaskId()); + entity.setNextStepOperator(""); + boolean flag = taskService.updateById(entity); + if (!flag){ + log.info("异常状态消息保存失败"+ response); + return R.success("消息保存失败"); + } + return R.fail("消息保存成功"); + } + /** * 填充日常维护信息 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java index 8b73cb7..b750e71 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java @@ -225,10 +225,7 @@ public class StationVideoTypeController extends BladeController { } - @RequestMapping(value = "/getVideoReviewerToken", method = {RequestMethod.GET, RequestMethod.POST}) - public R getVideoReviewerToken() { - return R.data(stationVideoTypeService.getVideoReviewerToken()); - } + @GetMapping("/getVideoMonitorByAgency") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java index 619386a..cb79a30 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java @@ -48,11 +48,7 @@ public interface IStationVideoTypeService extends IService getVideoByIds(String ids,String randomCode); - /** - * 获取视频查看人员Token - * @return 视频查看人员Token - */ - String getVideoReviewerToken(); + /** * 获取海康威视各站点列表 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java index 61749bc..c2227e9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java @@ -58,8 +58,6 @@ public class StationVideoTypeServiceImpl extends ServiceImpl getHikVisionStations() { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/controller/DistributeWorkOrderController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/controller/DistributeWorkOrderController.java index 545f392..6e1b7a7 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/controller/DistributeWorkOrderController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/controller/DistributeWorkOrderController.java @@ -32,21 +32,8 @@ public class DistributeWorkOrderController { private final IOperAccessTaskService operAccessTaskService; private final IOperDefectService operDefectService; - @GetMapping("/testDistributeWorkOrder") - @ApiOperation(value = "检修工单派发",notes = "检修工单派发") - @ApiImplicitParam(name = "operAccessTaskEntity", value = "检修任务", paramType = "body", dataType = "OperAccessTaskEntity") - @ApiOperationSupport(order = 1) - public R distributeWorkOrder(@RequestBody OperAccessTaskEntity operAccessTaskEntity){ - return distributeWorkOrderService.distributeAccessTask(operAccessTaskEntity); - } - @GetMapping("/testDistributeDefect") - @ApiOperation(value = "消缺工单派发",notes = "消缺工单派发") - @ApiImplicitParam(name = "operAccessTaskEntity", value = "消缺对象", paramType = "query", dataType = "operDefectEntity") - @ApiOperationSupport(order = 2) - public R testDistributeDefect(@RequestBody OperDefectEntity operDefectEntity){ - return distributeWorkOrderService.distributeDefectTask(operDefectEntity); - } + @GetMapping("/getAccessWorkOrderList") @ApiOperation(value = "获取检修工单列表",notes = "获取检修工单列表") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/IDistributeWorkOrderService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/IDistributeWorkOrderService.java index 77e7955..07a2702 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/IDistributeWorkOrderService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/IDistributeWorkOrderService.java @@ -5,19 +5,8 @@ import com.hnac.hzims.operational.defect.entity.OperDefectEntity; import org.springblade.core.tool.api.R; @Deprecated public interface IDistributeWorkOrderService { - /** - * 派发检修任务 - * @param operAccessTaskEntity - * @return - */ - R distributeAccessTask(OperAccessTaskEntity operAccessTaskEntity); - /** - * 派发消缺任务 - * @param operDefectEntity - * @return - */ - R distributeDefectTask(OperDefectEntity operDefectEntity); + /** * 获取检修工单列表 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/impl/DistributeWorkOrderServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/impl/DistributeWorkOrderServiceImpl.java index 98f7dc6..7b2b594 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/impl/DistributeWorkOrderServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/workOrder/service/impl/DistributeWorkOrderServiceImpl.java @@ -51,11 +51,6 @@ public class DistributeWorkOrderServiceImpl implements IDistributeWorkOrderServi private final IOperPhenomenonService operPhenomenonService; private final RedisTemplate redisTemplate; - @Value("${url.water-out.orderCrtPackage}") - private String orderCrtPackageUrl; - - @Value("${url.water-out.orderCrtGrabPackage}") - private String orderCrtGrabPackageUrl; @Value("${hzims.operation.workOrder.access}") private String accessWorkOrderKey; @@ -63,152 +58,6 @@ public class DistributeWorkOrderServiceImpl implements IDistributeWorkOrderServi @Value("${hzims.operation.workOrder.defect}") private String defectWorkOrderKey; - @Override - public R distributeAccessTask(OperAccessTaskEntity operAccessTaskEntity){ - if(ObjectUtil.isEmpty(operAccessTaskEntity)){ - return R.fail("暂无检修记录!"); - } - OrderPackageDto orderPackageDto = new OrderPackageDto(); - orderPackageDto.setCreater(AuthUtil.getUser().getUserName()); - orderPackageDto.setFloatRange("1"); - orderPackageDto.setProjectCost(0); - /*结束时间需大于当前时间*/ - orderPackageDto.setFinishTime(DateUtil.format(LocalDateTime.now().plusHours(5),DateUtil.PATTERN_DATETIME)); - orderPackageDto.setProjectCode(operAccessTaskEntity.getId().toString()); - orderPackageDto.setProjectName(operAccessTaskEntity.getName()); - Publisher publisher = new Publisher(); - publisher.setId(operAccessTaskEntity.getCreateUser().toString()); - User user = UserCache.getUser(operAccessTaskEntity.getCreateUser()); - publisher.setContactAddress("123123"); - publisher.setContactName("123123"); - publisher.setContactPhone(user.getPhone()); - publisher.setPublisher(user.getRealName()); - publisher.setPublisherScale("123123"); - orderPackageDto.setPublisher(publisher); - SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - orderPackageDto.setStartTime(fmt.format(operAccessTaskEntity.getPlanStartTime())); - orderPackageDto.setWaterId(operAccessTaskEntity.getCreateDept().toString()); - //完善招标信息 - List tenderList = new ArrayList<>(); - TenderDto tenderDto = new TenderDto(); - //采用大修工单 - tenderDto.setOrderType("6"); - ZoneId zoneId = ZoneId.systemDefault(); - LocalDateTime planStartTime = LocalDateTime.ofInstant(operAccessTaskEntity.getPlanStartTime().toInstant(),zoneId); - LocalDateTime planEndTime = LocalDateTime.ofInstant(operAccessTaskEntity.getPlanEndTime().toInstant(),zoneId); - Long workHours = Duration.between(planStartTime,planEndTime).toHours(); - tenderDto.setWorkHours(workHours.intValue()); - tenderDto.setWorkPrice("0"); - //大修工单内容 - List overhaulOrderList = new ArrayList<>(); - OtherOrderDTO overHaulOrder = new OtherOrderDTO(); - overHaulOrder.setOrderType("6"); - overHaulOrder.setWorkCode(operAccessTaskEntity.getCode()); - overHaulOrder.setTenantId(operAccessTaskEntity.getTenantId()); - overHaulOrder.setWorkHour(workHours.intValue()); - overHaulOrder.setWorkName(operAccessTaskEntity.getName()); - EmInfoEntity emInfoEntity = emInfoClient.getByCode(operAccessTaskEntity.getEmCode()); - overHaulOrder.setWorkPos(Optional.ofNullable(emInfoEntity).map(EmInfoEntity::getName).orElse(null)); - overHaulOrder.setWorkTime(DateUtil.format(operAccessTaskEntity.getPlanStartTime(),DateUtil.PATTERN_DATETIME)); - overhaulOrderList.add(overHaulOrder); - tenderDto.setOverhaulOrderList(overhaulOrderList); - tenderList.add(tenderDto); - orderPackageDto.setTenderList(tenderList); - - log.info("-------------------------------------派发工单对象为-------------------------------------"); - log.info(JSON.toJSONString(orderPackageDto)); - HttpResponse httpResponse = HttpClientUtils.post(orderCrtPackageUrl, JSONObject.toJSONString(orderPackageDto)); - if(httpResponse.getCode() == 200){ - JSONObject jsonObject = JSONObject.parseObject(httpResponse.getData()); - try{ - String id = JSONObject.parseObject(jsonObject.getString("data")).getString("id"); - //将工单处理结果暂存入redis中 -// long maxSize = redisTemplate.opsForZSet().zCard(accessWorkOrderKey); -// redisTemplate.opsForZSet().add(accessWorkOrderKey,id, maxSize > 0 ? (maxSize - 1) : 0L); - } - catch (Exception e){ - e.printStackTrace(); - } - } - return R.data("调用成功!"); - } - - @Override - public R distributeDefectTask(OperDefectEntity operDefectEntity){ - if(ObjectUtil.isEmpty(operDefectEntity)){ - return R.fail("暂无消缺单记录!"); - } - GrabPackageDTO grabPackageDTO = new GrabPackageDTO(); - grabPackageDTO.setCreateUser(AuthUtil.getUser().getUserName()); - grabPackageDTO.setFinishTime(DateUtil.format(LocalDateTime.now().plusHours(8),DateUtil.PATTERN_DATETIME)); - List repairOrderAcptDtos = new ArrayList<>(); - RepairOrderAcptDto repairOrderAcptDto = new RepairOrderAcptDto(); - //完善工单内容 - if(StringUtil.isNotBlank(operDefectEntity.getDefectCode())){ - //根据现象、缺陷编码获取现象 - OperPhenomenonEntity operPhenomenonEntity = operPhenomenonService.getOne(new LambdaQueryWrapper(){{ - eq(OperPhenomenonEntity::getDefectCode,operDefectEntity.getDefectCode()); - }}.last("limit 1")); - if(ObjectUtil.isNotEmpty(operPhenomenonEntity)){ - if(StringUtil.isNotBlank(operPhenomenonEntity.getEmCode())){ - repairOrderAcptDto.setEquCode(operPhenomenonEntity.getEmCode()); - EmInfoEntity emInfoEntity = emInfoClient.getByCode(operPhenomenonEntity.getEmCode()); - repairOrderAcptDto.setEquName(Optional.ofNullable(emInfoEntity).map(EmInfoEntity::getName).orElse(null)); - } - if(StringUtil.isNotBlank(operPhenomenonEntity.getFaultCode())){ - List contentDTOList = new ArrayList<>(); - RepairOrderContentDTO repairOrderContentDTO = new RepairOrderContentDTO(); - repairOrderContentDTO.setFaultCode(operPhenomenonEntity.getFaultCode()); - repairOrderContentDTO.setFaultName(operPhenomenonEntity.getFaultName()); - contentDTOList.add(repairOrderContentDTO); - repairOrderAcptDto.setContentList(contentDTOList); - } - } - } - SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String startTime = Optional.ofNullable(operDefectEntity.getActStartTime()).map(time->fmt.format(time)).orElse(null); - repairOrderAcptDto.setStartTime(startTime); - R deptR = sysClient.getDept(operDefectEntity.getCreateDept()); - repairOrderAcptDto.setEquType("010101"); - repairOrderAcptDto.setOrgName("长沙敢胜院"); - repairOrderAcptDto.setCreateUser(operDefectEntity.getCreateUser().toString()); - repairOrderAcptDto.setTenantId(operDefectEntity.getTenantId()); - repairOrderAcptDto.setWorkTime(DateUtil.format(operDefectEntity.getActStartTime(),DateUtil.PATTERN_DATETIME)); - repairOrderAcptDto.setFaultDisp("捞渣、清渣装置故障"); - repairOrderAcptDto.setInstallPos("粗格栅间"); - repairOrderAcptDto.setIsBallot(0); - repairOrderAcptDto.setUserName(UserCache.getUser(operDefectEntity.getCreateUser()).getName()); - repairOrderAcptDto.setIsMajorRepairs("一般维修"); - repairOrderAcptDto.setRepairType("general_repair"); - repairOrderAcptDto.setSeverity("严重"); - repairOrderAcptDto.setSpecModel("GL1400"); - repairOrderAcptDto.setTimeLimit("6.00"); - repairOrderAcptDto.setWorkCode(operDefectEntity.getId().toString()); - repairOrderAcptDto.setWorkPrice(0); - repairOrderAcptDto.setWorkRatio(1); - repairOrderAcptDto.setWorkHour(4); - - List repairOrderPrognosisDTOS = new ArrayList<>(); - RepairOrderPrognosisDTO repairOrderPrognosisDTO = new RepairOrderPrognosisDTO(); - repairOrderPrognosisDTO.setCause("测试..."); - repairOrderPrognosisDTO.setDescribeContent("测试..."); - repairOrderPrognosisDTO.setProjectCode("test0000001"); - repairOrderPrognosisDTO.setProjectContent("测试...."); - repairOrderPrognosisDTO.setProjectName("测试..."); - repairOrderPrognosisDTO.setWorkHour("4.00"); - repairOrderPrognosisDTOS.add(repairOrderPrognosisDTO); - repairOrderAcptDto.setPrognosisList(repairOrderPrognosisDTOS); - - repairOrderAcptDtos.add(repairOrderAcptDto); - grabPackageDTO.setRepairOrderAcptDtos(repairOrderAcptDtos); - log.info("-------------------------------------派发消缺单对象为-------------------------------------"); - log.info(JSON.toJSONString(grabPackageDTO)); - HttpResponse httpResponse = HttpClientUtils.post(orderCrtGrabPackageUrl, JSONObject.toJSONString(grabPackageDTO)); - //将工单处理结果暂存入redis中 - long maxSize = redisTemplate.opsForZSet().zCard(defectWorkOrderKey); - //redisTemplate.opsForZSet().add(defectWorkOrderKey,"", maxSize > 0 ? (maxSize - 1) : 0L); - return R.data("调用成功!"); - } @Override public R getAccessWorkOrderList(){ diff --git a/hzims-service/operational/src/main/resources/db/3.0.1.sql b/hzims-service/operational/src/main/resources/db/3.0.1.sql index 0dc314e..9ec9561 100644 --- a/hzims-service/operational/src/main/resources/db/3.0.1.sql +++ b/hzims-service/operational/src/main/resources/db/3.0.1.sql @@ -1,5 +1,7 @@ ALTER TABLE `hzims_oper_phenomenon` MODIFY COLUMN `REMARK` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '冗余字段' ; +ALTER TABLE `hzims_oper_phenomenon` + ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ; ALTER TABLE `hz_ims_duty_rec` ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ; ALTER TABLE `hzims_oper_access_task` diff --git a/hzims-service/operational/src/main/resources/template/template.yml b/hzims-service/operational/src/main/resources/template/template.yml index a9364cc..abfef98 100644 --- a/hzims-service/operational/src/main/resources/template/template.yml +++ b/hzims-service/operational/src/main/resources/template/template.yml @@ -8,7 +8,7 @@ spring: autoconfigure: exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure datasource: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} @@ -162,20 +162,10 @@ blade: lock: enabled: true address: redis://${hzinfo.redis.ip}:${hzinfo.redis.hzinfo.redis.port} - password: + password: ${hzims.sdk.password} database: 0 ssl: false logging: level: com.hnac.hzinfo.inspect.task.feign.IInspectTaskClient: NONE - -url: - video: - stationsPath: http://localhost:10001/stations - monitorsPath: http://localhost:10001/monitor - login: https://175.6.40.67:9300/hzApi/auth/mix/login?tenantId=200000&account=videoViewers&pwd=e10adc3949ba59abbe56e057f20f883e&grant_type=password&scope=all&type=account - water-out: - #工单受理 - orderCrtPackage: http://175.6.40.67:9021/api/water-out/orderCrt/package - orderCrtGrabPackage: http://175.6.40.67:9021/api/water-out/orderCrt/grabPackage diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java index 513b05c..d9110cf 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/flow/service/impl/InnerDangerFlowServiceImpl.java @@ -13,7 +13,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.middle.process.feign.ICompensateProcessClient; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity; import com.hnac.hzims.safeproduct.dto.InnerDangerDTO; import com.hnac.hzims.safeproduct.entity.InnerDangerEntity; import com.hnac.hzims.safeproduct.flow.mapper.InnerDangerMapper; @@ -31,6 +33,7 @@ import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; +import org.springblade.flow.core.utils.FlowUtil; import org.springblade.message.dto.BusinessMessageDTO; import org.springblade.message.fegin.IMessageClient; import org.springblade.system.feign.ISysClient; @@ -61,6 +64,8 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl" + innerDangerEntity.getHiddenDangerName(); // 开启新的隐患处理流程 Map variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(innerDangerVo, DateUtil.PATTERN_DATETIME), Map.class); - R result = processClient.startProcessInstanceContainNameByKey(dictValue, innerDangerVo.getId().toString(), processName, variable); + R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(), + dictValue, FlowUtil.getBusinessKey("hzims_inner_danger_info", String.valueOf(innerDangerVo.getId())), + processName, variable); // 流程开启失败 - if (!result.isSuccess()) { + if (200!=result.getCode()) { innerDangerEntity.setIsNormal(false); innerDangerEntity.setRemark(JSONObject.toJSONString(variable)); - this.baseMapper.updateById(innerDangerVo); + this.baseMapper.updateById(innerDangerEntity); log.error("隐患处理流程开启失败,错误描述 : {}", result); R r=new R(); r.setCode(result.getCode()); @@ -146,19 +145,28 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl() {{ eq(InnerDangerEntity::getCode, hiddenDangerVo.getCode()); last("limit 1"); @@ -193,6 +204,21 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl getHiddenDangerBase(HiddenDangerBaseVo hiddenDangerBaseVo, Query query) { InnerDangerEntity innerDangerEntity = new InnerDangerEntity(); @@ -292,6 +318,7 @@ public class InnerDangerFlowServiceImpl extends ServiceImpl()); } + return iPage; } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardTaskServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardTaskServiceImpl.java index 7d05dfa..952f6cc 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardTaskServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardTaskServiceImpl.java @@ -3,6 +3,7 @@ package com.hnac.hzims.safeproduct.risk.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -159,7 +160,7 @@ public class HazardTaskServiceImpl extends ServiceImpl variables = (Map) processWorkFlowResponse.getVariables(); + //流程找不到下一个审批人处理 + if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){ + handException(processWorkFlowResponse); + log.info("风险排查流程补偿流程处理完毕"); + return false; + } // 对象转换 HazardRiskProcessDTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference(){}); try{ @@ -238,11 +245,7 @@ public class HazardTaskServiceImpl extends ServiceImpl() {{ + eq(HazardTask::getId, split[1]); + }}); + hazardTask.setIsNormal(false); + hazardTask.setProcessInstanceId(processWorkFlowResponse.getTaskId()); + hazardTask.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); + hazardTask.setProcessSteps(processWorkFlowResponse.getTaskName()); + hazardTask.setNextStepOperator(""); + this.baseMapper.updateById(hazardTask); + log.info("补偿流程消息转换结束"+ processWorkFlowResponse); + return R.success("补偿流程消息保存成功"); + } /** * 风险评估变量值流程穿插 * @param processWorkFlowResponse diff --git a/hzims-service/safeproduct/src/main/resources/template/template.yml b/hzims-service/safeproduct/src/main/resources/template/template.yml index 7088dda..c7db302 100644 --- a/hzims-service/safeproduct/src/main/resources/template/template.yml +++ b/hzims-service/safeproduct/src/main/resources/template/template.yml @@ -14,11 +14,11 @@ spring: primary: master datasource: master: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} slave: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java index 6302741..d3cfa36 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java @@ -2,13 +2,18 @@ package com.hnac.hzims.ticket.repair.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.common.constant.CommonConstant; import com.hnac.hzims.common.flow.StartProcessService; +import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.middle.process.feign.ICompensateProcessClient; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity; import com.hnac.hzims.ticket.repair.constants.WorkTaskConstants; import com.hnac.hzims.ticket.repair.entity.WorkTaskEntity; import com.hnac.hzims.ticket.repair.mapper.WorkTaskMapper; @@ -42,6 +47,8 @@ import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.support.TransactionTemplate; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -58,6 +65,8 @@ public class WorkTaskServiceImpl extends ServiceImpl variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(workTask, DateUtil.PATTERN_DATETIME), Map.class); + Map variables; + if (StringUtil.isNotBlank(param)) { + variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param, DateUtil.PATTERN_DATETIME), Map.class); + }else { + variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(workTask, DateUtil.PATTERN_DATETIME), Map.class); + } variables.put("head", TaskUtil.getTaskUser(String.valueOf(workTask.getHead()))); // 班组成员 String[] member = workTask.getMember().split(","); @@ -139,13 +157,16 @@ public class WorkTaskServiceImpl extends ServiceImpl result = flowClient.startProcessInstanceContainNameByKey(dictValue, FlowUtil.getBusinessKey("work_task_v4",String.valueOf(workTask.getId())), workTask.getCode(), variables); + R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(), + dictValue,FlowUtil.getBusinessKey("work_task_v4",String.valueOf(workTask.getId())) + , workTask.getCode(), variables); log.error("work_task_start_process_result :{}",result); // 更新任务流程Id - if (result.isSuccess()) { - BladeFlow flow = result.getData(); - workTask.setProcessInstanceId(flow.getProcessInstanceId()); + if (200==result.getCode()) { + workTask.setIsNormal(true); + workTask.setProcessInstanceId(result.getData().toString()); this.updateById(workTask); + return R.success("启动流程成功"); } else { workTask.setIsNormal(false); workTask.setRemark(JSONObject.toJSONString(variables)); @@ -156,7 +177,6 @@ public class WorkTaskServiceImpl extends ServiceImpl variables = (Map) processWorkFlowResponse.getVariables(); + if(ObjectUtils.isNotEmpty(processWorkFlowResponse.getCode())&&700==processWorkFlowResponse.getCode()){ + handException(processWorkFlowResponse); + return false; + } log.error("work_task_listener_variables : {}",variables); Object head = variables.get("head"); if(ObjectUtil.isNotEmpty(head)){ @@ -176,6 +200,7 @@ public class WorkTaskServiceImpl extends ServiceImpl(){}); // 当前流程名称 entity.setTaskName(processWorkFlowResponse.getTaskName()); + entity.setIsNormal(true); // 流程阶段执行人员名称 entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator()); entity.setHeadHandleTime(new Date()); @@ -198,6 +223,21 @@ public class WorkTaskServiceImpl extends ServiceImpl { //3. 保存操作对象 StandardTicketInfoEntity standardTicketInfo = getStandardTicketInfoEntity(standardTicketInfoVo); standardTicketInfo.setStatus(1); @@ -167,6 +179,8 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star standardTicketInfoVo.setStandardTicketMeasureVos(standardTicketInfoVos); log.info("保存操作对象 :{}", standardTicketInfoVo); return JSON.toJSONString(standardTicketInfoVo); + }); + return res; } @@ -175,20 +189,23 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star public R startProcess(String entity, String dictValue,String param) { StandardTicketInfoVo standardTicketInfoVo= JSONObject.parseObject(entity, StandardTicketInfoVo.class); StandardTicketInfoEntity standardTicketInfoEntity = getStandardTicketInfoEntity(standardTicketInfoVo); - Instant start = Instant.now(); Map params = new HashMap<>(4); params.put("standardTicketInfoVo", standardTicketInfoVo); params.put("taskId", standardTicketInfoVo.getId()); if (ObjectUtils.isNotEmpty(standardTicketInfoVo.getGuardian())) { params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString())); } + if (StringUtils.isNotBlank(param)){ + params=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param, DateUtil.PATTERN_DATETIME), Map.class); + } //已开启流程 - R processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(standardTicketInfoVo.getId()), - standardTicketInfoVo.getTitle(), params); - if (!processInstanceContainNameByKey.isSuccess()) { + R processInstanceContainNameByKey = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(), + dictValue, FlowUtil.getBusinessKey("hzims_standard_ticket_info", + String.valueOf(standardTicketInfoVo.getId())),standardTicketInfoVo.getTitle(), params); + if (200!=processInstanceContainNameByKey.getCode()) { standardTicketInfoEntity.setIsNormal(false); standardTicketInfoEntity.setRemarkFlow(JSONObject.toJSONString(params)); - standardTicketInfoService.save(standardTicketInfoEntity); + standardTicketInfoService.updateById(standardTicketInfoEntity); R r=new R(); r.setCode(processInstanceContainNameByKey.getCode()); r.setMsg(processInstanceContainNameByKey.getMsg()); @@ -196,17 +213,21 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star log.error("开启流程失败 {}", processInstanceContainNameByKey.getMsg()); return r; } - Duration between = Duration.between(start, Instant.now()); - log.info("================================================================"); - log.info("耗时: " + (between.getSeconds()) + "秒"); - log.info("耗时: " + (between.toMillis()) + "毫秒"); - log.info("================================================================"); + standardTicketInfoEntity.setProcessInstanceId(processInstanceContainNameByKey.getData().toString()); + standardTicketInfoEntity.setIsNormal(true); + standardTicketInfoService.updateById(standardTicketInfoEntity); return R.success("启动流程成功"); } @Override public R compensationProcess(String id) { - return null; + //查询流程对应value + String dictValue = processDictFeignService.selectDictValueByKey(OPERATION_TICKET_KEY); + StandardTicketInfoEntity entity = standardTicketInfoService.getById(id); + if (ObjectUtils.isNotEmpty(entity)){ + return this.startProcess(JSON.toJSONString(entity), dictValue,entity.getRemark()); + } + return R.fail("找不到对应流程数据,请稍后重试!"); } /** @@ -227,6 +248,10 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star String formData = JSON.toJSONString(response.getVariables()); log.info("获取表单的数据:{}", formData); StandardTicketInfoVo standardTicketInfoVo = null; + if(ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){ + handException(response); + return ; + } try { JSONObject jsonObject = JSONObject.parseObject(formData); // standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, StandardTicketInfoVo.class); @@ -238,6 +263,7 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star e.printStackTrace(); throw new IllegalArgumentException(e.getMessage()); } + //1.查询操作票信息 Long id = NumberUtils.toLong(response.getBusinessKey()); StandardTicketInfoEntity standardTicketInfoEntity = standardTicketInfoService.getById(id); @@ -310,6 +336,27 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star } } + private R handException(ProcessWorkFlowResponse processWorkFlowResponse) { + String[] split = processWorkFlowResponse.getBusinessKey().split(":"); + if (StringUtils.isBlank(split[1])){ + log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse); + return R.fail("异常消息处理失败"); + } + StandardTicketInfoEntity entity = standardTicketInfoService.getOne(new LambdaQueryWrapper() {{ + eq(StandardTicketInfoEntity::getId, split[1]); + }}); + entity.setIsNormal(false); + entity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); + entity.setTaskName(processWorkFlowResponse.getTaskName()); + entity.setProcessInstanceId(processWorkFlowResponse.getTaskId()); + entity.setNextStepOperator(""); + boolean flag = standardTicketInfoService.updateById(entity); + if (!flag){ + log.info("异常状态消息保存失败"+ processWorkFlowResponse); + return R.success("消息保存失败"); + } + return R.fail("消息保存成功"); + } /** * 填充数据 diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java index 994bd28..c875b77 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java @@ -3,13 +3,16 @@ package com.hnac.hzims.ticket.twoTicket.service.impl; import cn.afterturn.easypoi.word.WordExportUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.hnac.hzims.common.flow.StartProcessService; import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.middle.process.feign.ICompensateProcessClient; import com.hnac.hzims.middle.process.feign.ProcessDictFeignService; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient; import com.hnac.hzims.operational.feign.IAccessTaskClient; @@ -51,6 +54,7 @@ import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; +import org.springblade.flow.core.utils.FlowUtil; import org.springblade.message.MessageConstants; import org.springblade.message.dto.BusinessMessageDTO; import org.springblade.message.fegin.IMessageClient; @@ -60,7 +64,9 @@ import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionTemplate; import org.springframework.util.Assert; import javax.servlet.ServletOutputStream; @@ -140,6 +146,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc @Value("${hzims.ticket.path.word.templatePath}") private String templatePath; + private final ICompensateProcessClient compensateProcessClient; private final TicketInfoDangerService ticketInfoDangerService; @@ -162,7 +169,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc */ // @SneakyThrows @Override - @Transactional +// @Transactional public R startUp(WorkTicketVo workTicketVo) { log.info("ticket:start:request",JSON.toJSONString(workTicketVo)); log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法"); @@ -179,7 +186,8 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc R r = this.startProcess(saveEntity, dictValue,""); return r; } - + private final PlatformTransactionManager transactionManager; + private final TransactionTemplate transactionTemplate; @Override public String saveEntity(String entity) { WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class); @@ -208,7 +216,6 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc throw new ServiceException("票据抬头未配置,请您到站点管理配置"); } //signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2); - workTicketVo.getWorkTicket().setSignage(station.getSignage()); workTicketVo.getWorkTicket().setSignageCode(station.getCode()); //2. 获取编码 @@ -217,6 +224,8 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc if (StringUtils.isBlank(code)) { throw new ServiceException("服务器异常,请联系管理员"); } + transactionTemplate.setTransactionManager(transactionManager); + String res = transactionTemplate.execute(status -> { workTicketVo.getWorkTicket().setCode(code); //保存工作对象 log.info("ticket:start:vo",JSON.toJSONString(workTicketVo.getWorkTicket())); @@ -231,6 +240,8 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc //保存工作任务 this.saveWorkTicketContentDto(workTicketVo.getWorkTicketContentDtoList(), workTicketVo.getWorkTicket()); return JSONObject.toJSONString(workTicketVo); + }); + return res; } @@ -245,7 +256,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) { return R.success("线下流程,开票成功"); } - Map params = new HashMap<>(4); + Map params = new HashMap<>(); params.put("workTicketVo", workTicketVo); //获取当前登录人 Long userId = AuthUtil.getUserId(); @@ -255,7 +266,10 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc params.put("principal", "taskUser_" + workTicketVo.getWorkTicket().getPrincipal()); } //已开启流程 - R processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(workTicketVo.getWorkTicket().getId()), workTicketVo.getWorkTicket().getWorkContent(), params); + R processInstanceContainNameByKey = compensateProcessClient.startFlow( + AuthUtil.getUserId().toString(),dictValue, + FlowUtil.getBusinessKey("hzims_work_ticket_info",String.valueOf(workTicketVo.getWorkTicket().getId())), + workTicketVo.getWorkTicket().getWorkContent(),params); log.info("processInstanceContainNameByKey.isSuccess() : {}", processInstanceContainNameByKey.isSuccess()); if (!processInstanceContainNameByKey.isSuccess()) { //保存流程开始失败情况 @@ -272,20 +286,24 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc r.setMsg("流程开启失败,请检查流程和用户权限后重试!"); r.setData(params); return r; + }else { + workTicket.setProcessInstanceId(processInstanceContainNameByKey.getData().toString()); + workTicket.setIsNormal(true); + firstWorkTicketService.updateById(workTicket); + return R.success("启动流程成功"); } - log.info("获取启动流程数据 : {}", processInstanceContainNameByKey); - Duration between = Duration.between(start, Instant.now()); - - log.info("================================================================"); - log.info("耗时: " + (between.getSeconds()) + "秒"); - log.info("耗时: " + (between.toMillis()) + "毫秒"); - log.info("================================================================"); - return R.success("启动流程成功"); } @Override public R compensationProcess(String id) { - return null; + WorkTicketInfoEntity entity = firstWorkTicketService.getById(id); + if (ObjectUtils.isNotEmpty(entity)){ + WorkTicketVo workTicketVo = new WorkTicketVo(); + workTicketVo.setWorkTicket(entity); + String dictValue = getDictValue(workTicketVo); + return this.startProcess(JSON.toJSONString(entity), dictValue,entity.getRemark()); + } + return R.fail("找不到对应流程数据,请稍后重试!"); } /** @@ -321,7 +339,6 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc @Override @Transactional(rollbackFor = Exception.class) public void findPending(ProcessWorkFlowResponse response) { - try { log.info("获取待处理的数据 {}", response); log.info("获取businessKey: {}", response.getBusinessKey()); @@ -332,6 +349,10 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType()); //json转换表单 String formData = JSON.toJSONString(response.getVariables()); + if(ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){ + handException(response); + return ; + } log.info("获取表单的数据:{}", formData); FristWorkTicketVo fristWorkFlowResponse = null; try { @@ -343,6 +364,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc //获取表单数据 WorkTicketVo workTicketVo = fristWorkFlowResponse.getWorkTicketVo(); WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); + workTicket.setIsNormal(true); //2.流程处理 String businessKey = response.getBusinessKey(); WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey); @@ -503,10 +525,33 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc } } catch (Exception e) { e.printStackTrace(); + log.error("工作票流转失败,失败原因:{}",e); } } + private R handException(ProcessWorkFlowResponse processWorkFlowResponse) { + String[] split = processWorkFlowResponse.getBusinessKey().split(":"); + if (StringUtils.isBlank(split[1])){ + log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse); + return R.fail("异常消息处理失败"); + } + WorkTicketInfoEntity workTicketInfoEntity = ticketInfoService.getOne(new LambdaQueryWrapper() {{ + eq(WorkTicketInfoEntity::getId, split[1]); + }}); + workTicketInfoEntity.setIsNormal(false); + workTicketInfoEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); + workTicketInfoEntity.setTaskName(processWorkFlowResponse.getTaskName()); + workTicketInfoEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId()); + workTicketInfoEntity.setNextStepOperator(""); + boolean flag = ticketInfoService.updateById(workTicketInfoEntity); + if (!flag){ + log.info("异常状态消息保存失败"+ processWorkFlowResponse); + return R.success("消息保存失败"); + } + return R.fail("消息保存成功"); + } + @Override public Boolean offlineTicketFindPending(ProcessWorkFlowResponse response) { log.info("线下工作票接收到的工作票数据为:{}",JSON.toJSONString(response)); @@ -515,6 +560,10 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc log.error("接收到的数据为:{}",JSON.toJSONString(response.getVariables())); throw new ServiceException("线下工作票处理流程环节接收数据失败,请联系管理员"); }); + if(ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){ + handException(response); + return false; + } WorkTicketVo workTicketVo = ticketResponse.getWorkTicketVo(); WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); WorkTicketInfoEntity info = firstWorkTicketService.getById(workTicket.getId()); diff --git a/hzims-service/ticket/src/main/resources/db/3.0.0.sql b/hzims-service/ticket/src/main/resources/db/3.0.0.sql index 983e8e9..f4ac06d 100644 --- a/hzims-service/ticket/src/main/resources/db/3.0.0.sql +++ b/hzims-service/ticket/src/main/resources/db/3.0.0.sql @@ -2,11 +2,15 @@ ALTER TABLE `hzims_standard_ticket_info` ADD COLUMN `remark_flow` text NULL ; ALTER TABLE `hzims_work_ticket_info` ADD COLUMN `remark` text NULL ; +ALTER TABLE `hzims_work_task` + ADD COLUMN `remark` text NULL ; ALTER TABLE `hzims_standard_ticket_info` ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ; ALTER TABLE `hzims_work_ticket_info` ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ; +ALTER TABLE `hzims_work_task` + ADD COLUMN `is_normal` tinyint(2) NULL DEFAULT 1 ; ALTER TABLE `hzims_standard_ticket_info` ADD COLUMN `em_code` varchar(255) NULL COMMENT '设备编号' , diff --git a/hzims-service/ticket/src/main/resources/template/template.yml b/hzims-service/ticket/src/main/resources/template/template.yml index 68ab4d5..b50348e 100644 --- a/hzims-service/ticket/src/main/resources/template/template.yml +++ b/hzims-service/ticket/src/main/resources/template/template.yml @@ -8,7 +8,7 @@ spring: autoconfigure: exclude: com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DruidDataSourceAutoConfigure datasource: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/prod_hzims_ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} diff --git a/hzims-service/weather/src/main/resources/template/template.yml b/hzims-service/weather/src/main/resources/template/template.yml index 04c3cb4..a7d604f 100644 --- a/hzims-service/weather/src/main/resources/template/template.yml +++ b/hzims-service/weather/src/main/resources/template/template.yml @@ -8,7 +8,7 @@ spring: autoconfigure: exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure datasource: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/test_hzims_weather?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true + url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims_weather?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password}