Browse Source

#巡检打卡功能开发

zhongwei
yang_shj 1 week ago
parent
commit
5475b7a444
  1. 30
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/ClockInRequestDTO.java
  2. 19
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/ClockInResponseDTO.java
  3. 6
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/PlanContants.java
  4. 62
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/ClockInEntity.java
  5. 2
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java
  6. 44
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/ClockInController.java
  7. 19
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/EventController.java
  8. 43
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/impl/ConcurrentTaskServcie.java
  9. 14
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.java
  10. 5
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.xml
  11. 22
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/IClockInService.java
  12. 76
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/ClockInServiceImpl.java
  13. 17
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java
  14. 44
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java
  15. 26
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/ClockInEventVO.java
  16. 21
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/wrapper/ClockInWrapper.java

30
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/ClockInRequestDTO.java

@ -0,0 +1,30 @@
package com.hnac.hzinfo.inspect.ai.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author ysj
*/
@Data
@ApiModel(value = "巡检打卡分页请求参数", description = "巡检打卡分页请求参数")
public class ClockInRequestDTO implements Serializable {
private static final long serialVersionUID = 8445346022067680992L;
@ApiModelProperty(value = "打卡人")
private Long clockPerson;
@ApiModelProperty(value = "打卡状态: 0-未打卡 1-打卡完成")
private Integer status;
@ApiModelProperty(value = "打卡开始时间 : yyyy-MM-dd HH:mm:ss")
private String startTime;
@ApiModelProperty(value = "打卡结束时间 : yyyy-MM-dd HH:mm:ss")
private String endTime;
}

19
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/ClockInResponseDTO.java

@ -0,0 +1,19 @@
package com.hnac.hzinfo.inspect.ai.vo;
import com.hnac.hzinfo.inspect.task.entity.ClockInEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author ysj
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "巡检打卡分页查询响应对象", description = "巡检打卡分页查询响应对象")
public class ClockInResponseDTO extends ClockInEntity {
private static final long serialVersionUID = 8445346022067680992L;
}

6
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/PlanContants.java

@ -157,7 +157,11 @@ public interface PlanContants {
/** /**
* 2机器人巡检 * 2机器人巡检
*/ */
ROBOT("2"); ROBOT("2"),
/**
* 3打卡巡检
*/
CLOCKIN("3");
private final String val; private final String val;
InspectTypeEnum(String val){ InspectTypeEnum(String val){
this.val = val; this.val = val;

62
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/ClockInEntity.java

@ -0,0 +1,62 @@
package com.hnac.hzinfo.inspect.task.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.Date;
/**
* @author ysj
*/
@Data
@TableName("hz_st_ex_clock_in")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "巡检打卡对象")
public class ClockInEntity extends TenantEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "巡检任务ID")
private Long taskId;
@ApiModelProperty(value = "巡检对象Id")
private Long objectId;
@ApiModelProperty(value = "计划打卡开始时间")
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
private LocalDateTime planStartTime;
@ApiModelProperty(value = "计划打卡结束时间")
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
private LocalDateTime planEndTime;
@ApiModelProperty(value = "打卡人")
private Long clockPerson;
@ApiModelProperty(value = "打卡时间")
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
private LocalDateTime clockTime;
}

2
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java

