diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/entity/PlanEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/entity/PlanEntity.java index 2382a03..ed78383 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/entity/PlanEntity.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/entity/PlanEntity.java @@ -3,6 +3,8 @@ package com.hnac.hzinfo.inspect.plan.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import jdk.nashorn.internal.ir.annotations.Ignore; @@ -195,4 +197,8 @@ public class PlanEntity extends TenantEntity { @ApiModelProperty(value = "值班id") private Long dutyId; + @ApiModelProperty(value = "消息模板ID") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Long messageTemplateId; + } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java index f3ce072..83c4274 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java @@ -3,6 +3,8 @@ package com.hnac.hzinfo.inspect.task.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -165,5 +167,8 @@ public class TaskEntity extends TenantEntity { @ApiModelProperty(value = "值班id") private Long dutyId; + @ApiModelProperty(value = "消息模板ID") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Long messageTemplateId; } diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/MessagePushRecordDto.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/MessagePushRecordDto.java index c064174..4ddcfc7 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/MessagePushRecordDto.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/MessagePushRecordDto.java @@ -22,4 +22,7 @@ public class MessagePushRecordDto extends MessagePushRecordEntity implements Ser @NotNull private List types; + @ApiModelProperty("创建人") + private Long createUser; + } diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/PlanMsgRecordDto.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/PlanMsgRecordDto.java index ae8e695..d2e233d 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/PlanMsgRecordDto.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/PlanMsgRecordDto.java @@ -52,13 +52,20 @@ public class PlanMsgRecordDto implements Serializable { @NotNull private LocalDateTime planTime; + @ApiModelProperty("短信推送资源编码") + private String resourceCode; + @ApiModelProperty("消息创建人") @JsonSerialize(nullsUsing = NullSerializer.class) private Long createUser; + @ApiModelProperty("阿里云短信模板参数") + private String smsParam; + @ApiModelProperty("消息推送耳机") @NotNull private String content; + @ApiModelProperty("租户ID") private String tenantId; diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/MessagePushRecordEntity.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/MessagePushRecordEntity.java index 39bd263..c64316e 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/MessagePushRecordEntity.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/MessagePushRecordEntity.java @@ -68,6 +68,9 @@ public class MessagePushRecordEntity extends MessageTemplateEntity { @ApiModelProperty(value = "内容") private String content; + @ApiModelProperty("阿里云短信模板参数") + private String smsParam; + @ApiModelProperty(value = "计划推送时间") @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeEquipmentTrialFeignClient.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeEquipmentTrialFeignClient.java index 1781d1b..7fec8c9 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeEquipmentTrialFeignClient.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeEquipmentTrialFeignClient.java @@ -26,7 +26,7 @@ public interface SafeEquipmentTrialFeignClient { /** * 分页 */ - @GetMapping("/list") + @GetMapping("/safeEquimentTrial/list") @ApiOperationSupport(order = 50) @ApiOperation(value = "分页", notes = "查询条件:createDept,fileName,startTime,endTime") public R> list(SafeEquipmentTrialDTO safeEquipmentTrialDTO, Query query) ; diff --git a/hzims-service/hzims-middle/src/main/resources/application.yml b/hzims-service/hzims-middle/src/main/resources/application.yml index 5630ab0..f3bb7f5 100644 --- a/hzims-service/hzims-middle/src/main/resources/application.yml +++ b/hzims-service/hzims-middle/src/main/resources/application.yml @@ -20,6 +20,8 @@ mybatis-plus: mapper-locations: classpath:com/hnac/hzims/**/mapper/*Mapper.xml #实体扫描,多个package用逗号或者分号分隔 typeAliasesPackage: com.hnac.hzims.**.entity + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #swagger扫描路径配置 swagger: diff --git a/hzims-service/inspect/pom.xml b/hzims-service/inspect/pom.xml index 7376582..3da9278 100644 --- a/hzims-service/inspect/pom.xml +++ b/hzims-service/inspect/pom.xml @@ -13,6 +13,7 @@ com.hnac.hzinfo.inspect hzinfo-inspect + 4.0.0-SNAPSHOT jar @@ -134,7 +135,11 @@ blade-starter-oss-minio ${bladex.project.version} - + + com.hnac.hzims + message-api + ${hzims.project.version} + diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/plan/controller/PlanController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/plan/controller/PlanController.java index 247bc93..c41efa0 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/plan/controller/PlanController.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/plan/controller/PlanController.java @@ -137,7 +137,7 @@ public class PlanController extends BladeController { @ApiImplicitParam(name="status",value="0:待审核-->1:已审核-->2:派发中-->3:暂停-->4:结束-->5审核不通过-->6待提交") }) public R modifyPlanStatus(@RequestParam(value = "id") @ApiParam(value = "主键ID",required = true) Long id, - @RequestParam @DictInvalid(dictKey = PlanContants.PLAN_STATUS) Integer status) { + @RequestParam Integer status) { return R.status(planService.modifyPlanStatus(id, status)); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java new file mode 100644 index 0000000..3a7b5bb --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java @@ -0,0 +1,126 @@ +package com.hnac.hzinfo.inspect.task.aspect; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.hnac.hzims.message.dto.PlanMsgRecordDto; +import com.hnac.hzims.message.fegin.IMessageClient; +import com.hnac.hzinfo.inspect.plan.entity.PlanEntity; +import com.hnac.hzinfo.inspect.task.entity.TaskEntity; +import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity; +import com.hnac.hzinfo.inspect.task.job.service.TaskRemindManager; +import com.hnac.hzinfo.inspect.task.service.ITaskService; +import com.hnac.hzinfo.inspect.task.service.ITaskUserService; +import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @ClassName TaskGenerateAspect + * @description: 消息生成后业务操作 + * @author: hx + * @create: 2023-04-17 11:21 + * @Version 4.0 + **/ +@Aspect +@Component +@RequiredArgsConstructor +@Slf4j +public class TaskGenerateAspect { + + private final IMessageClient messageClient; + private final ITaskService taskService; + private final ITaskUserService taskUserService; + + /** + * 巡检任务开始前发送短信信息阿里云模板 + **/ + @Value("${hzims.inspect.task.templateCode.taskBegin}") + private String taskBeginTemplateCode; + + /** + * 巡检任务结束前发送短信信息阿里云模板 + **/ + @Value("${hzims.inspect.task.templateCode.taskEnd}") + private String taskEndTemplateCode; + + @Pointcut("execution(* com.hnac.hzinfo.inspect.task.job.service.ITaskJobService.sendTask(..))") + public void taskSaveCut() { + } + + @AfterReturning(value = "taskSaveCut()") + private void saveTask(JoinPoint joinPoint) { + Object[] args = joinPoint.getArgs(); + new Thread(() -> { + if(ObjectUtil.isNotEmpty(args[0]) && args[0] instanceof PlanEntity) { + PlanEntity plan = (PlanEntity) args[0]; + List list = taskService.list( + Wrappers.lambdaQuery().eq(TaskEntity::getPlanId,plan.getId()) + ); + if(CollectionUtil.isNotEmpty(list)) { + list.forEach(this::pushMessageByTask); + } + TaskEntity task = JSONObject.parseObject(JSON.toJSONString(args[0]),TaskEntity.class); + this.pushMessageByTask(task); + } + },"巡检任务消息推送").start(); + } + + /** + * 根据巡检任务生成消息推送记录 + * @param taskEntity 巡检任务 + */ + private void pushMessageByTask(TaskEntity taskEntity) { + PlanMsgRecordDto recordDto = new PlanMsgRecordDto(); + recordDto.setDeptId(taskEntity.getCreateDept()); + recordDto.setTemplateId(taskEntity.getMessageTemplateId()); + recordDto.setTaskId(taskEntity.getId()); + if(Func.isEmpty(AuthUtil.getUserId())) { + recordDto.setTenantId(taskEntity.getTenantId()); + } + // 获取巡检任务的消息推送人 + LambdaQueryWrapper eq = Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId, taskEntity.getId()); + List taskUserList = taskUserService.list(eq); + if(CollectionUtil.isNotEmpty(taskUserList)) { + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + taskUserList.stream().map(TaskUserEntity::getUserId).filter(Func::isNotEmpty).forEach(userId -> { + recordDto.setReceiver(userId); + recordDto.setCreateUser(userId); + Map smsMap = new HashMap<>(2); + // 消息开始前提醒 + recordDto.setResourceCode(taskBeginTemplateCode); + smsMap.put("one",taskEntity.getPlanName()); + smsMap.put("two",df.format(taskEntity.getPlanStartTime())); + recordDto.setPlanTime(taskEntity.getPlanStartTime()); + recordDto.setSmsParam(JSON.toJSONString(smsMap)); + recordDto.setContent("任务“"+ taskEntity.getPlanName() + "”的计划执行时间是:" + df.format(taskEntity.getPlanStartTime())+ " —— " + df.format(taskEntity.getPlanEndTime())); + messageClient.planSendMessage(recordDto); + // 消息结束前提醒 +/* smsMap.put("two",df.format(taskEntity.getPlanEndTime())); + recordDto.setPlanTime(taskEntity.getPlanEndTime()); + recordDto.setSmsParam(JSON.toJSONString(smsMap)); + messageClient.planSendMessage(recordDto);*/ + }); + } + } +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/TaskJobService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/TaskJobService.java index 501bef5..b256697 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/TaskJobService.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/TaskJobService.java @@ -18,6 +18,7 @@ import com.hnac.hzinfo.inspect.plan.entity.*; import com.hnac.hzinfo.inspect.plan.service.*; import com.hnac.hzinfo.inspect.task.TaskContants; import com.hnac.hzinfo.inspect.task.TaskContants.ClaimStatusEnum; +import com.hnac.hzinfo.inspect.task.aspect.TaskGenerateAspect; import com.hnac.hzinfo.inspect.task.entity.*; import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService; import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectService; @@ -89,6 +90,9 @@ public class TaskJobService { @Autowired private IDutyMainClient dutyMainClient; + @Autowired + private TaskGenerateAspect taskGenerateAspect; + private final String dateSplit = "_"; /** @@ -401,6 +405,7 @@ public class TaskJobService { task.setCreateUser(plan.getCreateUser()); task.setCreateDept(plan.getCreateDept()); task.setAutoVideo(plan.getAutoVideo()); + task.setMessageTemplateId(plan.getMessageTemplateId()); task.setMethod(plan.getMethod()); task.setEndRemindFlag(true); task.setStartRemindFlag(true); diff --git a/hzims-service/inspect/src/main/resources/db/1.0.0.sql b/hzims-service/inspect/src/main/resources/db/1.0.0.sql new file mode 100644 index 0000000..9053136 --- /dev/null +++ b/hzims-service/inspect/src/main/resources/db/1.0.0.sql @@ -0,0 +1,4 @@ +-- 巡检计划添加消息模板字段 +alter table `hz_st_re_plan` add column `message_template_id` bigint(20) comment '消息模板ID'; +-- 巡检任务添加消息模板字段 +alter table `hz_st_ex_task` add column `message_template_id` bigint(20) comment '消息模板ID'; \ No newline at end of file diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java index 2bff11e..a09551f 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java @@ -70,7 +70,7 @@ public class MessagePushRecordController extends BladeController { @ApiOperationSupport(order = 6) public R readMessage(@PathVariable @ApiParam("消息记录ID") String id) { MessagePushRecordEntity record = messagePushRecordService.getById(id); - if(!record.getPusher().equals(AuthUtil.getUserId())) { + if(!(Long.parseLong(record.getPusher()) == AuthUtil.getUserId())) { return R.fail("当前登录人不是消息推送人,修改状态失败"); } LambdaUpdateWrapper eq = Wrappers.lambdaUpdate() diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java index 7565730..57afdb2 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java @@ -18,12 +18,14 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.SpringUtil; import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.*; @@ -31,6 +33,7 @@ import javax.validation.Valid; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Arrays; +import java.util.Optional; /** * @author hx @@ -58,6 +61,10 @@ public class MessageClient extends BladeController implements IMessageClient{ request.getTypes().forEach(type -> { MessagePushRecordEntity entity = BeanUtil.copy(request,MessagePushRecordEntity.class); entity.setType(type); + if(Func.isEmpty(AuthUtil.getUserId())) { + entity.setCreateUser(request.getCreateUser()); + entity.setCreateDept(request.getCreateDept()); + } entity.setMessageId(messageId); recordService.saveAndSend(entity); }); @@ -88,13 +95,15 @@ public class MessageClient extends BladeController implements IMessageClient{ entity.setTemplateId(request.getTemplateId()); entity.setDeptId(request.getDeptId()); entity.setCreateUser(request.getCreateUser()); + entity.setResourceCode(request.getResourceCode()); entity.setCreateDept(request.getDeptId()); entity.setPlanTime(request.getPlanTime()); entity.setPushType(MessageConstants.PLAN); entity.setPusher(request.getReceiver().toString()); - entity.setPusherName(UserCache.getUser(request.getReceiver()).getName()); + entity.setPusherName(Optional.ofNullable(UserCache.getUser(request.getReceiver())).map(User::getName).orElse("")); entity.setAccount(request.getReceiver().toString()); entity.setContent(request.getContent()); + entity.setSmsParam(request.getSmsParam()); if(Func.isNotEmpty(request.getTenantId())) { entity.setTenantId(request.getTenantId()); } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java index 82fc76d..97357e2 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java @@ -84,6 +84,9 @@ public class MessagePushSchedule { MessagePushRecordEntity request = records.get(0); // 完善推送内容 request.setContent(this.getPushContent(type,records)); + if(MessageConstants.SMS_PUSH.equals(type)) { + request.setSmsParam(request.getContent()); + } request.setMessageId(IdWorker.getId()); Boolean flag = service.send(request); if(!flag) { @@ -111,9 +114,9 @@ public class MessagePushSchedule { } else if(MessageConstants.SMS_PUSH.equals(type)) { Map params = new HashMap<>(); - list.stream().map(MessagePushRecordEntity::getContent).forEachOrdered(record -> { - JSONObject param = JSONObject.parseObject(record); - param.forEach((k,v) -> { + list.stream().map(MessagePushRecordEntity::getSmsParam).forEachOrdered(param -> { + JSONObject paramJson = JSONObject.parseObject(param); + paramJson.forEach((k,v) -> { params.put(k, params.containsKey(k) && Func.isNotEmpty(params.get(k)) ? params.get(k) + "," + v : (String) v); }); }); diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java index ae77d04..9e4d2aa 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java @@ -97,6 +97,7 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl response = smsClient.sendMessage( Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId(), request.getResourceCode(), - request.getContent(), + request.getSmsParam(), this.getAccountByPusher(Long.parseLong(request.getPusher()),request.getType()) ); Assert.isTrue(response.isSuccess(),() -> { diff --git a/hzims-service/message/src/main/resources/db/1.0.0.sql b/hzims-service/message/src/main/resources/db/1.0.0.sql index 9bee075..fb8dac5 100644 --- a/hzims-service/message/src/main/resources/db/1.0.0.sql +++ b/hzims-service/message/src/main/resources/db/1.0.0.sql @@ -25,7 +25,7 @@ SET FOREIGN_KEY_CHECKS = 1; CREATE TABLE IF NOT EXISTS `hzims_message_push_record` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID', `TASK_ID` bigint(20) NOT NULL COMMENT '消息类型', - `TEMPLATE_ID` bigint(20) NOT NULL COMMENT '消息模板ID', + `TEMPLATE_ID` bigint(20) COMMENT '消息模板ID', `PUSHER` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '推送人', `PUSHER_NAME` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '推送人名称', `CONTENT` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '内容', diff --git a/hzims-service/message/src/main/resources/db/1.0.1.sql b/hzims-service/message/src/main/resources/db/1.0.1.sql index 308434e..39833ff 100644 --- a/hzims-service/message/src/main/resources/db/1.0.1.sql +++ b/hzims-service/message/src/main/resources/db/1.0.1.sql @@ -1,4 +1,6 @@ -- 添加消息ID alter table hzims_message_push_record add COLUMN `MESSAGE_ID` bigint(20) DEFAULT NULL comment '消息ID'; -- 添加消息推送类型 -alter table hzims_message_push_record add COLUMN `PUSH_TYPE` VARCHAR(2) DEFAULT NULL comment '推送类型,0:即时推送,1:计划推送'; \ No newline at end of file +alter table hzims_message_push_record add COLUMN `PUSH_TYPE` VARCHAR(2) DEFAULT NULL comment '推送类型,0:即时推送,1:计划推送'; +-- 添加短信推送参数 +alter table `hzims_message_push_record` add COLUMN `SMS_PARAM` VARCHAR(255) COMMENT '阿里云短信模板参数'; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/scheduled/DutyRecCreateTask.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/scheduled/DutyRecCreateTask.java index 0eb2aa8..54fa3fd 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/scheduled/DutyRecCreateTask.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/scheduled/DutyRecCreateTask.java @@ -5,8 +5,6 @@ import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import static com.hnac.hzims.operational.duty.constant.DutyScheduledConstant.TASK_VALUE_MESSAGE_REMINDING_CREATE; @@ -24,13 +22,17 @@ public class DutyRecCreateTask { * @return * @throws Exception */ +// @XxlJob(TASK_VALUE_MESSAGE_REMINDING_CREATE) +// public ReturnT messageRemonding(String param) throws Exception { +// recService.messageRemonding(); +// return new ReturnT<>("SUCCESS"); +// } + @XxlJob(TASK_VALUE_MESSAGE_REMINDING_CREATE) - public ReturnT messageRemonding(String param) throws Exception { - recService.messageRemonding(); + public ReturnT messageRemondingV2(String param) throws Exception { + recService.messageRemondingV2(); return new ReturnT<>("SUCCESS"); } - - } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainPersonService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainPersonService.java index 8082f09..a00abe1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainPersonService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainPersonService.java @@ -14,4 +14,7 @@ public interface IImsDutyMainPersonService extends BaseService list); + + List selectByMainIds(List dutyMainIds); + List selectByMainId(Long dutyMainId); } 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 d47481f..cde2617 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 @@ -6,10 +6,8 @@ import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; import com.hnac.hzims.operational.duty.entity.ImsDutyClassEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity; -import com.hnac.hzims.operational.duty.vo.ImsDutyQrCodeVo; import com.hnac.hzims.operational.duty.vo.ImsDutyRecVO; import com.hnac.hzims.operational.duty.vo.ImsRecVo; -import com.hnac.hzims.operational.duty.vo.ImsSchedulingVo; import com.hnac.hzinfo.inspect.plan.vo.PlanVO; import org.springblade.core.mp.base.BaseService; import org.springblade.core.tool.api.R; @@ -62,9 +60,15 @@ public interface IImsDutyRecService extends BaseService { String getQRCode(); /** + * 消息提醒 20230414之后已弃用 + * 根据黄兴的消息中心模板,更新为新的V2的接口 + */ +// void messageRemonding(); + + /** * 消息提醒 */ - void messageRemonding(); + void messageRemondingV2(); /** * 消息提醒测试 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java index 4fb9d92..c71d13d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java @@ -3,12 +3,10 @@ package com.hnac.hzims.operational.duty.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.hnac.hzims.operational.duty.entity.ImsDutyGroupEntity; -import com.hnac.hzims.operational.duty.entity.ImsDutyGroupPEntity; -import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; -import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity; +import com.hnac.hzims.operational.duty.entity.*; import com.hnac.hzims.operational.duty.mapper.ImsDutyGroupMapper; import com.hnac.hzims.operational.duty.mapper.ImsDutyGroupPMapper; +import com.hnac.hzims.operational.duty.mapper.ImsDutyMainPersonMapper; import com.hnac.hzims.operational.duty.service.IImsDutyGroupPService; import com.hnac.hzims.operational.duty.service.IImsDutyGroupService; import com.hnac.hzims.operational.duty.service.IImsDutyMainService; @@ -48,7 +46,8 @@ public class ImsDutyGroupServiceImpl extends BaseServiceImpl userR = userClient.userInfoById(groupEntity.getManagerId()); + Long managerId = null; + String groupName = ""; + if (imsDutyMainEntity.getDutyGroupId()!=null) { + ImsDutyGroupEntity groupEntity = this.baseMapper.selectById(imsDutyMainEntity.getDutyGroupId()); + if (null != groupEntity.getManagerId()){ + managerId=groupEntity.getManagerId(); + } + groupName=groupEntity.getGroupName(); + }else { + ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, imsDutyMainEntity.getId()); + last(" limit 1"); + }}); + managerId=imsDutyMainPersonEntity.getDutyChargePerson(); + groupName="灵活排班"; + } + + if (managerId!=null) { + R userR = userClient.userInfoById(managerId); if (userR.isSuccess() && ObjectUtil.isNotEmpty(userR.getData())) { userName = userR.getData().getName(); } } - return R.fail(groupEntity.getGroupName() + userName + - "是负责人,且存在排班不能直接删除,请先更换" + groupEntity.getGroupName() + "负责人,再进行删除操作!"); + return R.fail(groupName +"-"+ userName + + "是负责人,且存在排班不能直接删除,请先更换" + groupName + "负责人,再进行删除操作!"); } } imsDutyGroupPService.deleteBatch(ids); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainPersonServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainPersonServiceImpl.java index 4456fb9..525f119 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainPersonServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainPersonServiceImpl.java @@ -1,47 +1,19 @@ package com.hnac.hzims.operational.duty.service.impl; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.serializer.SerializerFeature; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.IdWorker; -import com.hnac.hzims.monitor.utils.DateUtils; -import com.hnac.hzims.operational.defect.constants.DefectConstant; -import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.mapper.OperPhenomenonMapper; -import com.hnac.hzims.operational.duty.entity.*; -import com.hnac.hzims.operational.duty.enume.DutyRecStatus; -import com.hnac.hzims.operational.duty.enume.JoinStatus; +import com.hnac.hzims.operational.duty.entity.ImsDutyMainPersonEntity; import com.hnac.hzims.operational.duty.mapper.*; -import com.hnac.hzims.operational.duty.scheduled.ThreadTask; import com.hnac.hzims.operational.duty.service.IImsDutyGroupPService; import com.hnac.hzims.operational.duty.service.IImsDutyMainPersonService; -import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.duty.service.IImsDutyMainTemplateService; -import com.hnac.hzims.operational.duty.vo.*; -import com.hnac.hzims.operational.main.vo.DutyPersonalReportVO; -import com.hnac.hzims.operational.report.vo.DutyReportVO; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.collections4.CollectionUtils; import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.secure.utils.AuthUtil; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.*; -import org.springblade.system.user.cache.UserCache; -import org.springblade.system.user.entity.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.sql.Time; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.stream.Collectors; +import java.util.List; /** * 服务实现类 @@ -71,4 +43,28 @@ public class ImsDutyMainPersonServiceImpl extends BaseServiceImpl list) { this.saveBatch(list); } + + @Override + public List selectByMainIds(List dutyMainIds) { + List imsDutyMainPersonEntities = this.baseMapper.selectList(new LambdaQueryWrapper() {{ + in(ImsDutyMainPersonEntity::getDutyMainId, dutyMainIds); + }}); + if (CollectionUtils.isNotEmpty(imsDutyMainPersonEntities)){ + + return imsDutyMainPersonEntities; + } + return null; + } + + @Override + public List selectByMainId(Long dutyMainId) { + List imsDutyMainPersonEntities = this.baseMapper.selectList(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainId); + }}); + if (CollectionUtils.isNotEmpty(imsDutyMainPersonEntities)){ + + return imsDutyMainPersonEntities; + } + return null; + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java index c633a72..01c3bfa 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java @@ -160,6 +160,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl() {{ eq(ImsDutyMainPersonEntity::getDutyMainId, id); + last(" limit 1"); }}); imsSchedulingVo.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson()); } else { @@ -927,10 +928,13 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl personIdlist = new ArrayList<>(Arrays.asList(dutyMainPersonIds)); if (1 == changeDutyMainVo.getType()) { personIdlist.addAll(personId); + } else { personIdlist.removeAll(personId); } String resIds = StringUtils.join(personIdlist, "^"); @@ -1375,7 +1379,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl() {{ eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainInfoVo.getId()); }}); @@ -1633,7 +1637,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl getDutyDataV2(Long deptId) { List dutyMainInfoVos = this.baseMapper.selectDutyMainInfoVoV2(deptId); dutyMainInfoVos = dutyMainInfoVos.stream().map(s -> { - if (null == s.getGroupName()) { + if (null == s.getDutyGroupId()) { ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper() {{ eq(ImsDutyMainPersonEntity::getDutyMainId, s.getId()); }}); @@ -1657,7 +1661,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl() {{ eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainInfoVo.getId()); }}); 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 fb42004..87ca79c 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 @@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.MessagePushRecordDto; +import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.message.fegin.IMessagePushClient; import com.hnac.hzims.message.req.PushExtrasReq; import com.hnac.hzims.monitor.utils.DateUtils; @@ -46,6 +49,7 @@ import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; import java.math.BigDecimal; import java.text.SimpleDateFormat; @@ -64,312 +68,335 @@ import java.util.stream.Collectors; @Service public class ImsDutyRecServiceImpl extends BaseServiceImpl implements IImsDutyRecService { - @Autowired - private ImsDutyMainMapper imsDutyMainMapper; - @Autowired - private IImsDutyMainService imsDutyMainService; - @Autowired - private IImsDutyClassService imsDutyClassService; - @Autowired - private IImsDutyGroupService imsDutyGroupService; - @Autowired - private ImsDutyMainServiceImpl imsDutyMainServiceImpl; - @Autowired - private IStationService stationService; - @Autowired - private IMessagePushClient messagePushClient; - @Autowired - private IUserClient userClient; - @Autowired - private IFlowClient flowClient; - @Autowired - private ISysClient sysClient; - @Autowired - private IInspectPlanClient inspectPlanClient; - @Autowired - private IImsDutyGroupPService imsDutyGroupPService; - @Autowired - private IImsDutyMainPersonService imsDutyMainPersonService; - - - @Override - public R submit(ImsDutyRecEntity recEntity, PlanVO vo) { - //获取交班人值班信息 - ImsDutyMainEntity handDutyMainEntity = imsDutyMainMapper.selectOne(new LambdaQueryWrapper() {{ - eq(ImsDutyMainEntity::getId, recEntity.getDutyId()); - }}); - - //判断是否已交班 - List imsDutyRecEntities = this.baseMapper.selectList(new LambdaQueryWrapper() {{ - eq(ImsDutyRecEntity::getDutyId, recEntity.getDutyId()); - }}); - if (CollectionUtil.isNotEmpty(imsDutyRecEntities)) { - return R.fail("您已交班,请勿重复交班"); - } - //根据上一班值班id查询值班信息 - ImsDutyMainEntity dutyMainEntity = imsDutyMainMapper.selectOne(new QueryWrapper() {{ - eq("PRE_DUTY_ID", recEntity.getDutyId()); - }}); - if (ObjectUtil.isEmpty(dutyMainEntity)) { - return R.fail("当前时间没有接班人!"); - } - //获取交班人班组 - ImsDutyGroupEntity handGroupEntity = imsDutyGroupService.getById(handDutyMainEntity.getDutyGroupId()); - //获取接班人班组 - ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(dutyMainEntity.getDutyGroupId()); - - //判断班组长是否存在 - R userR = userClient.userInfoById(groupEntity.getManagerId()); - ImsDutyGroupPEntity groupPEntity = imsDutyGroupPService.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyGroupPEntity::getGroupId, groupEntity.getId()); - eq(ImsDutyGroupPEntity::getPersonId, groupEntity.getManagerId()).last(" LIMIT 1"); - }}); - - if (!userR.isSuccess() || ObjectUtil.isEmpty(userR.getData()) || ObjectUtil.isEmpty(groupPEntity)) { - return R.fail("接班班组长不存在,请指定班组长后进行交班!"); - } - - Long inspectTaskId = getInspectTaskId(vo, groupEntity.getManagerId());//新增巡检任务 - if (null == inspectTaskId) { - return R.fail("创建巡检计划失败"); - } - if (Func.isEmpty(recEntity.getId())) { - // 保存 - save(recEntity); - } - log.info("groupEntity-------------------------:" + groupEntity + "----- inspectTaskId-------------------------:" + inspectTaskId); - R result = flowClient.startProcessInstanceByKey(DutyRecProcessConstant. - DUTY_REC_FLOW_KEY, StringUtil.format("{}:{}", - DutyRecProcessConstant.DUTY_REC_PROCESS_TABLE, recEntity.getId()), new HashMap() {{ - put("taskId", recEntity.getId()); - put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, TaskUtil.getTaskUser(groupEntity.getManagerId().toString())); - //put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, Arrays.stream(dutyMainEntity.getDutyPersonIds().split("\\^")).map(o -> TaskUtil.getTaskUser(o)).collect(Collectors.joining(","))); - }}); - log.info("result-------------------------:" + result); - if (result.isSuccess()) { - Date date = new Date(); - //消息提醒 - handMessageRemind(handGroupEntity, groupEntity, date); - //判断是否延时交班 - judgeDelayedHand(handDutyMainEntity, recEntity);//判断交班是否延时 - - // 返回流程id写入业务表 - recEntity.setExecTime(date); - recEntity.setProcessInstanceId(result.getData().getProcessInstanceId()); - recEntity.setStatus(DutyRecStatus.EXEC.getVal()); - recEntity.setInspectTaskId(inspectTaskId); - updateById(recEntity); - } else { - throw new ServiceException("开启流程失败"); - } - return R.status(true); - } - - - private void updateMain(Long dutyId) { - ImsDutyMainEntity imsDutyMainEntity = new ImsDutyMainEntity(); - ImsDutyMainEntity dutyMainEntity = imsDutyMainMapper.selectOne(new QueryWrapper() {{ - eq("PRE_DUTY_ID", dutyId); - }}); - //修改接班人所在主表数据状态为 值班中 - imsDutyMainEntity.setId(dutyMainEntity.getId()); - imsDutyMainEntity.setStatus(DutyMainStatus.EXEC.getVal()); - imsDutyMainMapper.updateById(imsDutyMainEntity); - } - - void handMessageRemind(ImsDutyGroupEntity handGroupEntity, ImsDutyGroupEntity groupEntity, Date date) { - //消息提醒 - R userR = userClient.userInfoById(handGroupEntity.getManagerId()); - if (userR.isSuccess()) { - String userName = ""; - PushExtrasReq req = new PushExtrasReq(); - log.info("--------------------------req:" + req, groupEntity.getManagerId(), userName, date); - if (ObjectUtil.isNotEmpty(userR.getData()) && StringUtil.isNotBlank(userR.getData().getName())) { - userName = userR.getData().getName(); - log.info("--------------------------req2:" + req, groupEntity.getManagerId(), userName, date); - } - String format = DateUtil.format(date, DateUtil.PATTERN_DATETIME); + @Autowired + private ImsDutyMainMapper imsDutyMainMapper; + @Autowired + private IImsDutyMainService imsDutyMainService; + @Autowired + private IImsDutyClassService imsDutyClassService; + @Autowired + private IImsDutyGroupService imsDutyGroupService; + @Autowired + private ImsDutyMainServiceImpl imsDutyMainServiceImpl; + @Autowired + private IStationService stationService; + @Autowired + private IMessagePushClient messagePushClient; + @Autowired + private IMessageClient messageClient; + @Autowired + private IUserClient userClient; + @Autowired + private IFlowClient flowClient; + @Autowired + private ISysClient sysClient; + @Autowired + private IInspectPlanClient inspectPlanClient; + @Autowired + private IImsDutyGroupPService imsDutyGroupPService; + @Autowired + private IImsDutyMainPersonService imsDutyMainPersonService; + + + @Override + public R submit(ImsDutyRecEntity recEntity, PlanVO vo) { + //获取交班人值班信息 + ImsDutyMainEntity handDutyMainEntity = imsDutyMainMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getId, recEntity.getDutyId()); + }}); + + //判断是否已交班 + List imsDutyRecEntities = this.baseMapper.selectList(new LambdaQueryWrapper() {{ + eq(ImsDutyRecEntity::getDutyId, recEntity.getDutyId()); + }}); + if (CollectionUtil.isNotEmpty(imsDutyRecEntities)) { + return R.fail("您已交班,请勿重复交班"); + } + //根据上一班值班id查询值班信息 + ImsDutyMainEntity dutyMainEntity = imsDutyMainMapper.selectOne(new QueryWrapper() {{ + eq("PRE_DUTY_ID", recEntity.getDutyId()); + }}); + if (ObjectUtil.isEmpty(dutyMainEntity)) { + return R.fail("当前时间没有接班人!"); + } + Long handGroupManagerId; + if (handDutyMainEntity.getDutyGroupId() != null) { + //获取交班人班 + ImsDutyGroupEntity handGroupEntity = imsDutyGroupService.getById(handDutyMainEntity.getDutyGroupId()); + handGroupManagerId = handGroupEntity.getManagerId(); + } else { + List imsDutyMainPersonEntities = imsDutyMainPersonService.selectByMainId(handDutyMainEntity.getId()); + handGroupManagerId = imsDutyMainPersonEntities.get(0).getDutyChargePerson(); + } + Long groupEntityManagerId; + //获取接班人班组 + if (dutyMainEntity.getDutyGroupId() != null) { + ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(dutyMainEntity.getDutyGroupId()); + groupEntityManagerId = groupEntity.getManagerId(); + ImsDutyGroupPEntity groupPEntity = imsDutyGroupPService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyGroupPEntity::getGroupId, groupEntity.getId()); + eq(ImsDutyGroupPEntity::getPersonId, groupEntityManagerId).last(" LIMIT 1"); + }}); + if (ObjectUtil.isEmpty(groupPEntity)) { + return R.fail("接班班组长不存在,请指定班组长后进行交班!"); + } + } else { + List imsDutyMainPersonEntities2 = imsDutyMainPersonService.selectByMainId(dutyMainEntity.getId()); + groupEntityManagerId = imsDutyMainPersonEntities2.get(0).getDutyChargePerson(); + + } + //判断班组长是否存在 + R userR = userClient.userInfoById(groupEntityManagerId); + if (!userR.isSuccess() || ObjectUtil.isEmpty(userR.getData())) { + return R.fail("接班班组长不存在,请指定班组长后进行交班!"); + } + + Long inspectTaskId = getInspectTaskId(vo, groupEntityManagerId);//新增巡检任务 + if (null == inspectTaskId) { + return R.fail("创建巡检计划失败"); + } + if (Func.isEmpty(recEntity.getId())) { + // 保存 + save(recEntity); + } + log.info("groupEntityManagerId-------------------------:" + groupEntityManagerId + "----- inspectTaskId-------------------------:" + inspectTaskId); + R result = flowClient.startProcessInstanceByKey(DutyRecProcessConstant. + DUTY_REC_FLOW_KEY, StringUtil.format("{}:{}", + DutyRecProcessConstant.DUTY_REC_PROCESS_TABLE, recEntity.getId()), new HashMap() {{ + put("taskId", recEntity.getId()); + put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, TaskUtil.getTaskUser(groupEntityManagerId.toString())); + //put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, Arrays.stream(dutyMainEntity.getDutyPersonIds().split("\\^")).map(o -> TaskUtil.getTaskUser(o)).collect(Collectors.joining(","))); + }}); + log.info("result-------------------------:" + result); + if (result.isSuccess()) { + Date date = new Date(); + //消息提醒 + handMessageRemind(handGroupManagerId, groupEntityManagerId, date); + //判断是否延时交班 + judgeDelayedHand(handDutyMainEntity, recEntity);//判断交班是否延时 + + // 返回流程id写入业务表 + recEntity.setExecTime(date); + recEntity.setProcessInstanceId(result.getData().getProcessInstanceId()); + recEntity.setStatus(DutyRecStatus.EXEC.getVal()); + recEntity.setInspectTaskId(inspectTaskId); + updateById(recEntity); + } else { + throw new ServiceException("开启流程失败"); + } + return R.status(true); + } + + + private void updateMain(Long dutyId) { + ImsDutyMainEntity imsDutyMainEntity = new ImsDutyMainEntity(); + ImsDutyMainEntity dutyMainEntity = imsDutyMainMapper.selectOne(new QueryWrapper() {{ + eq("PRE_DUTY_ID", dutyId); + }}); + //修改接班人所在主表数据状态为 值班中 + imsDutyMainEntity.setId(dutyMainEntity.getId()); + imsDutyMainEntity.setStatus(DutyMainStatus.EXEC.getVal()); + imsDutyMainMapper.updateById(imsDutyMainEntity); + } + + void handMessageRemind(Long handGroupManagerId, Long groupEntityManagerId, Date date) { + //消息提醒 + R userR = userClient.userInfoById(handGroupManagerId); + if (userR.isSuccess()) { + String userName = ""; + PushExtrasReq req = new PushExtrasReq(); + log.info("--------------------------req:" + req, groupEntityManagerId, userName, date); + if (ObjectUtil.isNotEmpty(userR.getData()) && StringUtil.isNotBlank(userR.getData().getName())) { + userName = userR.getData().getName(); + log.info("--------------------------req2:" + req, groupEntityManagerId, userName, date); + } + String format = DateUtil.format(date, DateUtil.PATTERN_DATETIME); /*remondingCarry(req, OperationalConstants.RecTypeEnum.HAND_REMIND.getVal(), groupEntity.getManagerId(), userName, null, format, groupEntity.getTenantId(), groupEntity.getCreateDept(), groupEntity.getCreateUser());*/ - log.info("--------------------------req3:" + req, groupEntity.getManagerId(), userName, date); - - } - } - - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean completeTask(BladeFlow flow) { - log.info("-----------------打印参数-----------------------" + flow); - // 创建变量 - Map variables = flow.getVariables(); - if (variables == null) { - variables = Kv.create(); - } - variables.put(ProcessConstant.PASS_KEY, flow.isPass()); - //获取task 变量 - Map var = flowClient.taskVariables(flow.getTaskId()).getData(); - if (Func.isNotEmpty(var)) { - //完成工作流 - R re = flowClient.completeTask(flow.getTaskId(), flow.getProcessInstanceId(), flow.getComment(), variables); - if (!re.isSuccess()) { - return false; - } - log.info("-----------------完成工作流-----------------------" + var.containsKey(DutyProcessConstant.FINISH_IS_NEXT)); - if (flow.isPass()) { - log.info("-----------------修改状态-----------------------"); - ImsDutyMainEntity imsDutyMainEntity = new ImsDutyMainEntity(); - ImsDutyRecEntity recEntity = this.baseMapper.selectById(Long.valueOf(flow.getBusinessId())); - //修改交班人所在主表数据状态为 已完成 - imsDutyMainEntity.setId(recEntity.getDutyId()); - imsDutyMainEntity.setStatus(DutyMainStatus.ACCEPT.getVal()); - imsDutyMainMapper.updateById(imsDutyMainEntity); - //修改接班人所在主表数据状态为 值班中 - ImsDutyMainEntity mainEntity = new ImsDutyMainEntity(); - mainEntity.setStatus(DutyMainStatus.EXEC.getVal()); - imsDutyMainMapper.update(mainEntity, new UpdateWrapper() {{ - eq("PRE_DUTY_ID", recEntity.getDutyId()); - }}); - ImsDutyMainEntity entity = imsDutyMainMapper.selectOne(new LambdaQueryWrapper() {{ - eq(ImsDutyMainEntity::getPreDutyId, recEntity.getDutyId()); - }}); - if (ObjectUtil.isNotEmpty(entity)) { - judgeDelayedCarry(entity, recEntity);//判断接班是否延时 - } - //工作流完成更新业务表状态 - updateMain(recEntity.getDutyId()); - recEntity.setStatus(DutyRecStatus.ACCEPT.getVal()); - recEntity.setAcceptTime(new Date()); - recEntity.setQrCodeContent(System.currentTimeMillis() + ""); - this.updateById(recEntity); - } - } else { - return false; - } - return true; - } - - /** - * 详情 - * @param vo - * @return - */ - @Override - public ImsDutyRecVO getDdetail(ImsDutyRecVO vo) { - ImsSchedulingVo imsSchedulingVo1 = imsDutyMainService.getByIdOneV2(vo.getDutyId()); - vo.setHeadDutyMainVo(imsSchedulingVo1); - ImsDutyMainEntity imsDutyMainEntity = imsDutyMainMapper.selectOne(new QueryWrapper() {{ - eq("PRE_DUTY_ID", vo.getDutyId()); - }}); - if (ObjectUtil.isNotEmpty(imsDutyMainEntity)) { - ImsSchedulingVo imsSchedulingVo = imsDutyMainService.getByIdOneV2(imsDutyMainEntity.getId()); - vo.setCarryDutyMainVo(imsSchedulingVo); - } - return vo; - } - - @Override - public IPage getRecVoPage(IPage page, ImsDutyRecVO vo) { - - IPage imsDutyRecEntityIPage = this.baseMapper.selectPage(page, new LambdaQueryWrapper() {{ - orderByDesc(ImsDutyRecEntity::getExecTime); - if (StringUtil.isNotBlank(vo.getDutyInfo())) { - like(ImsDutyRecEntity::getDutyInfo, vo.getDutyInfo()); - } - if (StringUtil.isNotBlank(vo.getAcceptInfo())) { - like(ImsDutyRecEntity::getAcceptInfo, vo.getAcceptInfo()); - } - if (StringUtil.isNotBlank(vo.getLeftProblem())) { - like(ImsDutyRecEntity::getLeftProblem, vo.getLeftProblem()); - } - if (StringUtil.isNotBlank(vo.getStartDate())) { - ge(ImsDutyRecEntity::getAcceptTime, vo.getStartDate()); - } - if (StringUtil.isNotBlank(vo.getEndDate())) { - le(ImsDutyRecEntity::getAcceptTime, vo.getEndDate()); - } - }}); - IPage imsDutyRecVOIPage = ImsDutyRecWrapper.build().pageVO(imsDutyRecEntityIPage); - List records = imsDutyRecVOIPage.getRecords(); - if(CollectionUtil.isEmpty(records)){ - return imsDutyRecVOIPage; - } - for (ImsDutyRecVO imsDutyRecVO : records) { - ImsSchedulingVo imsSchedulingVo = imsDutyMainMapper.selectByIdOneV2(imsDutyRecVO.getDutyId(), null); - imsDutyRecVO.setCarryDutyMainVo(imsDutyMainMapper.selectByPreDutyIdOne(Optional.ofNullable(imsSchedulingVo).map(ImsSchedulingVo::getId).orElse(null))); - if (ObjectUtil.isEmpty(imsDutyRecVO)) { - continue; - } - imsDutyRecVO.setHeadDutyMainVo(imsSchedulingVo); - // 机构名称 - R result = sysClient.getDeptName(imsDutyRecVO.getCreateDept()); - if (result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())) { - imsDutyRecVO.setStationName(result.getData()); - } - } - imsDutyRecVOIPage.setRecords(records); - return imsDutyRecVOIPage; - } - - - /** - * 获取当前值班班组 -- 交接班 - * - * @return - */ - @Override - public R getTheManinGroupRec(Long deptId) { - ImsDutyRecVO vo = new ImsDutyRecVO(); - - ImsDutyMainEntity entity = imsDutyMainMapper.selectOne(new LambdaQueryWrapper() {{ - eq(ImsDutyMainEntity::getStatus, DutyMainStatus.EXEC.getVal()); - eq(ImsDutyMainEntity::getCreateDept, deptId); - like(ImsDutyMainEntity::getDutyPersonIds, AuthUtil.getUserId()).last(" limit 1"); - }}); - if (ObjectUtil.isEmpty(entity)) { - return R.success("您当前未值班"); - } - - ImsDutyGroupEntity groupEntity = imsDutyGroupService.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyGroupEntity::getId, entity.getDutyGroupId()); - eq(ImsDutyGroupEntity::getManagerId, AuthUtil.getUserId()); - }}); - ImsDutyMainPersonEntity personEntity = imsDutyMainPersonService.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyMainPersonEntity::getDutyMainId, entity.getId()); - eq(ImsDutyMainPersonEntity::getDutyChargePerson, AuthUtil.getUserId()); - last(" limit 1"); - - }}); - if (ObjectUtil.isEmpty(groupEntity)&&ObjectUtil.isEmpty(personEntity)) { - return R.success("您不是该班组负责人,不可交班!"); - } - - ImsDutyRecEntity recEntity = this.baseMapper.selectOne(new LambdaQueryWrapper() {{ - eq(ImsDutyRecEntity::getDutyId, entity.getId()); - }}); - if (ObjectUtil.isNotEmpty(recEntity)) { - return R.success("您已提交交班申请"); - } - - ImsDutyRecEntity dutyRecEntity = this.baseMapper.selectOne(new LambdaQueryWrapper() {{ - eq(ImsDutyRecEntity::getDutyId, entity.getPreDutyId()); - }}); - if (ObjectUtil.isNotEmpty(dutyRecEntity)) { - vo.setInspectTaskId(dutyRecEntity.getInspectTaskId()); - } - ImsSchedulingVo imsSchedulingVo = imsDutyMainServiceImpl.getByIdOneV2(entity.getId(), null);//交班人 - if (null != imsSchedulingVo.getManagerId()) { - imsSchedulingVo.setUserName(userClient.userInfoById(imsSchedulingVo.getManagerId()).getData().getName()); - } - ImsSchedulingVo imsSchedulingVo1 = imsDutyMainServiceImpl.getByIdOneV2(null, entity.getId()); - if (null != imsSchedulingVo1.getManagerId()) { - imsSchedulingVo1.setUserName(userClient.userInfoById(imsSchedulingVo1.getManagerId()).getData().getName()); - } - vo.setHeadDutyMainVo(imsSchedulingVo); - vo.setCarryDutyMainVo(imsSchedulingVo1); - return R.data(vo); - } + log.info("--------------------------req3:" + req, groupEntityManagerId, userName, date); + + } + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean completeTask(BladeFlow flow) { + log.info("-----------------打印参数-----------------------" + flow); + // 创建变量 + Map variables = flow.getVariables(); + if (variables == null) { + variables = Kv.create(); + } + variables.put(ProcessConstant.PASS_KEY, flow.isPass()); + //获取task 变量 + Map var = flowClient.taskVariables(flow.getTaskId()).getData(); + if (Func.isNotEmpty(var)) { + //完成工作流 + R re = flowClient.completeTask(flow.getTaskId(), flow.getProcessInstanceId(), flow.getComment(), variables); + if (!re.isSuccess()) { + return false; + } + log.info("-----------------完成工作流-----------------------" + var.containsKey(DutyProcessConstant.FINISH_IS_NEXT)); + if (flow.isPass()) { + log.info("-----------------修改状态-----------------------"); + ImsDutyMainEntity imsDutyMainEntity = new ImsDutyMainEntity(); + ImsDutyRecEntity recEntity = this.baseMapper.selectById(Long.valueOf(flow.getBusinessId())); + //修改交班人所在主表数据状态为 已完成 + imsDutyMainEntity.setId(recEntity.getDutyId()); + imsDutyMainEntity.setStatus(DutyMainStatus.ACCEPT.getVal()); + imsDutyMainMapper.updateById(imsDutyMainEntity); + //修改接班人所在主表数据状态为 值班中 + ImsDutyMainEntity mainEntity = new ImsDutyMainEntity(); + mainEntity.setStatus(DutyMainStatus.EXEC.getVal()); + imsDutyMainMapper.update(mainEntity, new UpdateWrapper() {{ + eq("PRE_DUTY_ID", recEntity.getDutyId()); + }}); + ImsDutyMainEntity entity = imsDutyMainMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getPreDutyId, recEntity.getDutyId()); + }}); + if (ObjectUtil.isNotEmpty(entity)) { + judgeDelayedCarry(entity, recEntity);//判断接班是否延时 + } + //工作流完成更新业务表状态 + updateMain(recEntity.getDutyId()); + recEntity.setStatus(DutyRecStatus.ACCEPT.getVal()); + recEntity.setAcceptTime(new Date()); + recEntity.setQrCodeContent(System.currentTimeMillis() + ""); + this.updateById(recEntity); + } + } else { + return false; + } + return true; + } + + /** + * 详情 + * + * @param vo + * @return + */ + @Override + public ImsDutyRecVO getDdetail(ImsDutyRecVO vo) { + ImsSchedulingVo imsSchedulingVo1 = imsDutyMainService.getByIdOneV2(vo.getDutyId()); + vo.setHeadDutyMainVo(imsSchedulingVo1); + ImsDutyMainEntity imsDutyMainEntity = imsDutyMainMapper.selectOne(new QueryWrapper() {{ + eq("PRE_DUTY_ID", vo.getDutyId()); + }}); + if (ObjectUtil.isNotEmpty(imsDutyMainEntity)) { + ImsSchedulingVo imsSchedulingVo = imsDutyMainService.getByIdOneV2(imsDutyMainEntity.getId()); + vo.setCarryDutyMainVo(imsSchedulingVo); + } + return vo; + } + + @Override + public IPage getRecVoPage(IPage page, ImsDutyRecVO vo) { + + IPage imsDutyRecEntityIPage = this.baseMapper.selectPage(page, new LambdaQueryWrapper() {{ + orderByDesc(ImsDutyRecEntity::getExecTime); + if (StringUtil.isNotBlank(vo.getDutyInfo())) { + like(ImsDutyRecEntity::getDutyInfo, vo.getDutyInfo()); + } + if (StringUtil.isNotBlank(vo.getAcceptInfo())) { + like(ImsDutyRecEntity::getAcceptInfo, vo.getAcceptInfo()); + } + if (StringUtil.isNotBlank(vo.getLeftProblem())) { + like(ImsDutyRecEntity::getLeftProblem, vo.getLeftProblem()); + } + if (StringUtil.isNotBlank(vo.getStartDate())) { + ge(ImsDutyRecEntity::getAcceptTime, vo.getStartDate()); + } + if (StringUtil.isNotBlank(vo.getEndDate())) { + le(ImsDutyRecEntity::getAcceptTime, vo.getEndDate()); + } + }}); + IPage imsDutyRecVOIPage = ImsDutyRecWrapper.build().pageVO(imsDutyRecEntityIPage); + List records = imsDutyRecVOIPage.getRecords(); + if (CollectionUtil.isEmpty(records)) { + return imsDutyRecVOIPage; + } + for (ImsDutyRecVO imsDutyRecVO : records) { + ImsSchedulingVo imsSchedulingVo = imsDutyMainMapper.selectByIdOneV2(imsDutyRecVO.getDutyId(), null); + imsDutyRecVO.setCarryDutyMainVo(imsDutyMainMapper.selectByPreDutyIdOne(Optional.ofNullable(imsSchedulingVo).map(ImsSchedulingVo::getId).orElse(null))); + if (ObjectUtil.isEmpty(imsDutyRecVO)) { + continue; + } + imsDutyRecVO.setHeadDutyMainVo(imsSchedulingVo); + // 机构名称 + R result = sysClient.getDeptName(imsDutyRecVO.getCreateDept()); + if (result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())) { + imsDutyRecVO.setStationName(result.getData()); + } + } + imsDutyRecVOIPage.setRecords(records); + return imsDutyRecVOIPage; + } + + + /** + * 获取当前值班班组 -- 交接班 + * + * @return + */ + @Override + public R getTheManinGroupRec(Long deptId) { + ImsDutyRecVO vo = new ImsDutyRecVO(); + + ImsDutyMainEntity entity = imsDutyMainMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getStatus, DutyMainStatus.EXEC.getVal()); + eq(ImsDutyMainEntity::getCreateDept, deptId); + like(ImsDutyMainEntity::getDutyPersonIds, AuthUtil.getUserId()).last(" limit 1"); + }}); + if (ObjectUtil.isEmpty(entity)) { + return R.success("您当前未值班"); + } + + if (entity.getDutyGroupId() != null) { + ImsDutyGroupEntity groupEntity = imsDutyGroupService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyGroupEntity::getId, entity.getDutyGroupId()); + eq(ImsDutyGroupEntity::getManagerId, AuthUtil.getUserId()); + }}); + if (ObjectUtils.isEmpty(groupEntity)) { + return R.success("您不是该班组负责人,不可交班!"); + } + } else { + ImsDutyMainPersonEntity personEntity = imsDutyMainPersonService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, entity.getId()); + eq(ImsDutyMainPersonEntity::getDutyChargePerson, AuthUtil.getUserId()); + last(" limit 1"); + }}); + if ( ObjectUtil.isEmpty(personEntity)) { + return R.success("您不是该班组负责人,不可交班!"); + } + } + ImsDutyRecEntity recEntity = this.baseMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyRecEntity::getDutyId, entity.getId()); + }}); + if (ObjectUtil.isNotEmpty(recEntity)) { + return R.success("您已提交交班申请"); + } + + ImsDutyRecEntity dutyRecEntity = this.baseMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyRecEntity::getDutyId, entity.getPreDutyId()); + }}); + if (ObjectUtil.isNotEmpty(dutyRecEntity)) { + vo.setInspectTaskId(dutyRecEntity.getInspectTaskId()); + } + ImsSchedulingVo imsSchedulingVo = imsDutyMainServiceImpl.getByIdOneV2(entity.getId(), null);//交班人 + if (null != imsSchedulingVo.getManagerId()) { + imsSchedulingVo.setUserName(userClient.userInfoById(imsSchedulingVo.getManagerId()).getData().getName()); + } + ImsSchedulingVo imsSchedulingVo1 = imsDutyMainServiceImpl.getByIdOneV2(null, entity.getId()); + if (null != imsSchedulingVo1.getManagerId()) { + imsSchedulingVo1.setUserName(userClient.userInfoById(imsSchedulingVo1.getManagerId()).getData().getName()); + } + vo.setHeadDutyMainVo(imsSchedulingVo); + vo.setCarryDutyMainVo(imsSchedulingVo1); + return R.data(vo); + } // /** // * 获取当前值班班组 -- 交接班 // * @@ -421,29 +448,30 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl() {{ - eq(ImsDutyRecEntity::getStatus, DutyRecStatus.EXEC.getVal()).orderByDesc(ImsDutyRecEntity::getCreateTime). - last("limit 1"); - }}); - - if (ObjectUtil.isEmpty(recEntity)) { - return null; - } - return recEntity.getProcessInstanceId() + "," + thisTimeToRub; - } - /* - *//** - * 消息提醒 - *//* + /** + * 获取签到二维码 + * + * @return + */ + @Override + public String getQRCode() { + Long thisTimeToRub = System.currentTimeMillis(); + ImsDutyRecEntity recEntity = this.baseMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyRecEntity::getStatus, DutyRecStatus.EXEC.getVal()).orderByDesc(ImsDutyRecEntity::getCreateTime). + last("limit 1"); + }}); + + if (ObjectUtil.isEmpty(recEntity)) { + return null; + } + return recEntity.getProcessInstanceId() + "," + thisTimeToRub; + + } + /* + *//** + * 消息提醒 + *//* @Override public void messageRemonding() { List list = imsDutyMainService.list(new LambdaQueryWrapper() {{ @@ -500,517 +528,682 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl list = imsDutyMainService.list(new LambdaQueryWrapper() {{ - eq(ImsDutyMainEntity::getStatus, JoinStatus.DUTY_ING.getStatus()); - }}); - if (CollectionUtil.isNotEmpty(list)) { - for (ImsDutyMainEntity entity : list) { - ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(entity.getDutyGroupId()); - ImsDutyClassEntity classEntity = imsDutyClassService.getById(entity.getClassId()); - if (ObjectUtil.isNotEmpty(groupEntity) && ObjectUtil.isNotEmpty(classEntity)) { - String userName = ""; - if (null != groupEntity.getManagerId()) { - userName = userClient.userInfoById(groupEntity.getManagerId()).getData().getName(); - } - PushExtrasReq req = new PushExtrasReq(); - if (null != entity.getPreDutyId()) { - ImsDutyRecEntity one = this.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyRecEntity::getDutyId, entity.getId()); - }}); - ImsDutyMainEntity carryMainentity = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyMainEntity::getPreDutyId, entity.getPreDutyId()); - }}); - ImsDutyGroupEntity carryGroupEntity = imsDutyGroupService.getById(carryMainentity.getDutyGroupId()); - if (ObjectUtil.isEmpty(one)) {//未发起交班流程 判断是否提醒交班 - Long differMinute = DateUtils.getDifferMinute(calculateDate(entity, classEntity, OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal())); - if (differMinute == -OperationalConstants.MessageRecTypeEnum.HAND_REC_MESSAGE.getVal()) { // 提醒交班 - remondingHead(req, OperationalConstants.RecTypeEnum.HAND_REMIND.getVal(), groupEntity.getManagerId(), groupEntity.getTenantId(), groupEntity.getCreateDept(), groupEntity.getCreateUser()); - } else if (differMinute == OperationalConstants.MessageRecTypeEnum.DELAYED_HAND_REC_MESSAGE.getVal()) {//延时交班提醒 - //提醒站长 接班人 交班人 - User admin = userClient.userByAccount(entity.getTenantId(), "admin").getData(); - remondingStation(req, admin, userName, classEntity);//提醒站长 - remondingCarry(req, OperationalConstants.RecTypeEnum.HAND_DELAY.getVal(), carryGroupEntity.getManagerId(), userName, classEntity, null, carryGroupEntity.getTenantId(), carryGroupEntity.getCreateDept(), carryGroupEntity.getCreateUser());//提醒接班人 - remondingHead(req, OperationalConstants.RecTypeEnum.HAND_DELAY.getVal(), groupEntity.getManagerId(), groupEntity.getTenantId(), groupEntity.getCreateDept(), groupEntity.getCreateUser());//提醒交班人 - } - } else {//已发起接班流程 判断是否提醒接班 - ImsDutyClassEntity carryClassEntity = imsDutyClassService.getById(carryMainentity.getClassId()); - Long differMinute = DateUtils.getDifferMinute(calculateDate(carryMainentity, carryClassEntity, OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal())); - if (differMinute > 0 && one.getDelayStatus() == 0) { - ImsDutyGroupEntity groupEntity1 = imsDutyGroupService.getById(carryMainentity.getDutyGroupId()); - //提醒站长 接班人 交班人 - User admin = userClient.userByAccount(entity.getTenantId(), "admin").getData(); - remondingStation(req, admin, groupEntity1.getManagerId().toString(), classEntity);//提醒站长 - remondingCarry(req, 2, carryGroupEntity.getManagerId(), groupEntity1.getManagerId().toString(), classEntity, null, groupEntity1.getTenantId(), groupEntity1.getCreateDept(), groupEntity1.getCreateUser());//提醒接班人 - } - } - } - } - } - } - } - - @Override - public void messageRemondingTest() { - PushExtrasReq req = new PushExtrasReq(); - User admin = userClient.userByAccount(AuthUtil.getTenantId(), "admin").getData(); - ImsDutyClassEntity classEntity = imsDutyClassService.getById("1417744967255752705"); - remondingStation(req, admin, "1380746947515691009", classEntity);//提醒站长 - } - - /** - * 修改值班状态 - * - * @return - */ - @Override - public R doUpdate(String date, Long id) { - ImsDutyMainEntity entity = new ImsDutyMainEntity(); - entity.setId(id); - entity.setDutyDate(DateUtil.parse(date, DateUtil.PATTERN_DATE)); - String format1 = DateUtil.format(new Date(), DateUtil.PATTERN_DATE); - Date dutyDate = entity.getDutyDate(); - Date parse = DateUtil.parse(format1, DateUtil.PATTERN_DATE); - if (dutyDate.getTime() > parse.getTime()) { - return R.fail("值班时间不能大于当前时间"); - } - ImsDutyMainEntity mainEntityById = imsDutyMainService.getById(id); - - //获取当前值班 - ImsDutyMainEntity mainEntity = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyMainEntity::getStatus, DutyMainStatus.EXEC.getVal()); - eq(ImsDutyMainEntity::getCreateDept, mainEntityById.getCreateDept()); - }}); - - - - List idList = new ArrayList<>(); - boolean bool = true; - ImsDutyMainEntity dutyMainEntity = new ImsDutyMainEntity(); - dutyMainEntity.setPreDutyId(id); - while (bool) { - ImsDutyMainEntity imsDutyMainServiceOne = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyMainEntity::getDutyDate, date); - eq(ImsDutyMainEntity::getPreDutyId, Long.valueOf(dutyMainEntity.getPreDutyId())); - ne(ImsDutyMainEntity::getStatus, "-1"); - eq(ImsDutyMainEntity::getCreateDept, mainEntityById.getCreateDept()); - }}); - - if (ObjectUtil.isEmpty(imsDutyMainServiceOne)) { - bool = false; - } - if (bool) { - dutyMainEntity.setPreDutyId(imsDutyMainServiceOne.getId()); - idList.add(imsDutyMainServiceOne.getId()); - } - } - - ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(mainEntityById.getDutyGroupId()); - if(ObjectUtil.isNotEmpty(groupEntity)){ - if(null == groupEntity.getManagerId()){ - return R.fail("该指定班组中的班组长不存在,请添加班组长后进行指定!"); - } - //判断班组长是否存在 - R userR = userClient.userInfoById(groupEntity.getManagerId()); - ImsDutyGroupPEntity groupPEntity = imsDutyGroupPService.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyGroupPEntity::getGroupId, groupEntity.getId()); - eq(ImsDutyGroupPEntity::getPersonId, groupEntity.getManagerId()).last(" LIMIT 1"); - }}); - - if (!userR.isSuccess() || ObjectUtil.isEmpty(userR.getData()) || ObjectUtil.isEmpty(groupPEntity)) { - return R.fail("该指定班组中的班组长不存在,请添加班组长后进行指定!"); - } - } - - - if (ObjectUtil.isNotEmpty(mainEntity)) { - List list = imsDutyMainService.list(new LambdaQueryWrapper() {{ - ge(ImsDutyMainEntity::getDutyDate, mainEntity.getDutyDate()); - le(ImsDutyMainEntity::getDutyDate, entity.getDutyDate()); - ne(ImsDutyMainEntity::getStatus, DutyMainStatus.ACCEPT.getVal()); - ne(ImsDutyMainEntity::getStatus, "-1"); - eq(ImsDutyMainEntity::getCreateDept, mainEntityById.getCreateDept()); - idList.add(id); - if (CollectionUtil.isNotEmpty(idList)) { - for (Long id : idList) { - ne(ImsDutyMainEntity::getId, id); - } - } - }}); - if (CollectionUtil.isNotEmpty(list)) { - for (ImsDutyMainEntity imsDutyMainEntity : list) { - ImsDutyMainEntity mainEntity1 = new ImsDutyMainEntity(); - ImsDutyRecEntity recEntity = this.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyRecEntity::getDutyId, imsDutyMainEntity.getId()); - eq(ImsDutyRecEntity::getCreateDept, mainEntityById.getCreateDept()); - }}); - if (ObjectUtil.isNotEmpty(recEntity)) { - flowClient.delProcessInstanceById(recEntity.getProcessInstanceId(), "交接班-异常数据处理"); - recEntity.setStatus(DutyRecStatus.ANOMALY.getVal()); - recEntity.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.CARRY_DELAY_STATUS.getStatus()); - this.updateById(recEntity); - } else { - ImsDutyRecEntity imsDutyRecEntity = new ImsDutyRecEntity(); - imsDutyRecEntity.setDutyId(imsDutyMainEntity.getId()); - imsDutyRecEntity.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus()); - imsDutyRecEntity.setStatus(DutyRecStatus.ANOMALY.getVal()); - - this.save(imsDutyRecEntity); - } - mainEntity1.setId(imsDutyMainEntity.getId()); - mainEntity1.setStatus(DutyMainStatus.ACCEPT.getVal()); - mainEntity1.setCreateDept(mainEntityById.getCreateDept()); - imsDutyMainService.updateById(mainEntity1); - } - } - } - entity.setStatus(DutyMainStatus.EXEC.getVal()); - entity.setCreateDept(mainEntityById.getCreateDept()); - return R.status(imsDutyMainService.updateById(entity)); - } - - - /** - * 分钟 - */ - private String minutlDateTest(Date date, int i) {//减多少分钟 - String reStr = ""; - try { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//"yyyy-MM-dd HH:mm:ss" - Calendar rightNow = Calendar.getInstance(); - rightNow.setTime(date); - rightNow.add(Calendar.MINUTE, i); - Date dt1 = rightNow.getTime(); - reStr = sdf.format(dt1); - } catch (Exception e) { - e.printStackTrace(); - } - return reStr; - } - - - /** - * 判断延时接班 - */ - @Override - public void judgeDelayedCarry(ImsDutyMainEntity entity, ImsDutyRecEntity recEntity) { - ImsDutyClassEntity classEntity = imsDutyClassService.getById(entity.getClassId()); - Long differMinute = DateUtils.getDifferMinute(calculateDate(entity, classEntity, OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal())); - ImsDutyRecEntity recEntity1 = new ImsDutyRecEntity(); - if (differMinute > 30) { - recEntity1.setId(recEntity.getId()); - if (recEntity.getDelayStatus() == DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus()) { - recEntity1.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.REC_DELAY_STATUS.getStatus());//赋值延时状态 为3 交接班延时 - } else { - recEntity1.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.CARRY_DELAY_STATUS.getStatus());//赋值延时状态 为2 接班延时 - } - recEntity1.setQrCodeContent(System.currentTimeMillis() + ""); - this.baseMapper.updateById(recEntity1); - } - } - - /** - * 判断延时交班 - */ - @Override - public void judgeDelayedHand(ImsDutyMainEntity handDutyMainEntity, ImsDutyRecEntity recEntity) { - ImsDutyClassEntity classEntity = imsDutyClassService.getById(handDutyMainEntity.getClassId()); - Long differMinute = DateUtils.getDifferMinute(calculateDate(handDutyMainEntity, classEntity, OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal())); - log.info("-------------------------延迟:" + differMinute + " 分钟"); - if (differMinute > 0) { - ImsDutyRecEntity entity = new ImsDutyRecEntity(); - entity.setId(recEntity.getId()); - entity.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus());//赋值延时状态 为1 交班延时 - this.baseMapper.updateById(entity); - } - } - - @Override - public String calculateDate(ImsDutyMainEntity dutyMainEntity, ImsDutyClassEntity classEntity, int type) { - Boolean preBool = false; - Boolean bool = false; - String strDate = ""; - String preDate = ""; - String format = ""; - String time = ""; - String preTime = ""; - - if (type == OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal()) { - time = classEntity.getEndTime() + ""; - } else if (type == OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()) { - time = classEntity.getStartTime() + ""; - } - - format = DateUtil.format(dutyMainEntity.getDutyDate(), DateUtil.PATTERN_DATE) + " " + time; - strDate = format; - Date parse = DateUtil.parse(format, DateUtil.PATTERN_DATETIME); - - - ImsDutyMainEntity imsDutyMainServiceOne1 = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ - orderByAsc(ImsDutyMainEntity::getId); - eq(ImsDutyMainEntity::getCreateDept, AuthUtil.getDeptId()); - eq(ImsDutyMainEntity::getDutyDate, DateUtil.format(dutyMainEntity.getDutyDate(), DateUtil.PATTERN_DATE)).last(" limit 1"); - }}); - - - if (ObjectUtil.isNotEmpty(imsDutyMainServiceOne1)) { - if (!dutyMainEntity.getId().equals(imsDutyMainServiceOne1.getId())) { - ImsDutyClassEntity dutyClassEntity = imsDutyClassService.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyClassEntity::getId, imsDutyMainServiceOne1.getClassId()); - }}); - if (type == OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal()) { - preTime = dutyClassEntity.getEndTime() + ""; - } else if (type == OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()) { - preTime = dutyClassEntity.getStartTime() + ""; - } - preDate = DateUtil.format(imsDutyMainServiceOne1.getDutyDate(), DateUtil.PATTERN_DATE) + " " + preTime; - Date preParse = DateUtil.parse(preDate, DateUtil.PATTERN_DATETIME); - if (preParse.getTime() > parse.getTime()) { - bool = true; - strDate = calculateDutyDate(parse); - } - } - } - - if (bool == false) { - ImsDutyMainEntity imsDutyMainServiceOne = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyMainEntity::getId, dutyMainEntity.getPreDutyId()); - }}); - if (ObjectUtil.isNotEmpty(imsDutyMainServiceOne)) { - if (dutyMainEntity.getDutyDate().getTime() == imsDutyMainServiceOne.getDutyDate().getTime()) { - ImsDutyClassEntity one = imsDutyClassService.getOne(new LambdaQueryWrapper() {{ - eq(ImsDutyClassEntity::getId, imsDutyMainServiceOne.getClassId()); - }}); - if (ObjectUtil.isNotEmpty(one)) { - preBool = true; - if (type == OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal()) { - preTime = one.getEndTime() + ""; - } else if (type == OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()) { - preTime = one.getStartTime() + ""; - } - preDate = DateUtil.format(imsDutyMainServiceOne.getDutyDate(), DateUtil.PATTERN_DATE) + " " + preTime; - } - } - } - } - - - if (preBool) { - Date preParse = DateUtil.parse(preDate, DateUtil.PATTERN_DATETIME); - if (preParse.getTime() > parse.getTime()) { - strDate = calculateDutyDate(parse); - } - } - return strDate; - } - - @Override - public List getRecInfoByDepts(List depts, String date) { - return this.baseMapper.selectRecInfoByDepts(depts, date); - } - - @Override - public R delProcessInstanceIds(String processInstanceIds) { - String[] split = processInstanceIds.split(","); - for (String processInstanceId : split) { - flowClient.delProcessInstanceById(processInstanceId, "交接班-异常数据处理"); - } - return R.success("操作成功"); - } - - - /** - * 天数加1 - * - * @param date - * @return - */ - private String calculateDutyDate(Date date) { - Calendar c = Calendar.getInstance(); - c.setTime(date); - c.add(Calendar.DAY_OF_MONTH, 1); - date = c.getTime(); - return DateUtil.format(date, DateUtil.PATTERN_DATETIME); - } - - /** - * 消息提醒站长 - */ - private void remondingStation(PushExtrasReq req, User admin, String userName, ImsDutyClassEntity - classEntity) { - req.setTitle("交接班"); - req.setType(DutyRecProcessConstant.MESSAGE_CLASS_TYPE_DUTY_REC); - req.setBusinessClassify(OperationalConstants.MessageClassifyEnum.MESSAGE_REMINDSY.getVal()); - req.setPushAlert(userName + " 负责人 值班日期为:(" + classEntity.getStartTime() + "-" + classEntity.getEndTime() + ") 目前已交班延迟,请尽快联系该负责人进行交班工作"); - messagePushClient.sendMessage(admin.getId().toString(), req, admin.getTenantId(), admin.getCreateDept(), admin.getCreateUser()); - } - - /** - * 消息提醒交班人 - */ - private void remondingHead(PushExtrasReq req, int type, Long managerId, String tenantId, Long createDept, Long createUser) { - req.setTitle("交接班"); - req.setType(DutyRecProcessConstant.MESSAGE_CLASS_TYPE_DUTY_REC); - req.setBusinessClassify(DutyRecProcessConstant.MESSAGE_CLASS_DAY); - if (type == OperationalConstants.RecTypeEnum.HAND_REMIND.getVal()) { - req.setPushAlert("您距离本次值班结束时间只剩 15 分钟,请尽快进行交班工作"); - } else if (type == OperationalConstants.RecTypeEnum.HAND_DELAY.getVal()) { - req.setPushAlert("您已交班延迟,请尽快进行交班工作"); - - } - messagePushClient.sendMessage(managerId.toString(), req, tenantId, createDept, createUser); - } - - /** - * 消息提醒接班人 - */ - private void remondingCarry(PushExtrasReq req, int type, Long managerId, String userName, ImsDutyClassEntity - classEntity, String date, String tenantId, Long createDept, Long createUser) { - req.setTitle("交接班"); - req.setType(DutyRecProcessConstant.MESSAGE_CLASS_TYPE_DUTY_REC); - req.setBusinessClassify(DutyRecProcessConstant.MESSAGE_CLASS_DAY); - if (type == OperationalConstants.RecTypeEnum.HAND_REMIND.getVal()) { - req.setPushAlert(userName + " 于 " + date + " 时已提交交班工作"); - } else if (type == OperationalConstants.RecTypeEnum.HAND_DELAY.getVal()) { - req.setPushAlert(userName + " 值班日期为(" + classEntity.getStartTime() + " - " + classEntity.getEndTime() + "),目前已延迟交班"); - } else if (type == OperationalConstants.RecTypeEnum.REMIND_HAND_PERSON.getVal()) { - req.setPushAlert("您已交班延迟,请尽快进行交班工作"); - } - messagePushClient.sendMessage(managerId.toString(), req, tenantId, createDept, createUser); - } - - //新增巡检计划 获取巡检任务ID - public Long getInspectTaskId(PlanVO vo, Long princId) { - vo.setName(DateUtil.format(new Date(), "yyyy-MM-dd HH") + "-交接班巡视"); - vo.setMethod(DutyRecProcessConstant.INSPECT_PANL_METHOD); - vo.setAutoVideo(DutyRecProcessConstant.INSPECT_PANL_AUTO_VIDEO); - vo.setCycle(DutyRecProcessConstant.INSPECT_PANL_AUTO_CYCLE); - Date date = new Date(); - Date startDate = minutlDate(date, 5); - Date endDate = hrDate(date, 2); - LocalDate startTime = LocalDate.parse(DateUtil.format(startDate, DateUtil.PATTERN_DATE), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); - LocalDate endTime = LocalDate.parse(DateUtil.format(endDate, DateUtil.PATTERN_DATE), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); - vo.setStartTime(startTime); - vo.setEndTime(endTime); - vo.setType(DutyRecProcessConstant.INSPECT_PANL_TYPE); - vo.setTaskTimesADay(DutyRecProcessConstant.INSPECT_PANL_TASK_TIMES_A_DAY); - vo.setStartRemind(DutyRecProcessConstant.INSPECT_PANL_START_REMIND); - vo.setEndRemind(DutyRecProcessConstant.INSPECT_PANL_END_REMIND); - String execStartTime = DateUtil.format(startDate, DateUtil.PATTERN_TIME); - String execEndTime = DateUtil.format(endDate, DateUtil.PATTERN_TIME); - List> listMap = new ArrayList<>(); - Map map = new HashMap<>(); - map.put("execStartTime", execStartTime); - map.put("execEndTime", execEndTime); - listMap.add(map); - vo.setExecTimeJson(JSONObject.toJSONString(listMap)); - List list = new ArrayList<>(); - list.add(princId); - vo.setPlanType("common"); - vo.setPlanUsers(list); - R> listR = inspectPlanClient.addPlanAndChecked(vo); - List data = listR.getData(); - if (CollectionUtil.isNotEmpty(data)) { - return data.get(0); - } - return null; - } - - - /** - * 小时 - */ - private Date hrDate(Date date, int i) {//减多少小时 - Calendar rightNow = Calendar.getInstance(); - rightNow.setTime(date); - rightNow.add(Calendar.HOUR, i); - Date dt1 = rightNow.getTime(); - return dt1; - } - - - /** - * 分钟 - */ - private Date minutlDate(Date date, int i) {//减多少分钟 - Calendar rightNow = Calendar.getInstance(); - rightNow.setTime(date); - rightNow.add(Calendar.MINUTE, i); - Date dt1 = rightNow.getTime(); - return dt1; - } - - @Override - public R batchUpdateTest() { - - List imsDutyRecTestVos = this.baseMapper.selectTest(); - for (ImsDutyRecTestVo imsDutyRecTestVo : imsDutyRecTestVos) { - ImsDutyRecEntity entity = new ImsDutyRecEntity(); - entity.setId(imsDutyRecTestVo.getId()); - entity.setCreateUser(imsDutyRecTestVo.getManagerId()); - String startTime = imsDutyRecTestVo.getDutyDate() + " " + imsDutyRecTestVo.getEndTime(); - entity.setExecTime(DateUtil.parse(startTime, DateUtil.PATTERN_DATETIME)); - String endTime = minutlDateTest(DateUtil.parse(startTime, DateUtil.PATTERN_DATETIME), 10); - entity.setAcceptTime(DateUtil.parse(endTime, DateUtil.PATTERN_DATETIME)); - this.baseMapper.updateById(entity); - } - - return R.success("操作成功"); - } - - @Override - public String testClassDate(Long id, Integer type) { - ImsDutyMainEntity imsDutyMainEntity = imsDutyMainService.getById(id); - ImsDutyClassEntity classEntity = imsDutyClassService.getById(imsDutyMainEntity.getClassId()); - Long differMinute = DateUtils.getDifferMinute(calculateDate(imsDutyMainEntity, classEntity, type)); - return calculateDate(imsDutyMainEntity, classEntity, type) + "-分钟:" + differMinute; - } - - - /** - * 交接班统计 - * @param param - * @return - */ - @Override - public ChangeShiftsRspDTO getChangeShifts(ChangeShiftsReqDTO param) { - ChangeShiftsRspDTO response = new ChangeShiftsRspDTO(); - response.setShiftsCount(0); - response.setShiftsRate(0.0); - if(ObjectUtil.isEmpty(param)){ - return response; - } - // 查询交接班记录 - QueryWrapper queryWrapper = new QueryWrapper() {{ - if(Optional.ofNullable(param.getCreateDept()).isPresent()){ - eq("create_dept",param.getCreateDept()); - } - if(Optional.ofNullable(param.getStartTime()).isPresent()){ - gt("exec_time", param.getStartTime()); - } - if(Optional.ofNullable(param.getEndTime()).isPresent()){ - lt("exec_time", param.getEndTime()); - } - }}; - List list = this.baseMapper.selectList(queryWrapper); - if(CollectionUtil.isEmpty(list)){ - return response; - } - // 交接班次数 - response.setShiftsCount(list.size()); - List normal = list.stream().filter(o-> DutyContants.DutyRecDelayStatusEnum.WIT_DELAY_STATUS.getStatus() == o.getDelayStatus()).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(normal)){ - return response; - } - // 交接班正常率 - double shiftsRate = BigDecimal.valueOf((double)normal.size() / list.size() * 100L).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - response.setShiftsRate(shiftsRate); - return response; - } + /** + * 消息提醒 + */ + //20230414已弃用,改用V2 +// @Override +// public void messageRemonding() { +// List list = imsDutyMainService.list(new LambdaQueryWrapper() {{ +// eq(ImsDutyMainEntity::getStatus, JoinStatus.DUTY_ING.getStatus()); +// }}); +// if (CollectionUtil.isNotEmpty(list)) { +// for (ImsDutyMainEntity entity : list) { +// ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(entity.getDutyGroupId()); +// ImsDutyClassEntity classEntity = imsDutyClassService.getById(entity.getClassId()); +// if (ObjectUtil.isNotEmpty(groupEntity) && ObjectUtil.isNotEmpty(classEntity)) { +// String userName = ""; +// if (null != groupEntity.getManagerId()) { +// userName = userClient.userInfoById(groupEntity.getManagerId()).getData().getName(); +// } +// PushExtrasReq req = new PushExtrasReq(); +// if (null != entity.getPreDutyId()) { +// ImsDutyRecEntity one = this.getOne(new LambdaQueryWrapper() {{ +// eq(ImsDutyRecEntity::getDutyId, entity.getId()); +// }}); +// ImsDutyMainEntity carryMainentity = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ +// eq(ImsDutyMainEntity::getPreDutyId, entity.getPreDutyId()); +// }}); +// ImsDutyGroupEntity carryGroupEntity = imsDutyGroupService.getById(carryMainentity.getDutyGroupId()); +// if (ObjectUtil.isEmpty(one)) {//未发起交班流程 判断是否提醒交班 +// Long differMinute = DateUtils.getDifferMinute(calculateDate(entity, classEntity, OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal())); +// if (differMinute == -OperationalConstants.MessageRecTypeEnum.HAND_REC_MESSAGE.getVal()) { // 提醒交班 +// remondingHead(req, OperationalConstants.RecTypeEnum.HAND_REMIND.getVal(), groupEntity.getManagerId(), groupEntity.getTenantId(), groupEntity.getCreateDept(), groupEntity.getCreateUser()); +// } else if (differMinute == OperationalConstants.MessageRecTypeEnum.DELAYED_HAND_REC_MESSAGE.getVal()) {//延时交班提醒 +// //提醒站长 接班人 交班人 +// User admin = userClient.userByAccount(entity.getTenantId(), "admin").getData(); +// remondingStation(req, admin, userName, classEntity);//提醒站长 +// remondingCarry(req, OperationalConstants.RecTypeEnum.HAND_DELAY.getVal(), carryGroupEntity.getManagerId(), userName, classEntity, null, carryGroupEntity.getTenantId(), carryGroupEntity.getCreateDept(), carryGroupEntity.getCreateUser());//提醒接班人 +// remondingHead(req, OperationalConstants.RecTypeEnum.HAND_DELAY.getVal(), groupEntity.getManagerId(), groupEntity.getTenantId(), groupEntity.getCreateDept(), groupEntity.getCreateUser());//提醒交班人 +// } +// } else {//已发起接班流程 判断是否提醒接班 +// ImsDutyClassEntity carryClassEntity = imsDutyClassService.getById(carryMainentity.getClassId()); +// Long differMinute = DateUtils.getDifferMinute(calculateDate(carryMainentity, carryClassEntity, OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal())); +// if (differMinute > 0 && one.getDelayStatus() == 0) { +// ImsDutyGroupEntity groupEntity1 = imsDutyGroupService.getById(carryMainentity.getDutyGroupId()); +// //提醒站长 接班人 交班人 +// User admin = userClient.userByAccount(entity.getTenantId(), "admin").getData(); +// remondingStation(req, admin, groupEntity1.getManagerId().toString(), classEntity);//提醒站长 +// remondingCarry(req, 2, carryGroupEntity.getManagerId(), groupEntity1.getManagerId().toString(), classEntity, null, groupEntity1.getTenantId(), groupEntity1.getCreateDept(), groupEntity1.getCreateUser());//提醒接班人 +// } +// } +// } +// } +// } +// } +// } + + /** + * 消息提醒 + * 相较于上一个版本,大体逻辑没变,只改了推送消息的方式。调用黄兴接口 + */ + @Override + public void messageRemondingV2() { + List list = imsDutyMainService.list(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getStatus, JoinStatus.DUTY_ING.getStatus()); + }}); + if (CollectionUtil.isNotEmpty(list)) { + for (ImsDutyMainEntity entity : list) { + Long groupEntityManagerId; + if (entity.getDutyGroupId() != null) { + ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(entity.getDutyGroupId()); + groupEntityManagerId = groupEntity.getManagerId(); + } else { + List imsDutyMainPersonEntities = imsDutyMainPersonService.selectByMainId(entity.getId()); + groupEntityManagerId = imsDutyMainPersonEntities.get(0).getDutyChargePerson(); + } + ImsDutyClassEntity classEntity = imsDutyClassService.getById(entity.getClassId()); + if (ObjectUtil.isNotEmpty(groupEntityManagerId) && ObjectUtil.isNotEmpty(classEntity)) { + String userName = ""; + if (null != groupEntityManagerId) { + userName = userClient.userInfoById(groupEntityManagerId).getData().getName(); + } + PushExtrasReq req = new PushExtrasReq(); + if (null != entity.getPreDutyId()) { + ImsDutyRecEntity one = this.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyRecEntity::getDutyId, entity.getId()); + }}); + ImsDutyMainEntity carryMainentity = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getPreDutyId, entity.getPreDutyId()); + }}); + Long carryManagerId; + String carryTenantId; + Long carryCreateDept; + if (carryMainentity.getDutyGroupId() == null) { + List imsDutyMainPersonEntities = imsDutyMainPersonService.selectByMainId(carryMainentity.getId()); + carryManagerId = imsDutyMainPersonEntities.get(0).getDutyChargePerson(); + carryTenantId = imsDutyMainPersonEntities.get(0).getTenantId(); + carryCreateDept = imsDutyMainPersonEntities.get(0).getCreateDept(); + } else { + ImsDutyGroupEntity carryGroupEntity = imsDutyGroupService.getById(carryMainentity.getDutyGroupId()); + carryManagerId = carryGroupEntity.getManagerId(); + carryTenantId = carryGroupEntity.getTenantId(); + carryCreateDept = carryGroupEntity.getCreateDept(); + } + R user = userClient.userInfoById(carryManagerId); + if (ObjectUtil.isEmpty(one)) {//未发起交班流程 判断是否提醒交班 + Long differMinute = DateUtils.getDifferMinute(calculateDate(entity, classEntity, OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal())); + if (differMinute == -OperationalConstants.MessageRecTypeEnum.HAND_REC_MESSAGE.getVal()) { // 提醒交班 + remondingHeadV2(OperationalConstants.RecTypeEnum.HAND_REMIND.getVal(), groupEntityManagerId, userName, entity.getTenantId(), entity.getCreateDept(), entity.getId(), entity.getCreateUser()); + } else if (differMinute == OperationalConstants.MessageRecTypeEnum.DELAYED_HAND_REC_MESSAGE.getVal()) {//延时交班提醒 + //提醒站长 接班人 交班人 + User admin = userClient.userByAccount(entity.getTenantId(), "admin").getData(); + remondingStationV2(admin, userName, classEntity, carryMainentity.getTenantId(), carryMainentity.getId(), carryMainentity.getCreateDept(), carryMainentity.getCreateUser());//提醒站长 + remondingCarryV2(OperationalConstants.RecTypeEnum.HAND_DELAY.getVal(), carryManagerId, userName, classEntity, null, carryTenantId, carryCreateDept, carryMainentity.getId(), carryMainentity.getCreateUser());//提醒接班人 + remondingHeadV2(OperationalConstants.RecTypeEnum.HAND_DELAY.getVal(), groupEntityManagerId, userName, entity.getTenantId(), entity.getCreateDept(), entity.getId(), entity.getCreateUser());//提醒交班人 + } + } else {//已发起接班流程 判断是否提醒接班 + ImsDutyClassEntity carryClassEntity = imsDutyClassService.getById(carryMainentity.getClassId()); + Long differMinute = DateUtils.getDifferMinute(calculateDate(carryMainentity, carryClassEntity, OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal())); + if (differMinute > 0 && one.getDelayStatus() == 0) { + //提醒站长 接班人 交班人 + User admin = userClient.userByAccount(entity.getTenantId(), "admin").getData(); + remondingStationV2(admin, admin.getName(), classEntity, carryMainentity.getTenantId(), carryMainentity.getId(), carryMainentity.getCreateDept(), carryMainentity.getCreateUser());//提醒站长 + remondingCarryV2(2, carryManagerId, user.getData().getName(), classEntity, null, carryTenantId, carryCreateDept, carryMainentity.getId(), carryMainentity.getCreateUser());//提醒接班人 + } + } + } + } + } + } + } + + @Override + public void messageRemondingTest() { + PushExtrasReq req = new PushExtrasReq(); + User admin = userClient.userByAccount(AuthUtil.getTenantId(), "admin").getData(); + ImsDutyClassEntity classEntity = imsDutyClassService.getById("1417744967255752705"); + remondingStation(req, admin, "1380746947515691009", classEntity);//提醒站长 + } + + /** + * 修改值班状态 + * + * @return + */ + @Override + public R doUpdate(String date, Long id) { + ImsDutyMainEntity entity = new ImsDutyMainEntity(); + entity.setId(id); + entity.setDutyDate(DateUtil.parse(date, DateUtil.PATTERN_DATE)); + String format1 = DateUtil.format(new Date(), DateUtil.PATTERN_DATE); + Date dutyDate = entity.getDutyDate(); + Date parse = DateUtil.parse(format1, DateUtil.PATTERN_DATE); + if (dutyDate.getTime() > parse.getTime()) { + return R.fail("值班时间不能大于当前时间"); + } + ImsDutyMainEntity mainEntityById = imsDutyMainService.getById(id); + + //获取当前值班 + ImsDutyMainEntity mainEntity = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getStatus, DutyMainStatus.EXEC.getVal()); + eq(ImsDutyMainEntity::getCreateDept, mainEntityById.getCreateDept()); + }}); + + + List idList = new ArrayList<>(); + boolean bool = true; + ImsDutyMainEntity dutyMainEntity = new ImsDutyMainEntity(); + dutyMainEntity.setPreDutyId(id); + while (bool) { + ImsDutyMainEntity imsDutyMainServiceOne = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getDutyDate, date); + eq(ImsDutyMainEntity::getPreDutyId, Long.valueOf(dutyMainEntity.getPreDutyId())); + ne(ImsDutyMainEntity::getStatus, "-1"); + eq(ImsDutyMainEntity::getCreateDept, mainEntityById.getCreateDept()); + }}); + + if (ObjectUtil.isEmpty(imsDutyMainServiceOne)) { + bool = false; + } + if (bool) { + dutyMainEntity.setPreDutyId(imsDutyMainServiceOne.getId()); + idList.add(imsDutyMainServiceOne.getId()); + } + } + + ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(mainEntityById.getDutyGroupId()); + if (ObjectUtil.isNotEmpty(groupEntity)) { + if (null == groupEntity.getManagerId()) { + return R.fail("该指定班组中的班组长不存在,请添加班组长后进行指定!"); + } + //判断班组长是否存在 + R userR = userClient.userInfoById(groupEntity.getManagerId()); + ImsDutyGroupPEntity groupPEntity = imsDutyGroupPService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyGroupPEntity::getGroupId, groupEntity.getId()); + eq(ImsDutyGroupPEntity::getPersonId, groupEntity.getManagerId()).last(" LIMIT 1"); + }}); + + if (!userR.isSuccess() || ObjectUtil.isEmpty(userR.getData()) || ObjectUtil.isEmpty(groupPEntity)) { + return R.fail("该指定班组中的班组长不存在,请添加班组长后进行指定!"); + } + } + + + if (ObjectUtil.isNotEmpty(mainEntity)) { + List list = imsDutyMainService.list(new LambdaQueryWrapper() {{ + ge(ImsDutyMainEntity::getDutyDate, mainEntity.getDutyDate()); + le(ImsDutyMainEntity::getDutyDate, entity.getDutyDate()); + ne(ImsDutyMainEntity::getStatus, DutyMainStatus.ACCEPT.getVal()); + ne(ImsDutyMainEntity::getStatus, "-1"); + eq(ImsDutyMainEntity::getCreateDept, mainEntityById.getCreateDept()); + idList.add(id); + if (CollectionUtil.isNotEmpty(idList)) { + for (Long id : idList) { + ne(ImsDutyMainEntity::getId, id); + } + } + }}); + if (CollectionUtil.isNotEmpty(list)) { + for (ImsDutyMainEntity imsDutyMainEntity : list) { + ImsDutyMainEntity mainEntity1 = new ImsDutyMainEntity(); + ImsDutyRecEntity recEntity = this.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyRecEntity::getDutyId, imsDutyMainEntity.getId()); + eq(ImsDutyRecEntity::getCreateDept, mainEntityById.getCreateDept()); + }}); + if (ObjectUtil.isNotEmpty(recEntity)) { + flowClient.delProcessInstanceById(recEntity.getProcessInstanceId(), "交接班-异常数据处理"); + recEntity.setStatus(DutyRecStatus.ANOMALY.getVal()); + recEntity.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.CARRY_DELAY_STATUS.getStatus()); + this.updateById(recEntity); + } else { + ImsDutyRecEntity imsDutyRecEntity = new ImsDutyRecEntity(); + imsDutyRecEntity.setDutyId(imsDutyMainEntity.getId()); + imsDutyRecEntity.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus()); + imsDutyRecEntity.setStatus(DutyRecStatus.ANOMALY.getVal()); + + this.save(imsDutyRecEntity); + } + mainEntity1.setId(imsDutyMainEntity.getId()); + mainEntity1.setStatus(DutyMainStatus.ACCEPT.getVal()); + mainEntity1.setCreateDept(mainEntityById.getCreateDept()); + imsDutyMainService.updateById(mainEntity1); + } + } + } + entity.setStatus(DutyMainStatus.EXEC.getVal()); + entity.setCreateDept(mainEntityById.getCreateDept()); + return R.status(imsDutyMainService.updateById(entity)); + } + + + /** + * 分钟 + */ + private String minutlDateTest(Date date, int i) {//减多少分钟 + String reStr = ""; + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//"yyyy-MM-dd HH:mm:ss" + Calendar rightNow = Calendar.getInstance(); + rightNow.setTime(date); + rightNow.add(Calendar.MINUTE, i); + Date dt1 = rightNow.getTime(); + reStr = sdf.format(dt1); + } catch (Exception e) { + e.printStackTrace(); + } + return reStr; + } + + + /** + * 判断延时接班 + */ + @Override + public void judgeDelayedCarry(ImsDutyMainEntity entity, ImsDutyRecEntity recEntity) { + ImsDutyClassEntity classEntity = imsDutyClassService.getById(entity.getClassId()); + Long differMinute = DateUtils.getDifferMinute(calculateDate(entity, classEntity, OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal())); + ImsDutyRecEntity recEntity1 = new ImsDutyRecEntity(); + if (differMinute > 30) { + recEntity1.setId(recEntity.getId()); + if (recEntity.getDelayStatus() == DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus()) { + recEntity1.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.REC_DELAY_STATUS.getStatus());//赋值延时状态 为3 交接班延时 + } else { + recEntity1.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.CARRY_DELAY_STATUS.getStatus());//赋值延时状态 为2 接班延时 + } + recEntity1.setQrCodeContent(System.currentTimeMillis() + ""); + this.baseMapper.updateById(recEntity1); + } + } + + /** + * 判断延时交班 + */ + @Override + public void judgeDelayedHand(ImsDutyMainEntity handDutyMainEntity, ImsDutyRecEntity recEntity) { + ImsDutyClassEntity classEntity = imsDutyClassService.getById(handDutyMainEntity.getClassId()); + Long differMinute = DateUtils.getDifferMinute(calculateDate(handDutyMainEntity, classEntity, OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal())); + log.info("-------------------------延迟:" + differMinute + " 分钟"); + if (differMinute > 0) { + ImsDutyRecEntity entity = new ImsDutyRecEntity(); + entity.setId(recEntity.getId()); + entity.setDelayStatus(DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus());//赋值延时状态 为1 交班延时 + this.baseMapper.updateById(entity); + } + } + + @Override + public String calculateDate(ImsDutyMainEntity dutyMainEntity, ImsDutyClassEntity classEntity, int type) { + Boolean preBool = false; + Boolean bool = false; + String strDate = ""; + String preDate = ""; + String format = ""; + String time = ""; + String preTime = ""; + + if (type == OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal()) { + time = classEntity.getEndTime() + ""; + } else if (type == OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()) { + time = classEntity.getStartTime() + ""; + } + + format = DateUtil.format(dutyMainEntity.getDutyDate(), DateUtil.PATTERN_DATE) + " " + time; + strDate = format; + Date parse = DateUtil.parse(format, DateUtil.PATTERN_DATETIME); + + + ImsDutyMainEntity imsDutyMainServiceOne1 = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ + orderByAsc(ImsDutyMainEntity::getId); + eq(ImsDutyMainEntity::getCreateDept, AuthUtil.getDeptId()); + eq(ImsDutyMainEntity::getDutyDate, DateUtil.format(dutyMainEntity.getDutyDate(), DateUtil.PATTERN_DATE)).last(" limit 1"); + }}); + + + if (ObjectUtil.isNotEmpty(imsDutyMainServiceOne1)) { + if (!dutyMainEntity.getId().equals(imsDutyMainServiceOne1.getId())) { + ImsDutyClassEntity dutyClassEntity = imsDutyClassService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyClassEntity::getId, imsDutyMainServiceOne1.getClassId()); + }}); + if (type == OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal()) { + preTime = dutyClassEntity.getEndTime() + ""; + } else if (type == OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()) { + preTime = dutyClassEntity.getStartTime() + ""; + } + preDate = DateUtil.format(imsDutyMainServiceOne1.getDutyDate(), DateUtil.PATTERN_DATE) + " " + preTime; + Date preParse = DateUtil.parse(preDate, DateUtil.PATTERN_DATETIME); + if (preParse.getTime() > parse.getTime()) { + bool = true; + strDate = calculateDutyDate(parse); + } + } + } + + if (bool == false) { + ImsDutyMainEntity imsDutyMainServiceOne = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getId, dutyMainEntity.getPreDutyId()); + }}); + if (ObjectUtil.isNotEmpty(imsDutyMainServiceOne)) { + if (dutyMainEntity.getDutyDate().getTime() == imsDutyMainServiceOne.getDutyDate().getTime()) { + ImsDutyClassEntity one = imsDutyClassService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyClassEntity::getId, imsDutyMainServiceOne.getClassId()); + }}); + if (ObjectUtil.isNotEmpty(one)) { + preBool = true; + if (type == OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal()) { + preTime = one.getEndTime() + ""; + } else if (type == OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()) { + preTime = one.getStartTime() + ""; + } + preDate = DateUtil.format(imsDutyMainServiceOne.getDutyDate(), DateUtil.PATTERN_DATE) + " " + preTime; + } + } + } + } + + + if (preBool) { + Date preParse = DateUtil.parse(preDate, DateUtil.PATTERN_DATETIME); + if (preParse.getTime() > parse.getTime()) { + strDate = calculateDutyDate(parse); + } + } + return strDate; + } + + @Override + public List getRecInfoByDepts(List depts, String date) { + return this.baseMapper.selectRecInfoByDepts(depts, date); + } + + @Override + public R delProcessInstanceIds(String processInstanceIds) { + String[] split = processInstanceIds.split(","); + for (String processInstanceId : split) { + flowClient.delProcessInstanceById(processInstanceId, "交接班-异常数据处理"); + } + return R.success("操作成功"); + } + + + /** + * 天数加1 + * + * @param date + * @return + */ + private String calculateDutyDate(Date date) { + Calendar c = Calendar.getInstance(); + c.setTime(date); + c.add(Calendar.DAY_OF_MONTH, 1); + date = c.getTime(); + return DateUtil.format(date, DateUtil.PATTERN_DATETIME); + } + + /** + * 消息提醒站长 + */ + private void remondingStation(PushExtrasReq req, User admin, String userName, ImsDutyClassEntity + classEntity) { + req.setTitle("交接班"); + req.setType(DutyRecProcessConstant.MESSAGE_CLASS_TYPE_DUTY_REC); + req.setBusinessClassify(OperationalConstants.MessageClassifyEnum.MESSAGE_REMINDSY.getVal()); + req.setPushAlert(userName + " 负责人 值班日期为:(" + classEntity.getStartTime() + "-" + classEntity.getEndTime() + ") 目前已交班延迟,请尽快联系该负责人进行交班工作"); + messagePushClient.sendMessage(admin.getId().toString(), req, admin.getTenantId(), admin.getCreateDept(), admin.getCreateUser()); + } + + /** + * 消息提醒站长 + */ + private void remondingStationV2(User admin, String userName, ImsDutyClassEntity + classEntity, String tenantId, Long taskId, Long createDept, Long createUser) { + MessagePushRecordDto messagePushRecordDto = new MessagePushRecordDto(); + messagePushRecordDto.setBusinessClassify("dailyRemind"); + messagePushRecordDto.setBusinessKey(MessageConstants.BusinessClassifyEnum.DUTY.getKey()); + messagePushRecordDto.setSubject(MessageConstants.BusinessClassifyEnum.DUTY.getDescription()); + messagePushRecordDto.setTaskId(taskId); + messagePushRecordDto.setTenantId(tenantId); + messagePushRecordDto.setPusher(admin.getId().toString()); + messagePushRecordDto.setPusherName(userName); + messagePushRecordDto.setAccount(admin.getId().toString()); + messagePushRecordDto.setContent(userName + " 负责人 值班日期为:(" + classEntity.getStartTime() + + "-" + classEntity.getEndTime() + ") 目前已交班延迟,请尽快联系该负责人进行交班工作"); + messagePushRecordDto.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); + messagePushRecordDto.setPushType(MessageConstants.IMMEDIATELY); + messagePushRecordDto.setDeptId(Long.valueOf(admin.getDeptId())); + R deptName = sysClient.getDeptName(Long.valueOf(admin.getDeptId())); + if (deptName.isSuccess()) { + messagePushRecordDto.setDeptName(deptName.getData()); + } + messagePushRecordDto.setCreateDept(createDept); + messagePushRecordDto.setCreateUser(createUser); + R booleanR = messageClient.sendMessage(messagePushRecordDto); + System.out.println(booleanR.toString()); + } + + /** + * 消息提醒交班人 + */ + private void remondingHead(PushExtrasReq req, int type, Long managerId, String tenantId, Long createDept, Long createUser) { + req.setTitle("交接班"); + req.setType(DutyRecProcessConstant.MESSAGE_CLASS_TYPE_DUTY_REC); + req.setBusinessClassify(DutyRecProcessConstant.MESSAGE_CLASS_DAY); + if (type == OperationalConstants.RecTypeEnum.HAND_REMIND.getVal()) { + req.setPushAlert("您距离本次值班结束时间只剩 15 分钟,请尽快进行交班工作"); + } else if (type == OperationalConstants.RecTypeEnum.HAND_DELAY.getVal()) { + req.setPushAlert("您已交班延迟,请尽快进行交班工作"); + + } + messagePushClient.sendMessage(managerId.toString(), req, tenantId, createDept, createUser); + } + + /** + * 消息提醒交班人 + */ + private void remondingHeadV2(int type, Long managerId, String userName, String tenantId, Long createDept, Long taskId, Long createUser) { + MessagePushRecordDto messagePushRecordDto = new MessagePushRecordDto(); + messagePushRecordDto.setBusinessClassify("dailyRemind"); + messagePushRecordDto.setBusinessKey(MessageConstants.BusinessClassifyEnum.DUTY.getKey()); + messagePushRecordDto.setSubject(MessageConstants.BusinessClassifyEnum.DUTY.getDescription()); + messagePushRecordDto.setTaskId(taskId); + messagePushRecordDto.setTenantId(tenantId); + messagePushRecordDto.setPusher(managerId.toString()); + messagePushRecordDto.setPusherName(userName); + messagePushRecordDto.setAccount(managerId.toString()); + if (type == OperationalConstants.RecTypeEnum.HAND_REMIND.getVal()) { + messagePushRecordDto.setContent("您距离本次值班结束时间只剩 15 分钟,请尽快进行交班工作"); + } else if (type == OperationalConstants.RecTypeEnum.HAND_DELAY.getVal()) { + messagePushRecordDto.setContent("您已交班延迟,请尽快进行交班工作"); + } + messagePushRecordDto.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); + messagePushRecordDto.setDeptId(createDept); + messagePushRecordDto.setPushType(MessageConstants.IMMEDIATELY); + R deptName = sysClient.getDeptName(createDept); + messagePushRecordDto.setDeptName(deptName.getData()); + messagePushRecordDto.setCreateDept(createDept); + messagePushRecordDto.setCreateUser(createUser); + messageClient.sendMessage(messagePushRecordDto); + } + + /** + * 消息提醒接班人 启用 + */ + private void remondingCarry(PushExtrasReq req, int type, Long managerId, String userName, ImsDutyClassEntity + classEntity, String date, String tenantId, Long createDept, Long createUser) { + req.setTitle("交接班"); + req.setType(DutyRecProcessConstant.MESSAGE_CLASS_TYPE_DUTY_REC); + req.setBusinessClassify(DutyRecProcessConstant.MESSAGE_CLASS_DAY); + if (type == OperationalConstants.RecTypeEnum.HAND_REMIND.getVal()) { + req.setPushAlert(userName + " 于 " + date + " 时已提交交班工作"); + } else if (type == OperationalConstants.RecTypeEnum.HAND_DELAY.getVal()) { + req.setPushAlert(userName + " 值班日期为(" + classEntity.getStartTime() + " - " + classEntity.getEndTime() + "),目前已延迟交班"); + } else if (type == OperationalConstants.RecTypeEnum.REMIND_HAND_PERSON.getVal()) { + req.setPushAlert("您已交班延迟,请尽快进行交班工作"); + } + messagePushClient.sendMessage(managerId.toString(), req, tenantId, createDept, createUser); + } + + /** + * 消息提醒接班人 + */ + private void remondingCarryV2(int type, Long managerId, String userName, ImsDutyClassEntity + classEntity, String date, String tenantId, Long createDept, Long taskId, Long createUser) { + MessagePushRecordDto messagePushRecordDto = new MessagePushRecordDto(); + messagePushRecordDto.setBusinessClassify("dailyRemind"); + messagePushRecordDto.setBusinessKey(MessageConstants.BusinessClassifyEnum.DUTY.getKey()); + messagePushRecordDto.setSubject(MessageConstants.BusinessClassifyEnum.DUTY.getDescription()); + messagePushRecordDto.setTaskId(taskId); + messagePushRecordDto.setTenantId(tenantId); + messagePushRecordDto.setPusher(managerId.toString()); + messagePushRecordDto.setPusherName(userName); + messagePushRecordDto.setAccount(managerId.toString()); + if (type == OperationalConstants.RecTypeEnum.HAND_REMIND.getVal()) { + messagePushRecordDto.setContent(userName + " 于 " + date + " 时已提交交班工作"); + } else if (type == OperationalConstants.RecTypeEnum.HAND_DELAY.getVal()) { + messagePushRecordDto.setContent(userName + " 值班日期为(" + classEntity.getStartTime() + " - " + classEntity.getEndTime() + "),目前已延迟交班"); + } else if (type == OperationalConstants.RecTypeEnum.REMIND_HAND_PERSON.getVal()) { + messagePushRecordDto.setContent("您已交班延迟,请尽快进行交班工作"); + } + messagePushRecordDto.setPushType(MessageConstants.IMMEDIATELY); + messagePushRecordDto.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); + messagePushRecordDto.setDeptId(createDept); + R deptName = sysClient.getDeptName(createDept); + messagePushRecordDto.setDeptName(deptName.getData()); + messagePushRecordDto.setCreateDept(createDept); + messagePushRecordDto.setCreateUser(createUser); + R booleanR = messageClient.sendMessage(messagePushRecordDto); + System.out.println(booleanR.toString()); + } + + //新增巡检计划 获取巡检任务ID + public Long getInspectTaskId(PlanVO vo, Long princId) { + vo.setName(DateUtil.format(new Date(), "yyyy-MM-dd HH") + "-交接班巡视"); + vo.setMethod(DutyRecProcessConstant.INSPECT_PANL_METHOD); + vo.setAutoVideo(DutyRecProcessConstant.INSPECT_PANL_AUTO_VIDEO); + vo.setCycle(DutyRecProcessConstant.INSPECT_PANL_AUTO_CYCLE); + Date date = new Date(); + Date startDate = minutlDate(date, 5); + Date endDate = hrDate(date, 2); + LocalDate startTime = LocalDate.parse(DateUtil.format(startDate, DateUtil.PATTERN_DATE), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + LocalDate endTime = LocalDate.parse(DateUtil.format(endDate, DateUtil.PATTERN_DATE), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + vo.setStartTime(startTime); + vo.setEndTime(endTime); + vo.setType(DutyRecProcessConstant.INSPECT_PANL_TYPE); + vo.setTaskTimesADay(DutyRecProcessConstant.INSPECT_PANL_TASK_TIMES_A_DAY); + vo.setStartRemind(DutyRecProcessConstant.INSPECT_PANL_START_REMIND); + vo.setEndRemind(DutyRecProcessConstant.INSPECT_PANL_END_REMIND); + String execStartTime = DateUtil.format(startDate, DateUtil.PATTERN_TIME); + String execEndTime = DateUtil.format(endDate, DateUtil.PATTERN_TIME); + List> listMap = new ArrayList<>(); + Map map = new HashMap<>(); + map.put("execStartTime", execStartTime); + map.put("execEndTime", execEndTime); + listMap.add(map); + vo.setExecTimeJson(JSONObject.toJSONString(listMap)); + List list = new ArrayList<>(); + list.add(princId); + vo.setPlanType("common"); + vo.setPlanUsers(list); + R> listR = inspectPlanClient.addPlanAndChecked(vo); + List data = listR.getData(); + if (CollectionUtil.isNotEmpty(data)) { + return data.get(0); + } + return null; + } + + + /** + * 小时 + */ + private Date hrDate(Date date, int i) {//减多少小时 + Calendar rightNow = Calendar.getInstance(); + rightNow.setTime(date); + rightNow.add(Calendar.HOUR, i); + Date dt1 = rightNow.getTime(); + return dt1; + } + + + /** + * 分钟 + */ + private Date minutlDate(Date date, int i) {//减多少分钟 + Calendar rightNow = Calendar.getInstance(); + rightNow.setTime(date); + rightNow.add(Calendar.MINUTE, i); + Date dt1 = rightNow.getTime(); + return dt1; + } + + @Override + public R batchUpdateTest() { + + List imsDutyRecTestVos = this.baseMapper.selectTest(); + for (ImsDutyRecTestVo imsDutyRecTestVo : imsDutyRecTestVos) { + ImsDutyRecEntity entity = new ImsDutyRecEntity(); + entity.setId(imsDutyRecTestVo.getId()); + entity.setCreateUser(imsDutyRecTestVo.getManagerId()); + String startTime = imsDutyRecTestVo.getDutyDate() + " " + imsDutyRecTestVo.getEndTime(); + entity.setExecTime(DateUtil.parse(startTime, DateUtil.PATTERN_DATETIME)); + String endTime = minutlDateTest(DateUtil.parse(startTime, DateUtil.PATTERN_DATETIME), 10); + entity.setAcceptTime(DateUtil.parse(endTime, DateUtil.PATTERN_DATETIME)); + this.baseMapper.updateById(entity); + } + + return R.success("操作成功"); + } + + @Override + public String testClassDate(Long id, Integer type) { + ImsDutyMainEntity imsDutyMainEntity = imsDutyMainService.getById(id); + ImsDutyClassEntity classEntity = imsDutyClassService.getById(imsDutyMainEntity.getClassId()); + Long differMinute = DateUtils.getDifferMinute(calculateDate(imsDutyMainEntity, classEntity, type)); + return calculateDate(imsDutyMainEntity, classEntity, type) + "-分钟:" + differMinute; + } + + + /** + * 交接班统计 + * + * @param param + * @return + */ + @Override + public ChangeShiftsRspDTO getChangeShifts(ChangeShiftsReqDTO param) { + ChangeShiftsRspDTO response = new ChangeShiftsRspDTO(); + response.setShiftsCount(0); + response.setShiftsRate(0.0); + if (ObjectUtil.isEmpty(param)) { + return response; + } + // 查询交接班记录 + QueryWrapper queryWrapper = new QueryWrapper() {{ + if (Optional.ofNullable(param.getCreateDept()).isPresent()) { + eq("create_dept", param.getCreateDept()); + } + if (Optional.ofNullable(param.getStartTime()).isPresent()) { + gt("exec_time", param.getStartTime()); + } + if (Optional.ofNullable(param.getEndTime()).isPresent()) { + lt("exec_time", param.getEndTime()); + } + }}; + List list = this.baseMapper.selectList(queryWrapper); + if (CollectionUtil.isEmpty(list)) { + return response; + } + // 交接班次数 + response.setShiftsCount(list.size()); + List normal = list.stream().filter(o -> DutyContants.DutyRecDelayStatusEnum.WIT_DELAY_STATUS.getStatus() == o.getDelayStatus()).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(normal)) { + return response; + } + // 交接班正常率 + double shiftsRate = BigDecimal.valueOf((double) normal.size() / list.size() * 100L).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + response.setShiftsRate(shiftsRate); + return response; + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java index 574821d..1904404 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java @@ -1,8 +1,6 @@ package com.hnac.hzims.operational.main.controller.web; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; @@ -33,9 +31,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.support.BladePage; -import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.SpringQueryMap; @@ -132,10 +128,10 @@ public class AreaMonthlyDetailsController { /** - * 根据区域和月份分页查询日志维护列表 + * 根据区域和月份分页查询日常维护列表 */ @ApiOperationSupport(order = 100) - @ApiOperation(value = "根据区域和月份分页查询日志维护列表") + @ApiOperation(value = "根据区域和月份分页查询日常维护列表") @GetMapping("/queryLogMaintenancePageList/{page}/{size}") public R> queryLogMaintenancePageList( @ApiParam(name = "page", value = "当前页", required = true) @PathVariable("page") Long page, @@ -148,11 +144,11 @@ public class AreaMonthlyDetailsController { /** - * 根据区域和月份分页查询日志维护 根据id获取详情 + * 根据区域和月份分页查询日常维护 根据id获取详情 */ @GetMapping("/queryLogMaintenancePageList/detail/{id}") @ApiOperationSupport(order = 40) - @ApiOperation(value = "根据区域和月份分页查询日志维护 根据id获取详情") + @ApiOperation(value = "根据区域和月份分页查询日常维护 根据id获取详情") public R detail(@PathVariable Long id) { return taskService.detail(id); } @@ -163,8 +159,14 @@ public class AreaMonthlyDetailsController { */ @ApiOperationSupport(order = 50) @ApiOperation(value = "根据区域和月份分页查询巡检任务") - @GetMapping("/queryCheckTaskPageList") - public R> queryCheckTaskPageList(TaskListQuery task, Query query) { + @GetMapping("/queryCheckTaskPageList/{page}/{size}") + public R> queryCheckTaskPageList( + @ApiParam(name = "page", value = "当前页", required = true) @PathVariable("page") Long page, + @ApiParam(name = "size", value = "每页记录数", required = true) @PathVariable("size") Long size, + TaskListQuery task) { + Query query = new Query(); + query.setCurrent(page.intValue()); + query.setSize(size.intValue()); BladePage taskVoIPage = areaMonthlyDetailsService.queryCheckTaskPageList(task, query); return R.data(taskVoIPage); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainStatisticsServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainStatisticsServiceImpl.java index 500a342..7a7070e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainStatisticsServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainStatisticsServiceImpl.java @@ -16,10 +16,8 @@ import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.duty.entity.ImsDutyClassEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyGroupEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; -import com.hnac.hzims.operational.duty.service.IImsDutyClassService; -import com.hnac.hzims.operational.duty.service.IImsDutyGroupService; -import com.hnac.hzims.operational.duty.service.IImsDutyMainService; -import com.hnac.hzims.operational.duty.service.IImsDutyRecService; +import com.hnac.hzims.operational.duty.entity.ImsDutyMainPersonEntity; +import com.hnac.hzims.operational.duty.service.*; import com.hnac.hzims.operational.main.service.IMainStatisticsService; import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant; @@ -30,21 +28,15 @@ import com.hnac.hzinfo.inspect.task.entity.TaskEntity; import com.hnac.hzinfo.inspect.task.feign.IInspectTaskReportClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections4.CollectionUtils; -import org.springblade.core.secure.BladeUser; -import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; -import org.springblade.system.cache.DictCache; import org.springblade.system.entity.Dict; import org.springblade.system.feign.IDictClient; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; -import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -64,6 +56,7 @@ public class MainStatisticsServiceImpl implements IMainStatisticsService { private final IOperDefectStatisticsService operDefectStatisticsService; private final IImsDutyClassService iImsDutyClassService; private final IDictClient dictClient; + private final IImsDutyMainPersonService imsDutyMainPersonService; @Override @@ -85,13 +78,21 @@ public class MainStatisticsServiceImpl implements IMainStatisticsService { DutyStatisticsVO dutyStatisticsVo = new DutyStatisticsVO(); if(imsDutyMainEntity != null){ dutyStatisticsVo = BeanUtil.copy(imsDutyMainEntity, DutyStatisticsVO.class); - //完善负责人信息 - ImsDutyGroupEntity imsDutyGroupEntity = imsDutyGroupService.getById(dutyStatisticsVo.getDutyGroupId()); - if(imsDutyGroupEntity != null){ - dutyStatisticsVo.setGroupName(imsDutyGroupEntity.getGroupName()); - - User managerUser = UserCache.getUser(imsDutyGroupEntity.getManagerId()); - dutyStatisticsVo.setManager(managerUser); + if (dutyStatisticsVo.getDutyGroupId()!=null) { + //完善负责人信息 + ImsDutyGroupEntity imsDutyGroupEntity = imsDutyGroupService.getById(dutyStatisticsVo.getDutyGroupId()); + if (imsDutyGroupEntity != null) { + dutyStatisticsVo.setGroupName(imsDutyGroupEntity.getGroupName()); + User managerUser = UserCache.getUser(imsDutyGroupEntity.getManagerId()); + dutyStatisticsVo.setManager(managerUser); + } + }else { + List imsDutyMainPersonEntities = imsDutyMainPersonService.selectByMainId(dutyStatisticsVo.getId()); + dutyStatisticsVo.setGroupName("灵活排班"); + if (CollectionUtil.isNotEmpty(imsDutyMainPersonEntities)) { + User managerUser = UserCache.getUser(imsDutyMainPersonEntities.get(0).getDutyChargePerson()); + dutyStatisticsVo.setManager(managerUser); + } } String dutyPersonIds = dutyStatisticsVo.getDutyPersonIds(); int num = 0; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java index f243cc1..6229c71 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java @@ -162,6 +162,7 @@ public class MaintenanceTaskCreateTask { return; } } + BeanUtil.copyProperties(planEntity, taskEntity); taskService.save(taskEntity); //生成工作流实例 String processInstanceId = this.startProcessInstance(planEntity.getProcDefId(), taskEntity); @@ -169,6 +170,9 @@ public class MaintenanceTaskCreateTask { taskService.updateById(taskEntity); planEntity.setCreateTaskTime(DateUtil.now()); planMapper.updateById(planEntity); + + taskEntity = taskService.getById(taskEntity.getId()); + //taskEntity.setMessageTemplateId(1646694238095732738L); this.pushTaskMessage(taskEntity); } @@ -207,7 +211,7 @@ public class MaintenanceTaskCreateTask { XxlJobLogger.log("开始保存{}的日常维护消息推送记录",taskEntity.getDisposer()); R templateR = messageClient.getMsgTemplateById(taskEntity.getMessageTemplateId()); if(templateR.isSuccess() && ObjectUtil.isNotEmpty(templateR.getData())) { - Func.toLongList("",taskEntity.getDisposer()).forEach(userId -> { + Func.toLongList(",",taskEntity.getDisposer()).forEach(userId -> { // MessagePushRecordDto recordDto = BeanUtil.copy(templateR.getData(),MessagePushRecordDto.class); // recordDto.setTypes(Arrays.asList(Func.split(recordDto.getType(),","))); // recordDto.setDeptId(taskEntity.getCreateDept()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java index 19c19d7..56ce66b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java @@ -341,7 +341,8 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl queryLogMaintenancePageList(Page pageParam, MaintenanceTaskWithAreaVo areaMonthlyVo) { + public IPage + queryLogMaintenancePageList(Page pageParam, MaintenanceTaskWithAreaVo areaMonthlyVo) { //1.根据区域查询 QueryWrapper queryWrapper = new QueryWrapper<>(); //维护内容 diff --git a/hzims-service/operational/src/main/resources/db/1.0.1.sql b/hzims-service/operational/src/main/resources/db/1.0.1.sql index 0ab54ec..1beb842 100644 --- a/hzims-service/operational/src/main/resources/db/1.0.1.sql +++ b/hzims-service/operational/src/main/resources/db/1.0.1.sql @@ -3,4 +3,10 @@ alter table hzims_oper_maintenance_library add COLUMN `MESSAGE_TEMPLATE_ID` bigi -- 日常维护计划添加消息模板ID alter table hzims_oper_maintenance_plan add COLUMN `MESSAGE_TEMPLATE_ID` bigint(20) comment '消息推送模板ID'; -- 日常维护任务添加消息模板ID -alter table hzims_oper_maintenance_task add COLUMN `MESSAGE_TEMPLATE_ID` bigint(20) comment '消息推送模板ID'; \ No newline at end of file +alter table hzims_oper_maintenance_task add COLUMN `MESSAGE_TEMPLATE_ID` bigint(20) comment '消息推送模板ID'; +-- 日常维护库设备库编码长度修改 +alter table hzims_oper_maintenance_library MODIFY COLUMN `em_code` VARCHAR(50) comment '设备编码'; +-- 日常维护库设备计划编码长度修改 +alter table hzims_oper_maintenance_plan MODIFY COLUMN `em_code` VARCHAR(50) comment '设备编码'; +-- 日常维护库设备任务编码长度修改 +alter table hzims_oper_maintenance_task MODIFY COLUMN `em_code` VARCHAR(50) comment '设备编码'; \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/template/serviceimpl/MaintenanceTempleServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/template/serviceimpl/MaintenanceTempleServiceImpl.java index 9c1cce3..44420af 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/template/serviceimpl/MaintenanceTempleServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/template/serviceimpl/MaintenanceTempleServiceImpl.java @@ -5,6 +5,8 @@ import com.hnac.hzims.message.dto.PlanMsgRecordDto; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.safeproduct.template.abstracts.TemplateAbstractService; import com.qiniu.util.Json; +import org.apache.commons.lang3.StringUtils; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springframework.stereotype.Service; @@ -16,6 +18,7 @@ import java.util.Optional; /** * 日常维护计划 + * * @Author WL * @Version v1.0 * @Serial 1.0 @@ -25,7 +28,6 @@ import java.util.Optional; public class MaintenanceTempleServiceImpl extends TemplateAbstractService { - /** * 执行具体的业务场景,推送消息 * @@ -33,23 +35,23 @@ public class MaintenanceTempleServiceImpl extends TemplateAbstractService { */ @Override public PlanMsgRecordDto executeTemplateMessage(PlanMsgRecordDto planMsgRecord) { - Map map = new HashMap<>(); - map.put("one", - Optional.ofNullable(UserCache.getUser(planMsgRecord.getReceiver())).map(User::getName).orElse("")); + Map map = new HashMap<>(); + map.put("one", Optional.ofNullable(UserCache.getUser(planMsgRecord.getReceiver())).map(User::getName).orElse("")); map.put("two", planMsgRecord.getPlanTime()); planMsgRecord.setContent(JSON.toJSONString(map)); + planMsgRecord.setResourceCode("aliyun-safeTool-push"); return planMsgRecord; } /** * 模板状态 + * * @param status */ @Override public Boolean isTemplateStatus(int status) { - return Objects.equals(status,1); + return Objects.equals(status, 1); } - } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java index 7e44bfa..af1d2bc 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java @@ -123,6 +123,7 @@ public class StandardTicketInfoController extends BladeController { @SpringQueryMap StandardTicketWithAreaVo areaMonthlyVo) { Page searchPage = new Page<>(page, size); + BladePage standardTicketInfoEntity = standardTicketInfoService.areaMonthlyWithOperation(areaMonthlyVo, searchPage); return R.data(standardTicketInfoEntity); 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 94c55ef..164a40c 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 @@ -56,7 +56,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { Map params = new HashMap(2) {{ put("taskId", "1644624168666353665"); - put("signUserIds", AuthUtil.getUserId()); + put("signUserIds", "1377143375838359553"); }}; flowClient.startProcessInstanceContainNameByKey( @@ -64,12 +64,16 @@ public class TicketProcessServiceImpl implements TicketProcessService { "开启工作的任务", params); - R> listR = flowClient.todoList(processDefinitionKey); - listR.getData().forEach(taskList -> { - System.out.println("任务名称:"+taskList); - System.out.println(taskList.getTaskName()); - System.out.println(taskList.getStatus()); - }); + // R> listR = flowClient.todoList(processDefinitionKey); + // listR.getData().forEach(taskList -> { + // System.out.println("任务名称:"+taskList); + // System.out.println(taskList.getTaskName()); + // System.out.println(taskList.getStatus()); + // }); + + + // flowClient.completeTask() + } }