package com.gkhy.safePlatform.specialWork.service.impl; import cn.hutool.core.util.IdUtil; import com.gkhy.safePlatform.commons.co.ContextCacheUser; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.exception.BusinessException; import com.gkhy.safePlatform.specialWork.entity.WorkApplyRecordInfo; import com.gkhy.safePlatform.specialWork.enums.ProcessOperationEnum; import com.gkhy.safePlatform.specialWork.model.dto.resp.WorkApplyRecordRespDTO; import com.gkhy.safePlatform.specialWork.model.query.WorkApplyRecordListQuery; import com.gkhy.safePlatform.specialWork.model.query.db.WorkApplyRecordListDBQuery; import com.gkhy.safePlatform.specialWork.service.WorkApplyRecordService; import com.gkhy.safePlatform.specialWork.service.baseService.WorkApplyInfoService; import com.gkhy.safePlatform.specialWork.service.baseService.WorkApplyRecordInfoService; import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @Service("workApplyRecordService") public class WorkApplyRecordServiceImpl implements WorkApplyRecordService { @Autowired private WorkApplyRecordInfoService workApplyRecordInfoService; @Override public void log(ContextCacheUser user, ProcessOperationEnum operation, Long workApplyId, Long currentStepId, String stepName, String content) { WorkApplyRecordInfo record = new WorkApplyRecordInfo(); record.setWorkApplyId(workApplyId); record.setStepId(currentStepId); record.setStepName(stepName); record.setOperationTime(LocalDateTime.now()); record.setOperation(operation.code); record.setContent(content); record.setOperatorUid(user.getUid()); record.setOperatorUname(user.getRealName()); record.setSysten(Boolean.FALSE); workApplyRecordInfoService.save(record); } @Override // @Transactional(propagation = Propagation.NESTED) public void log(ProcessOperationEnum operation, Long workApplyId, Long currentStepId,String stepName, String content) { WorkApplyRecordInfo record = new WorkApplyRecordInfo(); record.setWorkApplyId(workApplyId); record.setStepId(currentStepId); record.setStepName(stepName); record.setOperationTime(LocalDateTime.now()); record.setOperation(operation.code); record.setContent(content); record.setSysten(Boolean.TRUE); workApplyRecordInfoService.save(record); } @Override public List list(ContextCacheUser currentUser, WorkApplyRecordListQuery query) { if (query.getWorkApplyId() == null) { throw new BusinessException(ResultCodes.CLIENT_PARAM_NULL); } WorkApplyRecordListDBQuery dbQuery = new WorkApplyRecordListDBQuery(); dbQuery.setOperatorName(query.getOperatorName()); dbQuery.setStepId(query.getStepId()); dbQuery.setWorkApplyId(query.getWorkApplyId()); dbQuery.setSystemEnable(query.isSystemEnable()); List dbData = workApplyRecordInfoService.listByConditions(dbQuery); List result = new ArrayList<>(dbData.size()); ProcessOperationEnum operationEnum; if (dbData.size() > 0) { WorkApplyRecordRespDTO respDTO; for (WorkApplyRecordInfo recordInfo : dbData) { respDTO = new WorkApplyRecordRespDTO(); respDTO.setId(recordInfo.getId()); respDTO.setWorkApplyId(recordInfo.getWorkApplyId()); respDTO.setStepId(recordInfo.getStepId()); respDTO.setStepName(recordInfo.getStepName()); respDTO.setOperatorUid(recordInfo.getOperatorUid()); respDTO.setOperatorUname(recordInfo.getOperatorUname()); respDTO.setOperationTime(recordInfo.getOperationTime()); respDTO.setSysten(recordInfo.getSysten()); respDTO.setOperation(recordInfo.getOperation()); operationEnum = ProcessOperationEnum.parse(recordInfo.getOperation()); if (operationEnum != null) { respDTO.setOperationDesc(operationEnum.value); } respDTO.setContent(recordInfo.getContent()); result.add(respDTO); } } return result; } }