diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java index 0d7b88d..93ad426 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java @@ -535,8 +535,16 @@ public class BackReceiveServiceImpl implements BackReceiveService { */ @Override public AjaxResult getDetailsReceiveList(BackApplyInfo record) { + // 是否完成退料的标识 + Boolean isFinish = false; BackApplyInfo backApplyInfo = new BackApplyInfo(); List backApplyInfos = backReceiveMapper.getbackReceiveList(record); + // 根据任务id查询任务状态 + int taskStatus = backReceiveMapper.selectTaskStatus(record.getTaskId()); + // 完成退料 + if (taskStatus == 40) { + isFinish = true; + } List useTypeTree = new ArrayList<>(); if (!CollectionUtils.isEmpty(backApplyInfos)) { backApplyInfos.get(0).setProjectId(Long.valueOf(backApplyInfos.get(0).getLotId())); @@ -548,89 +556,51 @@ public class BackReceiveServiceImpl implements BackReceiveService { } List backApplyInfoList = receiveView(record); List maCodeList = new ArrayList<>(); - if (!CollectionUtils.isEmpty(backApplyInfoList) && !CollectionUtils.isEmpty(useTypeTree)) { - for (TypeTreeNode typeTreeNode : useTypeTree) { - for (BackApplyInfo applyInfo : backApplyInfoList) { - if (String.valueOf(typeTreeNode.getTypeId()).equals(applyInfo.getModelId())) { - BackApplyInfo dto = new BackApplyInfo(); - dto.setTypeId(String.valueOf(typeTreeNode.getTypeId())); - dto.setParentId(backApplyInfos.get(0).getId()); - applyInfo.setUnitNames(typeTreeNode.getUnitNames()); - applyInfo.setTypeId(String.valueOf(typeTreeNode.getTypeId())); - applyInfo.setUseNum(typeTreeNode.getNum()); - applyInfo.setBackNum(applyInfo.getPreNum()); - // 查询设备合格及维修数量及详情 - List numList = new ArrayList<>(); - List hgList = backReceiveMapper.getHgList(dto); - if (!CollectionUtils.isEmpty(hgList)) { - if (StringUtils.isNotBlank(hgList.get(0).getMaCode())) { - List list = new ArrayList<>(); - applyInfo.setPassNum(hgList.size()); - for (BackApplyInfo info : hgList) { - if (!"16".equals(info.getMaStatus())) { - maCodeList.add(info.getMaCode()); - continue; - } - MaCodeDto maCodeDto = new MaCodeDto(); - maCodeDto.setMaId(info.getMaId()); - maCodeDto.setMaCode(info.getMaCode()); - maCodeDto.setMaStatus(info.getMaStatus()); - maCodeDto.setTypeId(info.getTypeId()); - maCodeDto.setMaterialType(info.getMaterialType()); - maCodeDto.setMaterialName(info.getMaterialName()); - maCodeDto.setTypeName(info.getTypeName()); - list.add(maCodeDto); - } - applyInfo.setPassMaCodeDtoList(list); - numList.addAll(list); - } else { - applyInfo.setPassNum(hgList.get(0).getBackNum()); - } - } - // 查询维修数量及详情 - List wxList = backReceiveMapper.getWxList(dto); - if (!CollectionUtils.isEmpty(wxList)) { - if (StringUtils.isNotBlank(wxList.get(0).getMaCode())) { - List list = new ArrayList<>(); - applyInfo.setMaintenanceNum(wxList.size()); - for (BackApplyInfo info : wxList) { - if (!"16".equals(info.getMaStatus())) { - maCodeList.add(info.getMaCode()); - continue; - } - MaCodeDto maCodeDto = new MaCodeDto(); - maCodeDto.setMaId(info.getMaId()); - maCodeDto.setMaCode(info.getMaCode()); - maCodeDto.setMaStatus(info.getMaStatus()); - maCodeDto.setTypeId(info.getTypeId()); - maCodeDto.setMaterialType(info.getMaterialType()); - maCodeDto.setMaterialName(info.getMaterialName()); - maCodeDto.setTypeName(info.getTypeName()); - list.add(maCodeDto); - } - applyInfo.setRepairMaCodeDtoList(list); - numList.addAll(list); - } else { - applyInfo.setMaintenanceNum(wxList.get(0).getBackNum()); - } - } - // 查询是否存在附件 - dto.setDicId(36L); - List fileInfoList = backReceiveMapper.selectFileInfoList(dto); - if (!CollectionUtils.isEmpty(fileInfoList)) { - applyInfo.setFileList(fileInfoList); - } - if (!CollectionUtils.isEmpty(numList)) { - applyInfo.setNumList(numList); + if (!CollectionUtils.isEmpty(backApplyInfoList)) { + for (BackApplyInfo applyInfo : backApplyInfoList) { + boolean foundMatch = false; + BackApplyInfo dto = new BackApplyInfo(); + if (!CollectionUtils.isEmpty(useTypeTree)) { + for (TypeTreeNode typeTreeNode : useTypeTree) { + if (String.valueOf(typeTreeNode.getTypeId()).equals(applyInfo.getModelId())) { + dto.setTypeId(String.valueOf(typeTreeNode.getTypeId())); + dto.setParentId(backApplyInfos.get(0).getId()); + applyInfo.setUnitNames(typeTreeNode.getUnitNames()); + applyInfo.setTypeId(String.valueOf(typeTreeNode.getTypeId())); + applyInfo.setUseNum(typeTreeNode.getNum()); + applyInfo.setBackNum(applyInfo.getPreNum()); + foundMatch = true; + break; } } } + if (!foundMatch) { + dto.setTypeId(applyInfo.getModelId()); + dto.setParentId(backApplyInfos.get(0).getId()); + applyInfo.setUnitNames(StringUtils.isNotBlank(applyInfo.getUnitName()) ? applyInfo.getUnitName() : " "); + applyInfo.setTypeId(applyInfo.getModelId()); + applyInfo.setUseNum("0"); + applyInfo.setBackNum(applyInfo.getPreNum()); + } + // 查询设备合格及维修数量及详情 + List numList = getHgMaCodeDtos(isFinish, maCodeList, applyInfo, dto); + // 查询维修数量及详情 + getWxMaCodeDtos(isFinish, maCodeList, applyInfo, dto, numList); + // 查询是否存在附件 + dto.setDicId(36L); + List fileInfoList = backReceiveMapper.selectFileInfoList(dto); + if (!CollectionUtils.isEmpty(fileInfoList)) { + applyInfo.setFileList(fileInfoList); + } + if (!CollectionUtils.isEmpty(numList)) { + applyInfo.setNumList(numList); + } } - backApplyInfo.setBackApplyDetails(backApplyInfoList); } + backApplyInfo.setBackApplyDetails(backApplyInfoList); AjaxResult ajaxResult = AjaxResult.success(); - ajaxResult.put("data", backApplyInfo); - if (!CollectionUtils.isEmpty(maCodeList)) { + ajaxResult.put("data",backApplyInfo); + if(!CollectionUtils.isEmpty(maCodeList)) { // 拼接消息内容 StringBuffer msgBuilder = new StringBuffer("您所选择的编码设备编号 +"); for (int i = 0; i < maCodeList.size(); i++) { @@ -642,12 +612,85 @@ public class BackReceiveServiceImpl implements BackReceiveService { } msgBuilder.append("+已被他人完成退料,请注意查看!"); String msg = msgBuilder.toString(); - msg = msg.replaceAll("\n",""); + msg = msg.replaceAll("\n", ""); ajaxResult.put("msg", msg); } return ajaxResult; } + private void getWxMaCodeDtos(Boolean isFinish, List maCodeList, BackApplyInfo applyInfo, BackApplyInfo dto, List numList) { + List wxList = backReceiveMapper.getWxList(dto); + if (!CollectionUtils.isEmpty(wxList)) { + if (StringUtils.isNotBlank(wxList.get(0).getMaCode())) { + List list = new ArrayList<>(); + applyInfo.setMaintenanceNum(wxList.size()); + for (BackApplyInfo info : wxList) { + if (!isFinish) { + if (!"16".equals(info.getMaStatus())) { + maCodeList.add(info.getMaCode()); + continue; + } + } + MaCodeDto maCodeDto = new MaCodeDto(); + maCodeDto.setMaId(info.getMaId()); + maCodeDto.setMaCode(info.getMaCode()); + maCodeDto.setMaStatus(info.getMaStatus()); + maCodeDto.setTypeId(info.getTypeId()); + maCodeDto.setMaterialType(info.getMaterialType()); + maCodeDto.setMaterialName(info.getMaterialName()); + maCodeDto.setTypeName(info.getTypeName()); + list.add(maCodeDto); + } + applyInfo.setRepairMaCodeDtoList(list); + numList.addAll(list); + } else { + applyInfo.setMaintenanceNum(wxList.get(0).getBackNum()); + } + } + } + + /** + * 获取合格退料详情数据 + * @param isFinish + * @param maCodeList + * @param applyInfo + * @param dto + * @return + */ + private List getHgMaCodeDtos(Boolean isFinish, List maCodeList, BackApplyInfo applyInfo, BackApplyInfo dto) { + List numList = new ArrayList<>(); + List hgList = backReceiveMapper.getHgList(dto); + if (!CollectionUtils.isEmpty(hgList)) { + if (StringUtils.isNotBlank(hgList.get(0).getMaCode())) { + List list = new ArrayList<>(); + applyInfo.setPassNum(hgList.size()); + for (BackApplyInfo info : hgList) { + if (!isFinish) { + if (!"16".equals(info.getMaStatus())) { + maCodeList.add(info.getMaCode()); + continue; + } + } + MaCodeDto maCodeDto = new MaCodeDto(); + maCodeDto.setMaId(info.getMaId()); + maCodeDto.setMaCode(info.getMaCode()); + maCodeDto.setMaStatus(info.getMaStatus()); + maCodeDto.setTypeId(info.getTypeId()); + maCodeDto.setMaterialType(info.getMaterialType()); + maCodeDto.setMaterialName(info.getMaterialName()); + maCodeDto.setTypeName(info.getTypeName()); + list.add(maCodeDto); + } + applyInfo.setPassMaCodeDtoList(list); + numList.addAll(list); + } else { + applyInfo.setPassNum(hgList.get(0).getBackNum()); + } + } + return numList; + } + + @Override public Integer getPreAuditNum(BackApplyInfo record) { return backApplyMapper.getPreAuditNum(record); diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml index 007116d..18fae20 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml @@ -910,7 +910,7 @@ WHERE bcd.parent_id=#{parentId} and bcd.type_id=#{typeId} - and bcd.back_status='1' and (bcd.is_finished is null or bcd.is_finished != 1) + and bcd.back_status='1'