法规清单导入
This commit is contained in:
+2
-1
@@ -194,6 +194,7 @@ public class ProjectRelatedPersonnelController extends JeroController<ProjectRel
|
||||
@ApiOperation(value="项目库-相关人员维护表-根据projectId查询编辑时下拉数据", notes="项目库-相关人员维护表-根据projectId查询编辑时下拉数据")
|
||||
@GetMapping(value = "/queryPersonByProjectId")
|
||||
public Result<?> queryPersonByProjectId(@RequestParam(name="projectId",required=true) String projectId,@RequestParam(name="dutyTerritory",required=true) String dutyTerritory) {
|
||||
return this.projectRelatedPersonnelService.queryPersonByProjectId(projectId,dutyTerritory);
|
||||
Map<String, Object> objectMap = this.projectRelatedPersonnelService.queryPersonByProjectId(projectId, dutyTerritory);
|
||||
return Result.OK(objectMap);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 相关人员维护表
|
||||
@@ -66,7 +67,7 @@ public interface IProjectRelatedPersonnelService extends IService<ProjectRelated
|
||||
|
||||
List<ProjectRelatedPersonnel> queryPageList(String projectId);
|
||||
|
||||
Result<?> queryPersonByProjectId(String projectId,String dutyTerritory);
|
||||
Map<String,Object> queryPersonByProjectId(String projectId, String dutyTerritory);
|
||||
|
||||
/**处理导出数据*/
|
||||
List<ProjectRelatedPersonnel> disposeExportXls(String id,String projectId);
|
||||
|
||||
+752
-1
@@ -1,6 +1,7 @@
|
||||
package com.jero.modules.project.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.utils.IOUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -15,6 +16,7 @@ import com.jero.common.constant.enums.MessageTypeEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.DateUtils;
|
||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||
import com.jero.modules.dummy.entity.DummyInventoryInfoEO;
|
||||
@@ -34,24 +36,35 @@ import com.jero.modules.project.enums.TaskAffirmStatusEnum;
|
||||
import com.jero.modules.project.mapper.*;
|
||||
import com.jero.modules.project.service.IProjectLawsInventoryEOService;
|
||||
import com.jero.modules.project.service.IProjectTaskInventoryEOService;
|
||||
import com.jero.modules.project.service.IProjectRelatedPersonnelService;
|
||||
import com.jero.modules.split.common.FileUnZip;
|
||||
import com.jero.modules.system.entity.SysAnnouncement;
|
||||
import com.jero.modules.system.entity.SysCategory;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.mapper.SysUserMapper;
|
||||
import com.jero.modules.system.service.ISysAnnouncementService;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
|
||||
import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
@@ -63,6 +76,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -73,11 +87,13 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -134,6 +150,10 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
|
||||
|
||||
@Autowired
|
||||
private SysCategoryServiceImpl sysCategoryService;
|
||||
@Autowired
|
||||
private SysDictItemServiceImpl sysDictItemServiceImpl;
|
||||
@Autowired
|
||||
private IProjectRelatedPersonnelService iProjectRelatedPersonnelService;
|
||||
|
||||
/**
|
||||
* 保存
|
||||
@@ -1375,7 +1395,7 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
titleOne = "*编号,子标题,WVTA ID," +
|
||||
"实施类别,认证类型,*认证级别," +
|
||||
"*责任领域,*法规工程师,*认证工程师,*工程接口人," +
|
||||
"*责任领域,法规工程师,认证工程师,工程接口人," +
|
||||
"备注," +
|
||||
"设计符合性确认,Pre-homo确认,验证符合性确认";
|
||||
titleTwo = "交付物类型,交付物模板,发起人,责任人,截止时间,交付物类型,交付物模板,发起人,责任人,截止时间,交付物类型,交付物模板,发起人,责任人,截止时间,";
|
||||
@@ -1573,11 +1593,742 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
|
||||
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void importData(MultipartFile file, ProjectLawsInventoryEO projectLawsInventoryEO) {
|
||||
String title = "";
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
title = "*编号,子标题,WVTA ID,实施类别,认证类型,*认证级别,*责任领域,法规工程师,认证工程师,工程接口人,备注," +
|
||||
"设计交付物类型,设计交付物模板,设计发起人,设计责任人,设计截止时间," +
|
||||
"pre交付物类型,pre交付物模板,pre发起人,pre责任人,pre截止时间," +
|
||||
"验证交付物类型,验证交付物模板,验证发起人,验证责任人,验证截止时间";
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
int pos = file.getOriginalFilename().lastIndexOf(".");
|
||||
String str = file.getOriginalFilename().substring(pos + 1).toLowerCase();
|
||||
String filenameorg = file.getOriginalFilename().substring(0, pos);
|
||||
//判断上传文件必须是zip
|
||||
if (!str.equals("zip")) {
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
throw new JeroBootException("请上传zip格式的文件或rar格式的文件");
|
||||
}else{
|
||||
throw new JeroBootException("Please upload a zip file or rar file");
|
||||
}
|
||||
|
||||
}
|
||||
String path = uploadpath + File.separator + "modal" + File.separator + filenameorg + System.currentTimeMillis();
|
||||
File saveDirectory = new File(path);
|
||||
if (!saveDirectory.isDirectory()) {
|
||||
saveDirectory.mkdir();
|
||||
}
|
||||
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path + File.separator + file.getOriginalFilename()));
|
||||
//解压缩
|
||||
String zipEntryName = "";
|
||||
if (str.equals("zip")) {
|
||||
zipEntryName = FileUnZip.unZipFiles(path + File.separator + file.getOriginalFilename(), path);
|
||||
}
|
||||
|
||||
|
||||
//判断压缩包下是否只有一个文件夹
|
||||
File fileTemp = new File(path);
|
||||
int length = fileTemp.listFiles().length;
|
||||
if (length > 2) {
|
||||
//删除原上传文件
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
throw new JeroBootException("压缩包中必须有且仅有一个文件夹,请重新上传");
|
||||
}else{
|
||||
throw new JeroBootException("There must be only one folder in the compressed package Please upload it again");
|
||||
}
|
||||
|
||||
}
|
||||
File fileNew = new File(zipEntryName);
|
||||
List<File> fileList = new ArrayList<>();
|
||||
for (File file1 : fileNew.listFiles()) {
|
||||
if (file1.getName().contains(".xls") || file1.getName().contains(".xlsx")) {
|
||||
fileList.add(file1);
|
||||
}
|
||||
}
|
||||
if (fileList.size() == 0) {
|
||||
//删除原上传文件
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
throw new JeroBootException("压缩包根目录下没有excel作为导入数据,请重新上传");
|
||||
}else{
|
||||
throw new JeroBootException("Excel does not exist in the root directory of the compressed package Please upload it again");
|
||||
}
|
||||
|
||||
} else if (fileList.size() > 1) {
|
||||
//删除原上传文件
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
throw new JeroBootException("压缩包根目录下仅能存在一个excel为导入数据,请重新上传");
|
||||
}else{
|
||||
throw new JeroBootException("Only one Excel file can be imported in the compressed package root directory. Please upload data again");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 数据相关处理,
|
||||
// 1.获取其中的Excel,
|
||||
List<File> excelfilelist = FileUnZip.readImpExcelFile(zipEntryName);
|
||||
System.gc();
|
||||
if (excelfilelist.size() < 1) {
|
||||
//删除原上传文件
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
throw new JeroBootException("压缩包内没有上传Excel数据");
|
||||
}else{
|
||||
throw new JeroBootException("No Excel data is uploaded in the compressed package");
|
||||
}
|
||||
|
||||
} else if (excelfilelist.size() > 1) {
|
||||
//删除原上传文件
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
throw new JeroBootException("压缩包内有多个Excel数据源");
|
||||
}else{
|
||||
throw new JeroBootException("There are multiple Excel data sources in the zip package");
|
||||
}
|
||||
|
||||
}
|
||||
List<ProjectLawsInventoryEO> datas = new ArrayList<>();
|
||||
File excelFile = excelfilelist.get(0);
|
||||
Workbook workbook = WorkbookFactory.create(excelFile);
|
||||
List<Map<String, String>> dataList = new ArrayList<>();
|
||||
if (workbook != null) {
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
if (sheet != null) {
|
||||
StringBuilder headerSb = new StringBuilder();
|
||||
int rowNos = sheet.getLastRowNum();// 得到excel的总记录条数
|
||||
for (int i = 0; i <= rowNos; i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
Row headerRow = sheet.getRow(i);
|
||||
boolean isBlank = isRowEmpty(row);
|
||||
String key = "";
|
||||
if (row != null && !isBlank) {
|
||||
int columNos = headerRow.getLastCellNum();// 表头总共的列数
|
||||
Map<String, String> rowList = new LinkedHashMap<>();
|
||||
for (int j = 0; j < columNos; j++) {
|
||||
Cell cell = row.getCell(j);
|
||||
Cell headerCell = headerRow.getCell(j);
|
||||
if (cell != null) {
|
||||
if (i == 0) {
|
||||
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
||||
headerSb.append(cell.getStringCellValue() + ",");
|
||||
if(j == 10){
|
||||
break;
|
||||
}
|
||||
}else if(i == 1){
|
||||
if(j > 10){
|
||||
String flag = "";
|
||||
if(10 < j && j < 16){
|
||||
flag ="设计";
|
||||
key = flag + headerCell.getStringCellValue();
|
||||
}
|
||||
if(15 < j && j < 21){
|
||||
flag ="pre";
|
||||
key = flag + headerCell.getStringCellValue();
|
||||
}
|
||||
if(20 < j && j < 26){
|
||||
flag ="验证";
|
||||
key = flag + headerCell.getStringCellValue();
|
||||
|
||||
}
|
||||
headerSb.append(key + ",");
|
||||
}
|
||||
} else if(i > 2){
|
||||
List<String> headList = Arrays.asList(headerSb.toString().split(","));
|
||||
String field ="";
|
||||
if (HSSFCell.CELL_TYPE_NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)) {
|
||||
Date d = cell.getDateCellValue();
|
||||
field = fieldConvert(headList.get(j));
|
||||
rowList.put(field, df.format(d));
|
||||
} else {
|
||||
field = fieldConvert(headList.get(j));
|
||||
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
||||
String stringCellValue = cell.getStringCellValue();
|
||||
if (StringUtils.isNotBlank(stringCellValue)) {
|
||||
String replace = stringCellValue.replace(",", ",");
|
||||
rowList.put(field, replace);
|
||||
} else {
|
||||
rowList.put(field, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i > 2) {
|
||||
dataList.add(rowList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dataList.size() == 0) {
|
||||
//删除原上传文件
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
throw new JeroBootException("请填写必填字段内容,带*的为必填");
|
||||
}else{
|
||||
throw new JeroBootException("Please fill in the required fields marked with *");
|
||||
}
|
||||
|
||||
}else{
|
||||
//数据转换 JSON.parseObject(JSON.toJSONString(map), MyUser.class)
|
||||
for (Map<String, String> stringStringMap : dataList) {
|
||||
ProjectLawsInventoryEO projectLawsInventoryEOTemp = JSON.parseObject(JSON.toJSONString(stringStringMap), ProjectLawsInventoryEO.class);
|
||||
projectLawsInventoryEOTemp.setCut(projectLawsInventoryEO.getCut());
|
||||
projectLawsInventoryEOTemp.setProjectLibraryId(projectLawsInventoryEO.getProjectLibraryId());
|
||||
datas.add(projectLawsInventoryEOTemp);
|
||||
}
|
||||
}
|
||||
// 校验头部是否符合模板
|
||||
String substring = headerSb.toString();
|
||||
if (substring.endsWith(",") || substring.endsWith(",")){
|
||||
substring = headerSb.substring(0, headerSb.length() - 1);
|
||||
}
|
||||
|
||||
String excelHeader = substring.toString();
|
||||
if (!title.equals(excelHeader)) {
|
||||
workbook.close();
|
||||
//删除原上传文件
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
throw new JeroBootException("读取失败,请严格按照模板文件导入数据");
|
||||
}else{
|
||||
throw new JeroBootException("The data fails to be read. Import data strictly according to the template file");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
workbook.close();
|
||||
|
||||
|
||||
// //树形数据字典
|
||||
List<SysCategory> categoryList = sysCategoryService.list();
|
||||
//普通数据字典
|
||||
List<SysDictItem> dictItemList = sysDictItemServiceImpl.selectItemsAll();
|
||||
importDatas(datas, categoryList, dictItemList, zipEntryName,saveDirectory,projectLawsInventoryEO);
|
||||
//删除原上传文件
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
|
||||
}
|
||||
|
||||
private void importDatas(List<ProjectLawsInventoryEO> dataList,
|
||||
List<SysCategory> categoryList,
|
||||
List<SysDictItem> dictItemList,
|
||||
String zipEntryName,
|
||||
File saveDirectory,
|
||||
ProjectLawsInventoryEO projectLawsInventoryEOTemp) {
|
||||
int i = 3;
|
||||
List<String> msgList = new ArrayList<>();
|
||||
String value = "";
|
||||
boolean flag = true;
|
||||
//iProjectRelatedPersonnelService
|
||||
|
||||
//编号验证
|
||||
// List<BussDocumentLibraryEO> bussDocumentLibraryEOList = verifySerialNumber(dataList,projectLawsInventoryEOTemp);
|
||||
for (ProjectLawsInventoryEO projectLawsInventoryEO : dataList) {
|
||||
i++;
|
||||
String errorMsg = "";
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEOTemp.getCut())){
|
||||
errorMsg = "第" + i + "行:";
|
||||
}else{
|
||||
errorMsg = i + " line:";
|
||||
}
|
||||
//编号
|
||||
String serialNumber = projectLawsInventoryEO.getSerialNumber();
|
||||
//认证级别
|
||||
String attestationRank = projectLawsInventoryEO.getAttestationRank();
|
||||
//责任领域
|
||||
String dutyTerritory = projectLawsInventoryEO.getDutyTerritory();
|
||||
//认证类型
|
||||
String attestationType = projectLawsInventoryEO.getAttestationType();
|
||||
//实施类别
|
||||
String implementType = projectLawsInventoryEO.getImplementType();
|
||||
//法规工程师regulationOwnerId
|
||||
String regulationOwnerId = projectLawsInventoryEO.getRegulationOwnerId();
|
||||
|
||||
//认证工程师homologationEngineerId
|
||||
String homologationEngineerId = projectLawsInventoryEO.getHomologationEngineerId();
|
||||
|
||||
//工程接口人engineeringInterfacePerson
|
||||
String engineeringInterfacePerson = projectLawsInventoryEO.getEngineeringInterfacePerson();
|
||||
|
||||
//设计交付物类型
|
||||
String designDeliverableType = projectLawsInventoryEO.getDesignDeliverableType();
|
||||
//设计发起人
|
||||
String designInitiator = projectLawsInventoryEO.getDesignInitiator();
|
||||
//设计责任人
|
||||
String designDuty = projectLawsInventoryEO.getDesignDuty();
|
||||
//设计截止时间designDueDate
|
||||
Date designDueDate = projectLawsInventoryEO.getDesignDueDate();
|
||||
|
||||
//pre交付物类型
|
||||
String prehomoDeliverableType = projectLawsInventoryEO.getPrehomoDeliverableType();
|
||||
//pre发起人
|
||||
String prehomoInitiator = projectLawsInventoryEO.getPrehomoInitiator();
|
||||
//pre责任人
|
||||
String prehomoDuty = projectLawsInventoryEO.getPrehomoDuty();
|
||||
//pre截止时间prehomoDueDate
|
||||
Date prehomoDueDate = projectLawsInventoryEO.getPrehomoDueDate();
|
||||
|
||||
//确认交付物类型
|
||||
String verifyDeliverableType = projectLawsInventoryEO.getVerifyDeliverableType();
|
||||
//确认发起人
|
||||
String verifyInitiator = projectLawsInventoryEO.getVerifyInitiator();
|
||||
//确认责任人
|
||||
String verifyDuty = projectLawsInventoryEO.getVerifyDuty();
|
||||
//确认截止时间verifyDueDate
|
||||
Date verifyDueDate = projectLawsInventoryEO.getVerifyDueDate();
|
||||
|
||||
//文件
|
||||
String designDeliverableTemplate = projectLawsInventoryEO.getDesignDeliverableTemplate();
|
||||
String prehomoDeliverableTemplate = projectLawsInventoryEO.getPrehomoDeliverableTemplate();
|
||||
String verifyDeliverableTemplate = projectLawsInventoryEO.getVerifyDeliverableTemplate();
|
||||
|
||||
//编号(输入框必填)
|
||||
flag = must(projectLawsInventoryEO, errorMsg, msgList, serialNumber, "编号", "serial number");
|
||||
|
||||
|
||||
//实施类别(单选不必填)
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, implementType,msgList,"实施类别","implementation category");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setImplementType(value);
|
||||
}
|
||||
|
||||
//新车实施日期 xin1Che1Xing2Shi2Shi1Ri4Qi1
|
||||
// flag = dateVerify(dummyInventoryInfoEO, errorMsg, xin1Che1Xing2Shi2Shi1Ri4Qi1,msgList,"新车实施日期","new car implementation date");
|
||||
// if(flag){
|
||||
// dummyInventoryInfoEO.setXin1Che1Xing2Shi2Shi1Ri4Qi1(xin1Che1Xing2Shi2Shi1Ri4Qi1);
|
||||
// }
|
||||
|
||||
//在产车实施日期 implementTime
|
||||
// flag = dateVerify(dummyInventoryInfoEO, errorMsg, implementTime,msgList,"在产车实施日期","on the production vehicle implementation date");
|
||||
// if(flag){
|
||||
// dummyInventoryInfoEO.setImplementTime(implementTime);
|
||||
// }
|
||||
//认证类型(单选不必填)
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, attestationType,msgList,"认证类型","certification type");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setAttestationType(value);
|
||||
}
|
||||
|
||||
//认证级别(单选必填)
|
||||
flag = must(projectLawsInventoryEO, errorMsg, msgList, attestationRank,"认证级别","certification level");
|
||||
if(flag){
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, attestationRank,msgList,"认证级别","certification level");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setAttestationRank(value);
|
||||
}
|
||||
}
|
||||
|
||||
//责任领域(多选必填)
|
||||
flag = must(projectLawsInventoryEO, errorMsg, msgList, dutyTerritory,"责任领域","area of responsibility");
|
||||
if(flag){
|
||||
value = pullMore(dictItemList, projectLawsInventoryEO, errorMsg, dutyTerritory,msgList,"责任领域","area of responsibility");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setDutyTerritory(value);
|
||||
}
|
||||
}
|
||||
//工程接口人(责任领域下的工程接口人)
|
||||
Map<String, Object> objectMap = iProjectRelatedPersonnelService.queryPersonByProjectId(projectLawsInventoryEOTemp.getProjectLibraryId(), value);
|
||||
|
||||
//法规工程师
|
||||
List<Map<String, String>> mapLawList = (List<Map<String, String>>) objectMap.get("lawEngineerList");
|
||||
//认证工程师
|
||||
List<Map<String, String>> mapCertificationList = (List<Map<String, String>>) objectMap.get("certificationEngineerList");
|
||||
//工程接口人
|
||||
List<Map<String, String>> mapPersonList = (List<Map<String, String>>) objectMap.get("engineeringInterfacePersonList");
|
||||
|
||||
String nameCn = "";
|
||||
String nameEn = "";
|
||||
//法规工程师
|
||||
if(StringUtils.isNotBlank(regulationOwnerId)){
|
||||
nameCn = "法规工程师";
|
||||
nameEn = "regulatory engineer";
|
||||
//验证人员是否存在
|
||||
personnelVerify(projectLawsInventoryEO, errorMsg, regulationOwnerId, mapLawList,nameCn,nameEn);
|
||||
}
|
||||
|
||||
//认证工程师
|
||||
if(StringUtils.isNotBlank(homologationEngineerId)){
|
||||
nameCn = "认证工程师";
|
||||
nameEn = "certification engineer ";
|
||||
//验证人员是否存在
|
||||
personnelVerify(projectLawsInventoryEO, errorMsg, homologationEngineerId, mapCertificationList,nameCn,nameEn);
|
||||
}
|
||||
|
||||
//工程接口人
|
||||
if(StringUtils.isNotBlank(engineeringInterfacePerson)){
|
||||
nameCn = "工程接口人";
|
||||
nameEn = "engineering interface person ";
|
||||
//验证人员是否存在
|
||||
personnelVerify(projectLawsInventoryEO, errorMsg, homologationEngineerId, mapPersonList,nameCn,nameEn);
|
||||
}
|
||||
|
||||
|
||||
//设计
|
||||
//交付物类型
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, designDeliverableType,msgList,"交付物类型","type of deliverables");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setDesignDeliverableType(value);
|
||||
}
|
||||
|
||||
//交付物模板
|
||||
value = templateTransition(zipEntryName, projectLawsInventoryEO, errorMsg, designDeliverableTemplate,msgList,"交付物模板","deliverable template");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setDesignDeliverableTemplate(value);
|
||||
}
|
||||
|
||||
//发起人
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, designInitiator,msgList,"发起人","initiator");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setDesignInitiator(value);
|
||||
}
|
||||
|
||||
//责任人
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, designDuty,msgList,"责任人","person liable");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setDesignDuty(value);
|
||||
}
|
||||
|
||||
//截止时间
|
||||
flag = dateVerify(projectLawsInventoryEO, errorMsg, designDueDate,msgList,"在产车实施日期","on the production vehicle implementation date");
|
||||
if(flag){
|
||||
projectLawsInventoryEO.setImplementTime(designDueDate);
|
||||
}
|
||||
|
||||
|
||||
//pre
|
||||
//交付物类型
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, prehomoDeliverableType,msgList,"交付物类型","type of deliverables");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setPrehomoDeliverableType(value);
|
||||
}
|
||||
|
||||
//交付物模板
|
||||
value = templateTransition(zipEntryName, projectLawsInventoryEO, errorMsg, prehomoDeliverableTemplate,msgList,"交付物模板","deliverable template");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setPrehomoDeliverableTemplate(value);
|
||||
}
|
||||
|
||||
//发起人
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, prehomoInitiator,msgList,"发起人","initiator");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setPrehomoInitiator(value);
|
||||
}
|
||||
|
||||
//责任人
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, prehomoDuty,msgList,"责任人","person liable");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setPrehomoDuty(value);
|
||||
}
|
||||
|
||||
//截止时间
|
||||
flag = dateVerify(projectLawsInventoryEO, errorMsg, prehomoDueDate,msgList,"在产车实施日期","on the production vehicle implementation date");
|
||||
if(flag){
|
||||
projectLawsInventoryEO.setPrehomoDueDate(prehomoDueDate);
|
||||
}
|
||||
|
||||
//确认
|
||||
//交付物类型
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, verifyDeliverableType,msgList,"交付物类型","type of deliverables");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setVerifyDeliverableType(value);
|
||||
}
|
||||
|
||||
//交付物模板
|
||||
value = templateTransition(zipEntryName, projectLawsInventoryEO, errorMsg, verifyDeliverableTemplate,msgList,"交付物模板","deliverable template");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setVerifyDeliverableTemplate(value);
|
||||
}
|
||||
|
||||
|
||||
//发起人
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, verifyInitiator,msgList,"发起人","initiator");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setVerifyInitiator(value);
|
||||
}
|
||||
|
||||
//责任人
|
||||
value = pullSingle(dictItemList, projectLawsInventoryEO, errorMsg, verifyDuty,msgList,"责任人","person liable");
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
projectLawsInventoryEO.setVerifyDuty(value);
|
||||
}
|
||||
|
||||
//截止时间
|
||||
flag = dateVerify(projectLawsInventoryEO, errorMsg, verifyDueDate,msgList,"在产车实施日期","on the production vehicle implementation date");
|
||||
if(flag){
|
||||
projectLawsInventoryEO.setVerifyDueDate(verifyDueDate);
|
||||
}
|
||||
}
|
||||
|
||||
if (msgList.size() > 0) {
|
||||
//返回报错信息
|
||||
String html = "";
|
||||
for (String s : msgList) {
|
||||
html += s + "</br>";
|
||||
}
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
throw new JeroBootException(html);
|
||||
} else {
|
||||
if (dataList.size() != 0) {
|
||||
this.saveBatch(dataList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void personnelVerify(ProjectLawsInventoryEO projectLawsInventoryEO,
|
||||
String errorMsg, String regulationOwnerId,
|
||||
List<Map<String, String>> mapList,
|
||||
String nameCn,String nameEn) {
|
||||
//单选
|
||||
if(regulationOwnerId.contains(",")){
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
errorMsg += nameCn + "导入只能填写一个用户名";
|
||||
}else{
|
||||
errorMsg += "Only one user name can be entered for"+ nameEn +"import";
|
||||
}
|
||||
}
|
||||
|
||||
if(mapList.size() != 0){
|
||||
int count = 0;
|
||||
for (Map<String, String> stringStringMap : mapList) {
|
||||
String name = stringStringMap.get("name");
|
||||
if(regulationOwnerId.equals(name)){
|
||||
count ++;
|
||||
projectLawsInventoryEO.setRegulationOwnerId(stringStringMap.get("value"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(count == 0){
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
errorMsg += nameCn+regulationOwnerId+"与相关人员名单中责任领域下的人员不匹配";
|
||||
}else{
|
||||
errorMsg += nameEn+regulationOwnerId+"does not match a person under the area of responsibility in the relevant person list";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
errorMsg += nameCn+regulationOwnerId+"与相关人员名单中责任领域下的人员不匹配";
|
||||
}else{
|
||||
errorMsg += nameEn+regulationOwnerId+"does not match a person under the area of responsibility in the relevant person list";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean dateVerify(ProjectLawsInventoryEO projectLawsInventoryEO, String errorMsg,
|
||||
Date field,List<String> msgList,
|
||||
String nameCn,String nameEn) {
|
||||
//判断格式是否正确
|
||||
boolean flag = true;
|
||||
if(ObjectUtils.isNotEmpty(field)){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String format = sdf.format(field);
|
||||
if (!DateUtils.isValidDate(format)) {
|
||||
flag = false;
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
errorMsg += nameCn + "格式不正确,正确格式如:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
|
||||
}else{
|
||||
errorMsg += nameEn + " Incorrect format correct format is:yyyy/m/d、yyyy-MM-dd、yyyy年MM月dd日";
|
||||
}
|
||||
msgList.add(errorMsg);
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private boolean must(ProjectLawsInventoryEO projectLawsInventoryEO, String errorMsg,
|
||||
List<String> msgList, String serialNumber,String nameCn,String nameEn) {
|
||||
int errorCount = 0;
|
||||
if(StringUtils.isBlank(serialNumber)){
|
||||
errorCount ++;
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
errorMsg += "编号为必填项,不能为空";
|
||||
}else{
|
||||
errorMsg += "serial number this parameter is mandatory and cannot be empty";
|
||||
}
|
||||
msgList.add(errorMsg);
|
||||
}
|
||||
if(errorCount == 0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private String pullMore(List<SysDictItem> dictItemList, ProjectLawsInventoryEO projectLawsInventoryEO,
|
||||
String errorMsg, String value,List<String> msgList,
|
||||
String nameCn,String nameEn) {
|
||||
List<String> valueList = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
List<String> list = Arrays.asList(value.split(","));
|
||||
List<SysDictItem> collect = dictItemList.stream().filter(e -> list.contains(e.getItemText())).collect(Collectors.toList());
|
||||
if(list.size() == collect.size()){
|
||||
valueList = collect.stream().map(SysDictItem::getItemValue).collect(Collectors.toList());
|
||||
}else{
|
||||
//数据中有与数据字典不匹配的值
|
||||
List<String> finalValueList = valueList;
|
||||
List<String> diffList = list.stream().filter(e -> !finalValueList.contains(e)).collect(Collectors.toList());
|
||||
if (CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())) {
|
||||
errorMsg += nameCn + "中的" + StringUtils.join(diffList,",") + "与数据字典不匹配";
|
||||
} else {
|
||||
errorMsg += nameEn + " " + StringUtils.join(diffList,",") + " does not match the data dictionary";
|
||||
}
|
||||
msgList.add(errorMsg);
|
||||
}
|
||||
}
|
||||
return StringUtils.join(valueList,",");
|
||||
}
|
||||
|
||||
private String pullSingle(List<SysDictItem> dictItemList, ProjectLawsInventoryEO projectLawsInventoryEO,
|
||||
String errorMsg, String value,List<String> msgList,
|
||||
String nameCn,String nameEn) {
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
if(value.contains(",")){
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
errorMsg += nameCn + " 为单选项";
|
||||
}else{
|
||||
errorMsg += nameEn + " Is multiple Choice";
|
||||
}
|
||||
msgList.add(errorMsg);
|
||||
}else{
|
||||
List<SysDictItem> collect = dictItemList.stream().filter(e -> value.equals(e.getItemText())).collect(Collectors.toList());
|
||||
if (collect.size() == 0) {
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
errorMsg += nameCn + "中的" + value + "与数据字典不匹配";
|
||||
}else{
|
||||
errorMsg += nameEn +" "+ value + " does not match the data dictionary";
|
||||
}
|
||||
msgList.add(errorMsg);
|
||||
}else{
|
||||
return collect.get(0).getItemValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String templateTransition(String zipEntryName, ProjectLawsInventoryEO projectLawsInventoryEO,
|
||||
String errorMsg, String designDeliverableTemplate,List<String> msgList,
|
||||
String nameCn,String nameEn) {
|
||||
String value = "";
|
||||
if (StringUtils.isNotBlank(designDeliverableTemplate)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String fileName : designDeliverableTemplate.split(",")) {
|
||||
List<File> nowFileList = FileUnZip.readFileByFilename(zipEntryName, fileName);
|
||||
if (nowFileList.size() == 0) {
|
||||
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
|
||||
errorMsg += "压缩包中没有" + fileName + "文件; ";
|
||||
}else{
|
||||
errorMsg += " Not in the zip package" + fileName + "file; ";
|
||||
}
|
||||
msgList.add(errorMsg);
|
||||
} else {
|
||||
try {
|
||||
FileInputStream input = new FileInputStream(nowFileList.get(0));
|
||||
MultipartFile multipartFile =
|
||||
new MockMultipartFile(nowFileList.get(0).getName(), nowFileList.get(0).getName(), "text/plain", input);
|
||||
//文件存入文件表
|
||||
OSSFile ossFile = iOSSFileService.uploadLocal(multipartFile, "", null,null);
|
||||
if (ObjectUtils.isNotEmpty(ossFile)) {
|
||||
sb.append(ossFile.getId() + ",");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("虚拟清单导入"+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(sb)) {
|
||||
value = sb.substring(0, sb.length() - 1);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private String fieldConvert(String field){
|
||||
if (field == null) return null;
|
||||
switch (field) {
|
||||
case "*编号": return "serialNumber";
|
||||
case "标题": return "title";
|
||||
case "子标题": return "subtitle";
|
||||
case "适用范围": return "shi4Yong4Fan4Wei2";
|
||||
case "状态": return "state";
|
||||
case "对应标准": return "correspondingStandard";
|
||||
case "实施类别": return "implementType";
|
||||
case "新车实施日期": return "xin1Che1Xing2Shi2Shi1Ri4Qi1";
|
||||
case "在产车实施日期": return "implementTime";
|
||||
case "WVTA ID": return "wvtaId";
|
||||
case "认证类型": return "attestationType";
|
||||
case "*认证级别": return "attestationRank";
|
||||
case "技术领域": return "technologyTerritory";
|
||||
case "*责任领域": return "dutyTerritory";
|
||||
case "适用地区": return "region";
|
||||
case "备注": return "remark";
|
||||
case "设计交付物类型": return "designDeliverableType";
|
||||
case "设计交付物模板": return "designDeliverableTemplate";
|
||||
case "设计发起人": return "designInitiator";
|
||||
case "设计责任人": return "designDuty";
|
||||
case "pre交付物类型": return "prehomoDeliverableType";
|
||||
case "pre交付物模板": return "prehomoDeliverableTemplate";
|
||||
case "pre发起人": return "prehomoInitiator";
|
||||
case "pre责任人": return "prehomoDuty";
|
||||
case "验证交付物类型": return "verifyDeliverableType";
|
||||
case "验证交付物模板": return "verifyDeliverableTemplate";
|
||||
case "验证发起人": return "verifyInitiator";
|
||||
case "验证责任人": return "verifyDuty";
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//判断row是否为空 空返回true
|
||||
public boolean isRowEmpty(Row row) {
|
||||
if (null == row) {
|
||||
return true;
|
||||
}
|
||||
int firstCellNum = row.getFirstCellNum(); //第一个列位置
|
||||
int lastCellNum = row.getLastCellNum(); //最后一列位置
|
||||
int nullCellNum = 0; //空列数量
|
||||
for (int c = firstCellNum; c < lastCellNum; c++) {
|
||||
Cell cell = row.getCell(c);
|
||||
if (null == cell) {
|
||||
nullCellNum++;
|
||||
continue;
|
||||
}
|
||||
String value = "";
|
||||
switch (cell.getCellType()) {
|
||||
case HSSFCell.CELL_TYPE_NUMERIC: // 数字
|
||||
//如果为时间格式的内容
|
||||
value = String.valueOf(cell.getNumericCellValue());
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_STRING: // 字符串
|
||||
value = cell.getStringCellValue();
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_BOOLEAN: // Boolean
|
||||
value = cell.getBooleanCellValue() + "";
|
||||
break;
|
||||
case HSSFCell.CELL_TYPE_FORMULA: // 公式
|
||||
value = cell.getCellFormula() + "";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (org.apache.commons.lang.StringUtils.isEmpty(value)) {
|
||||
nullCellNum++;
|
||||
}
|
||||
}
|
||||
//所有列都为空
|
||||
if (nullCellNum == (lastCellNum - firstCellNum)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件
|
||||
|
||||
+10
-6
@@ -243,8 +243,8 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
|
||||
|
||||
|
||||
@Override
|
||||
public Result<?> queryPersonByProjectId(String projectId,String dutyTerritory) {
|
||||
JSONObject result = new JSONObject();
|
||||
public Map<String,Object> queryPersonByProjectId(String projectId,String dutyTerritory) {
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
List<Map<String,Object>> allPersonList = new ArrayList<>();
|
||||
List<Map<String,Object>> lawEngineerList = new ArrayList<>();
|
||||
List<Map<String,Object>> certificationEngineerList = new ArrayList<>();
|
||||
@@ -351,11 +351,15 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
|
||||
);
|
||||
|
||||
|
||||
result.put("lawEngineerList",lawEngineerList);
|
||||
result.put("certificationEngineerList",certificationEngineerList);
|
||||
result.put("engineeringInterfacePersonList",engineeringInterfacePersonList);
|
||||
result.put("lawEngineerList",lawEngineerList);//法规
|
||||
result.put("certificationEngineerList",certificationEngineerList);//认证
|
||||
result.put("engineeringInterfacePersonList",engineeringInterfacePersonList);//接口人
|
||||
result.put("allPersonList",allPersonList);
|
||||
return Result.OK(result);
|
||||
// result.put("lawEngineerList",lawEngineerList);
|
||||
// result.put("certificationEngineerList",certificationEngineerList);
|
||||
// result.put("engineeringInterfacePersonList",engineeringInterfacePersonList);
|
||||
// result.put("allPersonList",allPersonList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**处理导出数据*/
|
||||
|
||||
Reference in New Issue
Block a user