| | |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.inspect.dto.InsProductBindingDto; |
| | | import com.ruoyi.inspect.dto.WriteInspectionConditionDto; |
| | | import com.ruoyi.inspect.mapper.InsOrderDeviceRecordMapper; |
| | | import com.ruoyi.inspect.mapper.InsOrderMapper; |
| | | import com.ruoyi.inspect.mapper.InsOrderStandardTemplateMapper; |
| | | import com.ruoyi.inspect.mapper.InsOrderTemplateDeviceMapper; |
| | | import com.ruoyi.inspect.mapper.InsProductMapper; |
| | | import com.ruoyi.inspect.mapper.InsSampleMapper; |
| | | import com.ruoyi.inspect.pojo.InsOrder; |
| | | import com.ruoyi.inspect.pojo.InsOrderDeviceRecord; |
| | | import com.ruoyi.inspect.pojo.InsOrderStandardTemplate; |
| | | import com.ruoyi.inspect.pojo.InsOrderTemplateDevice; |
| | | import com.ruoyi.inspect.pojo.InsProduct; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private InsOrderStandardTemplateMapper insOrderStandardTemplateMapper; |
| | | |
| | | private InsOrderTemplateDeviceMapper insOrderTemplateDeviceMapper; |
| | | |
| | | private InsOrderDeviceRecordMapper insOrderDeviceRecordMapper; |
| | | |
| | | @Override |
| | | public int selectOrderManDay(Integer orderId) { |
| | |
| | | if (!hasSnapshotField && !dto.isDeviceIdsPresent()) { |
| | | throw new ErrorException("没有需要保存的模板检验条件"); |
| | | } |
| | | refreshPendingDeviceRecords(dto); |
| | | return true; |
| | | } |
| | | InsOrder insOrder = new InsOrder(); |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 原始记录的环境条件后补时,同步到尚未填写的使用记录。 |
| | | * 已手工改动过的记录(已有开始日期)不覆盖。 |
| | | */ |
| | | private void refreshPendingDeviceRecords(WriteInspectionConditionDto dto) { |
| | | boolean hasTemperature = dto.isTemperaturePresent() |
| | | && dto.getTemperature() != null && !dto.getTemperature().trim().isEmpty(); |
| | | boolean hasDetectionRange = dto.isDetectionTimePresent() && dto.getDetectionTime() != null; |
| | | if (!hasTemperature && !hasDetectionRange) { |
| | | return; |
| | | } |
| | | List<Integer> deviceIds = insOrderTemplateDeviceMapper |
| | | .selectDeviceIdsByOrderAndTemplate(dto.getId(), dto.getTemplateId()); |
| | | if (deviceIds == null || deviceIds.isEmpty()) { |
| | | return; |
| | | } |
| | | LocalDateTime start = null; |
| | | LocalDateTime end = null; |
| | | if (hasDetectionRange) { |
| | | start = dto.getDetectionTime().atTime(10, 0); |
| | | LocalDate endDate = dto.getDetectionEndTime() != null ? dto.getDetectionEndTime() : dto.getDetectionTime(); |
| | | end = endDate.atTime(19, 30); |
| | | } |
| | | insOrderDeviceRecordMapper.update(null, Wrappers.<InsOrderDeviceRecord>lambdaUpdate() |
| | | .eq(InsOrderDeviceRecord::getInsOrderId, dto.getId()) |
| | | .in(InsOrderDeviceRecord::getDeviceId, deviceIds) |
| | | .isNull(InsOrderDeviceRecord::getUseStartDate) |
| | | .set(hasTemperature, InsOrderDeviceRecord::getTemperature, dto.getTemperature()) |
| | | .set(hasDetectionRange, InsOrderDeviceRecord::getUseStartDate, start) |
| | | .set(hasDetectionRange, InsOrderDeviceRecord::getUseEndDate, end)); |
| | | } |
| | | |
| | | //查询待检项目 |
| | | @Override |
| | | public IPage<InsProduct> selectNoProducts(Page page, InsProduct insProduct, Integer orderId, String ids) { |