| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.mapper.StandardMethodListMapper; |
| | | import com.ruoyi.basic.mapper.StandardProductListMapper; |
| | | import com.ruoyi.basic.mapper.WorkShopMapper; |
| | | import com.ruoyi.basic.pojo.StandardMethodList; |
| | | import com.ruoyi.basic.pojo.StandardProductList; |
| | | import com.ruoyi.basic.pojo.WorkShop; |
| | | import com.ruoyi.basic.service.StandardMethodListService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | private StandardProductListMapper standardProductListMapper; |
| | | |
| | | @Autowired |
| | | private WorkShopMapper workShopMapper; |
| | | |
| | | |
| | | @Override |
| | | public Map<String, List<?>> selectsStandardMethodByFLSSM(String tree) { |
| | | String[] trees = tree.split(" - "); |
| | | // 判断是否包含车间 |
| | | boolean workshopExist = existWorkShop(tree); |
| | | Map<String, List<?>> map = new HashMap<>(); |
| | | String str = ""; |
| | | List<StandardMethodList> standardMethodLists = new ArrayList<>(); |
| | | switch (trees.length){ |
| | | case 5: |
| | | str += "\"" + trees[2] + "\",\"" + trees[3] + "\",\"" + trees[4] + "\""; |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists(str)); |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[2] + "\",\"" + trees[3] + "\"")); |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[2] + "\"")); |
| | | break; |
| | | case 4: |
| | | str += "\"" + trees[2] + "\",\"" + trees[3] + "\""; |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists(str)); |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[2] + "\"")); |
| | | break; |
| | | case 3: |
| | | str += "\"" + trees[2] + "\""; |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists3(str)); |
| | | break; |
| | | default: |
| | | map.put("standardMethodList", null); |
| | | return map; |
| | | String[] trees = tree.split(" - "); |
| | | if(trees != null && trees.length >= 4){ |
| | | // 判断是否有车间 |
| | | if(workshopExist){ |
| | | switch (trees.length - 4){ |
| | | case 3: |
| | | str += "\"" + trees[4] + "\",\"" + trees[5] + "\",\"" + trees[6] + "\""; |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists(str)); |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[4] + "\",\"" + trees[5] + "\"")); |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[4] + "\"")); |
| | | break; |
| | | case 2: |
| | | str += "\"" + trees[4] + "\",\"" + trees[5] + "\""; |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists(str)); |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[4] + "\"")); |
| | | break; |
| | | case 1: |
| | | str += "\"" + trees[4] + "\""; |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists3(str)); |
| | | break; |
| | | default: |
| | | map.put("standardMethodList", null); |
| | | return map; |
| | | } |
| | | }else { |
| | | switch (trees.length - 4){ |
| | | case 2: |
| | | str += "\"" + trees[3] + "\",\"" + trees[4] + "\",\"" + trees[5] + "\""; |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists(str)); |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[3] + "\",\"" + trees[4] + "\"")); |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[3] + "\"")); |
| | | break; |
| | | case 1: |
| | | str += "\"" + trees[3] + "\",\"" + trees[4] + "\""; |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists(str)); |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[3] + "\"")); |
| | | break; |
| | | case 0: |
| | | str += "\"" + trees[3] + "\""; |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists3(str)); |
| | | break; |
| | | default: |
| | | map.put("standardMethodList", null); |
| | | return map; |
| | | } |
| | | } |
| | | }else { |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodListsByNull(str)); |
| | | } |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodListsByNull(str)); |
| | | map.put("standardMethodList", standardMethodLists); |
| | | return map; |
| | | } |
| | |
| | | public Integer getStandardMethodId(String code) { |
| | | return baseMapper.getStandardMethodId(code); |
| | | } |
| | | |
| | | /** |
| | | * 判断是否包含车间 |
| | | * |
| | | * @param tree |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean existWorkShop(String tree){ |
| | | QueryWrapper<WorkShop> queryWrapper = new QueryWrapper<>(); |
| | | List<WorkShop> workShopList = workShopMapper.selectList(queryWrapper); |
| | | String[] trees = tree.split(" - "); |
| | | if(trees != null && trees.length > 0){ |
| | | for (int i = 0; i < trees.length; i++) { |
| | | for (WorkShop workShop : workShopList) { |
| | | if(workShop.getName().equals(trees[i].trim())){ |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |