| | |
| | | //新增原材料检验单 |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String addRawInspects(String userId, RawInspectVo rawInspectVo) throws Exception { |
| | | public String addRawInspects(String userId, RawInspectVo rawInspectVo) { |
| | | //报检人(新增检验单的人) |
| | | 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); |
| | |
| | | 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 = checkValues(required, internal, 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)) { |
| | |
| | | |
| | | |
| | | /*判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格*/ |
| | | private int checkValues(String standardValueStr, String controlValueStr, String detectionValueStr) { |
| | | //如果是±的操作 |
| | | private int conValues(String standardValueStr, String controlValueStr, String detectionValueStr) { |
| | | double standVar = Double.parseDouble(standardValueStr); |
| | | double controlVar = Double.parseDouble(controlValueStr); |
| | | double detecVar = Double.parseDouble(detectionValueStr); |
| | |
| | | return 1; |
| | | } |
| | | return 0; |
| | | /*boolean isStandardValueSatisfied = isValueSatisfied(standardValueStr, detectionValueStr); |
| | | } |
| | | //如果是> , < ,=的操作 |
| | | private int checkValues(String standardValueStr, String controlValueStr, String detectionValueStr) { |
| | | boolean isStandardValueSatisfied = isValueSatisfied(standardValueStr, detectionValueStr); |
| | | boolean isControlValueSatisfied = isValueSatisfied(controlValueStr, detectionValueStr); |
| | | |
| | | if (isStandardValueSatisfied && isControlValueSatisfied) { |
| | | return 1; |
| | | } else { |
| | | return 0; |
| | | }*/ |
| | | } |
| | | } |
| | | |
| | | private boolean isValueSatisfied(String valueStr, String detectionValueStr) { |