@ -143,7 +143,7 @@ public class TaskEntity extends TenantEntity {
/** /**
* 巡检类型标识 0普通巡检1视频自动巡检2机器人巡检 * 巡检类型标识 0普通巡检1视频自动巡检2机器人巡检
*/ */
@ApiModelProperty(value = "巡检类型标识: 0普通巡检,1视频自动巡检,2机器人巡检") @ApiModelProperty(value = "巡检类型标识: 0普通巡检,1视频自动巡检,2机器人巡检 3打卡巡检")
@QueryField(condition = SqlCondition.EQUAL) @QueryField(condition = SqlCondition.EQUAL)
private String autoVideo; private String autoVideo;

44
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/ClockInController.java

@ -0,0 +1,44 @@
package com.hnac.hzinfo.inspect.task.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
import com.hnac.hzims.common.logs.enums.BusinessType;
import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzinfo.inspect.Constants;
import com.hnac.hzinfo.inspect.ai.vo.ClockInRequestDTO;
import com.hnac.hzinfo.inspect.ai.vo.ClockInResponseDTO;
import com.hnac.hzinfo.inspect.task.service.IClockInService;
import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ysj
*/
@RestController
@AllArgsConstructor
@RequestMapping("/clockIn")
@Api(value = "巡检打卡", tags = "巡检打卡")
@Business(module = Constants.APP_NAME,value = "巡检任务管理")
public class ClockInController extends BladeController {
private final IClockInService clockInService;
@GetMapping("/page")
@ApiOperationSupport(order = 4)
@OperationAnnotation(moduleName = "巡检打卡",
title = "打卡记录",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,
action = "分页查询打卡记录")
@ApiOperation(value = "分页")
public R<IPage<ClockInResponseDTO>> list(ClockInRequestDTO param, Query query) {
return R.data(clockInService.pageCondition(param, query));
}
}

19
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/EventController.java

@ -19,10 +19,7 @@ import com.hnac.hzinfo.inspect.task.service.IEventAttachmentService;
import com.hnac.hzinfo.inspect.task.service.IEventRecordService; import com.hnac.hzinfo.inspect.task.service.IEventRecordService;
import com.hnac.hzinfo.inspect.task.service.IEventService; import com.hnac.hzinfo.inspect.task.service.IEventService;
import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService; import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService;
import com.hnac.hzinfo.inspect.task.vo.EventAddVO; import com.hnac.hzinfo.inspect.task.vo.*;
import com.hnac.hzinfo.inspect.task.vo.EventDetailVO;
import com.hnac.hzinfo.inspect.task.vo.EventRecordDetailVO;
import com.hnac.hzinfo.inspect.task.vo.ProblemVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -32,6 +29,7 @@ import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springblade.flow.core.constant.ProcessConstant; import org.springblade.flow.core.constant.ProcessConstant;
@ -154,4 +152,17 @@ public class EventController{
public R<Boolean> addTaskEvent(@RequestBody EventAddVO event){ public R<Boolean> addTaskEvent(@RequestBody EventAddVO event){
return R.status(eventService.addTaskEvent(event)); return R.status(eventService.addTaskEvent(event));
} }
@PostMapping("/clockInTaskEvent")
@ApiOperation(value = "打卡登记", notes = "传入eventId")
public R<Boolean> clockInTaskEvent(@RequestBody ClockInEventVO clockInEvent){
if(CollectionUtil.isEmpty(clockInEvent.getEvents())){
return R.status(false);
}
clockInEvent.getEvents().forEach(item->{
item.setDescription("打卡确认");
eventService.addTaskEvent(item);
});
return R.status(true);
}
} }

43
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/impl/ConcurrentTaskServcie.java

@ -10,19 +10,19 @@ import com.hnac.hzinfo.inspect.plan.PlanContants;
import com.hnac.hzinfo.inspect.plan.entity.PlanEntity; import com.hnac.hzinfo.inspect.plan.entity.PlanEntity;
import com.hnac.hzinfo.inspect.plan.entity.PlanUserEntity; import com.hnac.hzinfo.inspect.plan.entity.PlanUserEntity;
import com.hnac.hzinfo.inspect.plan.service.IPlanService; import com.hnac.hzinfo.inspect.plan.service.IPlanService;
import com.hnac.hzinfo.inspect.task.entity.TaskEntity; import com.hnac.hzinfo.inspect.task.entity.*;
import com.hnac.hzinfo.inspect.task.entity.TaskResultEntity;
import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity;
import com.hnac.hzinfo.inspect.task.job.service.ITaskJobService; import com.hnac.hzinfo.inspect.task.job.service.ITaskJobService;
import com.hnac.hzinfo.inspect.task.job.service.TaskJobService; import com.hnac.hzinfo.inspect.task.job.service.TaskJobService;
import com.hnac.hzinfo.inspect.task.job.service.TaskRemindManager; import com.hnac.hzinfo.inspect.task.job.service.TaskRemindManager;
import com.hnac.hzinfo.inspect.task.job.service.TaskVideoManager; import com.hnac.hzinfo.inspect.task.job.service.TaskVideoManager;
import com.hnac.hzinfo.inspect.task.service.IClockInService;
import com.hnac.hzinfo.inspect.task.service.ITaskResultService; import com.hnac.hzinfo.inspect.task.service.ITaskResultService;
import com.hnac.hzinfo.inspect.task.service.ITaskUserService; import com.hnac.hzinfo.inspect.task.service.ITaskUserService;
import com.xxl.job.core.log.XxlJobLogger; import com.xxl.job.core.log.XxlJobLogger;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -32,6 +32,7 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 并发任务派发 * 并发任务派发
@ -55,6 +56,8 @@ public class ConcurrentTaskServcie extends TaskJobService implements ITaskJobSer
private IPlanService planService; private IPlanService planService;
@Autowired @Autowired
private IDutyMainClient dutyMainClient; private IDutyMainClient dutyMainClient;
@Autowired
private IClockInService clockInService;
/** /**
* 派发任务 * 派发任务
@ -94,6 +97,10 @@ public class ConcurrentTaskServcie extends TaskJobService implements ITaskJobSer
} }
taskUserList.add(this.getTaskUser(user.getUserId(), task.getId(), plan.getTenantId())); taskUserList.add(this.getTaskUser(user.getUserId(), task.getId(), plan.getTenantId()));
String reason = distributeTaskObjs(plan, task); String reason = distributeTaskObjs(plan, task);
// 生成打卡记录
this.generateCheckIn(task,user.getUserId());
if (reason.equals(StringUtils.EMPTY)) { if (reason.equals(StringUtils.EMPTY)) {
reason = defaultReason; reason = defaultReason;
} }
@ -118,6 +125,36 @@ public class ConcurrentTaskServcie extends TaskJobService implements ITaskJobSer
} }
/** /**
* 打卡模式巡检生成打卡记录
* @param task
*/
private void generateCheckIn(TaskEntity task,Long userId) {
// 非打卡巡检模式
if(!PlanContants.InspectTypeEnum.CLOCKIN.getVal().equals(task.getAutoVideo())){
return;
}
// 查询巡检对象列表
List<TaskObjectEntity> objects = clockInService.pendingObjects(task.getId());
if(CollectionUtil.isEmpty(objects)){
return;
}
clockInService.saveBatch(objects.stream().map(object->{
ClockInEntity clock = new ClockInEntity();
clock.setCreateDept(object.getCreateDept());
clock.setCreateUser(object.getCreateUser());
clock.setUpdateUser(object.getCreateUser());
clock.setTenantId(object.getTenantId());
clock.setTaskId(task.getId());
clock.setObjectId(object.getId());
clock.setPlanStartTime(task.getPlanStartTime());
clock.setPlanEndTime(task.getPlanEndTime());
clock.setClockPerson(userId);
clock.setStatus(0);
return clock;
}).collect(Collectors.toList()));
}
/**
* 巡检计划为班次时生成任务 * 巡检计划为班次时生成任务
*/ */
@Override @Override

14
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.java

@ -0,0 +1,14 @@
package com.hnac.hzinfo.inspect.task.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzinfo.inspect.task.entity.ClockInEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @author ysj
*/
@Mapper
public interface ClockInMapper extends BaseMapper<ClockInEntity> {
}

5
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.hnac.hzinfo.inspect.task.mapper.ClockInMapper">
</mapper>

22
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/IClockInService.java

@ -0,0 +1,22 @@
package com.hnac.hzinfo.inspect.task.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzinfo.inspect.ai.vo.ClockInRequestDTO;
import com.hnac.hzinfo.inspect.ai.vo.ClockInResponseDTO;
import com.hnac.hzinfo.inspect.task.entity.ClockInEntity;
import com.hnac.hzinfo.inspect.task.entity.TaskObjectEntity;
import org.springblade.core.mp.support.Query;
import java.util.List;
/**
* @author ysj
*/
public interface IClockInService extends IService<ClockInEntity> {
IPage<ClockInResponseDTO> pageCondition(ClockInRequestDTO param, Query query);
List<TaskObjectEntity> pendingObjects(Long taskId);
}

76
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/ClockInServiceImpl.java

