package com.yuanchu.mom.service.impl; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.yuanchu.mom.mapper.StandardProductListMapper; import com.yuanchu.mom.pojo.StandardMethodList; import com.yuanchu.mom.pojo.StandardProductList; import com.yuanchu.mom.service.StandardMethodListService; import com.yuanchu.mom.mapper.StandardMethodListMapper; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author Administrator * @description 针对表【standard_method_list(标准树下的标准列表)】的数据库操作Service实现 * @createDate 2024-03-04 13:44:04 */ @Service @AllArgsConstructor public class StandardMethodListServiceImpl extends ServiceImpl implements StandardMethodListService{ private StandardMethodListMapper standardMethodListMapper; private StandardProductListMapper standardProductListMapper; @Override @Transactional(rollbackFor = Exception.class) public int addStandardMethodList(Integer standardId, String tree) { String[] trees = tree.split(" - "); Map map = standardMethodListMapper.selectStandardMethodById(standardId); StandardMethodList list = new StandardMethodList(); list.setCode(map.get("code")); list.setName(map.get("name")); list.setRemark(map.get("remark")); list.setFactory(trees[0]); try { list.setLaboratory(trees[1]); }catch (Exception e){} try { list.setSampleType(trees[2]); }catch (Exception e){} try { list.setSample(trees[3]); }catch (Exception e){} try { list.setModel(trees[4]); }catch (Exception e){} standardMethodListMapper.insert(list); List standardProductLists = standardMethodListMapper.selectParameterList(list.getCode()); for (StandardProductList standardProductList : standardProductLists) { standardProductList.setStandardMethodListId(list.getId()); standardProductList.setFactory(trees[0]); try { standardProductList.setLaboratory(trees[1]); }catch (Exception e){} try { standardProductList.setSampleType(trees[2]); }catch (Exception e){} try { standardProductList.setSample(trees[3]); }catch (Exception e){} try { standardProductList.setModel(trees[4]); }catch (Exception e){} standardProductListMapper.insert(standardProductList); } return 1; } @Override public Map> selectsStandardMethodByFLSSM(String tree) { String[] trees = tree.split(" - "); List standardMethodLists = null; switch (trees.length){ case 5: standardMethodLists = standardMethodListMapper.selectStandardMethodLists(trees[0],trees[1],trees[2],trees[3],trees[4]); // standardProductLists = standardProductListMapper.selectList(Wrappers.lambdaQuery().eq(StandardProductList::getFactory, trees[0]).eq(StandardProductList::getLaboratory, trees[1]).eq(StandardProductList::getSampleType, trees[2]).eq(StandardProductList::getSample, trees[3]).eq(StandardProductList::getModel, trees[4])); break; case 4: standardMethodLists = standardMethodListMapper.selectStandardMethodLists(trees[0],trees[1],trees[2],trees[3],null); break; case 3: standardMethodLists = standardMethodListMapper.selectStandardMethodLists(trees[0],trees[1],trees[2],null,null); break; case 2: standardMethodLists = standardMethodListMapper.selectStandardMethodLists(trees[0],trees[1],null,null,null); break; case 1: standardMethodLists = standardMethodListMapper.selectStandardMethodLists(trees[0],null,null,null,null); break; } Map> map = new HashMap<>(); map.put("standardMethodList", standardMethodLists); return map; } @Override @Transactional(rollbackFor = Exception.class) public int delStandardMethodByFLSSM(Integer id) { standardProductListMapper.delete(Wrappers.lambdaUpdate().eq(StandardProductList::getStandardMethodListId, id)); return standardMethodListMapper.deleteById(id); } }