| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | 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.enums.BasicTreeEnums; |
| | | import com.ruoyi.basic.enums.TestPorjectTypeEnums; |
| | | import com.ruoyi.basic.mapper.StandardMethodListMapper; |
| | | import com.ruoyi.basic.mapper.StandardMethodMapper; |
| | | import com.ruoyi.basic.mapper.StandardProductListMapper; |
| | | import com.ruoyi.basic.mapper.WorkShopMapper; |
| | | import com.ruoyi.basic.pojo.StandardMethod; |
| | | 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.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author Administrator |
| | |
| | | @Autowired |
| | | private WorkShopMapper workShopMapper; |
| | | |
| | | @Autowired |
| | | private StandardMethodMapper standardMethodMapper; |
| | | |
| | | |
| | | @Override |
| | | public Map<String, List<?>> selectsStandardMethodByFLSSM(String tree) { |
| | | // 判断是否包含车间 |
| | | boolean workshopExist = existWorkShop(tree); |
| | | Map<String, List<?>> map = new HashMap<>(); |
| | | String str = ""; |
| | | List<StandardMethodList> standardMethodLists = new ArrayList<>(); |
| | | String sampleType = ""; // 检验对象 |
| | | // 拼接树 |
| | | 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[5] + "\""; |
| | | 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; |
| | | } |
| | | map.put("standardMethodList", null); |
| | | if(trees == null && trees.length < 4){ |
| | | return map; |
| | | } |
| | | StringBuilder checkItemQueryTree = new StringBuilder(); // 检查项查询 |
| | | StringBuilder productTree = new StringBuilder(); // 检验产品树 |
| | | // 判断是否包含车间 |
| | | boolean existWorkShopFlag = this.existWorkShop(tree); |
| | | // 车间层级多一层级 |
| | | if(existWorkShopFlag){ |
| | | switch (trees.length) { |
| | | case 7: |
| | | sampleType = trees[4]; |
| | | checkItemQueryTree.append("\"").append(trees[4]).append("\",\"").append(trees[5]).append("\",\"").append(trees[6]).append("\""); |
| | | productTree.append("\"").append(trees[4]).append("\",\"").append(trees[5]).append("\""); |
| | | break; |
| | | case 6: |
| | | sampleType = trees[4]; |
| | | checkItemQueryTree.append("\"").append(trees[4]).append("\",\"").append(trees[5]).append("\""); |
| | | break; |
| | | case 5: |
| | | sampleType = trees[4]; |
| | | checkItemQueryTree.append("\"").append(trees[4]).append("\"").append("]"); |
| | | break; |
| | | } |
| | | }else { |
| | | standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodListsByNull(str)); |
| | | switch (trees.length) { |
| | | case 6: |
| | | sampleType = trees[3]; |
| | | checkItemQueryTree.append("\"").append(trees[3]).append("\",\"").append(trees[4]).append("\",\"").append(trees[5]).append("\""); |
| | | productTree.append("\"").append(trees[3]).append("\",\"").append(trees[4]).append("\""); |
| | | break; |
| | | case 5: |
| | | sampleType = trees[3]; |
| | | checkItemQueryTree.append("\"").append(trees[3]).append("\",\"").append(trees[4]).append("\""); |
| | | break; |
| | | case 4: |
| | | sampleType = trees[3]; |
| | | checkItemQueryTree.append("\"").append(trees[3]).append("\"").append("]"); |
| | | break; |
| | | } |
| | | } |
| | | map.put("standardMethodList", standardMethodLists); |
| | | if(StringUtils.isEmpty(checkItemQueryTree.toString())){ |
| | | return map; |
| | | } |
| | | List<StandardMethodList> standardMethodListArray = standardMethodListMapper.selectStandardMethodLists(checkItemQueryTree.toString()); |
| | | // 查不到查询检查对象 |
| | | if(CollectionUtils.isEmpty(standardMethodListArray)){ |
| | | // 如果是完整层级,向上推到产品层级 |
| | | if((existWorkShopFlag&&trees.length == 7) || (!existWorkShopFlag&&trees.length == 6)){ |
| | | standardMethodListArray = standardMethodListMapper.selectStandardMethodLists(productTree.toString()); |
| | | |
| | | } |
| | | // 还是为空查询对象层级 |
| | | if(CollectionUtils.isEmpty(standardMethodListArray)){ |
| | | standardMethodListArray = standardMethodListMapper.selectStandardMethodLists(sampleType); |
| | | } |
| | | } |
| | | // 判断是否是成品/半成品 |
| | | boolean isProduct = false; |
| | | for (int i = 0; i < trees.length; i++) { |
| | | if(TestPorjectTypeEnums.FINISHED_PRODUCT.getName().equals(trees[i]) || TestPorjectTypeEnums.SEMI_FINISHED_PRODUCT.getName().equals(trees[i])){ |
| | | isProduct = true; |
| | | break; |
| | | } |
| | | } |
| | | // 如果是成品/半成品 且 检验标准里不包含委托要求。查询并添加至集合 |
| | | boolean isContainDelegateRequest = false; |
| | | for (StandardMethodList standardMethodList : standardMethodListArray) { |
| | | if("委托要求".equals(standardMethodList.getName())){ |
| | | isContainDelegateRequest = true; |
| | | break; |
| | | } |
| | | } |
| | | if(isProduct && !isContainDelegateRequest){ |
| | | QueryWrapper<StandardMethod> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("name","委托要求"); |
| | | queryWrapper.eq("is_use","1"); |
| | | List<StandardMethod> standardMethods = standardMethodMapper.selectList(queryWrapper); |
| | | standardMethodListArray.addAll(standardMethods.stream().map(item -> { |
| | | StandardMethodList standardMethodList = new StandardMethodList(); |
| | | BeanUtils.copyProperties(item, standardMethodList); |
| | | return standardMethodList; |
| | | }).collect(Collectors.toList())); |
| | | } |
| | | map.put("standardMethodList", standardMethodListArray); |
| | | return map; |
| | | } |
| | | |