@ -0,0 +1,76 @@
package com.hnac.hzinfo.inspect.task.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzinfo.inspect.ai.vo.ClockInRequestDTO;
import com.hnac.hzinfo.inspect.ai.vo.ClockInResponseDTO;
import com.hnac.hzinfo.inspect.task.entity.ClockInEntity;
import com.hnac.hzinfo.inspect.task.entity.TaskObjectEntity;
import com.hnac.hzinfo.inspect.task.mapper.ClockInMapper;
import com.hnac.hzinfo.inspect.task.service.IClockInService;
import com.hnac.hzinfo.inspect.task.service.ITaskObjectService;
import com.hnac.hzinfo.inspect.task.wrapper.ClockInWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author ysj
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class ClockInServiceImpl extends ServiceImpl<ClockInMapper, ClockInEntity> implements IClockInService {
private final ITaskObjectService objectService;
/**
* 分页查看打卡记录
* @param param
* @param query
* @return
*/
@Override
public IPage<ClockInResponseDTO> pageCondition(ClockInRequestDTO param, Query query) {
QueryWrapper<ClockInEntity> queryWrapper = new QueryWrapper<ClockInEntity>() {{
if(ObjectUtil.isNotEmpty(param.getClockPerson())){
eq("CLOCK_PERSON",param.getClockPerson());
}
if(ObjectUtil.isNotEmpty(param.getStatus())){
eq("STATUS",param.getStatus());
}
if(StringUtils.isNotEmpty(param.getStartTime())){
ge("PLAN_START_TIME",param.getStartTime());
}
if(StringUtils.isNotEmpty(param.getEndTime())){
le("PLAN_END_TIME",param.getEndTime());
}
}};
IPage pages = super.page(Condition.getPage(query), queryWrapper);
List list = ClockInWrapper.build().listVO(pages.getRecords());
return pages.setRecords(list);
}
/**
* 待生成打卡记录巡检对象
* @param id
* @return
*/
@Override
public List<TaskObjectEntity> pendingObjects(Long taskId) {
if(ObjectUtil.isEmpty(taskId)){
return new ArrayList<>();
}
return objectService.list(Wrappers.<TaskObjectEntity>lambdaQuery()
.eq(TaskObjectEntity::getTaskId,taskId));
}
}

17
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java

@ -27,6 +27,7 @@ import org.springblade.core.tool.api.R;
import org.springblade.core.tool.support.Kv; import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.SpringUtil; import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.flow.core.constant.ProcessConstant; import org.springblade.flow.core.constant.ProcessConstant;
import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.entity.BladeFlow;
@ -56,6 +57,8 @@ public class EventServiceImpl extends ServiceImpl<TaskEventMapper, EventEntity>
@Autowired @Autowired
private ITaskObjectService taskObjectService; private ITaskObjectService taskObjectService;
@Autowired @Autowired
private IClockInService clockInService;
@Autowired
private ITaskObjectProjectContentService taskObjectProjectContentService; private ITaskObjectProjectContentService taskObjectProjectContentService;
@Autowired @Autowired
private IFlowClient flowClient; private IFlowClient flowClient;
@ -373,6 +376,20 @@ public class EventServiceImpl extends ServiceImpl<TaskEventMapper, EventEntity>
.set(TaskObjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus()) .set(TaskObjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus())
.eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId()) .eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId())
.eq(TaskObjectEntity::getObjectId, eventAddVO.getObjId())); .eq(TaskObjectEntity::getObjectId, eventAddVO.getObjId()));
// 更新打卡状态为已完成
ClockInEntity clock = clockInService.getOne(Wrappers.<ClockInEntity>lambdaQuery()
.eq(ClockInEntity::getTaskId, eventAddVO.getTaskId())
.eq(ClockInEntity::getObjectId, eventAddVO.getObjId())
);
if(ObjectUtil.isEmpty(clock)){
return;
}
clockInService.update(Wrappers.<ClockInEntity>lambdaUpdate()
.set(ClockInEntity::getClockTime,LocalDateTime.now())
.set(ClockInEntity::getStatus,1)
.eq(ClockInEntity::getId, clock.getId())
);
} }

44
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java

