package com.thhy.mobile.modules.biz.repo.service.impl; import com.alibaba.nacos.api.utils.StringUtils; import com.thhy.general.common.BasicStatus; import com.thhy.general.common.enums.ProListenType; import com.thhy.general.config.SysUserInfo; import com.thhy.general.exception.BasicException; import com.thhy.general.utils.ScreenMqUtils; import com.thhy.general.utils.UserInfoUtils; import com.thhy.mobile.modules.biz.cultivated.entity.PipeCulSampleInfo; import com.thhy.mobile.modules.biz.cultivated.entity.PipeIntoListVo; import com.thhy.mobile.modules.biz.cultivated.mapper.PipeCultivatedMapper; import com.thhy.mobile.modules.biz.pipeinfo.entity.PipeInfo; import com.thhy.mobile.modules.biz.pipeinfo.mapper.PipeInfoMapper; import com.thhy.mobile.modules.biz.repo.entity.*; import com.thhy.mobile.modules.biz.repo.mapper.RepoRecordMapper; import com.thhy.mobile.modules.biz.repo.service.RepoRecordService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.Serializable; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 服务实现类 * @author zhang_xiao_bo * @since 2023-05-15 11:18:04 */ @Service public class RepoRecordServiceImpl implements RepoRecordService { @Autowired private RepoRecordMapper repoRecordMapper; @Autowired private PipeInfoMapper pipeInfoMapper; @Autowired private PipeCultivatedMapper pipeCultivatedMapper; @Autowired private ScreenMqUtils screenMqUtils; public RepoRecord get(Serializable id){ return repoRecordMapper.queryById(id); } public List findList(RepoRecord repoRecord){ return repoRecordMapper.findList(repoRecord); } /** * 增加和修改 * @param repoRecord */ @Transactional public void addRepoRecord(RepoRecord repoRecord){ if(repoRecord.getRecordId() == null){ //增加操作 repoRecordMapper.insert(repoRecord); }else{ //修改操作 repoRecordMapper.update(repoRecord); } } /** * 修改 * @param repoRecord */ public void update(RepoRecord repoRecord){ repoRecordMapper.update(repoRecord); } /** * 删除 * @param recordId */ public void delete(Serializable recordId){ repoRecordMapper.deletelogic(recordId); } @Override public Map scanqr(RepoScanDto repoScanDto) { Map map = new HashMap<>(); PipeInfo pipeInfo = pipeInfoMapper.queryByPipeNum(repoScanDto.getPipeNum()); if(pipeInfo==null){ throw new BasicException(BasicStatus.SCAN_QR_IS_EORROR); } int RingCount = repoRecordMapper.countByRingNum(pipeInfo.getRingNum()); if(RingCount>0){ throw new BasicException(BasicStatus.RING_NUM_IS_EXIST); } List pipeIntoList = pipeInfoMapper.queryByRingNum(pipeInfo.getRingNum()); PipeCulSampleInfo sampleInfo = pipeCultivatedMapper.queryCultivateByRingNum(pipeInfo.getRingNum()); map.put("pipeIntoList",pipeIntoList); map.put("cultivatedInfo",sampleInfo); return map; } @Override public PipeCulSampleInfo queryCultivateByRingNum(String ringNum) { return pipeCultivatedMapper.queryCultivateByRingNum(ringNum); } @Override @Transactional public void intoRepo(RepoScanDto repoScanDto) { SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(); //入库记录 RepoRecord repoRecord = new RepoRecord(); repoRecord.setRepoId(repoScanDto.getRepoId()); repoRecord.setRepoUnitId(repoScanDto.getUnitId()); repoRecord.setRingNum(repoScanDto.getRingNum()); Date date = new Date(); repoRecord.setCreateTime(date); repoRecord.setCreateUser(userInfo.getUserId()); repoRecordMapper.insert(repoRecord); pipeCultivatedMapper.updateOutByRingNum(date,repoScanDto.getRingNum(),userInfo.getUserId()); List pipeIntoList = pipeInfoMapper.queryByRingNum(repoScanDto.getRingNum()); pipeIntoList.forEach(pi ->{ repoRecordMapper.insertRecordPipe(new RepoRecordPipe(pi.getPipeNum(),repoRecord.getRecordId(),repoScanDto.getRingNum(),repoScanDto.getRepoId(),date)); pipeInfoMapper.updatePipeInRepo(pi.getPipeNum()); }); //出水养窑 screenMqUtils.send(ProListenType.REPOINFO); } @Override public List recordList(RepoScanDto repoScanDto) { SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(); if(repoScanDto==null)repoScanDto=new RepoScanDto(); repoScanDto.setCompanyId(userInfo.getCompanyId()); return repoRecordMapper.recordList(repoScanDto); } @Override public List repoDetail(RepoRecordDto repoRecordDto) { if(StringUtils.isEmpty(repoRecordDto.getRepoId())){ throw new BasicException(BasicStatus.PARAM_IS_EMPTY); } return repoRecordMapper.repoDetail(repoRecordDto); } }