| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.mapper.RawInsProductMapper; |
| | | import com.yuanchu.mom.mapper.RawInspectMapper; |
| | | import com.yuanchu.mom.pojo.RawInsProduct; |
| | | import com.yuanchu.mom.pojo.RawInspect; |
| | | import com.yuanchu.mom.service.RawInsProductService; |
| | | import com.yuanchu.mom.utils.MyUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 原材料申请单中的项目列表(RawInsProduct)表服务实现类 |
| | |
| | | @Resource |
| | | RawInsProductMapper rawInsProductMapper; |
| | | |
| | | //更新检验项目 |
| | | @Resource |
| | | RawInspectMapper rawInspectMapper; |
| | | |
| | | //更新检验项目(填写检验值,检验设备) |
| | | @Override |
| | | public void updaterawInsProduct(int userId, RawInsProduct rawInsProduct) { |
| | | public void updaterawInsProduct(int userId,Integer rpId ,String testValue,Integer devId) { |
| | | RawInsProduct rawInsProduct = rawInsProductMapper.selectById(rpId); |
| | | //赋值设备 |
| | | rawInsProduct.setDeviceId(devId); |
| | | //赋值检验员id |
| | | rawInsProduct.setUserId(userId); |
| | | //判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格0 |
| | | String testValue = rawInsProduct.getTestValue();//检验值 |
| | | String required = rawInsProduct.getRequired();//标准值 |
| | | String internal = rawInsProduct.getInternal();//内控值 |
| | | rawInsProduct.setTestState(checkValues(required, internal, testValue)); |
| | | //根据检验项目名和关联的检验单id来查询检验项目的数据 |
| | | LambdaUpdateWrapper<RawInsProduct> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(RawInsProduct::getRawInspectId, rawInsProduct.getRawInspectId()) |
| | | .eq(RawInsProduct::getName, rawInsProduct.getName()); |
| | | rawInsProductMapper.update(rawInsProduct, updateWrapper); |
| | | 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)) { |
| | | //如果其中一个检验值不合格则该项目检验不合格 |
| | | rawInsProduct.setTestState(0); |
| | | }else { |
| | | rawInsProduct.setTestState(1); |
| | | } |
| | | /*更新原材料检验项目表*/ |
| | | rawInsProductMapper.updateById(rawInsProduct); |
| | | /*更新原材料检验单*/ |
| | | RawInspect rawInspect = new RawInspect(); |
| | | rawInspect.setId(rawInsProduct.getRawInspectId()); |
| | | rawInspect.setInsState(2); |
| | | rawInspectMapper.updateById(rawInspect); |
| | | } |
| | | |
| | | /*判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格*/ |