| | |
| | | import enumeration.general.WorkOrderDistributeWayEnum; |
| | | import enumeration.general.WorkOrderStatusEnum; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | * @author xp |
| | | * @since 2024-03-05 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder> implements WorkOrderService { |
| | |
| | | private RedisCache redisCache; |
| | | |
| | | @Override |
| | | public Result innerAdd(WorkOrder workOrder) throws Exception { |
| | | if (! StringUtils.hasText(workOrder.getSerialNumber())) { |
| | | throw new Exception("创建工单时,请传递设备编码"); |
| | | } |
| | | if (Objects.isNull(workOrder.getStatus())) { |
| | | throw new Exception("创建工单时,请传递工单状态"); |
| | | } |
| | | if (! StringUtils.hasText(workOrder.getErrorType())) { |
| | | throw new Exception("创建工单时,请传递异常类型"); |
| | | } |
| | | workOrder.setWorkOrderNo(IdUtils.timeAddRandomNO(5)); |
| | | workOrder.setCreateTime(DateUtils.getNowDate()); |
| | | baseMapper.insert(workOrder); |
| | | return Result.ok(); |
| | | public Boolean innerAdd(List<WorkOrder> workOrderList) { |
| | | int total = workOrderList.size(); |
| | | workOrderList.stream().filter(item -> { |
| | | return StringUtils.hasText(item.getSerialNumber()) && Objects.nonNull(item.getStatus()) && StringUtils.hasText(item.getErrorType()); |
| | | }); |
| | | int real = workOrderList.size(); |
| | | boolean result = this.saveBatch(workOrderList); |
| | | log.info("传入工单总数: {},实际添加工单数:{}", total, real); |
| | | return result; |
| | | } |
| | | |
| | | /** |