add: 企标计划excel导入
This commit is contained in:
@@ -45,6 +45,7 @@ import com.adc.da.sys.page.UserEOPage;
|
||||
import com.adc.da.sys.service.IUserEOService;
|
||||
import com.adc.da.util.LoginUserUtil;
|
||||
import com.adc.da.workFlow.entity.*;
|
||||
import com.adc.da.workFlow.entity.ProcessRollBackEO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
@@ -137,6 +137,12 @@
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
<version>2.2.0.RELEASE</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.adc.da.common;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wxyclub
|
||||
* @description
|
||||
* @date 2023/12/4
|
||||
*/
|
||||
@Data
|
||||
public class BusMes {
|
||||
|
||||
private String userId;
|
||||
|
||||
private String taskId;
|
||||
|
||||
private String json;
|
||||
|
||||
private String taskIds;
|
||||
|
||||
private String pId;
|
||||
|
||||
private String prcType;
|
||||
|
||||
private String createUser;
|
||||
|
||||
private String createUserName;
|
||||
|
||||
private String userName;
|
||||
|
||||
private int size;
|
||||
|
||||
private int current;
|
||||
|
||||
private String id;
|
||||
|
||||
private String nowStateType;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.adc.da.common;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wxyclub
|
||||
* @description
|
||||
* @date 2023/12/4
|
||||
*/
|
||||
@Data
|
||||
public class ProcessRollBackEO {
|
||||
|
||||
private String json;
|
||||
|
||||
private String type;
|
||||
|
||||
private String id;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String bpnId;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.adc.da.common;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
/**
|
||||
* @author wxyclub
|
||||
* @description
|
||||
* @date 2023/12/4
|
||||
*/
|
||||
@FeignClient(value = "bat-wkflow", contextId = "slrs")
|
||||
public interface WorkFlowFeignClient {
|
||||
|
||||
@RequestMapping(value = "/bat-wkflow/activiti_define_start_user_rollBack",method = RequestMethod.POST)
|
||||
Wrapper<String> activiti_define_start_rollBack(@RequestBody ProcessRollBackEO processRollBackEO);
|
||||
|
||||
@RequestMapping(value = "/bat-wkflow/completeTask",method = RequestMethod.POST)
|
||||
Wrapper<String> completeTaskByUserId(@RequestBody BusMes busMes);
|
||||
}
|
||||
+91
-3
@@ -2,6 +2,7 @@ package com.adc.da.slrs.esRevisePlan.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.adc.da.common.ReadExcel;
|
||||
import com.adc.da.exception.AdcDaBaseException;
|
||||
import com.adc.da.http.PageInfo;
|
||||
@@ -9,25 +10,32 @@ import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.esRevisePlan.service.IEsRevisePlanService;
|
||||
import com.adc.da.slrs.sarEnterpriseStandardEvaluation.service.IQualityEvaluationService;
|
||||
import com.adc.da.util.UUIDUtils;
|
||||
import com.adc.da.utils.util.EsRevisePlanExportUtil;
|
||||
import com.adc.da.utils.util.FieldConvertUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.adc.da.slrs.esRevisePlan.entity.EsRevisePlan;
|
||||
import io.swagger.annotations.Api;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -50,6 +58,9 @@ public class EsRevisePlanController extends BaseController<EsRevisePlan> {
|
||||
@Autowired
|
||||
private IQualityEvaluationService qualityEvaluationService;
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;
|
||||
|
||||
@ApiOperation(value = "获取所有企标计划")
|
||||
@GetMapping("getAllPlans")
|
||||
public ResponseMessage<Object> getAllPlans(EsRevisePlan esRevisePlan){
|
||||
@@ -291,4 +302,81 @@ public class EsRevisePlanController extends BaseController<EsRevisePlan> {
|
||||
return Result.success(iEsRevisePlanService.oaUpdatePlans(esId,date,s));
|
||||
}
|
||||
|
||||
@ApiOperation("企标计划Excel批量导入")
|
||||
@PostMapping("/importEsRevisePlan")
|
||||
public ResponseMessage<?> importEsRevisePlan(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
if (file == null) {
|
||||
return Result.error("文件为空,请重新上传");
|
||||
}
|
||||
return iEsRevisePlanService.importEsRevisePlan(file);
|
||||
}
|
||||
|
||||
@ApiOperation("企标计划导入模板下载")
|
||||
@GetMapping("/exportTemplateFile")
|
||||
public void exportTemplateFile(String fileName,HttpServletResponse response, HttpServletRequest request) throws Exception {
|
||||
OutputStream os = null;
|
||||
OutputStream excelOS = null;
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
String fileOriName = "企标计划导入模板";
|
||||
if (StringUtils.isNotEmpty(fileName)) {
|
||||
fileOriName = fileName;
|
||||
}
|
||||
try{
|
||||
//创建临时文件夹
|
||||
String fileNowPath = filePath + "/tempZip/" + UUIDUtils.randomUUID20() + "/" + fileOriName;
|
||||
File nowFile = new File(fileNowPath);
|
||||
if (nowFile.exists()){
|
||||
nowFile.delete();
|
||||
}
|
||||
nowFile.mkdirs();
|
||||
String fileName2 = "导入模板.xls";
|
||||
HSSFSheet sheetItems = workbook.createSheet("模板");
|
||||
sheetItems.setDefaultColumnWidth(17);
|
||||
Row rowHeader = sheetItems.createRow(1);//开始创建标题行
|
||||
sheetItems.addMergedRegion(new CellRangeAddress(0, 0, 0, 17));
|
||||
Row row2 = sheetItems.createRow(0);//开始创建填写说明
|
||||
String exportFieldName = FieldConvertUtil.exportFieldEsPlan;
|
||||
if (StringUtils.isNotBlank(exportFieldName)) {
|
||||
String[] headerArr = exportFieldName.split(",");
|
||||
for (int i=0;i < headerArr.length; i++) {
|
||||
rowHeader.createCell(i).setCellValue(headerArr[i]);
|
||||
}
|
||||
}
|
||||
Cell cellA2 = row2.createCell(0);
|
||||
cellA2.setCellValue(FieldConvertUtil.exportFieldEsPlanDesc);
|
||||
//sheetItems.setColumnWidth(0, 20 * 150);
|
||||
row2.setHeight((short) (100 * 25));
|
||||
HSSFCellStyle cellStyle =workbook.createCellStyle();
|
||||
cellStyle.setAlignment(HorizontalAlignment.LEFT);
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.TOP);
|
||||
cellStyle.setWrapText(true);
|
||||
cellA2.setCellStyle(cellStyle);
|
||||
String repFileName = fileName2.replaceAll("/","_");
|
||||
excelOS = new FileOutputStream(fileNowPath + "/" + repFileName);
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=\""+ ReadExcel.encodeFileName(fileOriName+".xls", request) +"\"");
|
||||
response.setContentType("application/force-download");
|
||||
response.flushBuffer();
|
||||
os = response.getOutputStream();
|
||||
workbook.write(excelOS);
|
||||
excelOS.flush();
|
||||
excelOS.close();
|
||||
InputStream inputStream = new FileInputStream(fileNowPath + "/" + repFileName);
|
||||
// FileInputStream fis = new FileInputStream(fileNowPath+".zip");
|
||||
int len = 0;
|
||||
while ((len = inputStream.read()) != -1) {
|
||||
os.write(len);
|
||||
}
|
||||
|
||||
os.flush();
|
||||
os.close(); // 后开先关
|
||||
// fis.close(); // 先开后关
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new com.adc.da.exception.AdcDaBaseException("下载文件失败,请重试");
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
IOUtils.closeQuietly(excelOS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.adc.da.slrs.esRevisePlan.entity;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.adc.da.base.page.BasePage;
|
||||
import com.adc.da.slrs.esMatingRelation.entity.EsMatingRelation;
|
||||
import com.adc.da.slrs.esStandRelation.entity.EsStandRelation;
|
||||
@@ -35,21 +36,26 @@ public class EsRevisePlan extends BasePage {
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "企标名称")
|
||||
@Excel(name = "*企标名称")
|
||||
private String esName;
|
||||
|
||||
@ApiModelProperty(value = "计划状态")
|
||||
private String planStatus;
|
||||
|
||||
@ApiModelProperty(value = "制修订状态")
|
||||
@Excel(name = "*制修订类型")
|
||||
private String reviseStatus;
|
||||
|
||||
@ApiModelProperty(value = "起草人")
|
||||
@Excel(name = "*起草人")
|
||||
private String drafter;
|
||||
|
||||
@ApiModelProperty(value = "评审责任人")
|
||||
@Excel(name = "*内部评审责任人")
|
||||
private String resPerson;
|
||||
|
||||
@ApiModelProperty(value = "工作组组长")
|
||||
@Excel(name = "*技术委员会评审负责人")
|
||||
private String wgLeader;
|
||||
|
||||
@ApiModelProperty(value = "企标ID")
|
||||
@@ -80,11 +86,13 @@ public class EsRevisePlan extends BasePage {
|
||||
@ApiModelProperty(value = "计划标准初稿完成时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "*计划标准初稿完成时间")
|
||||
private Date draftTime;
|
||||
|
||||
@ApiModelProperty(value = "计划标准发布时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "*计划标准发布时间")
|
||||
private Date releaseTime;
|
||||
|
||||
@ApiModelProperty(value = "起草责任单位ID")
|
||||
@@ -92,12 +100,14 @@ public class EsRevisePlan extends BasePage {
|
||||
|
||||
@ApiModelProperty(value = "起草责任单位名称")
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "*起草责任单位")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "引入企业标准json(标准id)")
|
||||
private String rqbJson;
|
||||
@ApiModelProperty(value = "引入企业标准json(标准名称)")
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "代替企标编号")
|
||||
private String rqbName;
|
||||
@ApiModelProperty(value = "引入企业标准json(标准编号)")
|
||||
@TableField(exist = false)
|
||||
@@ -106,10 +116,12 @@ public class EsRevisePlan extends BasePage {
|
||||
private String tsJson;
|
||||
@ApiModelProperty(value = "体系结构树(名称逗号拼接展示)")
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "体系结构")
|
||||
private String tsJsonName;
|
||||
@ApiModelProperty(value = "标准范围")
|
||||
private String area;
|
||||
@ApiModelProperty(value = "标准范围")
|
||||
@Excel(name = "适用车型")
|
||||
@TableField(exist = false)
|
||||
private String areaName;
|
||||
//企标类别
|
||||
@@ -122,10 +134,13 @@ public class EsRevisePlan extends BasePage {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "企标类别")
|
||||
@Excel(name = "引用标准")
|
||||
private String esMatingRelations;
|
||||
@Excel(name = "采用标准")
|
||||
private String esStandRelations;
|
||||
@ApiModelProperty(value = "是否引用标准")
|
||||
@TableField("is_relate")
|
||||
@Excel(name = "是否引用标准")
|
||||
private String isRelate;
|
||||
|
||||
@ApiModelProperty(value = "采用程度")
|
||||
@@ -133,6 +148,7 @@ public class EsRevisePlan extends BasePage {
|
||||
private String useLevel;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "采标程度")
|
||||
private String useLevelName;
|
||||
|
||||
@ApiModelProperty(value = "简述技术指标依据")
|
||||
@@ -141,6 +157,7 @@ public class EsRevisePlan extends BasePage {
|
||||
|
||||
@ApiModelProperty(value = "企标类别")
|
||||
@TableField("buss_sort")
|
||||
@Excel(name = "*企标类别")
|
||||
private String bussSort;
|
||||
|
||||
@TableField(exist = false)
|
||||
|
||||
+4
@@ -4,7 +4,9 @@ import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.slrs.esRevisePlan.entity.EsRevisePlan;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,5 +39,7 @@ public interface IEsRevisePlanService extends IService<EsRevisePlan> {
|
||||
|
||||
List<EsRevisePlan> batchToDoTasks(String json);
|
||||
|
||||
ResponseMessage<?> importEsRevisePlan(MultipartFile file) throws Exception;
|
||||
|
||||
// String modPlanByStateAndScore(EsRevisePlan esRevisePlan);
|
||||
}
|
||||
|
||||
+360
-6
@@ -1,5 +1,11 @@
|
||||
package com.adc.da.slrs.esRevisePlan.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import com.adc.da.common.BusMes;
|
||||
import com.adc.da.common.ProcessRollBackEO;
|
||||
import com.adc.da.common.WorkFlowFeignClient;
|
||||
import com.adc.da.common.Wrapper;
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.login.util.UserUtils;
|
||||
@@ -16,22 +22,32 @@ import com.adc.da.slrs.esStandRelation.service.IEsStandRelationService;
|
||||
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
|
||||
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
|
||||
import com.adc.da.slrs.sarEnterpriseStandardEvaluation.service.IQualityEvaluationService;
|
||||
import com.adc.da.sys.entity.UserEO;
|
||||
import com.adc.da.slrs.sarInstitution.entity.TsInstitution;
|
||||
import com.adc.da.slrs.sarInstitution.service.ITsInstitutionService;
|
||||
import com.adc.da.slrs.sarUser.entity.TsUser;
|
||||
import com.adc.da.slrs.sarUser.service.ITsUserService;
|
||||
import com.adc.da.slrs.tsDictionaryType.entity.TsDicType;
|
||||
import com.adc.da.slrs.tsDictionaryType.service.ITsDicTypeService;
|
||||
import com.adc.da.sys.sarMenuStandard.entity.SarMenuStandard;
|
||||
import com.adc.da.sys.sarMenuStandard.service.ISarMenuStandardService;
|
||||
import com.adc.da.util.LoginUserUtil;
|
||||
import com.adc.da.util.UUIDUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.adc.da.utils.util.FieldConvertUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -63,6 +79,17 @@ public class EsRevisePlanServiceImpl extends ServiceImpl<EsRevisePlanDao, EsRevi
|
||||
private IEsRevisePlanLogService esRevisePlanLogService;
|
||||
@Resource
|
||||
private IQualityEvaluationService qualityEvaluationService;
|
||||
@Resource
|
||||
private ITsDicTypeService tsDicTypeService;
|
||||
@Resource
|
||||
private ITsInstitutionService tsInstitutionService;
|
||||
@Resource
|
||||
private ITsUserService tsUserService;
|
||||
@Resource
|
||||
private ISarMenuStandardService sarMenuStandardService;
|
||||
@Resource
|
||||
private WorkFlowFeignClient workFlowFeignClient;
|
||||
|
||||
|
||||
@Override
|
||||
public List<EsRevisePlan> getAllPlans(EsRevisePlan esRevisePlan) {
|
||||
@@ -283,6 +310,333 @@ public class EsRevisePlanServiceImpl extends ServiceImpl<EsRevisePlanDao, EsRevi
|
||||
return esRevisePlans;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseMessage<?> importEsRevisePlan(MultipartFile file) throws Exception {
|
||||
String userId = LoginUserUtil.getUserId();
|
||||
//获取文件全称
|
||||
String fileNameStr = file.getOriginalFilename();
|
||||
//获取最后.的位置
|
||||
assert fileNameStr != null;
|
||||
int pos = fileNameStr.lastIndexOf(".");
|
||||
//获取文件后缀名并以小写显示
|
||||
String fileStr = fileNameStr.substring(pos + 1).toLowerCase();
|
||||
//校验是否是xls文件
|
||||
if (!(fileStr.equals("xls") || fileStr.equals("xlsx"))) {
|
||||
return Result.error("请上传Excel格式的文件");
|
||||
}
|
||||
Workbook workbook = null;
|
||||
InputStream inputStream = file.getInputStream();
|
||||
try {
|
||||
workbook = WorkbookFactory.create(inputStream);
|
||||
} catch (IOException e) {
|
||||
return Result.error("导入失败,需要导入的数据有问题");
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
if (sheet == null) {
|
||||
return Result.error("工作表为空");
|
||||
}
|
||||
List<String> headerList = new ArrayList<>();
|
||||
// 获取excel表头
|
||||
Row headerRow = sheet.getRow(1);
|
||||
try {
|
||||
for (int i = 0; i < 17; i++) {
|
||||
headerList.add(headerRow.getCell(i).getStringCellValue());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return Result.error("表头读取失败,请严格按照模板文件导入数据");
|
||||
}
|
||||
|
||||
// 判断表头字段是否相同
|
||||
if (!String.join(",",headerList).equals(FieldConvertUtil.exportFieldEsPlan)) {
|
||||
try {
|
||||
workbook.close();
|
||||
} catch (IOException e) {
|
||||
return Result.error("文件关闭出错");
|
||||
}
|
||||
return Result.error("fail", "读取失败,请严格按照模板文件导入数据");
|
||||
}
|
||||
// 获取总行数
|
||||
int rowNum = sheet.getPhysicalNumberOfRows();
|
||||
List<Map<String,String>> importDataList = new ArrayList<>();
|
||||
for (int rowIndex = 2; rowIndex < rowNum; rowIndex++) {
|
||||
// 获取每一行
|
||||
Row row = sheet.getRow(rowIndex);
|
||||
// 用于存储每行的键值对数据,对应一条数据
|
||||
Map<String, String> rowMap = new LinkedHashMap<>();
|
||||
// 总列数
|
||||
int columnNum = 17;
|
||||
// 遍历每个单元格
|
||||
for (int columnIndex = 0; columnIndex < columnNum; columnIndex++) {
|
||||
// 获取单元格
|
||||
Cell cell = row.getCell(columnIndex);
|
||||
// 获取表头单元格
|
||||
Cell headerCell = headerRow.getCell(columnIndex);
|
||||
if (cell != null) {
|
||||
if (CellType.NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)) {
|
||||
Date d = cell.getDateCellValue();
|
||||
try {
|
||||
if (d.before(sdf.parse("1900-01-01")) || d.after(sdf.parse("2500-01-01"))) {
|
||||
return Result.error("第"+(rowIndex-1)+"行第"+(columnIndex + 1)+"个单元格输入的日期异常,请按照实际日期填写");
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
return Result.error("第"+(rowIndex-1)+"行第"+(columnIndex + 1)+"个单元格输入的日期异常,请按照实际日期填写");
|
||||
}
|
||||
// 将单元格数据存入Map中
|
||||
rowMap.put(headerCell.getStringCellValue(), sdf.format(d));
|
||||
} else {
|
||||
cell.setCellType(CellType.STRING);
|
||||
if (cell.getStringCellValue().length() > 500) {
|
||||
return Result.error("第"+(rowIndex-1)+"行第"+(columnIndex + 1)+"个单元格输入过长");
|
||||
}
|
||||
rowMap.put(headerCell.getStringCellValue(), cell.getStringCellValue());
|
||||
}
|
||||
} else {
|
||||
rowMap.put(headerCell.getStringCellValue(), "");
|
||||
}
|
||||
}
|
||||
importDataList.add(rowMap);
|
||||
}
|
||||
if (importDataList.size() < 1) {
|
||||
return Result.error("您输入的数据为空");
|
||||
}
|
||||
ImportParams importParams = new ImportParams();
|
||||
importParams.setTitleRows(1);
|
||||
inputStream = file.getInputStream();
|
||||
List<EsRevisePlan> esRevisePlanList = ExcelImportUtil.importExcel(inputStream, EsRevisePlan.class, importParams);
|
||||
workbook.close();
|
||||
inputStream.close();
|
||||
// 获取需要校验的字段
|
||||
List<TsDicType> bussSortList = tsDicTypeService.selectAllDicTypeNameByDicCode("BUSSSTANDCLASS");
|
||||
List<String> bussSortNameList = bussSortList.stream().map(TsDicType::getDicTypeName).collect(Collectors.toList());
|
||||
List<TsDicType> areaList = tsDicTypeService.selectAllDicTypeNameByDicCode("ENERGYTYPES");
|
||||
List<String> areaNameList = areaList.stream().map(TsDicType::getDicTypeName).collect(Collectors.toList());
|
||||
List<TsDicType> useLevelList = tsDicTypeService.selectAllDicTypeNameByDicCode("DEGREESTANDARD");
|
||||
List<String> useLevelNameList = useLevelList.stream().map(TsDicType::getDicTypeName).collect(Collectors.toList());
|
||||
// 遍历索引
|
||||
int index = 1;
|
||||
// 去除空数据
|
||||
List<EsRevisePlan> esRevisePlanListNew = new ArrayList<>();
|
||||
for (EsRevisePlan esRevisePlan : esRevisePlanList) {
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getEsName())) {
|
||||
esRevisePlanListNew.add(esRevisePlan);
|
||||
}
|
||||
}
|
||||
if (esRevisePlanListNew.size() < 1) {
|
||||
return Result.error("您输入的数据为空");
|
||||
}
|
||||
for (EsRevisePlan esRevisePlan : esRevisePlanListNew){
|
||||
if (StringUtils.isBlank(esRevisePlan.getEsName())) {
|
||||
return Result.error("第" + index + "条记录的企标名称不能为空");
|
||||
}
|
||||
// 把excel表中的类别名转换为类别编号,并对类别名做检测
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getBussSort())) {
|
||||
if (!bussSortNameList.contains(esRevisePlan.getBussSort())){
|
||||
return Result.error("第" + index + "条记录的企标类别不符合输入要求");
|
||||
} else {
|
||||
for (TsDicType tsDicType : bussSortList) {
|
||||
if (esRevisePlan.getBussSort().equals(tsDicType.getDicTypeName())) {
|
||||
esRevisePlan.setBussSort(tsDicType.getDicTypeCode());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return Result.error("第" + index + "条记录的企标类别不能为空");
|
||||
}
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getAreaName())) {
|
||||
if (!areaNameList.contains(esRevisePlan.getAreaName())) {
|
||||
return Result.error("第" + index + "条记录的适用车型不符合输入要求");
|
||||
}
|
||||
List<String> tempAreaNameList = new ArrayList<>();
|
||||
for (String areaName : esRevisePlan.getAreaName().split(",")) {
|
||||
for (TsDicType tsDicType : areaList) {
|
||||
if (areaName.equals(tsDicType.getDicTypeName())) {
|
||||
tempAreaNameList.add(tsDicType.getDicTypeCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
esRevisePlan.setArea(String.join(",",tempAreaNameList));
|
||||
}
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getReviseStatus())) {
|
||||
if ("制定".equals(esRevisePlan.getReviseStatus())) {
|
||||
esRevisePlan.setReviseStatus("1");
|
||||
}else if( "修订".equals(esRevisePlan.getReviseStatus())) {
|
||||
esRevisePlan.setReviseStatus("2");
|
||||
}else {
|
||||
return Result.error("第" + index + "条记录的制修订类型只能是制定或修订");
|
||||
}
|
||||
esRevisePlan.setPlanStatus("6");
|
||||
}else {
|
||||
return Result.error("第" + index + "条记录的制修订类型不能为空");
|
||||
}
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getRqbName())) {
|
||||
LambdaQueryWrapper<SarBussionessStand> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SarBussionessStand::getStandCode, esRevisePlan.getRqbName());
|
||||
wrapper.eq(SarBussionessStand::getValidFlag,"0");
|
||||
wrapper.select(SarBussionessStand::getId);
|
||||
List<SarBussionessStand> standList = iSarBussionessStandService.list(wrapper);
|
||||
if (standList.size() < 1) {
|
||||
return Result.error("第" + index + "条记录的代替标准编号不存在");
|
||||
}
|
||||
esRevisePlan.setRqbJson(standList.get(0).getId());
|
||||
}
|
||||
if ("2".equals(esRevisePlan.getReviseStatus()) && StringUtils.isBlank(esRevisePlan.getRqbName())) {
|
||||
return Result.error("第" + index + "条记录的替换标准编号不能为空");
|
||||
}
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getUnitName())) {
|
||||
LambdaQueryWrapper<TsInstitution> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(TsInstitution::getName, esRevisePlan.getUnitName());
|
||||
wrapper.select(TsInstitution::getId);
|
||||
List<TsInstitution> institutionList = tsInstitutionService.list(wrapper);
|
||||
if (institutionList.size() < 1) {
|
||||
return Result.error("第" + index + "条记录的起草责任单位不存在");
|
||||
}
|
||||
esRevisePlan.setUnit(institutionList.get(0).getId());
|
||||
} else {
|
||||
return Result.error("第" + index + "条记录的起草责任单位不能为空");
|
||||
}
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getDrafter())) {
|
||||
int tempCount = 1;
|
||||
for (String drafter : esRevisePlan.getDrafter().split(",")) {
|
||||
LambdaQueryWrapper<TsUser> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(TsUser::getAccount, drafter);
|
||||
wrapper.eq(TsUser::getState, "1");
|
||||
wrapper.eq(TsUser::getValidFlag, "0");
|
||||
wrapper.eq(TsUser::getDisableFlag,"0");
|
||||
int count = tsUserService.count(wrapper);
|
||||
if (count < 1) {
|
||||
return Result.error("第" + index + "条记录的第"+tempCount+"个起草人不存在");
|
||||
}
|
||||
tempCount++;
|
||||
}
|
||||
}else {
|
||||
return Result.error("第" + index + "条记录的起草人不能为空");
|
||||
}
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getResPerson())) {
|
||||
int tempCount = 1;
|
||||
for (String resPerson : esRevisePlan.getResPerson().split(",")) {
|
||||
LambdaQueryWrapper<TsUser> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(TsUser::getAccount, resPerson);
|
||||
wrapper.eq(TsUser::getState, "1");
|
||||
wrapper.eq(TsUser::getValidFlag, "0");
|
||||
wrapper.eq(TsUser::getDisableFlag,"0");
|
||||
int count = tsUserService.count(wrapper);
|
||||
if (count < 1) {
|
||||
return Result.error("第" + index + "条记录的第"+tempCount+"个内部评审责任人不存在");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return Result.error("第" + index + "条记录的内部评审责任人不能为空");
|
||||
}
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getWgLeader())) {
|
||||
LambdaQueryWrapper<TsUser> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(TsUser::getAccount, esRevisePlan.getWgLeader());
|
||||
wrapper.eq(TsUser::getState, "1");
|
||||
wrapper.eq(TsUser::getValidFlag, "0");
|
||||
wrapper.eq(TsUser::getDisableFlag,"0");
|
||||
int count = tsUserService.count(wrapper);
|
||||
if (count < 1) {
|
||||
return Result.error("第" + index + "条记录的技术委员会评审负责人不存在");
|
||||
}
|
||||
}else {
|
||||
return Result.error("第" + index + "条记录的技术委员会评审负责人不能为空");
|
||||
}
|
||||
if (esRevisePlan.getDraftTime() == null) {
|
||||
return Result.error("第" + index + "条记录的计划标准初稿完成时间不能为空");
|
||||
}
|
||||
if (esRevisePlan.getReleaseTime() == null) {
|
||||
return Result.error("第" + index + "条记录的计划标准发布时间不能为空");
|
||||
}
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getTsJsonName())) {
|
||||
LambdaQueryWrapper<SarMenuStandard> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SarMenuStandard::getMenuName, esRevisePlan.getTsJsonName());
|
||||
wrapper.eq(SarMenuStandard::getDicId, "9m4qqqaansxmox5e82zm");
|
||||
wrapper.select(SarMenuStandard::getId);
|
||||
List<SarMenuStandard> menuStandardList = sarMenuStandardService.list(wrapper);
|
||||
if (menuStandardList.size() < 1) {
|
||||
return Result.error("第" + index + "条记录的体系类别不存在");
|
||||
}
|
||||
esRevisePlan.setTsJson(menuStandardList.get(0).getId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getIsRelate())) {
|
||||
if ("是".equals(esRevisePlan.getIsRelate())) {
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getEsStandRelations())) {
|
||||
int tempCount = 1;
|
||||
for (String standCode : esRevisePlan.getEsStandRelations().split(",")) {
|
||||
LambdaQueryWrapper<SarBussionessStand> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SarBussionessStand::getStandCode, standCode);
|
||||
wrapper.eq(SarBussionessStand::getValidFlag,"0");
|
||||
int count = iSarBussionessStandService.count(wrapper);
|
||||
if (count < 1) {
|
||||
return Result.error("第" + index + "条记录的第" + tempCount + "个采用标准不存在");
|
||||
}
|
||||
tempCount++;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getUseLevelName())) {
|
||||
if (useLevelNameList.contains(esRevisePlan.getUseLevelName())) {
|
||||
for (TsDicType tsDicType : useLevelList) {
|
||||
if (esRevisePlan.getUseLevelName().equals(tsDicType.getDicTypeName())) {
|
||||
esRevisePlan.setUseLevel(tsDicType.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return Result.error("第" + index + "条记录的采标程度不存在");
|
||||
}
|
||||
}
|
||||
esRevisePlan.setTechnologic(null);
|
||||
} else if ("否".equals(esRevisePlan.getIsRelate())) {
|
||||
esRevisePlan.setEsStandRelations(null);
|
||||
esRevisePlan.setUseLevel(null);
|
||||
} else {
|
||||
return Result.error("第" + index + "条记录的是否关联标准只能为'是'或'否'");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(esRevisePlan.getEsMatingRelations())) {
|
||||
int tempCount = 1;
|
||||
for (String standCode : esRevisePlan.getEsMatingRelations().split(",")) {
|
||||
LambdaQueryWrapper<SarBussionessStand> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SarBussionessStand::getStandCode, standCode);
|
||||
wrapper.eq(SarBussionessStand::getValidFlag,"0");
|
||||
int count = iSarBussionessStandService.count(wrapper);
|
||||
if (count < 1) {
|
||||
return Result.error("第" + index + "条记录的第" +tempCount+ "条应用标准不存在");
|
||||
}
|
||||
tempCount++;
|
||||
}
|
||||
}
|
||||
// 存入数据库
|
||||
ResponseMessage<Object> objectResponseMessage = addPlan(esRevisePlan);
|
||||
if (!objectResponseMessage.isOk()) {
|
||||
return Result.error("第" + index + "条记录存储失败");
|
||||
}
|
||||
ProcessRollBackEO rollBackEO=new ProcessRollBackEO();
|
||||
rollBackEO.setType("25");
|
||||
rollBackEO.setId("enterpriseStandardSystemRevisionPlan");
|
||||
String jsonString = JSONObject.toJSONString(esRevisePlan);
|
||||
rollBackEO.setJson(jsonString);
|
||||
rollBackEO.setUserId(userId);
|
||||
Wrapper<String> stringWrapper = workFlowFeignClient.activiti_define_start_rollBack(rollBackEO);
|
||||
if (!stringWrapper.isSuccess()) {
|
||||
return Result.error("第" + index + "条记录流程启动失败");
|
||||
}
|
||||
String result = stringWrapper.getResult();
|
||||
BusMes busMes = new BusMes();
|
||||
busMes.setTaskIds(result);
|
||||
busMes.setUserId(userId);
|
||||
busMes.setJson(jsonString);
|
||||
Wrapper<String> stringWrapper1 = workFlowFeignClient.completeTaskByUserId(busMes);
|
||||
if (!stringWrapper1.isSuccess()) {
|
||||
return Result.error("第" + index + "条记录流程启动失败");
|
||||
}
|
||||
// 索引 +1
|
||||
index++;
|
||||
}
|
||||
return Result.success("导入成功");
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String modPlanByStateAndScore(EsRevisePlan esRevisePlan) {
|
||||
// if (StringUtils.isBlank(esRevisePlan.getStandId())) {
|
||||
|
||||
@@ -77,6 +77,17 @@ public class FieldConvertUtil {
|
||||
// 政策课题关联表 表头
|
||||
public static String exportFieldLawsTopicRelation = "会议名称,会议时间,会议地点,参会人员(内部),会议主要内容,姓名,单位,电话,邮箱,身份,姓名,单位,电话,邮箱,身份";
|
||||
|
||||
public static String exportFieldEsPlan = "*企标类别,*企标名称,适用车型,*制修订类型,代替企标编号,*起草责任单位,*起草人,*内部评审责任人,*技术委员会评审负责人,*计划标准初稿完成时间,*计划标准发布时间,体系结构,是否引用标准,采用标准,采标程度,简述技术指标依据,引用标准";
|
||||
|
||||
public static String exportFieldEsPlanDesc = "填写说明\n" +
|
||||
"1.导入数据从第三行开始,第一行为填写说明,第二行为表头,第三行是正式数据\n" +
|
||||
"2.所有带*号的字段必须填写\n" +
|
||||
"3.企标类别(例如:Q/FD),体系结构(例如:物理集成)是单选属性,必须和系统中的对应字段选项相匹配,起草人因为涉及到同名问题只能填写账号例如(zhangsan3),如果有多个起草人需要使用英文逗号进行区分\n" +
|
||||
"4.适用车型,起草责任单位是多选属性,必须和系统中的对应字段选项相匹配,填写多个时采用英文逗号分割\n" +
|
||||
"5.制修订类型,只能是制定或修订\n" +
|
||||
"6.计划标准初稿完成时间,计划标准发布时间字段为年-月-日格式,必须精确到日,例如(2023-04-01)\n" +
|
||||
"7.企标类别,企标名称字段为文本,填写文本内容\n";
|
||||
|
||||
public static String exportBaseFieldNamesBussCode = "起草部门,废止日期,代替企标编号,复审日期,起草人,被代替企标编号,采用标准,文件上传人员,采标程度,引用标准,适用车型,能源类型,适用产品线,上传时间,体系类别,备案日期,关联模块-乘用车VPPS编码,关联模块--乘用车vpps中文名称,关联模块--卡车VPPS编码,关联模块--卡车vpps中文名称";
|
||||
|
||||
public static String exportAttrFieldNamesBuss = "SVPPS,规范性引用文件,废止日期,复审日期,密级,授权,相关部门," +
|
||||
|
||||
Reference in New Issue
Block a user