| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.DictUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.mapper.QualityTestStandardBindingMapper; |
| | | import com.ruoyi.quality.mapper.QualityTestStandardParamMapper; |
| | |
| | | import com.ruoyi.quality.service.QualityTestStandardParamService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | return qualityTestStandardMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveWithProcessTypeValidate(QualityTestStandard qualityTestStandard) { |
| | | validateProcessType(qualityTestStandard); |
| | | return this.save(qualityTestStandard); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateWithProcessTypeValidate(QualityTestStandard qualityTestStandard) { |
| | | validateProcessType(qualityTestStandard); |
| | | return this.updateById(qualityTestStandard); |
| | | } |
| | | |
| | | private void validateProcessType(QualityTestStandard qualityTestStandard) { |
| | | if (qualityTestStandard == null || qualityTestStandard.getProcessType() == null) { |
| | | return; |
| | | } |
| | | |
| | | String dictType = "product_process_type"; |
| | | String input = String.valueOf(qualityTestStandard.getProcessType()); |
| | | |
| | | String dictValue = DictUtils.getDictValue(dictType, input); |
| | | if (StringUtils.isNotEmpty(dictValue)) { |
| | | qualityTestStandard.setProcessType(Integer.valueOf(dictValue)); |
| | | return; |
| | | } |
| | | |
| | | String dictValues = DictUtils.getDictValues(dictType); |
| | | if (StringUtils.isNotEmpty(dictValues)) { |
| | | List<String> valueList = Arrays.asList(dictValues.split(DictUtils.SEPARATOR)); |
| | | if (valueList.contains(input)) { |
| | | return; |
| | | } |
| | | } |
| | | |
| | | throw new ServiceException("工序类型【" + input + "】不存在,请填写正确的类型:" + DictUtils.getDictLabels(dictType)); |
| | | } |
| | | |
| | | } |