@ -80,6 +80,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, TaskEntity> impleme
@Autowired @Autowired
private ITaskUserService taskUserService; private ITaskUserService taskUserService;
@Autowired @Autowired
private IClockInService clockInService;
@Autowired
private ITaskObjectProjectService taskObjectProjectService; private ITaskObjectProjectService taskObjectProjectService;
@Autowired @Autowired
private ITaskObjectProjectContentService taskObjectProjectContentService; private ITaskObjectProjectContentService taskObjectProjectContentService;
@ -251,12 +253,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, TaskEntity> impleme
} }
} }
//给当前人领取任务 // 给当前人领取任务
taskUserService.update(Wrappers.<TaskUserEntity>lambdaUpdate().set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).set(TaskUserEntity::getClaimTime, LocalDateTime.now()).eq(TaskUserEntity::getTaskId, task.getId()).eq(TaskUserEntity::getUserId, AuthUtil.getUserId())); taskUserService.update(Wrappers.<TaskUserEntity>lambdaUpdate().set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).set(TaskUserEntity::getClaimTime, LocalDateTime.now()).eq(TaskUserEntity::getTaskId, task.getId()).eq(TaskUserEntity::getUserId, AuthUtil.getUserId()));
//如果是抢占任务,删除能够抢占此任务的其他人 // 如果是抢占任务,删除能够抢占此任务的其他人
if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) {
taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).ne(TaskUserEntity::getUserId, AuthUtil.getUserId())); taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).ne(TaskUserEntity::getUserId, AuthUtil.getUserId()));
} }
// 生成打卡记录
this.generateCheckIn(task,AuthUtil.getUserId());
// 更新巡检领用状态
task.setStatus(Integer.valueOf(TaskStatusEnum.UNDERWAY_STATUS.getStatus())); task.setStatus(Integer.valueOf(TaskStatusEnum.UNDERWAY_STATUS.getStatus()));
task.setStartTime(LocalDateTime.now()); task.setStartTime(LocalDateTime.now());
boolean re = this.updateById(task); boolean re = this.updateById(task);
@ -264,6 +269,41 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, TaskEntity> impleme
return re; return re;
} }
/**
* 打卡模式巡检生成打卡记录
* @param task
*/
private void generateCheckIn(TaskEntity task,Long userId) {
// 非打卡巡检模式
if(!PlanContants.InspectTypeEnum.CLOCKIN.getVal().equals(task.getAutoVideo())){
return;
}
// 非抢占模式
if(!PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())){
return;
}
// 查询巡检对象列表
List<TaskObjectEntity> objects = clockInService.pendingObjects(task.getId());
if(CollectionUtil.isEmpty(objects)){
return;
}
clockInService.saveBatch(objects.stream().map(object->{
ClockInEntity clock = new ClockInEntity();
clock.setCreateDept(object.getCreateDept());
clock.setCreateUser(object.getCreateUser());
clock.setUpdateUser(object.getCreateUser());
clock.setTenantId(object.getTenantId());
clock.setTaskId(task.getId());
clock.setObjectId(object.getId());
clock.setPlanStartTime(task.getPlanStartTime());
clock.setPlanEndTime(task.getEndTime());
clock.setClockPerson(userId);
clock.setStatus(0);
return clock;
}).collect(Collectors.toList()));
}
/** /**
* 检查任务 * 检查任务
*/ */

26
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/ClockInEventVO.java

@ -0,0 +1,26 @@
/**
*
*/
package com.hnac.hzinfo.inspect.task.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.List;
/**
* @author ysj
*/
@ApiModel
@Getter
@Setter
public class ClockInEventVO implements Serializable{
private static final long serialVersionUID = -904847315218750903L;
@ApiModelProperty(value = "巡检巡检集合")
private List<EventAddVO> events;
}

21
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/wrapper/ClockInWrapper.java

@ -0,0 +1,21 @@
package com.hnac.hzinfo.inspect.task.wrapper;
import com.hnac.hzinfo.inspect.ai.vo.ClockInResponseDTO;
import com.hnac.hzinfo.inspect.task.entity.ClockInEntity;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
public class ClockInWrapper extends BaseEntityWrapper<ClockInEntity, ClockInResponseDTO> {
public static ClockInWrapper build() {
return new ClockInWrapper();
}
@Override
public ClockInResponseDTO entityVO(ClockInEntity entity) {
return BeanUtil.copy(entity, ClockInResponseDTO.class);
}
}
Loading…
Cancel
Save