| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.pojo.StandardMethodList; |
| | | import com.ruoyi.basic.event.StandardMethodSavedEvent; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.basic.mapper.StandardMethodMapper; |
| | | import com.ruoyi.basic.mapper.StandardProductListMapper; |
| | |
| | | import com.ruoyi.basic.utils.StandardTreePath; |
| | | import com.ruoyi.basic.utils.StandardTreePathParser; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | private LaboratoryMapper laboratoryMapper; |
| | | private StandardTreeMapper standardTreeMapper; |
| | | private StandardTreeTemplateBindingMapper standardTreeTemplateBindingMapper; |
| | | private final ApplicationEventPublisher eventPublisher; |
| | | |
| | | @Value("${file.path}") |
| | | private String filePath; |
| | |
| | | StandardMethodAttachmentMapper standardMethodAttachmentMapper, |
| | | LaboratoryMapper laboratoryMapper, |
| | | StandardTreeMapper standardTreeMapper, |
| | | StandardTreeTemplateBindingMapper standardTreeTemplateBindingMapper) { |
| | | StandardTreeTemplateBindingMapper standardTreeTemplateBindingMapper, |
| | | ApplicationEventPublisher eventPublisher) { |
| | | this.standardMethodMapper = standardMethodMapper; |
| | | this.standardProductListMapper = standardProductListMapper; |
| | | this.standardProductListService = standardProductListService; |
| | |
| | | this.laboratoryMapper = laboratoryMapper; |
| | | this.standardTreeMapper = standardTreeMapper; |
| | | this.standardTreeTemplateBindingMapper = standardTreeTemplateBindingMapper; |
| | | this.eventPublisher = eventPublisher; |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Integer addStandardMethod(StandardMethod standardMethod) { |
| | | standardMethod.setStructureTestObjectId(null); |
| | | if (standardMethod.getNeedSearchNew() == null) { |
| | | standardMethod.setNeedSearchNew(0); |
| | | } |
| | | standardMethodMapper.insert(standardMethod); |
| | | syncIndustries(standardMethod, Collections.<Integer>emptySet()); |
| | | publishSavedEvent(standardMethod, false); |
| | | return standardMethod.getId(); |
| | | } |
| | | |
| | |
| | | if (!oldStandardMethod.getCode().equals(standardMethod.getCode())) { |
| | | CompletableFuture.supplyAsync(() -> replaceMethod(oldStandardMethod.getCode(), standardMethod.getCode())); |
| | | } |
| | | if (standardMethod.getNeedSearchNew() == null) { |
| | | standardMethod.setNeedSearchNew(oldStandardMethod.getNeedSearchNew() == null |
| | | ? 0 : oldStandardMethod.getNeedSearchNew()); |
| | | } |
| | | int i = standardMethodMapper.updateById(standardMethod); |
| | | syncIndustries(standardMethod, new LinkedHashSet<>(selectIndustryIds(oldStandardMethod.getId()))); |
| | | publishSavedEvent(standardMethodMapper.selectById(standardMethod.getId()), true); |
| | | return i; |
| | | } |
| | | |
| | | private void publishSavedEvent(StandardMethod standardMethod, boolean edit) { |
| | | eventPublisher.publishEvent(new StandardMethodSavedEvent( |
| | | standardMethod.getId(), standardMethod.getCode(), standardMethod.getName(), |
| | | standardMethod.getNeedSearchNew(), edit)); |
| | | } |
| | | |
| | | private List<Integer> selectIndustryIds(Integer methodId) { |
| | | List<StandardMethodIndustry> list = standardMethodIndustryMapper.selectList( |
| | | Wrappers.<StandardMethodIndustry>lambdaQuery() |