bug51957+51803相关修改为不校验空字段+52795认证工程师关联查询

This commit is contained in:
xiejunyu
2022-05-23 17:36:36 +08:00
parent a1e0d47009
commit 3d97252141
4 changed files with 143 additions and 141 deletions
@@ -5,7 +5,6 @@ import com.jero.common.aspect.annotation.AutoLog;
import com.jero.common.system.base.controller.JeroController;
import com.jero.modules.project.entity.ProjectRelatedPersonnel;
import com.jero.modules.project.service.IProjectRelatedPersonnelService;
import com.jero.modules.system.entity.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -195,7 +194,7 @@ public class ProjectRelatedPersonnelController extends JeroController<ProjectRel
@ApiOperation(value="项目库-相关人员维护表-根据projectId查询认证工程师", notes="项目库-相关人员维护表-根据projectId查询认证工程师")
@GetMapping(value = "/queryCertificationEngineer")
public Result<?> queryCertificationEngineer(@RequestParam(name="projectId",required=true) String projectId){
List<SysUser> certificationEngineerList = projectRelatedPersonnelService.queryCertificationEngineer(projectId);
List<ProjectRelatedPersonnel> certificationEngineerList = projectRelatedPersonnelService.queryCertificationEngineer(projectId);
return Result.OK(certificationEngineerList);
}
}
@@ -4,7 +4,7 @@ public enum ProjectTaskPlanningNameEnum {
LIST_CONFIRMATION("法规清单确认"," Confirmation of regulations list"),
LEGAL_TASK_CONFIRMATION("法规任务确认","Regulatory task confirmation"),
DESIGN_DEADLINE("设计符合性确认","Design Compliance Check"),
PREHOMO_DEADLINE("Pre-Homo确认","Pre-homo Check"),
PREHOMO_DEADLINE("Pre-Homo确认","Pre-Homo Check"),
ATTESTATION_START_TIME("认证开始","Certification start"),
ATTESTATION_END_TIME("认证结束"," Certification end"),
VERIFY_DEADLINE("验证符合性确认截止时间","Verification compliance confirmation deadline"),
@@ -2,7 +2,6 @@ package com.jero.modules.project.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.project.entity.ProjectRelatedPersonnel;
import com.jero.modules.system.entity.SysUser;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.springframework.web.multipart.MultipartFile;
@@ -87,5 +86,5 @@ public interface IProjectRelatedPersonnelService extends IService<ProjectRelated
ProjectRelatedPersonnel queryByProjectIdAndDutyTerritory(String projectId, String dutyTerritory);
List<SysUser> queryCertificationEngineer(String projectId);
List<ProjectRelatedPersonnel> queryCertificationEngineer(String projectId);
}
@@ -11,6 +11,7 @@ import com.jero.common.util.RedisUtil;
import com.jero.common.util.TokenUtils;
import com.jero.modules.dummy.service.impl.DummyInventoryInfoEOServiceImpl;
import com.jero.modules.enums.DictCodeEnum;
import com.jero.modules.project.entity.ProjectLibraryBase;
import com.jero.modules.project.entity.ProjectRelatedPersonnel;
import com.jero.modules.project.mapper.ProjectRelatedPersonnelMapper;
import com.jero.modules.project.service.IProjectRelatedPersonnelService;
@@ -83,6 +84,8 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
@Lazy
private RedisUtil redisUtil;
@Autowired
private ProjectLibraryBaseServiceImpl projectLibraryBaseService;
/**
* 保存
*
@@ -465,9 +468,9 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
try {
String titleOne = "";
if(CutEnum.CN.getValue().equals(cut)){
titleOne = "*责任领域,*法规工程师,*工程接口人,*认证工程师,备注";
titleOne = "责任领域,法规工程师,工程接口人,认证工程师,备注";
}else{
titleOne = "*Responsible Field,*Regulation Engineer,*Engineering Interface,*Homologation Engineer,Comments";
titleOne = "Responsible Field,Regulation Engineer,Engineering Interface,Homologation Engineer,Comments";
}
//创建临时文件夹
@@ -566,92 +569,92 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
String token = request.getHeader("X-Access-Token");
TokenUtils.verifyToken(token, sysBaseAPI, redisUtil);
OutputStream os = null;
HSSFWorkbook workbook = new HSSFWorkbook();
String fileOriName = "";
String filePath = uploadpath + File.separator + fileOriName;
try {
String titleOne = "";
if (CutEnum.CN.getValue().equals(projectRelatedPersonnel.getCut())) {
titleOne = "*责任领域,*法规工程师,*工程接口人,*认证工程师,备注";
fileOriName = "相关人员导入模板.xls";
} else {
titleOne = "*Responsible Field,*Regulation Engineer,*Engineering Interface,*Homologation Engineer,Comments";
fileOriName = "Import template of related personnel.xls";
}
//创建临时文件夹
File nowFile = new File(filePath);
if (nowFile.exists()) {
nowFile.delete();
}
nowFile.mkdirs();
HSSFSheet sheet = workbook.createSheet("虚拟清单导入模板");
sheet.setDefaultColumnWidth(16);//列宽
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setWrapText(true);//自动换行
cellStyle.setAlignment(HorizontalAlignment.CENTER);//垂直居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//水平居中
HSSFCellStyle cellStyleTemp = workbook.createCellStyle();
cellStyleTemp.setWrapText(true);//自动换行
int startLine = 0;
int endLine = 4;
//合并单元格
CellRangeAddress region1 =
new CellRangeAddress(1, 1, startLine, endLine); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列
sheet.addMergedRegion(region1);
String explainInfo = null;
if (CutEnum.CN.getValue().equals(projectRelatedPersonnel.getCut())) {
explainInfo = "填写说明\n" +
"1.导入数据从第三行开始\n" +
"2.所有带*号的字段必须填写\n" +
"3.认证类型,认证级别,实施类别,交付物类型,发起人,责任人,字段是单选属性,必须和系统中的对应字段选项相匹配\n" +
"4.责任领域,字段是多选属性,必须和系统中的对应字段选项相匹配,填写多个时采用英文或中文逗号分割\n" +
"5.编号,子标题,WVTA ID,备注,填写文本内容\n" +
"6.交付物模板字段为文件属性,填写时需要在本文件同级目录下以标准号为名称建立文件夹,并在文件夹下放置文件,假设在AAA标准号下放置了B.docx,则应填写AAA/B.docx";
} else {
explainInfo = "filling explanation\n" +
"1.import data starts at the third line\n" +
"2.all fields marked with * must be filled in\n" +
"3.Certification Type,Certification Level,Usage,type of deliverables,initiator,person liable,Fields are radio attributes that must match the corresponding field option in the system\n" +
"4.Responsible Field, field is a multi-select attribute and must match the corresponding field in the system. If multiple fields are filled in, separate them by commas (,)\n" +
"5.Number,Sub-Title,WVTA ID,Comments,Fill in the text\n" +
"6.deliverable template,When filling in the field, you need to create a folder in the directory of the same level as the file with the name of the standard number and place the file in the folder. If b. diocx is stored under the AAA standard number, enter AAA/B. diocx";
}
HSSFRichTextString explain = new HSSFRichTextString(explainInfo);
//表头
Row row = sheet.createRow(0);//开始创建标题行
String[] headerArr = titleOne.split(",");
for (int m = 0; m < headerArr.length; m++) {
row.createCell(m).setCellValue(headerArr[m]);
}
Row rowExplain = sheet.createRow(1);
short height = (short) (7 * 252);
rowExplain.setHeight((short) height);
Cell cell = rowExplain.createCell(0);
cell.setCellValue(explain);
cell.setCellStyle(cellStyleTemp);
response.setHeader("Content-Disposition",
"attachment; filename=\"" + fileOriName + ".xls");
response.setContentType("application/force-download");
response.flushBuffer();
os = response.getOutputStream();
workbook.write(os);
} catch (Exception e) {
e.printStackTrace();
throw new JeroBootException("下载文件失败,请重试");
} finally {
IOUtils.closeQuietly(os);
OutputStream os = null;
HSSFWorkbook workbook = new HSSFWorkbook();
String fileOriName = "";
String filePath = uploadpath + File.separator + fileOriName;
try {
String titleOne = "";
if (CutEnum.CN.getValue().equals(projectRelatedPersonnel.getCut())) {
titleOne = "责任领域,法规工程师,工程接口人,认证工程师,备注";
fileOriName = "相关人员导入模板.xls";
} else {
titleOne = "Responsible Field,Regulation Engineer,Engineering Interface,Homologation Engineer,Comments";
fileOriName = "Import template of related personnel.xls";
}
//创建临时文件夹
File nowFile = new File(filePath);
if (nowFile.exists()) {
nowFile.delete();
}
nowFile.mkdirs();
HSSFSheet sheet = workbook.createSheet("虚拟清单导入模板");
sheet.setDefaultColumnWidth(16);//列宽
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setWrapText(true);//自动换行
cellStyle.setAlignment(HorizontalAlignment.CENTER);//垂直居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//水平居中
HSSFCellStyle cellStyleTemp = workbook.createCellStyle();
cellStyleTemp.setWrapText(true);//自动换行
int startLine = 0;
int endLine = 4;
//合并单元格
CellRangeAddress region1 =
new CellRangeAddress(1, 1, startLine, endLine); //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列
sheet.addMergedRegion(region1);
String explainInfo = null;
if (CutEnum.CN.getValue().equals(projectRelatedPersonnel.getCut())) {
explainInfo = "填写说明\n" +
"1.导入数据从第三行开始\n" +
"2.所有带*号的字段必须填写\n" +
"3.认证类型,认证级别,实施类别,交付物类型,发起人,责任人,字段是单选属性,必须和系统中的对应字段选项相匹配\n" +
"4.责任领域,字段是多选属性,必须和系统中的对应字段选项相匹配,填写多个时采用英文或中文逗号分割\n" +
"5.编号,子标题,WVTA ID,备注,填写文本内容\n" +
"6.交付物模板字段为文件属性,填写时需要在本文件同级目录下以标准号为名称建立文件夹,并在文件夹下放置文件,假设在AAA标准号下放置了B.docx,则应填写AAA/B.docx";
} else {
explainInfo = "filling explanation\n" +
"1.import data starts at the third line\n" +
"2.all fields marked with * must be filled in\n" +
"3.Certification Type,Certification Level,Usage,type of deliverables,initiator,person liable,Fields are radio attributes that must match the corresponding field option in the system\n" +
"4.Responsible Field, field is a multi-select attribute and must match the corresponding field in the system. If multiple fields are filled in, separate them by commas (,)\n" +
"5.Number,Sub-Title,WVTA ID,Comments,Fill in the text\n" +
"6.deliverable template,When filling in the field, you need to create a folder in the directory of the same level as the file with the name of the standard number and place the file in the folder. If b. diocx is stored under the AAA standard number, enter AAA/B. diocx";
}
HSSFRichTextString explain = new HSSFRichTextString(explainInfo);
//表头
Row row = sheet.createRow(0);//开始创建标题行
String[] headerArr = titleOne.split(",");
for (int m = 0; m < headerArr.length; m++) {
row.createCell(m).setCellValue(headerArr[m]);
}
Row rowExplain = sheet.createRow(1);
short height = (short) (7 * 252);
rowExplain.setHeight((short) height);
Cell cell = rowExplain.createCell(0);
cell.setCellValue(explain);
cell.setCellStyle(cellStyleTemp);
response.setHeader("Content-Disposition",
"attachment; filename=\"" + fileOriName + ".xls");
response.setContentType("application/force-download");
response.flushBuffer();
os = response.getOutputStream();
workbook.write(os);
} catch (Exception e) {
e.printStackTrace();
throw new JeroBootException("下载文件失败,请重试");
} finally {
IOUtils.closeQuietly(os);
}
}
@@ -670,7 +673,7 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
String titleOne = "";
if(CutEnum.CN.getValue().equals(cut)){
titleOne = "*责任领域,*法规工程师,*工程接口人,*认证工程师,备注";
titleOne = "责任领域,法规工程师,工程接口人,认证工程师,备注";
explainInfo = "填写说明\n" +
"1.导入数据从第三行开始\n" +
"2.所有带*号的字段必须填写\n"+
@@ -679,7 +682,7 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
"5.编号,子标题,WVTA ID,备注,填写文本内容\n" +
"6.交付物模板字段为文件属性,填写时需要在本文件同级目录下以标准号为名称建立文件夹,并在文件夹下放置文件,假设在AAA标准号下放置了B.docx,则应填写AAA/B.docx";
}else{
titleOne = "*Responsible Field,*Regulation Engineer,*Engineering Interface,*Homologation Engineer,Comments";
titleOne = "Responsible Field,Regulation Engineer,Engineering Interface,Homologation Engineer,Comments";
explainInfo = "filling explanation\n" +
"1.import data starts at the third line\n" +
"2.all fields marked with * must be filled in\n"+
@@ -710,46 +713,48 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
Row headerRow = sheet.getRow(i);
boolean isBlank = dummyInventoryInfoEOService.isRowEmpty(row);
if (row != null && !isBlank) {
int columNos = headerRow.getLastCellNum();// 表头总共的列数
if (columNos == 5) {//列数对
for (int j = 0; j < columNos; j++) {
Cell cell = row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
if (i == 0){
if (i == 0 && !cell.getStringCellValue().equals(titleOneList.get(j))) {//检查表头
if (CutEnum.CN.getValue().equals(cut)) {
throw new JeroBootException("读取失败.请检查第 " + (i+1) + " 行表头,请严格按照模板文件导入数据");
} else {
throw new JeroBootException("The data fails to be read.Please check header in line " + (i+1) + " .Import data strictly according to the template file.");
}
// if (row != null && !isBlank) {
int columHeadNos = headerRow.getLastCellNum();// 表头总共的列数
if (columHeadNos == 5) {//列数对
for (int j = 0; j < columHeadNos; j++) {
Cell cell = row.getCell(j,Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
if (i == 0){
if (i == 0 && !cell.getStringCellValue().equals(titleOneList.get(j))) {//检查表头
if (CutEnum.CN.getValue().equals(cut)) {
throw new JeroBootException("读取失败.请检查第 " + (i+1) + " 行表头,请严格按照模板文件导入数据");
} else {
throw new JeroBootException("The data fails to be read.Please check header in line " + (i+1) + " .Import data strictly according to the template file.");
}
}
}
}else if((i!=1 && columNos != 5) || (i==2 && columNos !=1)){
}
}/*else if(i!=1 && columNos != 5) {
if (CutEnum.CN.getValue().equals(cut)) {
throw new JeroBootException("导入的列数不对,请检查");
} else {
throw new JeroBootException("The number of imported columns is wrong. Please check!");
}
}
}else{
if (CutEnum.CN.getValue().equals(cut)) {
throw new JeroBootException("导入的数据不能为空,请检查");
} else {
throw new JeroBootException("The imported data of cannot be empty. Please check!");
}
}
}*/
// }else{
// if (CutEnum.CN.getValue().equals(cut)) {
// throw new JeroBootException("导入的数据不能为空,请检查");
// } else {
// throw new JeroBootException("The imported data of cannot be empty. Please check!");
// }
// }
if (i == 1) {//校验填写说明
row = sheet.getRow(i);
int columNos = row.getLastCellNum();
if(columNos != 1 /*|| (!row.getCell(0).getStringCellValue().equals(explainInfo))*/){
if (CutEnum.CN.getValue().equals(cut)) {
throw new JeroBootException("填写说明列数不对,请严格按照模板文件导入数据");
}else{
throw new JeroBootException("The number of columns of filling explanation is wrong. Please import data strictly according to the template file.");
//if(columNos != 1 /*|| (!row.getCell(0).getStringCellValue().equals(explainInfo))*/){
for (int k = 0; k < columNos; k++){
if (k>0 && StringUtils.isNotBlank(row.getCell(k).getStringCellValue())) {
if (CutEnum.CN.getValue().equals(cut)) {
throw new JeroBootException("填写说明列数不对,请严格按照模板文件导入数据");
} else {
throw new JeroBootException("The number of columns of filling explanation is wrong. Please import data strictly according to the template file.");
}
}
}
}
if (i > 1) {//读取数据
//获取每一行数据
@@ -762,7 +767,7 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
projectRelatedPersonnel.setDutyTerritory(row.getCell(0).toString());
}else{//责任领域不能为空,报错
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("请填写责任领域,带*的为必填.请检查第 "+ (i+1) + "");
throw new JeroBootException("请填写责任领域,为必填.请检查第 "+ (i+1) + "");
}else{
throw new JeroBootException("Please fill in the Responsible Field and those marked with * are required. .Please check line" + (i+1));
}
@@ -777,18 +782,18 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
projectRelatedPersonnel.setLawEngineerName(lawEngineerName);
projectRelatedPersonnel.setEngineeringInterfacePersonName(engineeringInterfacePersonName);
projectRelatedPersonnel.setCertificationEngineerName(certificationEngineerName);
}else if(StringUtils.isBlank(lawEngineerName) && StringUtils.isBlank(engineeringInterfacePersonName) && StringUtils.isBlank(certificationEngineerName)) {
//除了责任领域,带*的全为空->可以
}else if(StringUtils.isBlank(lawEngineerName) || StringUtils.isBlank(engineeringInterfacePersonName) || StringUtils.isBlank(certificationEngineerName)) {
//除了责任领域,其他的可以全为空->可以
projectRelatedPersonnel.setLawEngineerName("");
projectRelatedPersonnel.setEngineeringInterfacePersonName("");
projectRelatedPersonnel.setCertificationEngineerName("");
}else {//除了责任领域,备注,有一个为空都报错
}/*else {//除了责任领域,备注,有一个为空都报错
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("请填写必填字段内容,带*的为必填.请检查第 "+ (i+1) + "行");
}else{
throw new JeroBootException("Please fill in the required fields marked with * .Please check line" + (i+1));
}
}
}*/
String remark = row.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).toString();
if(StringUtils.isNotEmpty(row.getCell(4).toString())) {
@@ -803,7 +808,7 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
}
workbook.close();
//把数据翻译成id,并保存
oppositeDisposeData(list, projectId, cut);
oppositeDisposeData(list, projectId, cut);
}
@@ -1037,28 +1042,27 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
// }
@Override
public List<SysUser> queryCertificationEngineer(String projectId) {
public List<ProjectRelatedPersonnel> queryCertificationEngineer(String projectId) {
QueryWrapper<ProjectRelatedPersonnel> queryWrapper = new QueryWrapper<>();
List<ProjectRelatedPersonnel> list = list(queryWrapper.eq("project_id",projectId));
List<String> certificationEngineerList = list.stream().map(e -> e.getCertificationEngineer()).collect(Collectors.toList());
// List<String> certificationEngineerIdList = list.stream().map(e -> e.getCertificationEngineer()).collect(Collectors.toList());
StringBuilder userIdBuilder=new StringBuilder();
List<SysUser> certificationEngineerUsers = new ArrayList<>();
if(CollectionUtils.isNotEmpty(certificationEngineerList)){
for(String certificationEngineerId :certificationEngineerList){
if(StringUtils.isNotBlank(certificationEngineerId)) {
userIdBuilder.append(certificationEngineerId).append(",");
//查询基础表认证工程师的值
QueryWrapper<ProjectLibraryBase> baseQueryWrapper = new QueryWrapper<>();
List<ProjectLibraryBase> baseDataList = projectLibraryBaseService.list(baseQueryWrapper.eq("id", projectId));
String baseCertificationEngineer = baseDataList.get(0).getCertificationEngineer();
// List<ProjectRelatedPersonnel> certificationEngineerUsers = new ArrayList<>();//认证工程师非空
if(StringUtils.isNotBlank(baseCertificationEngineer)) {
for (ProjectRelatedPersonnel projectRelatedPersonnel : list) {
if (StringUtils.isBlank(projectRelatedPersonnel.getCertificationEngineer())) {
projectRelatedPersonnel.setCertificationEngineer(baseCertificationEngineer);
}
}
String userId = userIdBuilder.substring(0, userIdBuilder.toString().length() - 1);
List userIdList = Arrays.asList(userId.split(","));
userIdList.stream().distinct().collect(Collectors.toList());
QueryWrapper<SysUser> userqueryWrapper = new QueryWrapper<>();
userqueryWrapper.in("id ", userIdList);
certificationEngineerUsers = sysUserMapper.selectList(userqueryWrapper);
}
return certificationEngineerUsers;
disposeData(list);
return list;
}