XiaoRuby
2023-07-19 2d44844cafa096bd42391b8d2c2185f0bfbf2d79
standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/StandardsServiceImpl.java
@@ -1,14 +1,18 @@
package com.yuanchu.limslaboratory.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.limslaboratory.pojo.Standards;
import com.yuanchu.limslaboratory.mapper.StandardsMapper;
import com.yuanchu.limslaboratory.pojo.User;
import com.yuanchu.limslaboratory.service.SerialNumberService;
import com.yuanchu.limslaboratory.service.StandardsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.limslaboratory.service.UserService;
import com.yuanchu.limslaboratory.utils.MyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@@ -33,6 +37,10 @@
    @Autowired
    private UserService userService;
    @Lazy
    @Autowired
    private SerialNumberService serialNumberService;
    @Override
    public Integer addStandardsInformation(Standards standards) {
        Boolean userIsNull = userService.userIsNull(standards.getUserId());
@@ -43,8 +51,20 @@
    }
    @Override
    public List<Map<String, Object>>  listStandardsInformation(String IdOrNameOfStandards) {
        return standardsMapper.listStandardsInformation(IdOrNameOfStandards);
    public List<Map<String, Object>> listStandardsInformation() {
        LambdaQueryWrapper<Standards> wrapper = new LambdaQueryWrapper<>();
        wrapper.select(Standards::getId, Standards::getName);
        List<Map<String, Object>> maps = standardsMapper.selectMaps(wrapper);
        for (Map<String, Object> map : maps){
            String id = map.get("id").toString();
            List<Map<String, Object>> serialNumberList = serialNumberService.selectIdSerialNumberInformation(id);
            if (ObjectUtils.isEmpty(serialNumberList)){
                map.put("serialNumber", null);
            } else {
                map.put("serialNumber", serialNumberList);
            }
        }
        return maps;
    }
    @Override
@@ -54,4 +74,9 @@
        Standards standardsIsNull = standardsMapper.selectOne(wrapper);
        return !ObjectUtils.isEmpty(standardsIsNull);
    }
    @Override
    public IPage<Map<String, Object>> listPageStandardsInformation(Page<Object> page, String idOrNameOfStandards) {
        return standardsMapper.listPageStandardsInformation(page, idOrNameOfStandards);
    }
}