| | |
| | | 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.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.mapper.LinkDetectionMapper; |
| | | import com.yuanchu.limslaboratory.mapper.SpecificationsMapper; |
| | | import com.yuanchu.limslaboratory.pojo.LinkBasicInformation; |
| | | import com.yuanchu.limslaboratory.mapper.LinkBasicInformationMapper; |
| | | import com.yuanchu.limslaboratory.pojo.vo.InspectionVo; |
| | | 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.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | 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; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String addLinkBasicInformation(LinkBasicInformation linkBasicInformation) { |
| | | String code = MyUtil.getTimeSixNumberCode("SL"); |
| | | System.out.println(linkBasicInformation.getLinkDetectionList()); |
| | | 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); |
| | | optionalId.ifPresent(l->{ |
| | | //执行删除 |
| | | linkDetectionMapper.deleteByLinkbasic(linkBasicInformation1.getId()); |
| | | linkBasicInformationMapper.deleteByID(linkBasicInformation1.getId()); |
| | | }); |
| | | //委托编号 |
| | | 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 linkBasicInformationMapper.selectLinkAll(); |
| | | } |
| | | |
| | | //根据委托检验id和样品id查询委托检验和样品 |
| | | @Override |
| | | public InspectionVo selectLinkByid(Integer bid, Integer did) { |
| | | InspectionVo inspectionVo = linkBasicInformationMapper.selectLinkByid(bid, did); |
| | | inspectionVo.setType(1); |
| | | return inspectionVo; |
| | | 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 Object lookProByVer(String name, String mcode, String specifications,Integer version, Integer id) { |
| | | LinkDetection linkDetection = linkDetectionMapper.selectById(id); |
| | | return inspectionService.lookProByVer(name, mcode, specifications, version, linkDetection.getExperiment()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |