勾选认证清单进行关联平台件

This commit is contained in:
zhn
2023-09-20 19:00:32 +08:00
parent 6578af3925
commit 0bef771651
3 changed files with 143 additions and 20 deletions
@@ -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<Pr
return Result.OK(cut,pageList);
}
/**
* 勾选认证清单进行关联平台件
*
* @return
*/
@AutoLog(value = "勾选认证清单进行关联平台件")
@ApiOperation(value="勾选认证清单进行关联平台件", notes="勾选认证清单进行关联平台件")
@PostMapping(value = "/listPlatform")
public Result<?> listPlatform(@RequestBody Map<String,Object> params) {
projectCertificationInventoryEOService.listPlatform(params);
return Result.OK();
}
/**
* 列表查询
*
@@ -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<Projec
* @return
*/
Result<?> matchRelevantPeople(Map<String, Object> params);
/**
* 勾选认证清单进行关联平台件
* @param params
* @return
*/
void listPlatform(Map<String, Object> params);
}
@@ -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<Proj
private IProjectLibraryRoleRelEOService projectLibraryRoleRelEOService;
@Autowired
private IProcessHistoryEOService processHistoryEOService;
@Autowired
private LawsInventoryPlatformEOServiceImpl lawsInventoryPlatformEOService;
/**
* 保存
@@ -6847,4 +6850,98 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
return result;
}
/**
* 勾选认证清单进行关联平台件
*
* @return
*/
@Override
public void listPlatform(Map<String,Object> params) {
String cut = (String) params.get("cut");//
String ids = (String) params.get("ids");//认证清单id
String projectLibraryIds = (String) params.get("projectLibraryIds");//平台件项目id
//认证清单数据
LambdaQueryWrapper<ProjectCertificationInventoryEO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(ProjectCertificationInventoryEO::getId,Arrays.asList(ids.split(",")));
List<ProjectCertificationInventoryEO> certificationInventoryEOList = this.list(wrapper);
//平台件项目对应的认证清单数据
LambdaQueryWrapper<ProjectCertificationInventoryEO> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.in(ProjectCertificationInventoryEO::getProjectLibraryId,Arrays.asList(projectLibraryIds.split(",")));
List<ProjectCertificationInventoryEO> certificationInventoryEOS = this.list(wrapper1);
//平台件项目信息
List<ProjectLibraryBase> projectLibraryBaseList = new ArrayList<>();
if(!certificationInventoryEOList.isEmpty()){
List<String> projectIdList = certificationInventoryEOS.stream().map(ProjectCertificationInventoryEO::getProjectLibraryId).distinct().collect(Collectors.toList());
LambdaQueryWrapper<ProjectLibraryBase> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.in(ProjectLibraryBase::getId,projectIdList);
projectLibraryBaseList = projectLibraryBaseService.list(wrapper2);
}
List<LawsInventoryPlatformEO> lawsInventoryPlatformEOS = new ArrayList<>();
for (ProjectCertificationInventoryEO projectCertificationInventoryEO : certificationInventoryEOList) {
Map<String,Object> map = new HashMap<>();
List<ProjectLawsInventoryEO> 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<ProjectLibraryBase> 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<LawsInventoryPlatformEO> 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);
}
}