| | |
| | | package org.dromara.qa.qm.service.impl; |
| | | |
| | | import org.dromara.common.core.service.JudgeService; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | |
| | | import org.dromara.qa.qm.service.IQmStdService; |
| | | import org.dromara.qa.qm.mapper.QmStdMapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import org.dromara.qa.qm.domain.QmCheckitem; |
| | | import org.dromara.qa.qm.domain.QmJudgeDetails; |
| | | import org.dromara.qa.qm.mapper.QmCheckitemMapper; |
| | | import org.dromara.qa.qm.mapper.QmJudgeDetailsMapper; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Collection; |
| | |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class QmJudgeServiceImpl implements IQmJudgeService { |
| | | public class QmJudgeServiceImpl implements IQmJudgeService, JudgeService { |
| | | |
| | | private final QmJudgeMapper baseMapper; |
| | | private final QmStdMapper qmStdMapper; |
| | | private final QmCheckitemMapper qmCheckitemMapper; |
| | | private final QmJudgeDetailsMapper qmJudgeDetailsMapper; |
| | | |
| | | /** |
| | | * 查询判定依据 |
| | |
| | | * @return 是否新增成功 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean insertByBo(QmJudgeBo bo) { |
| | | QmJudge add = MapstructUtils.convert(bo, QmJudge.class); |
| | | if (add.getCdate() == null) { |
| | | add.setCdate(new java.util.Date()); |
| | | } |
| | | validEntityBeforeSave(add); |
| | | boolean flag = baseMapper.insert(add) > 0; |
| | | if (flag) { |
| | | bo.setId(add.getId()); |
| | | |
| | | // 1. 根据 stdCod 查询启用的规程检验项目 |
| | | LambdaQueryWrapper<QmCheckitem> itemLqw = Wrappers.lambdaQuery(); |
| | | itemLqw.eq(QmCheckitem::getStdCode, bo.getStdCod()); |
| | | itemLqw.eq(QmCheckitem::getEnable, 1L); |
| | | itemLqw.ne(QmCheckitem::getDel, 1L); |
| | | List<QmCheckitem> checkitems = qmCheckitemMapper.selectList(itemLqw); |
| | | |
| | | if (!checkitems.isEmpty()) { |
| | | List<QmJudgeDetails> detailsList = checkitems.stream().map(item -> { |
| | | QmJudgeDetails detail = new QmJudgeDetails(); |
| | | detail.setJudgeId(add.getId()); |
| | | detail.setItemCod(item.getId()); |
| | | detail.setItemName(item.getItemName()); |
| | | detail.setValue3(0.0); |
| | | detail.setValue1(0.0); |
| | | detail.setValue2(0.0); |
| | | detail.setLocation(item.getLocation()); |
| | | detail.setCls(item.getCheckLevel()); |
| | | detail.setStdscore(item.getScore() != null ? item.getScore() : 0.0); |
| | | detail.setIsmix(item.getIsmix() != null ? item.getIsmix() : 0L); |
| | | detail.setRid(item.getRid()); |
| | | detail.setCategory(item.getCategory()); |
| | | detail.setDecisionDes(item.getItemDes()); |
| | | return detail; |
| | | }).collect(Collectors.toList()); |
| | | qmJudgeDetailsMapper.insertBatch(detailsList); |
| | | } |
| | | |
| | | // 2. 将原来存在的相同物料牌号和类型的依据设置为禁用 |
| | | LambdaUpdateWrapper<QmJudge> updateWrapper = Wrappers.lambdaUpdate(); |
| | | updateWrapper.set(QmJudge::getStatus, 0L) |
| | | .eq(QmJudge::getMatCode, bo.getMatCode()) |
| | | .eq(QmJudge::getCategory, bo.getCategory()) |
| | | .ne(QmJudge::getId, add.getId()); |
| | | baseMapper.update(null, updateWrapper); |
| | | } |
| | | return flag; |
| | | } |
| | |
| | | } |
| | | return baseMapper.deleteByIds(ids) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public String selectJudgeNameByCode(String judgeCode) { |
| | | QmJudgeVo qmJudgeVo = baseMapper.selectVoById(judgeCode); |
| | | if(qmJudgeVo!=null){ |
| | | return qmJudgeVo.getJudgeName(); |
| | | } |
| | | return null; |
| | | } |
| | | } |