| | |
| | | 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 |
| | |
| | | private GetLook getLook; |
| | | |
| | | private StandardMethodMapper standardMethodMapper; |
| | | |
| | | StandardProductListMapper standardProductListMapper; |
| | | StandardProductListService standardProductListService; |
| | | |
| | | StructureItemParameterMapper structureItemParameterMapper; |
| | | StructureItemParameterService structureItemParameterService; |
| | | |
| | | @Override |
| | | public Map<String, Object> selectStandardMethodList(Page page, StandardMethod standardMethod) { |
| | |
| | | |
| | | @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) |
| | | @Override |
| | | public void inputExcel(MultipartFile file) throws IOException { |