| | |
| | | package com.yuanchu.limslaboratory.service.impl; |
| | | |
| | | 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.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.mapper.LinkDetectionMapper; |
| | | import com.yuanchu.limslaboratory.mapper.ProductMapper; |
| | | import com.yuanchu.limslaboratory.mapper.SpecificationsMapper; |
| | | import com.yuanchu.limslaboratory.pojo.LinkBasicInformation; |
| | | import com.yuanchu.limslaboratory.mapper.LinkBasicInformationMapper; |
| | | import com.yuanchu.limslaboratory.pojo.LinkDetection; |
| | | import com.yuanchu.limslaboratory.pojo.Specifications; |
| | | import com.yuanchu.limslaboratory.service.InspectionService; |
| | | import com.yuanchu.limslaboratory.service.LinkBasicInformationService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.limslaboratory.service.LinkDetectionService; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | |
| | | @Resource |
| | | private LinkBasicInformationMapper linkBasicInformationMapper; |
| | | |
| | | @Resource |
| | | private LinkDetectionMapper linkDetectionMapper; |
| | | |
| | | @Autowired |
| | | private LinkDetectionService linkDetectionService; |
| | | |
| | | @Autowired |
| | | private SpecificationsMapper specificationsMapperOn; |
| | | |
| | | @Resource |
| | | private InspectionService inspectionService; |
| | | |
| | | @Resource |
| | | private ProductMapper productMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String addLinkBasicInformation(LinkBasicInformation linkBasicInformation) { |
| | | String code = MyUtil.getTimeSixNumberCode("SL"); |
| | | QueryWrapper<LinkBasicInformation> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.lambda().select(LinkBasicInformation::getId).eq(LinkBasicInformation::getUid, linkBasicInformation.getUid()); |
| | | LinkBasicInformation linkBasicInformation1 = linkBasicInformationMapper.selectOne(queryWrapper); |
| | | Optional<Integer> optionalId = Optional.ofNullable(linkBasicInformation1) |
| | | .map(LinkBasicInformation::getId); |
| | | AtomicBoolean b=new AtomicBoolean(true); |
| | | optionalId.ifPresent(l->{ |
| | | QueryWrapper<LinkDetection>queryWrapperLd = new QueryWrapper<>(); |
| | | queryWrapperLd.lambda().select(LinkDetection::getInspectionStatus).eq(LinkDetection::getLinkBasicId,linkBasicInformation1.getId()); |
| | | List<LinkDetection> linkDetections = linkDetectionMapper.selectList(queryWrapperLd).stream().filter(ld->ld.getInspectionStatus()==2).collect(Collectors.toList()); |
| | | if(linkDetections.size()<1){ |
| | | //执行删除 |
| | | linkDetectionMapper.deleteByLinkbasic(linkBasicInformation1.getId()); |
| | | linkBasicInformationMapper.deleteByID(linkBasicInformation1.getId()); |
| | | b.set(false); |
| | | }else { |
| | | b.set(true); |
| | | } |
| | | }); |
| | | if(b.get()){ |
| | | return "提交失败,含有已报检样品"; |
| | | } |
| | | //委托编号 |
| | | String code = MyUtil.getTimeSixNumberCode("SL", "SL"); |
| | | linkBasicInformation.setEntrustCoding(code); |
| | | //新增基本信息表 |
| | | int insert = linkBasicInformationMapper.insert(linkBasicInformation); |
| | | if (insert == 1) { |
| | | //新增委托样品表 |
| | | linkDetectionService.insertListData(linkBasicInformation.getId(), linkBasicInformation.getLinkDetectionList()); |
| | | return code; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<Map<String, Object>> getLinkBasicPage(Page<Object> page, String entrustCoding, String sampleName, String entrusted, Integer inspectionStatus) { |
| | | return linkBasicInformationMapper.getLinkBasicPage(page, entrustCoding, sampleName, entrusted, inspectionStatus); |
| | | } |
| | | |
| | | //查询所有委托检验和样品 |
| | | @Override |
| | | public List<Map<String, Object>> selectLinkAll() { |
| | | return linkBasicInformationMapper.selectLinkAll(); |
| | | } |
| | | |
| | | @Override |
| | | public String getViewUUID(int day) { |
| | | String id = String.valueOf(UUID.randomUUID()); |
| | | RedisUtil.set("viewId", id, day * 24 * 60); |
| | | return id; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, String> selectViewUUID() { |
| | | Map<String, String> map = new HashMap<>(); |
| | | try { |
| | | map.put("id", RedisUtil.get("viewId").toString()); |
| | | map.put("time", String.valueOf(RedisUtil.getExpire("viewId"))); |
| | | } catch (Exception e) { |
| | | map.put("id", null); |
| | | map.put("time", null); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isIfViewUUID(String uuid) { |
| | | return uuid.equals(RedisUtil.get("viewId")); |
| | | } |
| | | |
| | | @Override |
| | | public LinkBasicInformation getContractsSampleInfo(String viewId) { |
| | | return linkBasicInformationMapper.getLinkBasicInformation(viewId); |
| | | } |
| | | |
| | | //根据委托样品删除 |
| | | @Override |
| | | public void delLink(Integer id) { |
| | | LinkDetection linkDetection = new LinkDetection(); |
| | | linkDetection.setId(id); |
| | | linkDetection.setState(0); |
| | | linkDetectionService.updateById(linkDetection); |
| | | } |
| | | |
| | | @Override |
| | | public Specifications getSpecificationsName(String id) { |
| | | QueryWrapper<Specifications>queryWrapper=new QueryWrapper<>(); |
| | | queryWrapper.lambda().select(Specifications::getName) |
| | | .eq(Specifications::getId,id) |
| | | .eq(Specifications::getState,1); |
| | | return specificationsMapperOn.selectOne(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String,Object>> lookProByVer(String name, String mcode, String specifications,Integer version, Integer id) { |
| | | LinkDetection linkDetection = linkDetectionMapper.selectById(id); |
| | | List<String> experiments = Arrays.stream(linkDetection.getExperiment().split(",")).collect(Collectors.toList()); |
| | | //根据型号id和项目信息查询项目信息 |
| | | List<Map<String, Object>> products = new ArrayList<>(); |
| | | for (String exper : experiments) { |
| | | List<Map<String, Object>> list = productMapper.selFath(Integer.parseInt(linkDetection.getSpecificationsModels()), exper, version); |
| | | if (ObjectUtils.isEmpty(list)) { |
| | | Map<String, Object> project = productMapper.selNam(Integer.parseInt(linkDetection.getSpecificationsModels()), exper, version); |
| | | products.add(project); |
| | | } |
| | | products.addAll(list); |
| | | } |
| | | return products; |
| | | } |
| | | |
| | | @Override |
| | | public Object chooseVer( LinkDetection linkDetection) { |
| | | return productMapper.chooseVersion(Integer.parseInt(linkDetection.getSpecificationsModels())); |
| | | } |
| | | |
| | | |
| | | } |