| | |
| | | import com.yuanchu.mom.common.GetLook; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | | import com.yuanchu.mom.mapper.StandardMethodMapper; |
| | | import com.yuanchu.mom.mapper.StandardProductListMapper; |
| | | import com.yuanchu.mom.mapper.StructureItemParameterMapper; |
| | | import com.yuanchu.mom.pojo.StandardMethod; |
| | | import com.yuanchu.mom.pojo.StandardProductList; |
| | | import com.yuanchu.mom.pojo.StructureItemParameter; |
| | | import com.yuanchu.mom.service.StandardMethodService; |
| | | import com.yuanchu.mom.service.StandardProductListService; |
| | | import com.yuanchu.mom.service.StructureItemParameterService; |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | |
| | | /** |
| | | * @author Administrator |
| | | * @description 针对表【standard_method(标准方法)】的数据库操作Service实现 |
| | | * @createDate 2024-03-03 19:21:41 |
| | | */ |
| | | * @author Administrator |
| | | * @description 针对表【standard_method(标准方法)】的数据库操作Service实现 |
| | | * @createDate 2024-03-03 19:21:41 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class StandardMethodServiceImpl extends ServiceImpl<StandardMethodMapper, StandardMethod> |
| | | implements StandardMethodService{ |
| | | implements StandardMethodService { |
| | | |
| | | private GetLook getLook; |
| | | |
| | | private StandardMethodMapper standardMethodMapper; |
| | | |
| | | StandardProductListMapper standardProductListMapper; |
| | | StandardProductListService standardProductListService; |
| | | |
| | | StructureItemParameterMapper structureItemParameterMapper; |
| | | StructureItemParameterService structureItemParameterService; |
| | | |
| | | @Override |
| | | public Map<String, Object> selectStandardMethodList(Page page, StandardMethod standardMethod) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("head", PrintChina.printChina(StandardMethod.class)); |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectStandardMethodList"); |
| | | if(map1.get("look")==1) standardMethod.setCreateUser(map1.get("userId")); |
| | | if (map1.get("look") == 1) standardMethod.setCreateUser(map1.get("userId")); |
| | | map.put("body", standardMethodMapper.selectStandardMethodList(page, QueryWrappers.queryWrappers(standardMethod))); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<StandardMethod> selectStandardMethods() { |
| | | return standardMethodMapper.selectList(Wrappers.<StandardMethod>lambdaQuery().select(StandardMethod::getId,StandardMethod::getCode,StandardMethod::getName).ne(StandardMethod::getId, 0)); |
| | | return standardMethodMapper.selectList(Wrappers.<StandardMethod>lambdaQuery().select(StandardMethod::getId, StandardMethod::getCode, StandardMethod::getName).ne(StandardMethod::getId, 0)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public int upStandardMethod(StandardMethod standardMethod) { |
| | | StandardMethod oldStandardMethod = standardMethodMapper.selectById(standardMethod.getId()); |
| | | if (!oldStandardMethod.getCode().equals(standardMethod.getCode())) { |
| | | CompletableFuture.supplyAsync(() -> replaceMethod(oldStandardMethod.getCode(), standardMethod.getCode())); |
| | | } |
| | | int i = standardMethodMapper.updateById(standardMethod); |
| | | return i; |
| | | } |
| | | |
| | | //编辑method后全部替换 |
| | | public String replaceMethod(String oldCode, String code) { |
| | | //查询StandardProductList中所有Method如果包含之前的则替换 |
| | | List<StandardProductList> standardProductLists = standardProductListMapper.selectList(null); |
| | | for (StandardProductList standardProductList : standardProductLists) { |
| | | if (standardProductList.getMethod().contains(oldCode)) { |
| | | String[] split = standardProductList.getMethod().split(","); |
| | | String a = null; |
| | | for (int i = 0; i < split.length; i++) { |
| | | String methodName = split[i].substring(1, split[i].length() - 1); |
| | | if (i == 0) { |
| | | methodName = split[i].substring(2, split[i].length() - 1); |
| | | } else if (i == split.length - 1) { |
| | | methodName = split[i].substring(1, split[i].length() - 2); |
| | | } |
| | | if (methodName.equals(oldCode)) { |
| | | methodName = code; |
| | | } |
| | | a += "\"" + methodName + "\","; |
| | | } |
| | | String method = "[\"" + a.substring(0, a.length() - 1) + "\"]"; |
| | | standardProductList.setMethod(method); |
| | | } |
| | | } |
| | | standardProductListService.updateBatchById(standardProductLists); |
| | | //查询StructureItemParameter中所有Method如果包含之前的则替换 |
| | | List<StructureItemParameter> structureItemParameters = structureItemParameterMapper.selectList(null); |
| | | for (StructureItemParameter structureItemParameter : structureItemParameters) { |
| | | if (structureItemParameter.getMethod().contains(oldCode)) { |
| | | String[] split = structureItemParameter.getMethod().split(","); |
| | | String a = null; |
| | | for (int i = 0; i < split.length; i++) { |
| | | String methodName = split[i].substring(1, split[i].length() - 1); |
| | | if (i == 0) { |
| | | methodName = split[i].substring(2, split[i].length() - 1); |
| | | } else if (i == split.length - 1) { |
| | | methodName = split[i].substring(1, split[i].length() - 2); |
| | | } |
| | | if (methodName.equals(oldCode)) { |
| | | methodName = code; |
| | | } |
| | | a += "\"" + methodName + "\","; |
| | | } |
| | | String method = "[\"" + a.substring(0, a.length() - 1) + "\"]"; |
| | | structureItemParameter.setMethod(method); |
| | | } |
| | | } |
| | | structureItemParameterService.updateBatchById(structureItemParameters); |
| | | return "替换完毕!"; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | standardMethod.setField(list.get(1).toString()); |
| | | // 造格式 |
| | | List<List<Object>> structureTestObjectId = new ArrayList<>(); |
| | | if (ObjectUtils.isEmpty(list.get(3))){ |
| | | if (ObjectUtils.isEmpty(list.get(3))) { |
| | | structureTestObjectId.add(Arrays.asList(list.get(2))); |
| | | } else { |
| | | structureTestObjectId.add(Arrays.asList(list.get(2), list.get(3))); |