| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | |
| | | private DeviceMapper deviceMapper; |
| | | |
| | | private EnumServiceImpl enumService; |
| | | |
| | | private UserMapper userMapper; |
| | | |
| | | private StructureItemParameterMapper structureItemParameterMapper; |
| | | |
| | | @Autowired |
| | | private DataConfigService dataConfigService; |
| | | |
| | | private QrShowServiceImpl qrShowService; |
| | | |
| | | private InsSampleMapper insSampleMapper; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Device selectDeviceByCode(String code) { |
| | | return deviceMapper.selectOne(Wrappers.<Device>lambdaQuery().eq(Device::getFactoryNo, code).last("limit 1")); |
| | | public Device selectDeviceByCode(Integer id) { |
| | | DeviceDto deviceDto = deviceMapper.selectDeviceByCode(id); |
| | | List<Integer> ids = new ArrayList<>(); |
| | | if (Strings.isNotEmpty(deviceDto.getAuthorizedPerson())) { |
| | | if (deviceDto.getAuthorizedPerson().equals("null")) { |
| | | deviceDto.setAuthorizedPerson("[]"); |
| | | } |
| | | ids = JSON.parseArray(deviceDto.getAuthorizedPerson(), Integer.class); |
| | | } |
| | | String name = ""; |
| | | if (!ids.isEmpty()) { |
| | | name = userMapper.selectBatchIds(ids).stream().map(User::getName).collect(Collectors.joining(",")); |
| | | } |
| | | deviceDto.setAuthorizedPersonName(name); |
| | | //查询设备校准信息 |
| | | DeviceMetricRecord calibrate = qrShowService.getDeviceMetricRecord(id, "calibrate"); |
| | | //deviceDto.setCalibrationDate(qrShowService.formatDate(calibrate.getCalibrationDate(),"yyyy-MM-dd")); |
| | | deviceDto.setCalibrateNo(calibrate.getCertificateSerialNumber()); |
| | | |
| | | // 到了停用日期,自动将状态改为停用 |
| | | if (deviceDto.getNextCalibrationDate() != null) { |
| | | if (LocalDateTime.now().isAfter(deviceDto.getNextCalibrationDate())) { |
| | | List<Enums> enums = enumService.selectEnumByCategory("设备状态"); |
| | | List<Enums> status = enums.stream().filter(item -> item.getLabel().equals("停用")).collect(Collectors.toList()); |
| | | deviceDto.setDeviceStatus(Integer.parseInt(status.get(0).getValue())); |
| | | deviceMapper.updateById(deviceDto); |
| | | } |
| | | } |
| | | return deviceDto; |
| | | } |
| | | |
| | | @Override |