Merge remote-tracking branch 'origin/develop_master' into develop_master
This commit is contained in:
@@ -0,0 +1,80 @@
|
|||||||
|
package com.adc.da.slrs.ImportExcelDatas.comment;
|
||||||
|
|
||||||
|
import com.adc.da.slrs.ImportExcelDatas.entity.ImportDto;
|
||||||
|
import com.adc.da.utils.util.BussStandExportUtil;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ExclErrorOut {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(BussStandExportUtil.class);
|
||||||
|
|
||||||
|
public static Workbook exportDatas (List<ImportDto> datas,String header) {
|
||||||
|
Workbook workbook = new XSSFWorkbook();
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
//创建工作表对象
|
||||||
|
Sheet sheet = workbook.createSheet();
|
||||||
|
// 创建头部
|
||||||
|
createHeader(workbook,sheet,header);
|
||||||
|
// 创建数据
|
||||||
|
createDatas(workbook,sheet,datas);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return workbook;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void createHeader(Workbook workbook, Sheet sheet, String header){
|
||||||
|
CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象
|
||||||
|
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
Row rowHeader = sheet.createRow(0);//开始创建标题行
|
||||||
|
if (StringUtils.isNotBlank(header)) {
|
||||||
|
String[] headerArr = header.split(",");
|
||||||
|
for (int i=0;i < headerArr.length; i++) {
|
||||||
|
rowHeader.createCell(i).setCellValue(headerArr[i]);
|
||||||
|
// rowHeader.createCell(i).setCellStyle(cellStyle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void createDatas(Workbook workbook,Sheet sheet,List<ImportDto> datas) throws Exception{
|
||||||
|
CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象
|
||||||
|
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
if (datas != null && !datas.isEmpty()) {
|
||||||
|
for (int i=0;i < datas.size(); i++) {
|
||||||
|
ImportDto importDto = datas.get(i);
|
||||||
|
Row row = sheet.createRow(i+1);
|
||||||
|
|
||||||
|
int sheetNum = 0;
|
||||||
|
|
||||||
|
Class cls = importDto.getClass();
|
||||||
|
Field[] fields = cls.getDeclaredFields();
|
||||||
|
for (Field field : fields) {
|
||||||
|
field.setAccessible(true);
|
||||||
|
if (field.get(importDto)!=null){
|
||||||
|
String value = field.get(importDto).toString();
|
||||||
|
row.createCell(sheetNum).setCellValue(value);
|
||||||
|
}else {
|
||||||
|
row.createCell(sheetNum).setCellValue("");
|
||||||
|
}
|
||||||
|
sheetNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+47
-5
@@ -1,15 +1,23 @@
|
|||||||
package com.adc.da.slrs.ImportExcelDatas.controller;
|
package com.adc.da.slrs.ImportExcelDatas.controller;
|
||||||
|
|
||||||
import com.adc.da.base.web.BaseController;
|
import com.adc.da.base.web.BaseController;
|
||||||
|
import com.adc.da.common.ReadExcel;
|
||||||
import com.adc.da.http.ResponseMessage;
|
import com.adc.da.http.ResponseMessage;
|
||||||
|
import com.adc.da.slrs.ImportExcelDatas.comment.ExclErrorOut;
|
||||||
import com.adc.da.slrs.ImportExcelDatas.entity.ImportDto;
|
import com.adc.da.slrs.ImportExcelDatas.entity.ImportDto;
|
||||||
import com.adc.da.slrs.ImportExcelDatas.service.ImportExcelService;
|
import com.adc.da.slrs.ImportExcelDatas.service.ImportExcelService;
|
||||||
import com.adc.da.slrs.ImportExcelDatas.service.impl.ImportExcelServiceImpl;
|
import com.adc.da.slrs.ImportExcelDatas.service.impl.ImportExcelServiceImpl;
|
||||||
|
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
|
||||||
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStar;
|
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStar;
|
||||||
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStarEO;
|
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStarEO;
|
||||||
|
import com.adc.da.util.exception.AdcDaBaseException;
|
||||||
|
import com.adc.da.util.utils.IOUtils;
|
||||||
|
import com.adc.da.util.utils.StringUtils;
|
||||||
|
import com.adc.da.utils.util.BussStandExportUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -17,6 +25,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
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.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -28,14 +40,44 @@ public class ImportExcelController extends BaseController<ImportDto> {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ImportExcelService importExcelService;
|
private ImportExcelService importExcelService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ExclErrorOut exclErrorOut;
|
||||||
|
|
||||||
@ApiOperation("批量删除用户收藏")
|
@ApiOperation("批量删除用户收藏")
|
||||||
@PostMapping("/import")
|
@PostMapping("/import")
|
||||||
public ResponseMessage<Boolean> deleteList(MultipartFile file,MultipartFile file2) {
|
public void deleteList(MultipartFile file, MultipartFile file2, HttpServletResponse response, HttpServletRequest request) throws IOException {
|
||||||
Map<String, List<ImportDto>> mapMap=importExcelService.getExcelData(file,file2);
|
Map<String, List<ImportDto>> mapMap=importExcelService.getExcelData(file,file2);
|
||||||
ResponseMessage responseMessage=new ResponseMessage();
|
List<ImportDto> errorList = importExcelService.storageExclData(mapMap);
|
||||||
responseMessage.setMessage(mapMap.toString());
|
// ResponseMessage responseMessage=new ResponseMessage();
|
||||||
responseMessage.isOk();
|
// responseMessage.setMessage(mapMap.toString());
|
||||||
return responseMessage;
|
// responseMessage.isOk();
|
||||||
|
|
||||||
|
OutputStream os = null;
|
||||||
|
Workbook workbook = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
String exportName="错误表格";
|
||||||
|
response.setHeader("Content-Disposition",
|
||||||
|
"attachment; filename=" + ReadExcel.encodeFileName(exportName+".xlsx",request));
|
||||||
|
response.setContentType("application/force-download");
|
||||||
|
//导出数据
|
||||||
|
String headStr="标准号,标准名称,英文名称,发布时间,实施时间,标准状态,代替标准号,附件路径,错误原因";
|
||||||
|
workbook = exclErrorOut.exportDatas(errorList,headStr);
|
||||||
|
os = response.getOutputStream();
|
||||||
|
workbook.write(os);
|
||||||
|
os.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new AdcDaBaseException("下载文件失败,请重试");
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(os);
|
||||||
|
if (workbook != null) {
|
||||||
|
workbook.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// return responseMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,7 @@ public class ImportDto extends BaseEntity {
|
|||||||
private String replaceId;
|
private String replaceId;
|
||||||
// 附件路径
|
// 附件路径
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
|
// 错误原因
|
||||||
|
private String errorStr;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -11,4 +11,7 @@ public interface ImportExcelService extends IService<ImportDto> {
|
|||||||
|
|
||||||
Map<String, List<ImportDto>> getExcelData(MultipartFile file,MultipartFile file2);
|
Map<String, List<ImportDto>> getExcelData(MultipartFile file,MultipartFile file2);
|
||||||
|
|
||||||
|
|
||||||
|
public List<ImportDto> storageExclData(Map<String, List<ImportDto>> importListMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+468
@@ -1,8 +1,25 @@
|
|||||||
package com.adc.da.slrs.ImportExcelDatas.service.impl;
|
package com.adc.da.slrs.ImportExcelDatas.service.impl;
|
||||||
|
|
||||||
|
import com.adc.da.att.service.IAttFileEOService;
|
||||||
|
import com.adc.da.att.vo.AttFileVo;
|
||||||
|
import com.adc.da.mq.CreateStandMQService;
|
||||||
import com.adc.da.slrs.ImportExcelDatas.dao.ImportExcelDao;
|
import com.adc.da.slrs.ImportExcelDatas.dao.ImportExcelDao;
|
||||||
import com.adc.da.slrs.ImportExcelDatas.entity.ImportDto;
|
import com.adc.da.slrs.ImportExcelDatas.entity.ImportDto;
|
||||||
import com.adc.da.slrs.ImportExcelDatas.service.ImportExcelService;
|
import com.adc.da.slrs.ImportExcelDatas.service.ImportExcelService;
|
||||||
|
import com.adc.da.slrs.sarBussStandAttrInfo.dao.SarBussStandAttrInfoDao;
|
||||||
|
import com.adc.da.slrs.sarBussStandAttrInfo.entity.SarBussStandAttrInfo;
|
||||||
|
import com.adc.da.slrs.sarBussStandAttrInfo.service.impl.SarBussStandAttrInfoServiceImpl;
|
||||||
|
import com.adc.da.slrs.sarBussionessStand.dao.SarBussionessStandDao;
|
||||||
|
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
|
||||||
|
import com.adc.da.slrs.sarBussionessStand.service.impl.SarBussionessStandServiceImpl;
|
||||||
|
import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao;
|
||||||
|
import com.adc.da.slrs.sarStandAttrInfo.entity.SarStandAttrInfo;
|
||||||
|
import com.adc.da.slrs.sarStandAttrInfo.service.impl.SarStandAttrInfoServiceImpl;
|
||||||
|
import com.adc.da.slrs.sarStandardsInfo.dao.SarStandardsInfoDao;
|
||||||
|
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
|
||||||
|
import com.adc.da.slrs.sarStandardsInfo.service.impl.SarStandardsInfoServiceImpl;
|
||||||
|
import com.adc.da.util.UUIDUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
@@ -10,9 +27,12 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|||||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -20,6 +40,37 @@ import java.util.*;
|
|||||||
public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDto> implements ImportExcelService {
|
public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDto> implements ImportExcelService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAttFileEOService attFileEOService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CreateStandMQService createStandMQService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SarStandardsInfoServiceImpl sarStandardsInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SarStandardsInfoDao sarStandardInfoDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SarStandAttrInfoDao sarStandAttrInfoDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SarBussionessStandDao sarBussionessStandDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SarBussStandAttrInfoDao sarBussStandAttrInfoDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SarBussionessStandServiceImpl sarBussionessStandService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SarBussStandAttrInfoServiceImpl sarBussStandAttrInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SarStandAttrInfoServiceImpl sarStandAttrInfoService;
|
||||||
|
|
||||||
|
|
||||||
private final static String GN = "GB,GB/T,QC/T,GJB,JB,JT,HG,YV,SY,SH,GA,HJ,QB,JG,NB,JC,YS/T,FZ/T,TB/T,JJG,SJ/T,T/TBPS" +
|
private final static String GN = "GB,GB/T,QC/T,GJB,JB,JT,HG,YV,SY,SH,GA,HJ,QB,JG,NB,JC,YS/T,FZ/T,TB/T,JJG,SJ/T,T/TBPS" +
|
||||||
",NB/T,CJ/T,YS/T,SJ/T,BB/T,SN/T,SB/T,MH/T,DB11,SZDB/Z,HKG,T/ZSA,CSAE,T/CAS,T/CADA,T/CHTS,T/ITS,T/BJQC";
|
",NB/T,CJ/T,YS/T,SJ/T,BB/T,SN/T,SB/T,MH/T,DB11,SZDB/Z,HKG,T/ZSA,CSAE,T/CAS,T/CADA,T/CHTS,T/ITS,T/BJQC";
|
||||||
private final static String QB = "Q/QCBFC,Q/FT,Q/FL,Q/QCFLC,Q/BQB,Q/SGT," +
|
private final static String QB = "Q/QCBFC,Q/FT,Q/FL,Q/QCFLC,Q/BQB,Q/SGT," +
|
||||||
@@ -227,4 +278,421 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Value("file.importPath")
|
||||||
|
private String importPath;
|
||||||
|
|
||||||
|
private List<ImportDto> error=new ArrayList<>();
|
||||||
|
@Override
|
||||||
|
public List<ImportDto> storageExclData(Map<String, List<ImportDto>> importListMap) {
|
||||||
|
|
||||||
|
error = importListMap.get("error");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 海外标准
|
||||||
|
*/
|
||||||
|
importListMap.get("HWBZ").forEach(item->{
|
||||||
|
|
||||||
|
String standID = UUIDUtils.randomUUID20();
|
||||||
|
|
||||||
|
SarStandardsInfo sarStandardsInfo = parseImportDtoToStandardsInfo(item, standID);
|
||||||
|
|
||||||
|
|
||||||
|
if (sarStandardsInfo!=null)
|
||||||
|
{
|
||||||
|
SarStandAttrInfo sarStandAttrInfo = parseImportDtoToStandAttrInfo(item, standID);
|
||||||
|
|
||||||
|
sarStandardsInfo.setValidFlag("0");
|
||||||
|
sarStandardsInfo.setStandType("FOREIGN");
|
||||||
|
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
|
||||||
|
standSaveWrapper
|
||||||
|
.eq("STAND_SORT",sarStandardsInfo.getStandSort())
|
||||||
|
.eq("STAND_NUMBER",sarStandardsInfo.getStandNumber())
|
||||||
|
.eq("STAND_YEAR",sarStandardsInfo.getStandYear());
|
||||||
|
|
||||||
|
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper);
|
||||||
|
if (one!=null){
|
||||||
|
sarStandardsInfo.setId(one.getId());
|
||||||
|
|
||||||
|
sarStandardsInfoService.update(sarStandardsInfo,standSaveWrapper);
|
||||||
|
QueryWrapper<SarStandAttrInfo> standAttrWrapper = new QueryWrapper<>();
|
||||||
|
standAttrWrapper.eq("STAND_ID",one.getId());
|
||||||
|
|
||||||
|
sarStandAttrInfo.setStandId(one.getId());
|
||||||
|
sarStandAttrInfoService.update(sarStandAttrInfo,standAttrWrapper);
|
||||||
|
}else {
|
||||||
|
sarStandardsInfoService.save(sarStandardsInfo);
|
||||||
|
String field="ID,STAND_ID,VALID_FLAG,DTBJH,SSRQ";
|
||||||
|
String value="\'"+sarStandAttrInfo.getId()+"\'"+","+ "\'"+sarStandAttrInfo.getStandId()+"\'"+","+"\'"+"0"+"\'";
|
||||||
|
|
||||||
|
|
||||||
|
if (sarStandAttrInfo.getDtbjh()!=null){
|
||||||
|
value+=","+"\'"+sarStandAttrInfo.getDtbjh()+"\'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sarStandAttrInfo.getSsrq()!=null){
|
||||||
|
value+=","+"\'"+sarStandAttrInfo.getSsrq()+"\'";
|
||||||
|
}
|
||||||
|
sarStandAttrInfoDao.insertStandAttr(field,value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
item.setErrorStr("标准号无法解析");
|
||||||
|
error.add(item);
|
||||||
|
importListMap.replace("error",error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国内标准
|
||||||
|
*/
|
||||||
|
importListMap.get("GNBZ").forEach(item->{
|
||||||
|
String standID = UUIDUtils.randomUUID20();
|
||||||
|
|
||||||
|
SarStandardsInfo sarStandardsInfo = parseImportDtoToStandardsInfo(item, standID);
|
||||||
|
|
||||||
|
if (sarStandardsInfo!=null){
|
||||||
|
SarStandAttrInfo sarStandAttrInfo = parseImportDtoToStandAttrInfo(item, standID);
|
||||||
|
|
||||||
|
sarStandardsInfo.setValidFlag("0");
|
||||||
|
sarStandardsInfo.setStandType("INLAND");
|
||||||
|
|
||||||
|
|
||||||
|
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
|
||||||
|
standSaveWrapper
|
||||||
|
.eq("STAND_SORT",sarStandardsInfo.getStandSort())
|
||||||
|
.eq("STAND_NUMBER",sarStandardsInfo.getStandNumber())
|
||||||
|
.eq("STAND_YEAR",sarStandardsInfo.getStandYear());
|
||||||
|
|
||||||
|
|
||||||
|
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper);
|
||||||
|
if (one!=null){
|
||||||
|
sarStandardsInfo.setId(one.getId());
|
||||||
|
sarStandardsInfoService.update(sarStandardsInfo,standSaveWrapper);
|
||||||
|
|
||||||
|
QueryWrapper<SarStandAttrInfo> standAttrWrapper = new QueryWrapper<>();
|
||||||
|
standAttrWrapper.eq("STAND_ID",one.getId());
|
||||||
|
sarStandAttrInfo.setStandId(one.getId());
|
||||||
|
sarStandAttrInfoService.update(sarStandAttrInfo,standAttrWrapper);
|
||||||
|
}else {
|
||||||
|
|
||||||
|
|
||||||
|
sarStandardsInfoService.save(sarStandardsInfo);
|
||||||
|
|
||||||
|
|
||||||
|
String field="ID,STAND_ID,VALID_FLAG,DTBJH,SSRQ";
|
||||||
|
String value="\'"+sarStandAttrInfo.getId()+"\'"+","+"\'"+sarStandAttrInfo.getStandId()+"\'"+","+"\'"+"0"+"\'";
|
||||||
|
|
||||||
|
|
||||||
|
if (sarStandAttrInfo.getDtbjh()!=null){
|
||||||
|
value+=","+"\'"+sarStandAttrInfo.getDtbjh()+"\'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sarStandAttrInfo.getSsrq()!=null){
|
||||||
|
value+=","+"\'"+sarStandAttrInfo.getSsrq()+"\'";
|
||||||
|
}
|
||||||
|
sarStandAttrInfoDao.insertStandAttr(field,value);
|
||||||
|
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
item.setErrorStr("标准号无法解析");
|
||||||
|
error.add(item);
|
||||||
|
importListMap.replace("error",error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业标准
|
||||||
|
*/
|
||||||
|
importListMap.get("QYBZ").forEach(item->{
|
||||||
|
String standId=UUIDUtils.randomUUID20();
|
||||||
|
|
||||||
|
SarBussionessStand sarBussionessStand = parseImportDtoToSarBussionessStand(item, standId);
|
||||||
|
|
||||||
|
if (sarBussionessStand!=null) {
|
||||||
|
|
||||||
|
|
||||||
|
SarBussStandAttrInfo sarBussStandAttrInfo = parseImportDtoToSarBussStandAttrInfo(item, standId);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
QueryWrapper<SarBussionessStand> saveWrapper = new QueryWrapper<>();
|
||||||
|
saveWrapper.eq("STAND_CODE", item.getStandId());
|
||||||
|
SarBussionessStand one = sarBussionessStandService.getOne(saveWrapper);
|
||||||
|
if (one != null) {
|
||||||
|
sarBussionessStand.setId(one.getId());
|
||||||
|
sarBussionessStandService.update(sarBussionessStand, saveWrapper);
|
||||||
|
|
||||||
|
QueryWrapper<SarBussStandAttrInfo> bussAttrWrapper = new QueryWrapper<>();
|
||||||
|
bussAttrWrapper.eq("STAND_ID", one.getId());
|
||||||
|
sarBussStandAttrInfo.setStandId(one.getId());
|
||||||
|
sarBussStandAttrInfoService.update(sarBussStandAttrInfo, bussAttrWrapper);
|
||||||
|
sarBussStandAttrInfoDao.updateStandInfo(one.getId(), "GLWJBUSS", sarBussStandAttrInfo.getGlwj());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sarBussionessStandService.save(sarBussionessStand);
|
||||||
|
sarBussStandAttrInfoService.save(sarBussStandAttrInfo);
|
||||||
|
|
||||||
|
sarBussStandAttrInfoDao.updateStandInfo(sarBussStandAttrInfo.getStandId(), "GLWJBUSS", sarBussStandAttrInfo.getGlwj());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
item.setErrorStr("数据格式错误");
|
||||||
|
error.add(item);
|
||||||
|
importListMap.replace("error",error);
|
||||||
|
System.out.println("issueTime====Hello======" + sarBussionessStand.getIssueTime() + "===hello=====" + item);
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
item.setErrorStr("标准号无法解析");
|
||||||
|
error.add(item);
|
||||||
|
importListMap.replace("error",error);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// String head="standId,standName,standNameEN,publishTime,implementedTime" +
|
||||||
|
// ",standStatus,replaceId,path";
|
||||||
|
// String headStr="标准号,标准名称,英文名称,发布时间,实施时间,标准状态,代替标准号,附件路径";
|
||||||
|
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SarStandardsInfo parseImportDtoToStandardsInfo(ImportDto importDto,String standId){
|
||||||
|
|
||||||
|
String sort="";
|
||||||
|
String number="";
|
||||||
|
String year="";
|
||||||
|
try {
|
||||||
|
String[] sortAndNumberAndYear = importDto.getStandId().split("\\s+");
|
||||||
|
sort = sortAndNumberAndYear[0];
|
||||||
|
String[] numberAndYear = sortAndNumberAndYear[1].split("\\-");
|
||||||
|
number=numberAndYear[0];
|
||||||
|
year=numberAndYear[1];
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
|
||||||
|
System.out.println("id为"+importDto.getStandId()+"格式无法解析");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
|
||||||
|
sarStandardsInfo.setId(standId);
|
||||||
|
|
||||||
|
|
||||||
|
sarStandardsInfo.setStandSort(sort);
|
||||||
|
sarStandardsInfo.setStandNumber(number);
|
||||||
|
sarStandardsInfo.setStandYear(year);
|
||||||
|
|
||||||
|
sarStandardsInfo.setStandName(importDto.getStandName());
|
||||||
|
sarStandardsInfo.setStandEnName(importDto.getStandNameEN());
|
||||||
|
sarStandardsInfo.setIssueTime(importDto.getPublishTime());//标准发布日期
|
||||||
|
|
||||||
|
String standStatus = importDto.getStandStatus();
|
||||||
|
if ("有效".equals(standStatus)){
|
||||||
|
sarStandardsInfo.setTextStatus("vsaga7nwub");//现行有效
|
||||||
|
}
|
||||||
|
|
||||||
|
return sarStandardsInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SarStandAttrInfo parseImportDtoToStandAttrInfo(ImportDto importDto,String standId) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SarStandAttrInfo sarStandAttrInfo = new SarStandAttrInfo();
|
||||||
|
sarStandAttrInfo.setId(UUIDUtils.randomUUID20());
|
||||||
|
sarStandAttrInfo.setStandId(standId);
|
||||||
|
sarStandAttrInfo.setDtbjh(importDto.getReplaceId());
|
||||||
|
sarStandAttrInfo.setSsrq(importDto.getImplementedTime());
|
||||||
|
sarStandAttrInfo.setValidFlag("0");
|
||||||
|
|
||||||
|
|
||||||
|
// Arrays.stream(path).limit(2,path.length);
|
||||||
|
|
||||||
|
if (importDto.getPath()!=null)
|
||||||
|
{
|
||||||
|
String path[] = importDto.getPath().split("/");
|
||||||
|
String realPath="";
|
||||||
|
for (int i = 4; i < path.length; i++) {
|
||||||
|
realPath=realPath+"/"+path[i];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
// File file = new File("C:\\Users\\22501\\Desktop\\foton\\2021\\" + realPath);
|
||||||
|
// File file = new File(importPath + realPath);
|
||||||
|
File file = new File("/home/file/2021/" + realPath);
|
||||||
|
if (file.exists()){
|
||||||
|
AttFileVo fileInfo = attFileEOService.saveFileInfo(file);
|
||||||
|
HashMap<String, String> fileMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * @Param: [standId, fileMap] fileMap<field,fileIds>
|
||||||
|
*/
|
||||||
|
fileMap.put("GLWJ",fileInfo.getAttId());
|
||||||
|
try {
|
||||||
|
sarStandardsInfoService.createStandFile(standId,fileMap);
|
||||||
|
} catch (Exception e) {
|
||||||
|
importDto.setErrorStr("创建标准文件异常");
|
||||||
|
error.add(importDto);
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println("创建标准文件异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
sarStandAttrInfo.setGlwj(fileInfo.getAttId());
|
||||||
|
}else {
|
||||||
|
importDto.setErrorStr("文件不存在");
|
||||||
|
error.add(importDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
importDto.setErrorStr("文件打开失败");
|
||||||
|
error.add(importDto);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return sarStandAttrInfo;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SarBussionessStand parseImportDtoToSarBussionessStand(ImportDto importDto,String standId){
|
||||||
|
|
||||||
|
|
||||||
|
if(importDto.getStandId()==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String sort="";
|
||||||
|
String number="";
|
||||||
|
String year="";
|
||||||
|
try {
|
||||||
|
String[] sortAndNumberAndYear = importDto.getStandId().split("\\s+");
|
||||||
|
sort = sortAndNumberAndYear[0];
|
||||||
|
String[] numberAndYear = sortAndNumberAndYear[1].split("\\-");
|
||||||
|
number=numberAndYear[0];
|
||||||
|
year=numberAndYear[1];
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
System.out.println("id为"+importDto.getStandId()+"格式无法解析");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
SarBussionessStand sarBussionessStand = new SarBussionessStand();
|
||||||
|
sarBussionessStand.setId(standId);
|
||||||
|
sarBussionessStand.setStandSort(sort);
|
||||||
|
sarBussionessStand.setStandYear(year);
|
||||||
|
sarBussionessStand.setStandCode(importDto.getStandId());
|
||||||
|
sarBussionessStand.setStandName(importDto.getStandName());
|
||||||
|
sarBussionessStand.setStandEnName(importDto.getStandNameEN());
|
||||||
|
sarBussionessStand.setIssueTime(importDto.getPublishTime());
|
||||||
|
sarBussionessStand.setPutTime(importDto.getImplementedTime());
|
||||||
|
sarBussionessStand.setReplacedStandNum(importDto.getReplaceId());
|
||||||
|
sarBussionessStand.setValidFlag(0);
|
||||||
|
if ("有效".equals(importDto.getStandStatus())){
|
||||||
|
sarBussionessStand.setTextStatusBuss("vsaga7nwub");
|
||||||
|
}
|
||||||
|
return sarBussionessStand;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SarBussStandAttrInfo parseImportDtoToSarBussStandAttrInfo(ImportDto importDto,String standId){
|
||||||
|
SarBussStandAttrInfo sarBussStandAttrInfo = new SarBussStandAttrInfo();
|
||||||
|
sarBussStandAttrInfo.setId(UUIDUtils.randomUUID20());
|
||||||
|
sarBussStandAttrInfo.setStandId(standId);
|
||||||
|
sarBussStandAttrInfo.setValidFlag("0");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (importDto.getPath()!=null)
|
||||||
|
{
|
||||||
|
String path[] = importDto.getPath().split("/");
|
||||||
|
String realPath="";
|
||||||
|
for (int i = 4; i < path.length; i++) {
|
||||||
|
realPath=realPath+"/"+path[i];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
// File file = new File("C:\\Users\\22501\\Desktop\\foton\\2021\\" + realPath);
|
||||||
|
// File file = new File(importPath + realPath);
|
||||||
|
File file = new File("/home/file/2021/" + realPath);
|
||||||
|
|
||||||
|
if (file.exists()){
|
||||||
|
AttFileVo fileInfo = attFileEOService.saveFileInfo(file);
|
||||||
|
HashMap<String, String> fileMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * @Param: [standId, fileMap] fileMap<field,fileIds>
|
||||||
|
*/
|
||||||
|
fileMap.put("GLWJBUSS",fileInfo.getAttId());
|
||||||
|
try {
|
||||||
|
sarBussionessStandService.createStandFile(standId,fileMap);
|
||||||
|
} catch (Exception e) {
|
||||||
|
importDto.setErrorStr("创建标准文件异常");
|
||||||
|
error.add(importDto);
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println("创建标准文件异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
sarBussStandAttrInfo.setGlwj(fileInfo.getAttId());
|
||||||
|
|
||||||
|
}else {
|
||||||
|
importDto.setErrorStr("文件不存在");
|
||||||
|
error.add(importDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
importDto.setErrorStr("路径错误!");
|
||||||
|
error.add(importDto);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return sarBussStandAttrInfo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -14,7 +14,7 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author super_liu
|
* @author super_liu
|
||||||
@@ -52,6 +52,9 @@ public class SarBussStandAttrInfo extends BaseEntity {
|
|||||||
@TableField("MODIFY_TIME")
|
@TableField("MODIFY_TIME")
|
||||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
private Date modifyTime;
|
private Date modifyTime;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String glwj;
|
||||||
//
|
//
|
||||||
// @TableField("SVPPS")
|
// @TableField("SVPPS")
|
||||||
// private String svpps;
|
// private String svpps;
|
||||||
|
|||||||
Reference in New Issue
Block a user