| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.mapper.RawInsProductMapper; |
| | | import com.yuanchu.mom.mapper.RawInspectMapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.sql.Wrapper; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | //更新检验项目(填写检验值,检验设备) |
| | | @Override |
| | | public void updaterawInsProduct(int userId,Integer rpId ,String testValue,Integer devId) { |
| | | public void updaterawInsProduct(int userId, Integer rpId, String testValue, Integer devId) { |
| | | RawInsProduct rawInsProduct = rawInsProductMapper.selectById(rpId); |
| | | //赋值设备 |
| | | rawInsProduct.setDeviceId(devId); |
| | |
| | | String required = rawInsProduct.getRequired();//标准值 |
| | | String internal = rawInsProduct.getInternal();//内控值 |
| | | rawInsProduct.setTestValue(testValue); |
| | | 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 (testValue.equals("过")){ |
| | | rawInsProduct.setTestState(1); |
| | | }else if (testValue.equals("不过")){ |
| | | rawInsProduct.setTestState(0); |
| | | }else { |
| | | rawInsProduct.setTestState(1); |
| | | 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); |
| | | } |
| | | } |
| | | /*更新原材料检验项目表*/ |
| | | rawInsProductMapper.updateById(rawInsProduct); |
| | | /*更新原材料检验单*/ |
| | | RawInspect rawInspect = new RawInspect(); |
| | | rawInspect.setId(rawInsProduct.getRawInspectId()); |
| | | rawInspect.setInsState(2); |
| | | rawInspectMapper.updateById(rawInspect); |
| | | } |
| | | |
| | | //只更改设备,之前的检验值删掉 |
| | | @Override |
| | | public void updateDevByRpId(Integer rpId, Integer devId) { |
| | | LambdaUpdateWrapper<RawInsProduct> updateWrapper = Wrappers.<RawInsProduct>lambdaUpdate() |
| | | .eq(RawInsProduct::getId, rpId) |
| | | .set(RawInsProduct::getDeviceId, devId) |
| | | .set(RawInsProduct::getTestState, null) |
| | | .set(RawInsProduct::getTestValue, null); |
| | | rawInsProductMapper.update(new RawInsProduct(), updateWrapper); |
| | | } |
| | | |
| | | /*判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格*/ |
| | | //如果是±的操作 |
| | | 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); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |