diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/ClockInRequestDTO.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/ClockInRequestDTO.java new file mode 100644 index 0000000..aff5d32 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/ClockInResponseDTO.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/ClockInResponseDTO.java new file mode 100644 index 0000000..204e17d --- /dev/null +++ b/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; + +} \ No newline at end of file diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/PlanContants.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/PlanContants.java index 3ce1186..9ddae6d 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/PlanContants.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/PlanContants.java @@ -157,7 +157,11 @@ public interface PlanContants { /** * 2机器人巡检 */ - ROBOT("2"); + ROBOT("2"), + /** + * 3打卡巡检 + */ + CLOCKIN("3"); private final String val; InspectTypeEnum(String val){ this.val = val; diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/ClockInEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/ClockInEntity.java new file mode 100644 index 0000000..c631789 --- /dev/null +++ b/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; +} \ No newline at end of file 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 6cd2907..37b62bf 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 @@ -143,7 +143,7 @@ public class TaskEntity extends TenantEntity { /** * 巡检类型标识: 0普通巡检,1视频自动巡检,2机器人巡检 */ - @ApiModelProperty(value = "巡检类型标识: 0普通巡检,1视频自动巡检,2机器人巡检") + @ApiModelProperty(value = "巡检类型标识: 0普通巡检,1视频自动巡检,2机器人巡检 3打卡巡检") @QueryField(condition = SqlCondition.EQUAL) private String autoVideo; diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/ClockInController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/ClockInController.java new file mode 100644 index 0000000..42e26d9 --- /dev/null +++ b/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> list(ClockInRequestDTO param, Query query) { + return R.data(clockInService.pageCondition(param, query)); + } +} \ No newline at end of file diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/EventController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/EventController.java index 9f6eb1b..fa4594e 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/EventController.java +++ b/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.IEventService; import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService; -import com.hnac.hzinfo.inspect.task.vo.EventAddVO; -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 com.hnac.hzinfo.inspect.task.vo.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; 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.constant.BladeConstant; 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.StringUtil; import org.springblade.flow.core.constant.ProcessConstant; @@ -154,4 +152,17 @@ public class EventController{ public R addTaskEvent(@RequestBody EventAddVO event){ return R.status(eventService.addTaskEvent(event)); } + + @PostMapping("/clockInTaskEvent") + @ApiOperation(value = "打卡登记", notes = "传入eventId") + public R 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); + } } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/impl/ConcurrentTaskServcie.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/impl/ConcurrentTaskServcie.java index 8aeadfd..e7b1eb7 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/impl/ConcurrentTaskServcie.java +++ b/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.PlanUserEntity; import com.hnac.hzinfo.inspect.plan.service.IPlanService; -import com.hnac.hzinfo.inspect.task.entity.TaskEntity; -import com.hnac.hzinfo.inspect.task.entity.TaskResultEntity; -import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity; +import com.hnac.hzinfo.inspect.task.entity.*; 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.TaskRemindManager; 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.ITaskUserService; import com.xxl.job.core.log.XxlJobLogger; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -32,6 +32,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * 并发任务派发 @@ -55,6 +56,8 @@ public class ConcurrentTaskServcie extends TaskJobService implements ITaskJobSer private IPlanService planService; @Autowired 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())); String reason = distributeTaskObjs(plan, task); + + // 生成打卡记录 + this.generateCheckIn(task,user.getUserId()); + if (reason.equals(StringUtils.EMPTY)) { 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 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 diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.java new file mode 100644 index 0000000..3954988 --- /dev/null +++ b/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 { + +} \ No newline at end of file diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.xml b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.xml new file mode 100644 index 0000000..575ea7e --- /dev/null +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/IClockInService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/IClockInService.java new file mode 100644 index 0000000..4c9a065 --- /dev/null +++ b/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 { + + IPage pageCondition(ClockInRequestDTO param, Query query); + + List pendingObjects(Long taskId); +} \ No newline at end of file diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/ClockInServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/ClockInServiceImpl.java new file mode 100644 index 0000000..3dbd728 --- /dev/null +++ b/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 implements IClockInService { + + private final ITaskObjectService objectService; + + /** + * 分页查看打卡记录 + * @param param + * @param query + * @return + */ + @Override + public IPage pageCondition(ClockInRequestDTO param, Query query) { + QueryWrapper queryWrapper = new QueryWrapper() {{ + 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 pendingObjects(Long taskId) { + if(ObjectUtil.isEmpty(taskId)){ + return new ArrayList<>(); + } + return objectService.list(Wrappers.lambdaQuery() + .eq(TaskObjectEntity::getTaskId,taskId)); + } +} \ No newline at end of file diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java index 495e95e..4f07de3 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java +++ b/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.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.flow.core.constant.ProcessConstant; import org.springblade.flow.core.entity.BladeFlow; @@ -56,6 +57,8 @@ public class EventServiceImpl extends ServiceImpl @Autowired private ITaskObjectService taskObjectService; @Autowired + private IClockInService clockInService; + @Autowired private ITaskObjectProjectContentService taskObjectProjectContentService; @Autowired private IFlowClient flowClient; @@ -373,6 +376,20 @@ public class EventServiceImpl extends ServiceImpl .set(TaskObjectEntity::getStatus, TaskContants.StatusEnum.FINISH_STATUS.getStatus()) .eq(TaskObjectEntity::getTaskId, eventAddVO.getTaskId()) .eq(TaskObjectEntity::getObjectId, eventAddVO.getObjId())); + + // 更新打卡状态为已完成 + ClockInEntity clock = clockInService.getOne(Wrappers.lambdaQuery() + .eq(ClockInEntity::getTaskId, eventAddVO.getTaskId()) + .eq(ClockInEntity::getObjectId, eventAddVO.getObjId()) + ); + if(ObjectUtil.isEmpty(clock)){ + return; + } + clockInService.update(Wrappers.lambdaUpdate() + .set(ClockInEntity::getClockTime,LocalDateTime.now()) + .set(ClockInEntity::getStatus,1) + .eq(ClockInEntity::getId, clock.getId()) + ); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java index 24a5eaa..86e0ed5 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java @@ -80,6 +80,8 @@ public class TaskServiceImpl extends ServiceImpl impleme @Autowired private ITaskUserService taskUserService; @Autowired + private IClockInService clockInService; + @Autowired private ITaskObjectProjectService taskObjectProjectService; @Autowired private ITaskObjectProjectContentService taskObjectProjectContentService; @@ -251,12 +253,15 @@ public class TaskServiceImpl extends ServiceImpl impleme } } - //给当前人领取任务 + // 给当前人领取任务 taskUserService.update(Wrappers.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())) { taskUserService.remove(Wrappers.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.setStartTime(LocalDateTime.now()); boolean re = this.updateById(task); @@ -264,6 +269,41 @@ public class TaskServiceImpl extends ServiceImpl impleme 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 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())); + } + /** * 检查任务 */ diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/ClockInEventVO.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/ClockInEventVO.java new file mode 100644 index 0000000..1d68af8 --- /dev/null +++ b/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 events; +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/wrapper/ClockInWrapper.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/wrapper/ClockInWrapper.java new file mode 100644 index 0000000..cdee549 --- /dev/null +++ b/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 { + + public static ClockInWrapper build() { + return new ClockInWrapper(); + } + + @Override + public ClockInResponseDTO entityVO(ClockInEntity entity) { + + return BeanUtil.copy(entity, ClockInResponseDTO.class); + } + +}