| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.yuanchu.mom.mapper.InspectionItemMapper; |
| | | import com.yuanchu.mom.mapper.TechniqueMapper; |
| | | import com.yuanchu.mom.pojo.InspectionItem; |
| | |
| | | @Resource |
| | | private InspectionItemMapper inspectionItemMapper; |
| | | |
| | | @Resource |
| | | TechniqueMapper techniqueMapper; |
| | | |
| | | |
| | | |
| | |
| | | return inspectionItemMapper.selectInspectionItem(id,type); |
| | | } |
| | | |
| | | |
| | | //新增过程检验单-->选择设备 |
| | | @Override |
| | | public List<Map<String, Object>> chooseDev(Integer technologyId, String father, String name) { |
| | | //该工艺id下生产工艺最新版本 |
| | | Integer ver = techniqueMapper.selectVerByTeId(technologyId).get(0); |
| | | return techniqueMapper.selDevByVerTecIdFaNam(technologyId, father, name, ver); |
| | | } |
| | | |
| | | //更改设备 |
| | | @Override |
| | | public void updateDevByInsId(Integer id, Integer type, Integer devId) { |
| | | InspectionItem inspectionItem = new InspectionItem(); |
| | | inspectionItem.setId(id); |
| | | inspectionItem.setType(type); |
| | | inspectionItem.setDeviceId(devId); |
| | | inspectionItem.setInspectionValue(null); |
| | | inspectionItem.setResult(null); |
| | | inspectionItemMapper.updateById(inspectionItem); |
| | | LambdaUpdateWrapper<InspectionItem> updateWrapper = Wrappers.<InspectionItem>lambdaUpdate() |
| | | .eq(InspectionItem::getId, id) |
| | | .eq(InspectionItem::getType, type) |
| | | .set(InspectionItem::getDeviceId, devId) |
| | | .set(InspectionItem::getInspectionValue, null) |
| | | .set(InspectionItem::getResult, null); |
| | | inspectionItemMapper.update(new InspectionItem(), updateWrapper); |
| | | } |
| | | |
| | | //新增按钮-->2、检验项目-->失去焦点发起该请求 |
| | |
| | | InspectionItem inspectionItem = inspectionItemMapper.selectById(updateInspectionItemDto.getInspectionItemId()); |
| | | inspectionItem.setInspectionValue(updateInspectionItemDto.getInspectionValue()); |
| | | inspectionItem.setDeviceId(updateInspectionItemDto.getDeviceId()); |
| | | List<Integer> list = Arrays.stream( updateInspectionItemDto.getInspectionValue().split(",")).map(s -> { |
| | | int values = checkValues(inspectionItem.getRequired(), inspectionItem.getInternal(), s); |
| | | return values; |
| | | }).collect(Collectors.toList()); |
| | | if (list.contains(0)) { |
| | | //如果其中一个检验值不合格则该项目检验不合格 |
| | | inspectionItem.setResult(0); |
| | | } else { |
| | | if (updateInspectionItemDto.getInspectionValue().equals("过")){ |
| | | inspectionItem.setResult(1); |
| | | }else if (updateInspectionItemDto.getInspectionValue().equals("不过")){ |
| | | inspectionItem.setResult(0); |
| | | }else { |
| | | char req = inspectionItem.getRequired().charAt(0); |
| | | List<Integer> list = Arrays.stream(updateInspectionItemDto.getInspectionValue().split(",")).map(s -> { |
| | | int values=2; |
| | | if (req == '>' || req == '<' || req == '=') { |
| | | values = checkValues(inspectionItem.getRequired(), inspectionItem.getInternal(), s); |
| | | }else { |
| | | values = conValues(inspectionItem.getRequired(), inspectionItem.getInternal(), s); |
| | | } |
| | | return values; |
| | | }).collect(Collectors.toList()); |
| | | if (list.contains(0)) { |
| | | //如果其中一个检验值不合格则该项目检验不合格 |
| | | inspectionItem.setResult(0); |
| | | } else { |
| | | inspectionItem.setResult(1); |
| | | } |
| | | } |
| | | inspectionItem.setUsername(username); |
| | | inspectionItemMapper.updateById(inspectionItem); |
| | | //返回检验项目的结论 |
| | | return inspectionItem.getResult(); |
| | |
| | | |
| | | |
| | | /*判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格*/ |
| | | //如果是±的操作 |
| | | 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); |