| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.*; |
| | |
| | | import com.ruoyi.basic.pojo.*; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.basic.service.*; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int addStandardTree(StandardTree standardTree) { |
| | | |
| | | LambdaQueryWrapper<StandardTree> wrapper = Wrappers.<StandardTree>lambdaQuery() |
| | | .eq(StandardTree::getFactory, standardTree.getFactory()) |
| | | .eq(StandardTree::getLaboratory, standardTree.getLaboratory()) |
| | | .eq(StandardTree::getSampleType, standardTree.getSampleType()) |
| | | .eq(StandardTree::getSample, standardTree.getSample()) |
| | | .eq(StandardTree::getModel, standardTree.getModel()); |
| | | if (StringUtils.isNotBlank(standardTree.getSample())) { |
| | | wrapper.eq(StandardTree::getSample, standardTree.getSample()); |
| | | public int addStandardTree(ModelAddDto modelAddDto) { |
| | | // æ ¡éª |
| | | if(StringUtils.isEmpty(modelAddDto.getParentId())){ |
| | | throw new RuntimeException("缺å°ç¶å±çº§ç»å®å
³ç³»"); |
| | | } |
| | | |
| | | StandardTree tree = standardTreeMapper.selectOne(wrapper); |
| | | if (tree != null) { |
| | | throw new BaseException("该åå·å·²åå¨"); |
| | | Model model = new Model(); |
| | | String parentLevel = modelAddDto.getParentLevel(); |
| | | if(BasicTreeEnums.PRODUCT_TYPE.getCode().equals(parentLevel)){ |
| | | model.setProductId(Integer.valueOf(parentLevel)); |
| | | }else if(BasicTreeEnums.STRUCTURE_TEST_OBJECT_TYPE.getCode().equals(parentLevel)){ |
| | | model.setStructureTestObjectId(Integer.valueOf(parentLevel)); |
| | | }else { |
| | | throw new RuntimeException("åå·åªè½ç»å®å¯¹è±¡å产å"); |
| | | } |
| | | return standardTreeMapper.insert(standardTree); |
| | | // åç§°éè¯»æ§æ ¡éª |
| | | QueryWrapper<Model> modelQueryWrapper = new QueryWrapper<>(); |
| | | modelQueryWrapper.eq("product_id", model.getProductId()); |
| | | modelQueryWrapper.eq("structure_test_object_id", model.getStructureTestObjectId()); |
| | | modelQueryWrapper.eq("model_name", model.getModelName()); |
| | | Model modelResult = modelMapper.selectOne(modelQueryWrapper); |
| | | if(ObjectUtils.isNotEmpty(modelResult)){ |
| | | throw new RuntimeException("è¯·å¿æ·»å éå¤åå·"); |
| | | } |
| | | return modelMapper.insert(model); |
| | | } |
| | | |
| | | @Override |