| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.yuanchu.mom.pojo.Device; |
| | | import com.yuanchu.mom.pojo.InspectionItem; |
| | | import com.yuanchu.mom.mapper.InspectionItemMapper; |
| | | import com.yuanchu.mom.mapper.TechniqueMapper; |
| | | import com.yuanchu.mom.pojo.InspectionItem; |
| | | import com.yuanchu.mom.pojo.dto.InspectionItemDto; |
| | | import com.yuanchu.mom.pojo.dto.UpdateInspectionItemDto; |
| | | import com.yuanchu.mom.service.DeviceService; |
| | | import com.yuanchu.mom.service.InspectionItemService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.service.SpecificationsService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.utils.MyUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Resource |
| | | private InspectionItemMapper inspectionItemMapper; |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Resource |
| | | TechniqueMapper techniqueMapper; |
| | | |
| | | |
| | | |
| | | //新增按钮-->2、查询所有检验项目 |
| | | @Override |
| | | public void insertList(Integer finishInspectId, List<Map<String, Object>> list) { |
| | | List<InspectionItem> list1 = new ArrayList<>(); |
| | | for (Map<String, Object> map : list){ |
| | | try { |
| | | InspectionItem inspectionItem = JackSonUtil.unmarshal(JackSonUtil.marshal(map), InspectionItem.class); |
| | | inspectionItem.setFinishInspectId(finishInspectId); |
| | | list1.add(inspectionItem); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | inspectionItemMapper.insertBatchSomeColumn(list1); |
| | | public List<InspectionItemDto> selectInspectionItem(Integer finishInspectId, Integer type) { |
| | | return inspectionItemMapper.selectInspectionItem(finishInspectId,type); |
| | | } |
| | | |
| | | |
| | | //新增过程检验单-->选择设备 |
| | | @Override |
| | | public List<InspectionItemDto> selectInspectionItem(Integer finishInspectId) { |
| | | return inspectionItemMapper.selectInspectionItem(finishInspectId); |
| | | 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); |
| | | } |
| | | |
| | | //新增按钮-->2、检验项目-->失去焦点发起该请求 |
| | | @Override |
| | | public Integer addProcessInspectionSheet(String username, UpdateInspectionItemDto updateInspectionItemDto) { |
| | | LambdaUpdateWrapper<InspectionItem> wrapper = new LambdaUpdateWrapper<>(); |
| | | wrapper.eq(InspectionItem::getId, updateInspectionItemDto.getInspectionItemId()); |
| | | wrapper.set(InspectionItem::getInspectionValue, updateInspectionItemDto.getInspectionValue()); |
| | | wrapper.set(InspectionItem::getDeviceId, updateInspectionItemDto.getDeviceId()); |
| | | int i = checkValues(updateInspectionItemDto.getRequired(), updateInspectionItemDto.getInternal(), updateInspectionItemDto.getInspectionValue()); |
| | | wrapper.set(InspectionItem::getResult, i); |
| | | wrapper.set(InspectionItem::getUsername, username); |
| | | int update = inspectionItemMapper.update(new InspectionItem(), wrapper); |
| | | if (update > 0){ |
| | | return i; |
| | | //查询内控值和标准值 |
| | | 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 { |
| | | inspectionItem.setResult(1); |
| | | } |
| | | return 2; |
| | | inspectionItemMapper.updateById(inspectionItem); |
| | | //返回检验项目的结论 |
| | | return inspectionItem.getResult(); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectDeviceIdAndName() { |
| | | LambdaQueryWrapper<Device> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.select(Device::getId, Device::getName); |
| | | return deviceService.listMaps(wrapper); |
| | | } |
| | | |
| | | /*判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格*/ |
| | | private int checkValues(String standardValueStr, String controlValueStr, String detectionValueStr) { |