From 1052a8afdecf9dfd9688ff6287292b0a013b7f7c Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 26 Jun 2023 15:43:20 +0800 Subject: [PATCH 1/3] =?UTF-8?q?#=E6=A3=80=E4=BF=AE=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../access/entity/OperAccessTaskEntity.java | 6 ++++ .../serviceimpl/OverhaulPlanServiceImpl.java | 2 -- .../access/controller/AccessTaskV4Controller.java | 19 ++++++++++++ .../access/controller/AccessV4Controller.java | 19 ------------ .../access/dto/OperAccessTaskDetailDTO.java | 3 +- .../service/impl/AccessPlanV4ServiceImpl.java | 6 ++-- .../service/impl/AccessTaskV4ServiceImpl.java | 35 ++++++++++++++++------ .../controller/DangerSourceController.java | 12 ++++++++ .../safeproduct/service/IDangerSourceService.java | 2 ++ .../service/impl/DangerSourceServiceImpl.java | 22 +++++++++++--- 10 files changed, 87 insertions(+), 39 deletions(-) create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessTaskV4Controller.java delete mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessV4Controller.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java index 374114b..bbeb2a7 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java @@ -160,4 +160,10 @@ public class OperAccessTaskEntity extends TenantEntity { private YearMonth yearMonth; + @ApiModelProperty("当前步骤任务名称") + private String taskName; + + @ApiModelProperty("当前环节处理人") + private String nextStepOperator; + } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java index 8d52efb..57bc9e2 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java @@ -5,14 +5,12 @@ import com.hnac.hzims.middle.processflow.service.ProcessDictService; import com.hnac.hzims.middle.processflow.strategy.abstracts.ProcessAbstractService; import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue; import com.hnac.hzims.operational.access.feign.IAccessPlanV4Client; -import com.hnac.hzims.operational.defect.feign.IOperDefectClient; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; import org.springframework.stereotype.Service; -import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.DEFECT_KEY; import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.OVERHAUL_PLAN; /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessTaskV4Controller.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessTaskV4Controller.java new file mode 100644 index 0000000..42b738f --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessTaskV4Controller.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.operational.access.controller; + +import io.swagger.annotations.Api; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * @author ysj + */ +@RestController +@AllArgsConstructor +@RequestMapping("/overhaul_task") +@Api(tags = "v4检修计划流程") +public class AccessTaskV4Controller extends BladeController { + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessV4Controller.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessV4Controller.java deleted file mode 100644 index 6dbfc08..0000000 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessV4Controller.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.hnac.hzims.operational.access.controller; - -import io.swagger.annotations.Api; -import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - - -/** - * @author ysj - */ -@RestController -@AllArgsConstructor -@RequestMapping("/overhaul_task") -@Api(tags = "v4检修计划流程") -public class AccessV4Controller extends BladeController { - -} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessTaskDetailDTO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessTaskDetailDTO.java index 21fa509..b49684e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessTaskDetailDTO.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessTaskDetailDTO.java @@ -1,9 +1,8 @@ package com.hnac.hzims.operational.access.dto; -import io.swagger.annotations.ApiModelProperty; +import com.hnac.hzims.operational.access.entity.OperAccessTaskDetailEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import com.hnac.hzims.operational.access.entity.OperAccessTaskDetailEntity; /** * 模型DTO 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 8158577..269b491 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 @@ -1,6 +1,5 @@ package com.hnac.hzims.operational.access.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; @@ -179,12 +178,12 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ entity.setTaskName("流程结束"); entity.setNextStepOperator("流程结束,无需人员处理"); entity.setActEndTime(new Date()); - // 开启检修任务 - this.startTaskProcess(entity); } this.planService.updateById(entity); this.saveAccessMaterial(entity); this.saveAccessContent(entity); + // 开启检修任务 + this.startTaskProcess(entity); return true; } @@ -196,6 +195,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ for(OperAccessContentDTO item : entity.getAccessContents()){ //任务参数 AccessTaskV4DTO task = BeanUtil.copy(item, AccessTaskV4DTO.class); + task.setId(null); task.setCreateTime(new Date()); task.setCreateUser(entity.getCreateUser()); task.setProcDefId(entity.getProcDefId()); 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 111f711..47af7e6 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 @@ -2,6 +2,7 @@ package com.hnac.hzims.operational.access.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.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO; @@ -29,10 +30,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.text.DecimalFormat; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -78,8 +76,8 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { * @param entity */ private void startProcess(AccessTaskV4DTO entity) { - Map variables = JSONObject.parseObject(JSONObject.toJSONString(entity), Map.class); - variables.put("handler",TaskUtil.getTaskUser(entity.getHandler().toString())); + Map variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class); + variables.put("solve",TaskUtil.getTaskUser(entity.getHandler().toString())); R result = flowClient.startProcessInstanceContainNameByKey("overhaul_task", FlowUtil.getBusinessKey("access_task_v4", String.valueOf(entity.getId())), entity.getName(),variables); // 更新任务流程Id if (result.isSuccess()) { @@ -110,8 +108,8 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { return; } materialService.saveOrUpdateBatch(entity.getAccessMaterials().stream().peek(material -> { - material.setPlanId(null); material.setId(null); + material.setPlanId(entity.getPlanId()); material.setTaskId(entity.getId()); }).collect(Collectors.toList())); } @@ -154,7 +152,26 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { */ @Override public boolean listener(ProcessWorkFlowResponse processWorkFlowResponse) { - - return false; + // 对象转换 + Map variables = (Map) processWorkFlowResponse.getVariables(); + AccessTaskV4DTO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference(){}); + // 当前流程名称 + entity.setTaskName(processWorkFlowResponse.getTaskName()); + // 流程阶段执行人员名称 + entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator()); + if(ObjectUtil.isNotEmpty(variables.get("examine")) && (Boolean) variables.get("examine")){ + entity.setTaskName("流程结束"); + entity.setNextStepOperator("流程结束,无需人员处理"); + entity.setActEndTime(new Date()); + // 更新任务数据 + this.taskService.updateById(entity); + }else if(ObjectUtil.isNotEmpty(variables.get("examine")) && !(Boolean) variables.get("examine")){ + return this.taskService.updateById(entity); + } + // 保存检修材料 + this.saveMaterial(entity); + // 保存检修详情 + this.saveDetails(entity); + return true; } } \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DangerSourceController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DangerSourceController.java index 81f5068..994a819 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DangerSourceController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/DangerSourceController.java @@ -21,6 +21,8 @@ import org.springblade.core.tool.utils.Func; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import java.util.List; + /** * @author xiashandong @@ -89,6 +91,16 @@ public class DangerSourceController extends BladeController { } /** + * 根据ID查询危险源 + */ + @GetMapping("/safes") + @ApiOperationSupport(order = 60) + @ApiOperation(value = "查询危险源", notes = "传入safeInfos") + public R> safes(@RequestParam String safeInfos) { + return R.data(dangerSourceService.safes(safeInfos)); + } + + /** * 导入数据 */ @ApiOperation(value = "导入Excel") diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDangerSourceService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDangerSourceService.java index 7988c81..1676f9a 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDangerSourceService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IDangerSourceService.java @@ -39,4 +39,6 @@ public interface IDangerSourceService extends BaseService { List listByTenantId(String tenantId); List getSafeCreateTable(List tableNames); + + List safes(String safeInfos); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DangerSourceServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DangerSourceServiceImpl.java index d0df057..ce55832 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DangerSourceServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/DangerSourceServiceImpl.java @@ -31,6 +31,7 @@ import com.hnac.hzims.safeproduct.wrapper.DangerSourceWrapper; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang.ArrayUtils; import org.springblade.core.excel.support.ExcelException; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; @@ -46,17 +47,16 @@ import org.springblade.system.vo.CreateTableVO; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.multipart.MultipartFile; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; /** * @author xiashandong @@ -308,6 +308,20 @@ public class DangerSourceServiceImpl extends BaseServiceImpl safes(String safeInfos) { + if(StringUtil.isEmpty(safeInfos)){ + return new ArrayList<>(); + } + List sources = this.listByIds(Arrays.asList(safeInfos.split(","))); + //未查到数据返回空集合 + if (CollectionUtils.isEmpty(sources)) { + return new ArrayList<>(); + } + //查到数据则将数据排序后再返回 + return sources.stream().sorted(Comparator.comparing(DangerSourceEntity::getId)).collect(Collectors.toList()); + } + + @Override public List listByTenantId(String tenantId) { return this.baseMapper.listByTenantId(tenantId); } From 3035302f2b168995cf3be2589f2764c27d4152c1 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 26 Jun 2023 15:54:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?#=E6=A3=80=E4=BF=AE=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/operational/access/service/AccessTaskV4Service.java | 2 +- .../hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java index 409624b..db8abb2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessTaskV4Service.java @@ -8,7 +8,7 @@ import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO; */ public interface AccessTaskV4Service { - boolean startProcessV4(AccessTaskV4DTO entity); + void startProcessV4(AccessTaskV4DTO entity); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); } \ No newline at end of file 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 47af7e6..31351e4 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 @@ -56,7 +56,7 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { */ @Override @Transactional(rollbackFor = Exception.class) - public boolean startProcessV4(AccessTaskV4DTO entity) { + public void startProcessV4(AccessTaskV4DTO entity) { // 步骤1.保存检修任务 this.save(entity); @@ -68,7 +68,6 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { // 步骤4.开启检修任务流程 this.startProcess(entity); - return true; } /** From da7707ead3db27fbc7acd87eb0e0d00d14737d9a Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 26 Jun 2023 17:06:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?#=E6=A3=80=E4=BF=AE=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/message/MessageConstants.java | 5 ++ .../service/impl/AccessPlanV4ServiceImpl.java | 55 ++++++++++++++++++++-- .../service/impl/AccessTaskV4ServiceImpl.java | 53 ++++++++++++++++++++- 3 files changed, 108 insertions(+), 5 deletions(-) diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java index 9960a32..abe695b 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java @@ -52,10 +52,15 @@ public class MessageConstants { DUTY("duty","值班消息"), SAFE("safe","安全消息"), ACCESS("access","检修消息"), + BUSINESS("business","事务消息"), TICKETMESSAGE("ticket-message","工作票消息"), OPERATIONTICKETMESSAGE("operation-ticket-message","操作票消息"), ROUTINEMAINTENANCE("operation-maintenance-message","日常维护消息"), OPERATIONDEFECTMESSAGE("operation-defect-message","消缺消息"), + + OVERHAUL_PLAN("overhaul-plan","检修计划"), + + OVERHAUL_TASK("overhaul-task","检修任务"), ; @Getter private String key; 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 269b491..a7a13e0 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 @@ -3,6 +3,9 @@ package com.hnac.hzims.operational.access.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.BusinessMessageDTO; +import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.operational.access.dto.*; import com.hnac.hzims.operational.access.entity.OperAccessContentEntity; @@ -22,6 +25,9 @@ import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.utils.TaskUtil; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -46,8 +52,14 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ private final AccessTaskV4Service accessTaskV4Service; + private final ISysClient sysClient; + private final IFlowClient flowClient; + private final IUserClient userClient; + + private final IMessageClient messageClient; + /** * 开启检修计划流程 * @param entity @@ -178,12 +190,21 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ entity.setTaskName("流程结束"); entity.setNextStepOperator("流程结束,无需人员处理"); entity.setActEndTime(new Date()); + return this.planService.updateById(entity); + // 审核不通过 + } else if(ObjectUtil.isNotEmpty(variables.get("examine")) && !(Boolean) variables.get("examine")){ + String content = "您有一条检修计划待调整!检修计划名称:".concat(entity.getName()) + .concat(",当前环节:") + .concat(processWorkFlowResponse.getTaskName()); + this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); + return this.planService.updateById(entity); } - this.planService.updateById(entity); this.saveAccessMaterial(entity); this.saveAccessContent(entity); - // 开启检修任务 - this.startTaskProcess(entity); + String content = "您有一条检修计划待审批!检修计划名称:".concat(entity.getName()) + .concat(",当前环节:") + .concat(processWorkFlowResponse.getTaskName()); + this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); return true; } @@ -220,4 +241,32 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ accessTaskV4Service.startProcessV4(task); } } + + /** + * 推送业务流程消息 + * @param entity + * @param userId + * @param content + */ + private void sendMessage(AccessPlanV4DTO entity, String userId, String content) { + BusinessMessageDTO message = new BusinessMessageDTO(); + // 计划Id + message.setTaskId(entity.getId()); + message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OVERHAUL_PLAN.getKey()); + // 主题 + message.setSubject(MessageConstants.BusinessClassifyEnum.OVERHAUL_PLAN.getDescription()); + message.setDeptId(entity.getCreateDept()); + R result = sysClient.getDeptName(entity.getCreateDept()); + if (result.isSuccess()) { + message.setDeptName(result.getData()); + } + // 内容 + message.setContent(content); + message.setTenantId("200000"); + User admin = userClient.userByAccount("200000", "admin").getData(); + message.setCreateUser(admin.getId()); + message.setUserIds(userId); + messageClient.sendAppAndWsMsgByUsers(message); + } } \ No newline at end of file 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 31351e4..89cef1c 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 @@ -4,7 +4,11 @@ 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.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.BusinessMessageDTO; +import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.dto.AccessPlanV4DTO; import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO; import com.hnac.hzims.operational.access.dto.OperAccessTaskDetailDTO; import com.hnac.hzims.operational.access.entity.OperAccessMaterialEntity; @@ -25,6 +29,9 @@ import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.utils.TaskUtil; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -47,8 +54,14 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { private final IOperAccessTaskDetailService detailService; + private final ISysClient sysClient; + private final IFlowClient flowClient; + private final IUserClient userClient; + + private final IMessageClient messageClient; + /** * 开启检修任务流程 * @param entity @@ -161,16 +174,52 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { if(ObjectUtil.isNotEmpty(variables.get("examine")) && (Boolean) variables.get("examine")){ entity.setTaskName("流程结束"); entity.setNextStepOperator("流程结束,无需人员处理"); - entity.setActEndTime(new Date()); // 更新任务数据 this.taskService.updateById(entity); - }else if(ObjectUtil.isNotEmpty(variables.get("examine")) && !(Boolean) variables.get("examine")){ + }else if(ObjectUtil.isEmpty(variables.get("examine")) && !(Boolean) variables.get("examine")){ + String content = "您有一条检修任务待处理!检修任务名称:".concat(entity.getName()) + .concat(",当前环节:") + .concat(processWorkFlowResponse.getTaskName()); + this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); return this.taskService.updateById(entity); } // 保存检修材料 this.saveMaterial(entity); // 保存检修详情 this.saveDetails(entity); + // 发送消息 + String content = "您有一条检修任务待审批!检修任务名称:".concat(entity.getName()) + .concat(",当前环节:") + .concat(processWorkFlowResponse.getTaskName()); + this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); return true; } + + /** + * 推送业务流程消息 + * @param entity + * @param userId + * @param content + */ + private void sendMessage(AccessTaskV4DTO entity, String userId, String content) { + BusinessMessageDTO message = new BusinessMessageDTO(); + // 计划Id + message.setTaskId(entity.getId()); + message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OVERHAUL_TASK.getKey()); + // 主题 + message.setSubject(MessageConstants.BusinessClassifyEnum.OVERHAUL_TASK.getDescription()); + message.setDeptId(entity.getCreateDept()); + R result = sysClient.getDeptName(entity.getCreateDept()); + if (result.isSuccess()) { + message.setDeptName(result.getData()); + } + // 内容 + message.setContent(content); + message.setTenantId("200000"); + User admin = userClient.userByAccount("200000", "admin").getData(); + message.setCreateUser(admin.getId()); + message.setUserIds(userId); + messageClient.sendAppAndWsMsgByUsers(message); + } } \ No newline at end of file