diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectCertificationInventoryEOController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectCertificationInventoryEOController.java index c943f39cb..4c6b640f6 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectCertificationInventoryEOController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/controller/ProjectCertificationInventoryEOController.java @@ -1,32 +1,39 @@ package com.jero.modules.project.controller; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import com.alibaba.fastjson.JSONObject; -import com.jero.common.api.vo.Result; -import com.jero.common.system.query.QueryGenerator; -import com.jero.modules.project.entity.ProjectCertificationInventoryEO; -import com.jero.modules.project.entity.ProjectLawsInventoryEO; -import com.jero.modules.project.service.IProjectCertificationInventoryEOService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.jero.modules.system.entity.SysRole; -import lombok.extern.slf4j.Slf4j; +import com.jero.common.api.vo.Result; +import com.jero.common.aspect.annotation.AutoLog; import com.jero.common.system.base.controller.JeroController; +import com.jero.common.system.query.QueryGenerator; +import com.jero.modules.project.entity.ProjectCertificationInventoryEO; +import com.jero.modules.project.service.IProjectCertificationInventoryEOService; +import com.jero.modules.system.entity.SysRole; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import com.jero.common.aspect.annotation.AutoLog; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.List; +import java.util.Map; /** @@ -86,6 +93,19 @@ public class ProjectCertificationInventoryEOController extends JeroController listPlatform(@RequestBody Map params) { + projectCertificationInventoryEOService.listPlatform(params); + return Result.OK(); + } + /** * 列表查询 * diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectCertificationInventoryEOService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectCertificationInventoryEOService.java index 16dcdbaaf..472446bd3 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectCertificationInventoryEOService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectCertificationInventoryEOService.java @@ -4,10 +4,9 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.jero.common.api.vo.Result; -import com.jero.common.system.vo.DictModel; -import com.jero.modules.project.entity.ProjectCertificationInventoryEO; import com.baomidou.mybatisplus.extension.service.IService; +import com.jero.common.api.vo.Result; +import com.jero.modules.project.entity.ProjectCertificationInventoryEO; import com.jero.modules.system.entity.SysCategory; import com.jero.modules.system.entity.SysDictItem; import com.jero.modules.system.entity.SysRole; @@ -339,4 +338,11 @@ public interface IProjectCertificationInventoryEOService extends IService matchRelevantPeople(Map params); + + /** + * 勾选认证清单进行关联平台件 + * @param params + * @return + */ + void listPlatform(Map params); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java index 7c04dc814..830ccfbd3 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java @@ -31,6 +31,7 @@ import com.jero.modules.feishu.enums.TemplateInfoEnum2; import com.jero.modules.feishu.service.IFeishuService; import com.jero.modules.oss.entity.OSSFile; import com.jero.modules.oss.service.IOSSFileService; +import com.jero.modules.project.entity.LawsInventoryPlatformEO; import com.jero.modules.project.entity.ProjectCertificationInventoryDutyEnginnerEO; import com.jero.modules.project.entity.ProjectCertificationInventoryDutyEnginnerEOEn; import com.jero.modules.project.entity.ProjectCertificationInventoryEO; @@ -227,6 +228,8 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl params) { + String cut = (String) params.get("cut");// + String ids = (String) params.get("ids");//认证清单id + String projectLibraryIds = (String) params.get("projectLibraryIds");//平台件项目id + + //认证清单数据 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(ProjectCertificationInventoryEO::getId,Arrays.asList(ids.split(","))); + List certificationInventoryEOList = this.list(wrapper); + + //平台件项目对应的认证清单数据 + LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); + wrapper1.in(ProjectCertificationInventoryEO::getProjectLibraryId,Arrays.asList(projectLibraryIds.split(","))); + List certificationInventoryEOS = this.list(wrapper1); + + //平台件项目信息 + List projectLibraryBaseList = new ArrayList<>(); + if(!certificationInventoryEOList.isEmpty()){ + List projectIdList = certificationInventoryEOS.stream().map(ProjectCertificationInventoryEO::getProjectLibraryId).distinct().collect(Collectors.toList()); + LambdaQueryWrapper wrapper2 = new LambdaQueryWrapper<>(); + wrapper2.in(ProjectLibraryBase::getId,projectIdList); + projectLibraryBaseList = projectLibraryBaseService.list(wrapper2); + } + + List lawsInventoryPlatformEOS = new ArrayList<>(); + + for (ProjectCertificationInventoryEO projectCertificationInventoryEO : certificationInventoryEOList) { + Map map = new HashMap<>(); + List projectLawsInventoryEOS = new ArrayList<>(); + //类别 + String category = projectCertificationInventoryEO.getCategory(); + //检验项目 + String inspectionItem = projectCertificationInventoryEO.getInspectionItem(); + //配置项 + String configItem = projectCertificationInventoryEO.getConfigItem(); + //编号 + String serialNumber = projectCertificationInventoryEO.getSerialNumber(); + //责任领域 + String dutyTerritory = projectCertificationInventoryEO.getDutyTerritory(); + + for (ProjectCertificationInventoryEO certificationInventoryEO : certificationInventoryEOS) { + List libraryBaseList = projectLibraryBaseList.stream() + .filter(e -> certificationInventoryEO.getProjectLibraryId().equals(e.getId())).collect(Collectors.toList()); + //平台件项目库中的认证清单的配置项为平台件项目名称 + String configItemTemp = ""; + if(!libraryBaseList.isEmpty()){ + //配置项 + configItemTemp = libraryBaseList.get(0).getProjectNameId(); + } + //类别 + String categoryTemp = certificationInventoryEO.getCategory(); + //检验项目 + String inspectionItemTemp = certificationInventoryEO.getInspectionItem(); + //编号 + String serialNumberTemp = certificationInventoryEO.getSerialNumber(); + //责任领域 + String dutyTerritoryTemp = certificationInventoryEO.getDutyTerritory(); + + if(StringUtils.isBlank(configItem) || "标配".equals(configItem)){ + //如果车型项目库中的配置项为空或为标配时,直接将平台件信息添加到关联表 + setData(lawsInventoryPlatformEOS, projectCertificationInventoryEO, certificationInventoryEO); + }else if(StringUtils.isNotBlank(configItem) && !"标配".equals(configItem)){ + //如果车型项目库中的配置项不为空且不为标配时,如果车型项目库认证清单的配置项与平台件认证清单的配置项不一致,则不再匹配 + //如果一致,则用类别,检验项目,编号,责任领域去做匹配 + if(configItem.equals(configItemTemp) + && category.equals(categoryTemp) + && inspectionItem.equals(inspectionItemTemp) + && serialNumber.equals(serialNumberTemp) + && dutyTerritory.equals(dutyTerritoryTemp)){ + setData(lawsInventoryPlatformEOS, projectCertificationInventoryEO, certificationInventoryEO); + } + } + } + } + if(!lawsInventoryPlatformEOS.isEmpty()){ + lawsInventoryPlatformEOService.saveBatch(lawsInventoryPlatformEOS); + } + } + + private void setData(List lawsInventoryPlatformEOS, ProjectCertificationInventoryEO projectCertificationInventoryEO, ProjectCertificationInventoryEO certificationInventoryEO) { + LawsInventoryPlatformEO inventoryPlatformEO = new LawsInventoryPlatformEO(); + inventoryPlatformEO.setCreateTime(new Date()); + inventoryPlatformEO.setUpdateTime(new Date()); + inventoryPlatformEO.setLawsInventoryId(projectCertificationInventoryEO.getId()); + inventoryPlatformEO.setPlatformLawsInventoryId(certificationInventoryEO.getId()); + lawsInventoryPlatformEOS.add(inventoryPlatformEO); + } + }