| | |
| | | |
| | | import cn.hutool.json.JSONUtil; |
| | | import cn.hutool.poi.excel.ExcelUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | 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 |
| | | public IPage<StandardMethod> selectStandardMethodList(Page page, StandardMethod standardMethod) { |
| | | IPage<StandardMethod> result = standardMethodMapper.selectStandardMethodList(page, QueryWrappers.queryWrappers(standardMethod)); |
| | | public IPage<StandardMethod> selectStandardMethodList(Page page, StandardMethod standardMethod, Integer industryId) { |
| | | QueryWrapper<StandardMethod> wrapper = QueryWrappers.queryWrappers(standardMethod); |
| | | if (industryId != null) { |
| | | wrapper.exists("select 1 from standard_method_industry smi where smi.standard_method_id = a.id and smi.industry_id = {0}", industryId); |
| | | } |
| | | IPage<StandardMethod> result = standardMethodMapper.selectStandardMethodList(page, wrapper); |
| | | for (StandardMethod method : result.getRecords()) { |
| | | method.setIndustryIds(selectIndustryIds(method.getId())); |
| | | } |
| | |
| | | @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() |