From 064e6fbb965a95b0c780267575156313d6fd76e8 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 15 Mar 2024 08:48:23 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=A3=80=E4=BF=AEbug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/monitor/listener/AlarmListener.java | 2 +- .../source/service/impl/MessageServiceImpl.java | 21 ++++++++-------- .../access/controller/AccessTaskV4Controller.java | 19 ++++++++++++++ .../access/mapper/OperAccessTaskMapper.java | 2 ++ .../access/mapper/OperAccessTaskMapper.xml | 16 ++++++++++++ .../access/service/AccessTaskV4Service.java | 7 ++++++ .../service/impl/AccessPlanV4ServiceImpl.java | 9 +++++++ .../service/impl/AccessTaskV4ServiceImpl.java | 29 ++++++++++++++++++++-- .../operational/access/vo/MyAccessTaskVO.java | 20 +++++++++++++++ 9 files changed, 112 insertions(+), 13 deletions(-) create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/vo/MyAccessTaskVO.java diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java index daedb3f..e48bf9a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java @@ -45,7 +45,7 @@ public class AlarmListener implements IQueueConsume { // 步骤4.微信公众号发送 if(alarm.getIsWxMessage() == 0){ - messageService.weChatMessage(alarm); + //messageService.weChatMessage(alarm); } } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java index 124ccc4..1dd637b 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java @@ -60,13 +60,14 @@ public class MessageServiceImpl implements MessageService { @Override public void shortMessage(AlarmEntity entity) { R station = stationClient.getStationByCode(entity.getStationId()); - if (!station.isSuccess() && ObjectUtils.isEmpty(station.getData())) { + if (!station.isSuccess() || ObjectUtils.isEmpty(station.getData())) { log.error("消息发送失败:站点code获取失败 : {}",entity); return; } //通知站点项目经理这个角色 List users = userClient.relationUserListByRoleAlias(station.getData().getTenantId(), station.getData().getRefDept(), PROJECT_MANAGER).getData(); if(CollectionUtil.isEmpty(users)){ + log.error("消息发送失败:获取站点项目经理用户失败 : {}",entity); return; } SmsImmediatelyPushDTO push = SmsImmediatelyPushDTO.builder() @@ -98,14 +99,14 @@ public class MessageServiceImpl implements MessageService { public void webAppMessage(AlarmEntity entity) { R stationByCode = stationClient.getStationByCode(entity.getStationId()); if (!stationByCode.isSuccess() && ObjectUtils.isEmpty(stationByCode.getData())) { - log.error("消息发送失败:站点code获取失败 : {}",entity); + log.error("WEB/APP消息发送失败:站点code获取失败 : {}",entity); return; } - Long dept = stationByCode.getData().getCreateDept(); + Long dept = stationByCode.getData().getRefDept(); // 获取站点用户 - R> result = userClient.userListByDeptId(dept); + R> result = userClient.userList(stationByCode.getData().getTenantId(),dept); if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { - log.error("消息发送失败:用户获取失败 : {}",entity); + log.error("WEB/APP消息发送失败:用户获取失败 : {}",entity); return; } BusinessMessageDTO message = new BusinessMessageDTO(); @@ -113,7 +114,7 @@ public class MessageServiceImpl implements MessageService { message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription()); message.setTaskId(entity.getId()); - message.setTenantId("200000"); + message.setTenantId(stationByCode.getData().getTenantId()); message.setContent(entity.getAlarmContext()); message.setDeptId(dept); R deptName = sysClient.getDeptName(dept); @@ -133,14 +134,14 @@ public class MessageServiceImpl implements MessageService { public void weChatMessage(AlarmEntity entity) { R station = stationClient.getStationByCode(entity.getStationId()); if (!station.isSuccess() && ObjectUtils.isEmpty(station.getData())) { - log.error("消息发送失败:站点code获取失败 : {}",entity); + log.error("微信消息发送失败:站点code获取失败 : {}",entity); return; } Long dept = station.getData().getCreateDept(); // 获取站点用户 - R> result = userClient.userListByDeptId(dept); + R> result = userClient.userList(station.getData().getTenantId(),dept); if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { - log.error("消息发送失败:用户获取失败 : {}",entity); + log.error("微信消息发送失败:用户获取失败 : {}",entity); return; } WxMessageDTO message = new WxMessageDTO(); @@ -155,7 +156,7 @@ public class MessageServiceImpl implements MessageService { // 业务分类关键字 message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); // 任务Id - message.setTaskId(Long.valueOf(entity.getAlarmId())); + message.setTaskId(entity.getId()); // 微信参数键值对 HashMap map = new HashMap<>(); map.put("thing18",entity.getStationName()); 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 index 42b738f..257a87e 100644 --- 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 @@ -1,8 +1,18 @@ package com.hnac.hzims.operational.access.controller; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.access.service.AccessTaskV4Service; +import com.hnac.hzims.operational.access.vo.MyAccessTaskVO; +import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.log.annotation.ApiLog; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -16,4 +26,13 @@ import org.springframework.web.bind.annotation.RestController; @Api(tags = "v4检修计划流程") public class AccessTaskV4Controller extends BladeController { + private final AccessTaskV4Service accessTaskV4Service; + + @ApiLog + @GetMapping("/myAccessTasks") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "我的检修任务") + public R> myAccessTasks(MyAccessTaskVO myAccessTaskVO, Query query) { + return R.data(accessTaskV4Service.myAccessTasks(myAccessTaskVO.getTaskName(), query)); + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java index 2d2c6e5..2ac7929 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java @@ -45,4 +45,6 @@ public interface OperAccessTaskMapper extends UserDataScopeBaseMapper getRepairBill(@Param("deviceCodes") List deviceCodes,@Param("startTime") String startTime, @Param("endTime") String endTime); List accessTasks(@Param("planId") Long id); + + IPage myAccessTasks(@Param("handler") Long handler,@Param("taskName") String taskName, IPage page); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml index 3f04203..9e60267 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml @@ -245,4 +245,20 @@ FROM HZIMS_OPER_ACCESS_TASK WHERE PLAN_ID = #{planId} + + 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 db8abb2..d6147c5 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 @@ -1,7 +1,12 @@ package com.hnac.hzims.operational.access.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO; +import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; +import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; /** * @author ysj @@ -11,4 +16,6 @@ public interface AccessTaskV4Service { void startProcessV4(AccessTaskV4DTO entity); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); + + IPage myAccessTasks(String taskName, Query query); } \ No newline at end of file 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 dc1f1c4..4212b7f 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 @@ -5,6 +5,7 @@ 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.Wrappers; import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.BusinessMessageDTO; @@ -376,6 +377,14 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ } } IPage pages = this.planService.page(page,queryWrapper); + List plans = pages.getRecords(); + if(CollectionUtil.isEmpty(plans)){ + return pages; + } + // 查询计划项目 + List contents = contentService.list(Wrappers.lambdaQuery() + .eq(OperAccessContentEntity::getPlanId,plans.stream().map(OperAccessPlanEntity::getId).collect(Collectors.toList()))); + pages.setRecords(OperAccessPlanWrapper.build().listVO(pages.getRecords())); return pages; } 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 fe8dc20..1ef5460 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,6 +4,7 @@ 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.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.BusinessMessageDTO; @@ -16,11 +17,16 @@ import com.hnac.hzims.operational.access.entity.OperAccessContentEntity; import com.hnac.hzims.operational.access.entity.OperAccessMaterialEntity; import com.hnac.hzims.operational.access.entity.OperAccessStatisticsEntity; import com.hnac.hzims.operational.access.entity.OperAccessTaskDetailEntity; +import com.hnac.hzims.operational.access.mapper.OperAccessTaskMapper; import com.hnac.hzims.operational.access.service.*; +import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; +import com.hnac.hzims.operational.access.wrapper.OperAccessTaskWrapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.RandomUtils; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; @@ -37,10 +43,10 @@ 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; import java.text.DecimalFormat; -import java.util.*; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -61,6 +67,8 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { private final IOperAccessStatisticsService statisticsService; + private final OperAccessTaskMapper operAccessTaskMapper; + private final ISysClient sysClient; private final IFlowClient flowClient; @@ -96,6 +104,9 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { */ private void startProcess(AccessTaskV4DTO entity) { Map variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class); + if(ObjectUtil.isNotEmpty(entity.getCreateUser())){ + variables.put("startFlowUserId",entity.getCreateUser().toString()); + } 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 @@ -216,6 +227,7 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { return true; } + /** * 推送业务流程消息 * @param entity @@ -271,4 +283,17 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { } statisticsService.save(statisticsDTO); } + + /** + * 我的检修任务 + * @param taskName + * @param query + * @return + */ + @Override + public IPage myAccessTasks(String taskName, Query query) { + IPage pages = operAccessTaskMapper.myAccessTasks(AuthUtil.getUser().getUserId(),taskName, Condition.getPage(query)); + pages.setRecords(OperAccessTaskWrapper.build().listVOExtras(pages.getRecords())); + return pages; + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/vo/MyAccessTaskVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/vo/MyAccessTaskVO.java new file mode 100644 index 0000000..d87cbcd --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/vo/MyAccessTaskVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.operational.access.vo; + +import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + + +/** + * @author ysj + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class MyAccessTaskVO extends OperAccessTaskEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("任务名称") + private String taskName; +}