| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | 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.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.mapper.*; |
| | |
| | | import com.yuanchu.mom.pojo.vo.RawInsProductVo; |
| | | import com.yuanchu.mom.pojo.vo.RawInspectVo; |
| | | import com.yuanchu.mom.service.*; |
| | | import com.yuanchu.mom.utils.MyUtil; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | rawInspectVo.setUserName(userMapper.selectById(userId).getName()); |
| | | //校验标准值,内控值格式 |
| | | List<RawInsProductVo> rawInsProductVos = rawInspectVo.getRawInsProducts(); |
| | | for (RawInsProductVo rawInsProductVo : rawInsProductVos) { |
| | | char internal = rawInsProductVo.getInternal().charAt(0); |
| | | char required = rawInsProductVo.getRequired().charAt(0); |
| | | if (internal != '>' && internal != '<' && internal != '=') { |
| | | return "内控值输入格式有问题!"; |
| | | } |
| | | if (required != '>' && required != '<' && required != '=') { |
| | | return "标准值输入格式有问题!"; |
| | | } |
| | | } |
| | | /*新增原材料检验单*/ |
| | | RawInspect rawInspect = new RawInspect(); |
| | | BeanUtils.copyProperties(rawInspectVo, rawInspect); |
| | |
| | | RawInsProduct rawInsProduct = new RawInsProduct(); |
| | | BeanUtils.copyProperties(rawInsProVo, rawInsProduct); |
| | | if (ObjectUtils.isNotEmpty(rawInsProduct.getTestValue())) { |
| | | //判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格0 |
| | | String required = rawInsProduct.getRequired();//标准值 |
| | | String internal = rawInsProduct.getInternal();//内控值 |
| | | String testValue = rawInsProduct.getTestValue();//检测值 |
| | | List<Integer> list = Arrays.stream(testValue.split(",")).map(s -> { |
| | | int values = checkValues(required, internal, s); |
| | | return values; |
| | | }).collect(Collectors.toList()); |
| | | if (list.contains(0)) { |
| | | //如果其中一个检验值不合格则该项目检验不合格 |
| | | if (rawInsProduct.getTestValue().equals("过")) { |
| | | rawInsProduct.setTestState(1); |
| | | } else if (rawInsProduct.getTestValue().equals("不过")) { |
| | | rawInsProduct.setTestState(0); |
| | | } else { |
| | | rawInsProduct.setTestState(1); |
| | | //判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格0 |
| | | String required = rawInsProduct.getRequired();//标准值 |
| | | String internal = rawInsProduct.getInternal();//内控值 |
| | | String testValue = rawInsProduct.getTestValue();//检测值 |
| | | char req = required.charAt(0); |
| | | List<Integer> list = Arrays.stream(testValue.split(",")).map(s -> { |
| | | int values=2; |
| | | if (req == '>' || req == '<' || req == '=') { |
| | | values = checkValues(required, internal, s); |
| | | }else { |
| | | values = conValues(required, internal, s); |
| | | } |
| | | return values; |
| | | }).collect(Collectors.toList()); |
| | | if (list.contains(0)) { |
| | | //如果其中一个检验值不合格则该项目检验不合格 |
| | | rawInsProduct.setTestState(0); |
| | | } else { |
| | | rawInsProduct.setTestState(1); |
| | | } |
| | | } |
| | | rawInsProduct.setUserId(Integer.parseInt(userId)); |
| | | } |
| | |
| | | .build(); |
| | | inspectUnacceptedMapper.insert(rawUnaccepted); |
| | | } |
| | | return "上报成功!"; |
| | | return rawInspect.getJudgeState().toString(); |
| | | } |
| | | |
| | | |
| | | /*判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格*/ |
| | | //如果是±的操作 |
| | | private int conValues(String standardValueStr, String controlValueStr, String detectionValueStr) { |
| | | double standVar = Double.parseDouble(standardValueStr); |
| | | double controlVar = Double.parseDouble(controlValueStr); |
| | | double detecVar = Double.parseDouble(detectionValueStr); |
| | | double a = standVar + controlVar; |
| | | double b = standVar - controlVar; |
| | | if (detecVar >= b && detecVar <= a) { |
| | | return 1; |
| | | } |
| | | return 0; |
| | | } |
| | | //如果是> , < ,=的操作 |
| | | private int checkValues(String standardValueStr, String controlValueStr, String detectionValueStr) { |
| | | boolean isStandardValueSatisfied = isValueSatisfied(standardValueStr, detectionValueStr); |
| | | boolean isControlValueSatisfied = isValueSatisfied(controlValueStr, detectionValueStr); |