Merge branch 'develop_3' into 'develop_master'

Develop 3

See merge request LiuChao/foton-slrs-system-rest!207
This commit is contained in:
王夏晖
2021-10-20 15:51:05 +08:00
18 changed files with 564 additions and 167 deletions
@@ -62,6 +62,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
addInterceptor.excludePathPatterns("/api/att/attFile/downloadFileForSar"); addInterceptor.excludePathPatterns("/api/att/attFile/downloadFileForSar");
//水印下载 //水印下载
addInterceptor.excludePathPatterns("/api/att/attFile/downloadFileForSarWaterMark"); addInterceptor.excludePathPatterns("/api/att/attFile/downloadFileForSarWaterMark");
//企业标准导出
addInterceptor.excludePathPatterns("/api/lawss/sarBussionessStand/exportSarBussionessStand");
//OCR回调存储文件 //OCR回调存储文件
addInterceptor.excludePathPatterns("/api/ocr/OCRRestful/OcrHandleResult"); addInterceptor.excludePathPatterns("/api/ocr/OCRRestful/OcrHandleResult");
@@ -4,6 +4,7 @@ import com.adc.da.base.web.BaseController;
import com.adc.da.common.ReadExcel; 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.comment.ExclErrorOut;
import com.adc.da.slrs.ImportExcelDatas.comment.ExclExport;
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;
@@ -34,7 +35,7 @@ import java.util.Map;
@RestController @RestController
@Api(description = "|SarStandPutTime|") @Api(description = "|SarStandPutTime|")
@RequestMapping("/ImportExcel") @RequestMapping("/api/ImportExcel")
public class ImportExcelController extends BaseController<ImportDto> { public class ImportExcelController extends BaseController<ImportDto> {
@Autowired @Autowired
@@ -43,14 +44,24 @@ public class ImportExcelController extends BaseController<ImportDto> {
@Autowired @Autowired
private ExclErrorOut exclErrorOut; private ExclErrorOut exclErrorOut;
@ApiOperation("批量删除用户收藏")
@ApiOperation("从excl中导入标准信息")
@PostMapping("/import") @PostMapping("/import")
public void deleteList(MultipartFile file, MultipartFile file2, HttpServletResponse response, HttpServletRequest request) throws IOException { 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);
/**
* 导入系统
*/
List<ImportDto> errorList = importExcelService.storageExclData(mapMap); List<ImportDto> errorList = importExcelService.storageExclData(mapMap);
// mapMap.put("导入后的信息",errorList);
// List<ImportDto> guonei= mapMap.get("GNBZ"); // List<ImportDto> guonei= mapMap.get("GNBZ");
// List<ImportDto> haiwai = mapMap.get("HWBZ"); // List<ImportDto> haiwai = mapMap.get("HWBZ");
// List<ImportDto> qibiao = mapMap.get("QYBZ"); // List<ImportDto> qibiao = mapMap.get("QYBZ");
/**
* 生成错误表格
*/
OutputStream os = null; OutputStream os = null;
Workbook workbook = null; Workbook workbook = null;
try { try {
@@ -61,7 +72,11 @@ public class ImportExcelController extends BaseController<ImportDto> {
response.setContentType("application/force-download"); response.setContentType("application/force-download");
//导出数据 //导出数据
String headStr="标准号,标准名称,英文名称,发布时间,实施时间,标准状态,代替标准号,附件路径,错误原因"; String headStr="标准号,标准名称,英文名称,发布时间,实施时间,标准状态,代替标准号,附件路径,错误原因";
workbook = exclErrorOut.exportDatas(errorList,headStr); // workbook = exclErrorOut.exportDatas(guonei,headStr);
ExclExport exclExport = new ExclExport();
workbook = exclExport.exportData(mapMap, headStr);
os = response.getOutputStream(); os = response.getOutputStream();
workbook.write(os); workbook.write(os);
os.flush(); os.flush();
@@ -75,8 +90,8 @@ public class ImportExcelController extends BaseController<ImportDto> {
} }
// return responseMessage; // return responseMessage;
} }
} }
@@ -2,7 +2,6 @@ package com.adc.da.slrs.ImportExcelDatas.service.impl;
import com.adc.da.att.service.IAttFileEOService; import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.att.vo.AttFileVo; import com.adc.da.att.vo.AttFileVo;
import com.adc.da.http.Result;
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;
@@ -10,9 +9,7 @@ import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService; import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo; import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService; import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
import com.adc.da.sys.dao.DicTypeEODao;
import com.adc.da.sys.entity.DicTypeEO; import com.adc.da.sys.entity.DicTypeEO;
import com.adc.da.sys.entity.DictionaryEO;
import com.adc.da.sys.service.impl.DicTypeEOServiceImpl; import com.adc.da.sys.service.impl.DicTypeEOServiceImpl;
import com.adc.da.util.UUIDUtils; import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.InitStandAttrUtil; import com.adc.da.utils.util.InitStandAttrUtil;
@@ -26,13 +23,13 @@ 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.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.File;
import java.io.InputStream; import java.io.InputStream;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@Service @Service
@@ -54,7 +51,9 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
// private SarBussionessStandServiceImpl sarBussionessStandService; // private SarBussionessStandServiceImpl sarBussionessStandService;
/**
* 标准类别
*/
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," +
@@ -70,6 +69,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
dates.add("" + i); dates.add("" + i);
dates.add("- " + i); dates.add("- " + i);
dates.add("" + i); dates.add("" + i);
dates.add("" + i);
} }
if (file == null || file.getSize() == 0) { if (file == null || file.getSize() == 0) {
@@ -118,12 +118,18 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
//中间的Map 判断标准号属于哪种类型 //中间的Map 判断标准号属于哪种类型
Map<String, String> middle = new HashMap<>(); Map<String, String> middle = new HashMap<>();
datas.forEach(items -> { datas.forEach(items -> {
System.out.print(".");
//判断是否是正确的数据 //判断是否是正确的数据
String[] as = items.split(","); String[] as = items.split(",");
if (!inDate(as[0], dates)) { if( as.length < 8){
ImportDto importDto = new ImportDto();
importDto.setErrorStr(items);
error.add(importDto);
} else if (!inDate(as[0], dates) ) {
ImportDto importDto = getImportDto(as); ImportDto importDto = getImportDto(as);
error.add(importDto); error.add(importDto);
middle.put(as[0].trim(), "error-" + error.size()); middle.put(as[7].trim(), "error-" + error.size());
} else { } else {
//数据二次拆解 针对标准进行拆解 //数据二次拆解 针对标准进行拆解
String[] step2 = as[0].trim().split(" "); String[] step2 = as[0].trim().split(" ");
@@ -131,15 +137,15 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
if (isCheck(GNS, step2[0].trim())) { if (isCheck(GNS, step2[0].trim())) {
ImportDto importDto = getImportDto(as); ImportDto importDto = getImportDto(as);
InCountry.add(importDto); InCountry.add(importDto);
middle.put(as[0].trim(), "GNBZ-" + InCountry.size()); middle.put(as[7].trim(), "GNBZ-" + InCountry.size());
} else if (isCheck(QBS, step2[0].trim())) { } else if (isCheck(QBS, step2[0].trim())) {
ImportDto importDto = getImportDto(as); ImportDto importDto = getImportDto(as);
QiBiao.add(importDto); QiBiao.add(importDto);
middle.put(as[0].trim(), "QYBZ-" + QiBiao.size()); middle.put(as[7].trim(), "QYBZ-" + QiBiao.size());
} else { } else {
ImportDto importDto = getImportDto(as); ImportDto importDto = getImportDto(as);
OutCountry.add(importDto); OutCountry.add(importDto);
middle.put(as[0].trim(), "HWBZ-" + OutCountry.size()); middle.put(as[7].trim(), "HWBZ-" + OutCountry.size());
} }
} }
}); });
@@ -151,9 +157,11 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
fujian.forEach(items2 -> { fujian.forEach(items2 -> {
String[] fj = items2.split(","); String[] fj = items2.split(",");
if (fj.length > 2) { if (fj.length > 2) {
if (null != middle.get(null != fj[2] ? fj[2].trim() : "")) { if (null != middle.get(null != fj[1] ? fj[1].trim() : "")) {
//对应数据位置 //对应数据位置
String[] location = middle.get(fj[2].trim()).split("-"); String[] location = middle.get(fj[1].trim()).split("-");
// List<ImportDto> importDtos = res.get(location[0]);
res.get(location[0]).get(Integer.parseInt(location[1]) - 1).setPath(fj[3]); res.get(location[0]).get(Integer.parseInt(location[1]) - 1).setPath(fj[3]);
} }
} }
@@ -189,10 +197,15 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
} }
/**
* 数据数组转换为实体类
* @param as
* @return
*/
//赋值方法 //赋值方法
private ImportDto getImportDto(String[] as) { private ImportDto getImportDto(String[] as) {
ImportDto importDto = new ImportDto(); ImportDto importDto = new ImportDto();
if (as.length == 7) { if (as.length == 8) {
importDto.setStandId(null != as[0] ? as[0].trim() : ""); importDto.setStandId(null != as[0] ? as[0].trim() : "");
importDto.setStandName(null != as[1] ? as[1].trim() : ""); importDto.setStandName(null != as[1] ? as[1].trim() : "");
importDto.setStandNameEN(null != as[2] ? as[2].trim() : ""); importDto.setStandNameEN(null != as[2] ? as[2].trim() : "");
@@ -200,7 +213,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
importDto.setImplementedTime(null != as[4] ? as[4].trim() : ""); importDto.setImplementedTime(null != as[4] ? as[4].trim() : "");
importDto.setStandStatus(null != as[5] ? as[5].trim() : ""); importDto.setStandStatus(null != as[5] ? as[5].trim() : "");
importDto.setReplaceId(null != as[6] ? as[6].trim() : ""); importDto.setReplaceId(null != as[6] ? as[6].trim() : "");
} else if (as.length == 6) { } else if (as.length == 7) {
importDto.setStandId(null != as[0] ? as[0].trim() : ""); importDto.setStandId(null != as[0] ? as[0].trim() : "");
importDto.setStandName(null != as[1] ? as[1].trim() : ""); importDto.setStandName(null != as[1] ? as[1].trim() : "");
importDto.setStandNameEN(null != as[2] ? as[2].trim() : ""); importDto.setStandNameEN(null != as[2] ? as[2].trim() : "");
@@ -225,9 +238,10 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
HSSFSheet sheet = workbook.getSheetAt(i); HSSFSheet sheet = workbook.getSheetAt(i);
// 获取有多少行 // 获取有多少行
int lastNum = sheet.getLastRowNum(); int lastNum = sheet.getLastRowNum();
for (int j = 1; j <= lastNum; j++) { for (int j = 0; j <= lastNum; j++) {
HSSFRow row = sheet.getRow(j); HSSFRow row = sheet.getRow(j);
if (null != row) { if (null != row) {
System.out.println("正在读取第"+j+"行...");
strings.add(row.getCell(0).getStringCellValue()); strings.add(row.getCell(0).getStringCellValue());
} }
} }
@@ -248,11 +262,12 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
// 遍历sheet页 // 遍历sheet页
for (int i = 0; i <= sheetNum; i++) { for (int i = 0; i <= sheetNum; i++) {
XSSFSheet sheet = workbook.getSheetAt(i); XSSFSheet sheet = workbook.getSheetAt(i);
// 获取有多少行 // 获取有多少行 0行开始
int lastNum = sheet.getLastRowNum(); int lastNum = sheet.getLastRowNum();
for (int j = 1; j <= lastNum; j++) { for (int j = 0; j <= lastNum; j++) {
XSSFRow row = sheet.getRow(j); XSSFRow row = sheet.getRow(j);
if (null != row) { if (null != row) {
System.out.println("正在读取第"+j+"行...");
strings.add(row.getCell(0).getStringCellValue()); strings.add(row.getCell(0).getStringCellValue());
} }
} }
@@ -266,9 +281,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
private List<ImportDto> error = new ArrayList<>();
private List<ImportDto> fileError = new ArrayList<>();
@Autowired @Autowired
private ISarStandardsInfoService sarStandardsInfoService; private ISarStandardsInfoService sarStandardsInfoService;
@@ -278,12 +291,38 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
@Autowired @Autowired
private ISarBussionessStandService sarBussionessStandService; private ISarBussionessStandService sarBussionessStandService;
private List<ImportDto> error = new ArrayList<>();
private List<ImportDto> fileError = new ArrayList<>();
private HashSet<String> sarSort = new HashSet<>();
@Override @Override
public List<ImportDto> storageExclData(Map<String, List<ImportDto>> importListMap) { public List<ImportDto> storageExclData(Map<String, List<ImportDto>> importListMap) {
//TODO 利用stream把list变为set
// List<DicTypeEO> list = dicTypeEOService.list();
// list.stream().flatMap(dicTypeEO -> {
// return dicTypeEO;
// }.co)
List<DicTypeEO> isExist = dicTypeEOService.getTypeIdByDicIdAndTypeName("JKSADFH564S", null, null, null);
isExist.forEach(item->{
sarSort.add(item.getDicTypeCode());
});
error = importListMap.get("error"); error = importListMap.get("error");
AtomicInteger QYBZcount= new AtomicInteger();
AtomicInteger QYBZcountUpdate= new AtomicInteger();
AtomicInteger HWBZcount= new AtomicInteger();
AtomicInteger HWBZcountUpdate= new AtomicInteger();
AtomicInteger GNBZcount= new AtomicInteger();
AtomicInteger GNBZcountUpdate= new AtomicInteger();
/** /**
* 初始化国内外标准属性字段 * 初始化国内外标准属性字段
*/ */
@@ -296,24 +335,26 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
/** /**
* 海外标准 * 海外标准
*/ */
importListMap.get("HWBZ").forEach(item -> {
String standID = UUIDUtils.randomUUID20();
//使用初始化的属性字段映射 获得key值,value为"" /*importListMap.get("HWBZ").forEach(item -> {
Map<String, String> mapField = standAttrMap; if (true ) {
SarStandardsInfo ForeignEO = parseImportDtoToStandardsInfo(item,mapField, standID); String standID = UUIDUtils.randomUUID20();
if (ForeignEO != null) { //使用初始化的属性字段映射 获得key值,value为""
ForeignEO.setValidFlag("0"); Map<String, String> mapField = standAttrMap;
ForeignEO.setStandType("FOREIGN"); SarStandardsInfo ForeignEO = parseImportDtoToStandardsInfo(item,mapField, standID);
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
standSaveWrapper
.eq("STAND_SORT", ForeignEO.getStandSort())
.eq("STAND_NUMBER", ForeignEO.getStandNumber())
.eq("STAND_YEAR", ForeignEO.getStandYear());
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper); if (ForeignEO != null) {
ForeignEO.setValidFlag("0");
ForeignEO.setStandType("FOREIGN");
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
standSaveWrapper
.eq("STAND_SORT", ForeignEO.getStandSort())
.eq("STAND_NUMBER", ForeignEO.getStandNumber())
.eq("STAND_YEAR", ForeignEO.getStandYear());
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper);
@@ -322,6 +363,9 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
try { try {
sarStandardsInfoService.updateSarStandardsInfo(ForeignEO); sarStandardsInfoService.updateSarStandardsInfo(ForeignEO);
HWBZcountUpdate.getAndIncrement();
HWBZcount.getAndIncrement();
System.out.println("海外标准执行更新===第: "+HWBZcount+"行");
} catch (Exception e) { } catch (Exception e) {
item.setErrorStr("标准更新失败"); item.setErrorStr("标准更新失败");
error.add(item); error.add(item);
@@ -331,6 +375,8 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
} else { } else {
try { try {
sarStandardsInfoService.createSarStandardsInfo(ForeignEO); sarStandardsInfoService.createSarStandardsInfo(ForeignEO);
HWBZcount.getAndIncrement();
System.out.println("海外标准执行新增===第: "+HWBZcount+"行");
} catch (Exception e) { } catch (Exception e) {
item.setErrorStr("标准新增失败"); item.setErrorStr("标准新增失败");
error.add(item); error.add(item);
@@ -340,72 +386,80 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
} }
} else { } else {
item.setErrorStr("标准号无法解析"); item.setErrorStr("标准号无法解析");
error.add(item); error.add(item);
}
} }
});
});*/
/** /**
* 国内标准 * 国内标准
*/ */
importListMap.get("GNBZ").forEach(item -> { /*importListMap.get("GNBZ").forEach(item -> {
String standID = UUIDUtils.randomUUID20();
//使用初始化的属性字段映射 获得key值,value为""
Map<String, String> mapStandField = standAttrMap;
SarStandardsInfo InlandEO = parseImportDtoToStandardsInfo(item, mapStandField,standID);
if (InlandEO != null) {
InlandEO.setValidFlag("0"); if (true) {
InlandEO.setStandType("INLAND"); String standID = UUIDUtils.randomUUID20();
//使用初始化的属性字段映射 获得key值,value为""
Map<String, String> mapStandField = standAttrMap;
SarStandardsInfo InlandEO = parseImportDtoToStandardsInfo(item, mapStandField, standID);
if (InlandEO != null) {
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>(); InlandEO.setValidFlag("0");
standSaveWrapper InlandEO.setStandType("INLAND");
.eq("STAND_SORT", InlandEO.getStandSort())
.eq("STAND_NUMBER", InlandEO.getStandNumber())
.eq("STAND_YEAR", InlandEO.getStandYear());
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper); QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
if (one != null) { standSaveWrapper
.eq("STAND_SORT", InlandEO.getStandSort())
.eq("STAND_NUMBER", InlandEO.getStandNumber())
.eq("STAND_YEAR", InlandEO.getStandYear());
InlandEO.setId(one.getId()); SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper);
try { if (one != null) {
sarStandardsInfoService.updateSarStandardsInfo(InlandEO);
} catch (Exception e) {
item.setErrorStr("国内标准更新失败"); InlandEO.setId(one.getId());
error.add(item); try {
e.printStackTrace(); sarStandardsInfoService.updateSarStandardsInfo(InlandEO);
} catch (Exception e) {
item.setErrorStr("国内标准更新失败");
error.add(item);
e.printStackTrace();
}
} else {
try {
sarStandardsInfoService.createSarStandardsInfo(InlandEO);
} catch (Exception e) {
item.setErrorStr("国内标准新增失败");
error.add(item);
e.printStackTrace();
}
} }
} else { } else {
item.setErrorStr("标准号无法解析");
error.add(item);
try { importListMap.replace("error", error);
sarStandardsInfoService.createSarStandardsInfo(InlandEO);
} catch (Exception e) {
item.setErrorStr("国内标准新增失败");
error.add(item);
e.printStackTrace();
}
} }
} else {
item.setErrorStr("标准号无法解析");
error.add(item);
importListMap.replace("error", error);
} }
});*/
});
/** /**
@@ -420,38 +474,61 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
listStandBussField.forEach(item->{ listStandBussField.forEach(item->{
bussAttrMap.put(item,""); bussAttrMap.put(item,"");
}); });
importListMap.get("QYBZ").forEach(item -> { importListMap.get("QYBZ").forEach(item -> {
String standId = UUIDUtils.randomUUID20();
SarBussionessStand BussEO = parseImportDtoToSarBussionessStand(item, bussAttrMap,standId);
if (BussEO != null) {
try { if (true){
QueryWrapper<SarBussionessStand> saveWrapper = new QueryWrapper<>(); // if (item.getStandId().contains("Q/FT T396—2021") ){
saveWrapper.eq("STAND_CODE", item.getStandId());
SarBussionessStand one = sarBussionessStandService.getOne(saveWrapper); String standId = UUIDUtils.randomUUID20();
if (one != null) { SarBussionessStand BussEO = parseImportDtoToSarBussionessStand(item, bussAttrMap,standId);
BussEO.setId(one.getId());
sarBussionessStandService.updateSarBussionessStand(BussEO); if (BussEO != null) {
} else {
sarBussionessStandService.createSarBussionessStand(BussEO); try {
QueryWrapper<SarBussionessStand> saveWrapper = new QueryWrapper<>();
saveWrapper.eq("STAND_CODE", item.getStandId());
SarBussionessStand one = sarBussionessStandService.getOne(saveWrapper);
if (one != null) {
BussEO.setId(one.getId());
sarBussionessStandService.updateSarBussionessStand(BussEO);
QYBZcountUpdate.getAndIncrement();
QYBZcount.getAndIncrement();
System.out.println("企业标准执行更新====第: "+QYBZcount+"");
} else {
sarBussionessStandService.createSarBussionessStand(BussEO);
QYBZcount.getAndIncrement();
System.out.println("企业标准执行新增第: "+QYBZcount+"");
}
} catch (Exception e) {
item.setErrorStr("数据格式错误");
error.add(item);
e.printStackTrace();
} }
} catch (Exception e) {
item.setErrorStr("数据格式错误");
error.add(item);
e.printStackTrace();
} }
} }
}); });
error.addAll(fileError); error.addAll(fileError);
System.out.println("执行结束");
System.out.println("执行国内标准"+GNBZcount+"");
System.out.println("国内标准执行更新"+GNBZcountUpdate+"");
System.out.println("执行国外标准"+HWBZcount+"");
System.out.println("海外标准执行更新"+HWBZcountUpdate+"");
System.out.println("执行企业标准"+QYBZcount+"");
System.out.println("企业标准执行更新"+QYBZcountUpdate+"");
return error; return error;
} }
@@ -464,13 +541,10 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
* @return * @return
*/ */
public SarStandardsInfo parseImportDtoToStandardsInfo(ImportDto importDto,Map<String,String> fieldMap, String standId) { public SarStandardsInfo parseImportDtoToStandardsInfo(ImportDto importDto,Map<String,String> fieldMap, String standId) {
HashMap<String, String> analysis = analysisStandId(importDto); HashMap<String, String> analysis = analysisStandId(importDto);
if (analysis == null) { if (analysis == null) {
return null; return null;
} }
SarStandardsInfo sarStandardsInfoEO = new SarStandardsInfo(); SarStandardsInfo sarStandardsInfoEO = new SarStandardsInfo();
sarStandardsInfoEO.setId(standId); sarStandardsInfoEO.setId(standId);
@@ -507,21 +581,21 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
if (importDto.getPath() != null) { if (importDto.getPath() != null) {
String path[] = importDto.getPath().split("/"); String path[] = importDto.getPath().split("/");
String realPath = ""; String realPath = "";
for (int i = 4; i < path.length; i++) { for (int i = 3; i < path.length; i++) {
realPath = realPath + "/" + path[i]; realPath = realPath + "/" + path[i];
} }
try { try {
// File file = new File("C:\\Users\\22501\\Desktop\\foton\\2021\\" + realPath); // File file = new File("C:\\Users\\22501\\Desktop\\foton\\" + realPath);
// File file = new File(importPath + realPath); // File file = new File(importPath + realPath);
File file = new File("/home/file/2021/" + realPath); File file = new File("/data/from12/Attach_swf_bak" + realPath);
if (file.exists()) { if (file.exists()) {
AttFileVo fileInfo = attFileEOService.saveFileInfo(file); AttFileVo fileInfo = attFileEOService.saveFileInfo(file);
if (importDto.getImplementedTime() != null) { if (importDto.getImplementedTime() != null) {
fieldMap.put("FBGJBD", fileInfo.getAttId()); fieldMap.put("FBGBJBD", fileInfo.getAttId());
} else { } else {
fieldMap.put("GLWJ", fileInfo.getAttId()); fieldMap.put("GLWJ", fileInfo.getAttId());
} }
@@ -585,16 +659,16 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
if (importDto.getPath() != null) { if (importDto.getPath() != null) {
String path[] = importDto.getPath().split("/"); String path[] = importDto.getPath().split("/");
String realPath = ""; String realPath = "";
for (int i = 4; i < path.length; i++) { for (int i = 3; i < path.length; i++) {
realPath = realPath + "/" + path[i]; realPath = realPath + "/" + path[i];
} }
try { try {
// File file = new File("C:\\Users\\22501\\Desktop\\foton\\2021\\" + realPath); // File file = new File("C:\\Users\\22501\\Desktop\\foton\\" + realPath);
// File file = new File(importPath + realPath); // File file = new File(importPath + realPath);
File file = new File("/home/file/2021/" + realPath); File file = new File("/data/from12/Attach_swf_bak" + realPath);
if (file.exists()) { if (file.exists()) {
AttFileVo fileInfo = attFileEOService.saveFileInfo(file); AttFileVo fileInfo = attFileEOService.saveFileInfo(file);
@@ -670,25 +744,27 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
result.put("sort", sort); result.put("sort", sort);
result.put("number", number); result.put("number", number);
result.put("year", year); result.put("year", year);
//标准类别不存在,新增标准类别 /**
List<DicTypeEO> isExist = dicTypeEOService.getTypeIdByDicIdAndTypeName("JKSADFH564S", null, sort, null); * 标准类别不存在,新增标准类别
if (isExist == null || isExist.isEmpty() || isExist.size()==0){ */
// List<DicTypeEO> isExist = dicTypeEOService.getTypeIdByDicIdAndTypeName("JKSADFH564S", null, sort, null);
DicTypeEO dicTypeVO = new DicTypeEO(); // if (!sarSort.contains(sort)){
dicTypeVO.setId(null); //
dicTypeVO.setDicId("JKSADFH564S"); // DicTypeEO dicTypeVO = new DicTypeEO();
dicTypeVO.setDicTypeCode(sort); // dicTypeVO.setId(null);
dicTypeVO.setDicTypeName(sort); // dicTypeVO.setDicId("JKSADFH564S");
dicTypeVO.setShowIndex(1); // dicTypeVO.setDicTypeCode(sort);
Integer dicTypeEO = dicTypeEOService.saveDictype(dicTypeVO); // dicTypeVO.setDicTypeName(sort);
if (dicTypeEO>0){ // dicTypeVO.setShowIndex(1);
importDto.setErrorStr("标准类别不存在,已新增"); // Integer dicTypeEO = dicTypeEOService.saveDictype(dicTypeVO);
}else { // if (dicTypeEO>0){
importDto.setErrorStr("标准类别不存在,新增失败"); // sarSort.add(sort);
} // importDto.setErrorStr("标准类别不存在,已新增");
error.add(importDto); // }else {
} // importDto.setErrorStr("标准类别不存在,新增失败");
// }
// error.add(importDto);
// }
@@ -93,6 +93,14 @@ public class TsInstitutionController extends BaseController<TsInstitution> {
} }
@ApiOperation("通过部门机构名称查询部门树形结构 废弃使用")
@GetMapping("/findInstitution")
public List<TsInstitution> findInstitution(String institutionName){
//TODO 调用业务接口
tsInstitutionService.findInstitutionTreeByName(institutionName);
return null;
}
public static void main(String[] args) { public static void main(String[] args) {
// System.out.println(json); // System.out.println(json);
} }
@@ -3,6 +3,7 @@ package com.adc.da.slrs.sarInstitution.dao;
import com.adc.da.slrs.sarInstitution.entity.InstitutionAndUser; import com.adc.da.slrs.sarInstitution.entity.InstitutionAndUser;
import com.adc.da.slrs.sarInstitution.entity.TsInstitution; import com.adc.da.slrs.sarInstitution.entity.TsInstitution;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
@@ -29,7 +30,7 @@ public interface TsInstitutionDao extends BaseMapper<TsInstitution> {
List<TsInstitution> selectNextUser(String institutionId); List<TsInstitution> selectNextUser(String institutionId);
List<TsInstitution> selectTreeByIds(@Param("rootIds") List<String> rootIds);
/** /**
* 查询最高级机构及其人员 * 查询最高级机构及其人员
@@ -11,6 +11,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@@ -73,4 +75,12 @@ public class TsInstitution extends BaseEntity {
this.parentId = parentId; this.parentId = parentId;
this.name = name; this.name = name;
} }
// public void addChildren(TsInstitution node){
// if (this.children==null){
// this.children=Arrays.asList(node);
// }else {
// this.children.add(node);
// }
// }
} }
@@ -43,5 +43,13 @@ public interface ITsInstitutionService extends IService<TsInstitution> {
*/ */
public List<TsInstitution> getFirst(); public List<TsInstitution> getFirst();
/**
* 根据机构部门名称查询机构树
* @param institutionName
* @return
*/
public List<TsInstitution> findInstitutionTreeByName(String institutionName);
int clearData(); int clearData();
} }
@@ -6,6 +6,7 @@ import com.adc.da.slrs.sarInstitution.entity.SyncInstitution;
import com.adc.da.slrs.sarInstitution.entity.TsInstitution; import com.adc.da.slrs.sarInstitution.entity.TsInstitution;
import com.adc.da.slrs.sarInstitution.entity.TsUserVO; import com.adc.da.slrs.sarInstitution.entity.TsUserVO;
import com.adc.da.slrs.sarInstitution.service.ITsInstitutionService; import com.adc.da.slrs.sarInstitution.service.ITsInstitutionService;
import com.adc.da.slrs.sarInstitution.util.TreeUtil;
import com.adc.da.sync.service.SyncUserService; import com.adc.da.sync.service.SyncUserService;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
@@ -15,8 +16,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
/** /**
* <p> * <p>
@@ -38,17 +39,21 @@ public class TsInstitutionServiceImpl extends ServiceImpl<TsInstitutionDao, TsIn
*/ */
@Override @Override
public List<TsInstitution> getInstitution() { public List<TsInstitution> getInstitution() {
List<TsInstitution> institutionList = this.list();//查询所有的的数据
//查询第一层机构 //查询第一层机构
List<TsInstitution> institutionRoot=tsInstitutionDao.selectRoot(); List<TsInstitution> root=tsInstitutionDao.selectRoot();
for(TsInstitution tsInstitution:institutionRoot){
tsInstitution.setChildren(recursionGetInstitution(tsInstitution)); TreeUtil treeUtil = new TreeUtil();
} List<TsInstitution> institutionTree = treeUtil.treeAsList(institutionList, root);
return institutionRoot;
return institutionTree;
} }
/** /**
* 递归获取子机构 * 递归获取子机构
* @param tsInstitution:父机构 * @param tsInstitution:父机构
@@ -109,21 +114,29 @@ public class TsInstitutionServiceImpl extends ServiceImpl<TsInstitutionDao, TsIn
*/ */
@Override @Override
public List<TsInstitution> getInstitutionAndUser(String userName) { public List<TsInstitution> getInstitutionAndUser(String userName) {
//查询第一层机构 List<TsInstitution> tsInstitutions = new ArrayList<>();
List<TsInstitution> institutionRoot=tsInstitutionDao.selectRootAndUser(userName);
//把查到的数据结构修改,把用户放 //当条件为null时避免查询全部,直接返回第一级
for(TsInstitution tsInstitution:institutionRoot){ if (userName==null||userName==""){
tsInstitution.setDisabled(true); tsInstitutions=this.getFirst();
tsInstitution.setChildren( recursionGetInstitutionAndUser(tsInstitution) ); }else {
for(TsUserVO user:tsInstitution.getUsers()){ //查询第一层机构
if(tsInstitution.getChildren()==null){ tsInstitutions=tsInstitutionDao.selectRootAndUser(userName);
tsInstitution.setChildren(new ArrayList<>());
//把查到的数据结构修改,把用户放
for(TsInstitution tsInstitution:tsInstitutions){
tsInstitution.setDisabled(true);
// tsInstitution.setChildren( recursionGetInstitutionAndUser(tsInstitution) );
for(TsUserVO user:tsInstitution.getUsers()){
if(tsInstitution.getChildren()==null){
tsInstitution.setChildren(new ArrayList<>());
}
// tsInstitution.getChildren().add(user);
} }
tsInstitution.getChildren().add(user);
} }
} }
return institutionRoot;
return tsInstitutions;
} }
/** /**
@@ -213,6 +226,27 @@ public class TsInstitutionServiceImpl extends ServiceImpl<TsInstitutionDao, TsIn
return tsInstitutions; return tsInstitutions;
} }
@Override
public List<TsInstitution> findInstitutionTreeByName(String institutionName) {
QueryWrapper<TsInstitution> tsInstitutionQuery = new QueryWrapper<>();
tsInstitutionQuery.select("id")
.like("name",institutionName);
/**
* 查询出id的数据集合并转换成String类型
*/
List<String> rootIds = this.listObjs(tsInstitutionQuery)
.stream()
.map(item -> item.toString())
.collect(Collectors.toList());
List<TsInstitution> tsInstitutions = tsInstitutionDao.selectTreeByIds(rootIds);
return null;
}
@Override @Override
public int clearData() { public int clearData() {
return tsInstitutionDao.clearData(); return tsInstitutionDao.clearData();
@@ -0,0 +1,132 @@
package com.adc.da.slrs.sarInstitution.util;
import com.adc.da.slrs.sarInstitution.entity.TsInstitution;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class TreeUtil {
public List<TsInstitution> treeAsList(List<TsInstitution> institutionList,List<TsInstitution> rootList){
//转换为hashSet
List<String> root = rootList.stream()
.map(item -> item.getId())
.collect(Collectors.toList());
HashSet<String> rootSet = new HashSet<>(root);
//获取父节点,0表示父节点
List<TsInstitution> tree = institutionList.stream()
.filter(e -> rootSet.contains(e.getId()))
.map(e -> {
List<TsInstitution> childNode = getChildNode(e, institutionList);
e.setChildren(new ArrayList<>(childNode));
return e;
}).collect(Collectors.toList());
return tree;
}
/**
* 递归查询子节点
* @param root
* @param contentKnowledgeList
* @return
*/
private List<TsInstitution> getChildNode(TsInstitution root, List<TsInstitution> contentKnowledgeList) {
List<TsInstitution> childrenList = contentKnowledgeList.stream()
.filter(e -> Objects.equals(e.getParentId(), root.getId()))
.map(e -> {
List<TsInstitution> childNode = getChildNode(e, contentKnowledgeList);
e.setChildren(new ArrayList<>(childNode));
return e;
}
).collect(Collectors.toList());
return childrenList;
}
// public List<TsInstitution> getChildAsHash(TsInstitution root, Map<String, TsInstitution> hashInstitution){
// String id = root.getId();
// if (hashInstitution.containsKey(id)){
//
// }
// return null;
// }
// //TODO 利用HashMap组装树结构
//
// public List<TsInstitution> treeAsHash(List<TsInstitution> institutionList,List<TsInstitution> rootList) {
//
// Map<String, TsInstitution> idMap = institutionList.stream()
// .collect(Collectors.toMap(TsInstitution::getId, tsInstitution -> tsInstitution));
//
// Map<String, TsInstitution> pid_institution = institutionList.stream()
// .collect(Collectors.toMap(TsInstitution::getParentId, institution -> institution));
//
// for (TsInstitution institution : rootList) {
//
// String id = institution.getId();
// if (pid_institution.containsKey(id)) {
// institution.addChildren(pid_institution.get(id));
//
// }
//
// }
//
//
// Set<String> rootSet = rootList.stream()
// .map(TsInstitution::getId)
// .collect(Collectors.toSet());
//
// Iterator<TsInstitution> it = institutionList.iterator();
//
// ArrayList<TsInstitution> resultList = new ArrayList<>();
//
//
// HashMap<String, TsInstitution> id_obj = new HashMap<>();
// while (it.hasNext()) {
// TsInstitution next = it.next();
//
// String parentId = next.getParentId();
// id_obj.put(next.getId(), next);
// if (rootSet.contains(parentId)) {
// id_obj.put(next.getId(), next);
// } else if (id_obj.containsKey(parentId)) {
// id_obj.get(parentId).addChildren(next);
// }
//
// }
// return null ;
//
// }
//
//
//
// List<TreeNodeDTO> list = dbMapper.getNodeList();
// ArrayList<TreeNodeDTO> rootNodes = new ArrayList<>();
// Map<Integer, TreeNodeDTO> map = new HashMap<>();
// for (TreeNodeDTO node :list) {
// map.put(node.getId(), node);
// Integer parentId = node.getParentId();
// // 判断是否有父节点 (没有父节点本身就是个父菜单)
// if (parentId.equals('0')){
// rootNodes.add(node);
// // 找出不是父级菜单的且集合中包括其父菜单ID
// } else if (map.containsKey(parentId)){
// map.get(parentId).getChildren().add(node);
// }
// }
//
// }
}
@@ -42,7 +42,7 @@ public class SarModelTreeController extends BaseController<SarModelTree> {
@GetMapping("/list") @GetMapping("/list")
public ResponseMessage<List<SarModelTree>> getAll(){ public ResponseMessage<List<SarModelTree>> getAll(){
List<SarModelTree> tsResources = iSarModelTreeService.getAll(null); List<SarModelTree> tsResources = iSarModelTreeService.getAll(null);
// List<SarModelTree> tsResources = iSarModuleTreeService.getAll(null); // TODO List<SarModelTree> tsResources = iSarModuleTreeService.getAll(null);
return Result.success(tsResources); return Result.success(tsResources);
} }
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@@ -25,27 +26,38 @@ public class SarModuleTreeServiceImpl extends ServiceImpl<SarModuleTreeDao, SarM
@Autowired() @Autowired()
private SarModuleTreeServiceImpl sarModuleTreeService; private SarModuleTreeServiceImpl sarModuleTreeService;
/**
* @param sarModelTree
* @return 所有的根节点
*/
@Override @Override
public List<SarModelTree> getAll(SarModelTree sarModelTree) { public List<SarModelTree> getAll(SarModelTree sarModelTree) {
QueryWrapper<SarModuleTree> treeQueryWrapper = new QueryWrapper<>(); QueryWrapper<SarModuleTree> treeQueryWrapper = new QueryWrapper<>();
treeQueryWrapper.groupBy("FTVSTYPE1"); treeQueryWrapper.groupBy("FTVSTYPE1");
List<SarModuleTree> moduleTreeList = this.baseMapper.selectList(treeQueryWrapper); List<SarModuleTree> moduleTreeList = this.baseMapper.selectList(treeQueryWrapper);
//返回转换元素后的数组
//把SarModuleTree类型的list集合转换为SarModelTree类型的list集合 return listTransform(moduleTreeList);
List<SarModelTree> sarModelTreeList = moduleTreeList.stream().map(SarModuleTree -> {
SarModelTree modelTree = new SarModelTree();
modelTree.setId(SarModuleTree.getGuid());
modelTree.setName(SarModuleTree.getFtvstype1());
// modelTree.setModel("TS"+SarModuleTree.get);
return modelTree;
}).collect(Collectors.toList());
return sarModelTreeList;
} }
/**
* 根据根节点查询其所有的子节点
* @param parent
* @return
*/
@Override @Override
public List<SarModelTree> recursionGetChildren(SarModelTree parent) { public List<SarModelTree> recursionGetChildren(SarModelTree parent) {
QueryWrapper<SarModuleTree> treeQueryWrapper = new QueryWrapper<>();
treeQueryWrapper.eq("GUID",parent.getId());
List<SarModuleTree> moduleTreeList = this.baseMapper.selectList(treeQueryWrapper);
Map<String, List<SarModuleTree>> collect = moduleTreeList.stream().collect(Collectors.groupingBy(SarModuleTree::getFtvstype1));
collect.forEach((k, v)->{
SarModelTree modelTree = new SarModelTree();
//TODO 生成树型结构
// modelTree
});
return null; return null;
} }
@@ -93,5 +105,25 @@ public class SarModuleTreeServiceImpl extends ServiceImpl<SarModuleTreeDao, SarM
return head; return head;
} }
/**
* 把SarModuleTree类型的list集合转换为SarModelTree类型的list集合,这样就不用修改前端代码( •̀ ω •́ )✧
* --->对修改关闭,对扩展开放
* @param moduleTreeList
* @return
*/
public List<SarModelTree> listTransform(List<SarModuleTree> moduleTreeList){
return moduleTreeList.stream().map(SarModuleTree -> {
SarModelTree modelTree = new SarModelTree();
modelTree.setId(SarModuleTree.getGuid());
modelTree.setName(SarModuleTree.getFtvstype1());
modelTree.setModel("TS"
+SarModuleTree.getFtvstype2().substring(SarModuleTree.getFtvstype2().length()-2)
+SarModuleTree.getSeriesid()
+SarModuleTree.getReserved()
+SarModuleTree.getStarted()); //"TS"+SF_ID+SE_ID+SU_ID 拼接模块编号ID
return modelTree;
}).collect(Collectors.toList());
}
} }
@@ -57,6 +57,14 @@ public interface TsPositionDao extends BaseMapper<TsPosition> {
*/ */
List<TsPosition> selectPositionAndRole(TsPosition tsPosition); List<TsPosition> selectPositionAndRole(TsPosition tsPosition);
/**
* 总数
* @param tsPosition
* @return
*/
Integer countPositionAndRole(TsPosition tsPosition);
/** /**
* 通过岗位列表查询绑定的角色列表 * 通过岗位列表查询绑定的角色列表
* @param positionIds:岗位列表 * @param positionIds:岗位列表
@@ -44,9 +44,10 @@ public class TsPositionServiceImpl extends ServiceImpl<TsPositionDao, TsPosition
@Override @Override
public IPage<TsPosition> getPosition(TsPosition tsPosition) { public IPage<TsPosition> getPosition(TsPosition tsPosition) {
IPage page=new Page(); IPage page=new Page();
// page.setTotal(tsPositionDao.pageTotal());
page.setTotal(tsPositionDao.pageTotal()); page.setTotal(tsPositionDao.countPositionAndRole(tsPosition));
page.setRecords(tsPositionDao.selectPositionAndRole(tsPosition)); page.setRecords(tsPositionDao.selectPositionAndRole(tsPosition));
page.setTotal(page.getTotal());
page.setCurrent(tsPosition.getCurrent()); page.setCurrent(tsPosition.getCurrent());
page.setSize(tsPosition.getPageSize()); page.setSize(tsPosition.getPageSize());
System.out.println(page.getTotal()); System.out.println(page.getTotal());
@@ -1,6 +1,9 @@
package com.adc.da.slrs.sarStandardsInfo.service.impl; package com.adc.da.slrs.sarStandardsInfo.service.impl;
import com.adc.da.att.entity.AttFileEO; import com.adc.da.att.entity.AttFileEO;
import com.adc.da.slrs.sarPosition.entity.TsPosition;
import com.adc.da.slrs.sarPosition.service.ITsPositionService;
import com.adc.da.slrs.sarUser.entity.TsUser;
import com.adc.da.att.service.IAttFileEOService; import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.att.vo.AttFileVo; import com.adc.da.att.vo.AttFileVo;
import com.adc.da.common.*; import com.adc.da.common.*;
@@ -69,6 +72,7 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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 net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.catalina.User;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.util.PDFTextStripper; import org.apache.pdfbox.util.PDFTextStripper;
@@ -116,6 +120,9 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
@Value("${file.path}") @Value("${file.path}")
private String filePath;//文件存储路径 private String filePath;//文件存储路径
@Autowired
private ITsPositionService iTsPositionService;
@Autowired @Autowired
private SarStandardsInfoDao dao; private SarStandardsInfoDao dao;
@@ -482,7 +489,30 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
}else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) { }else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) {
value = entry.getValue().toString(); value = entry.getValue().toString();
List<String> valArr = Arrays.asList(value.split(",")); List<String> valArr = Arrays.asList(value.split(","));
value = dicTypeEODao.getDicNamesByCodes(valArr);
switch (name){
//通过id绑定责任工程师名称
case "ZRGCS":{
QueryWrapper<TsUser> tsUserQW = new QueryWrapper<>();
tsUserQW.select("UNAME")
.in("USID",valArr);
List<String> stringList = tsUserService.listObjs(tsUserQW, o ->o.toString());
value= String.join(",", stringList);
break;
}
//通过id绑定责任部门师名称
case "ZRBM":{
QueryWrapper<TsPosition> tsPositionQW = new QueryWrapper<>();
tsPositionQW.select("name")
.in("id",valArr);
List<String> stringList = iTsPositionService.listObjs(tsPositionQW, o -> o.toString());
value = String.join(",", stringList);
break;
}
default:value = dicTypeEODao.getDicNamesByCodes(valArr);
}
entry.setValue(value); entry.setValue(value);
} }
} }
@@ -40,6 +40,24 @@
select * from ts_user select * from ts_user
WHERE institution_id=#{institutionId} WHERE institution_id=#{institutionId}
</select> </select>
<select id="selectTreeByIds" resultMap="TsInstitution">
<foreach collection="rootIds" item="id">
SELECT
*
FROM
ts_institution
WHERE
FIND_IN_SET(
id,
GET_PARENT_NODE (#{id})
);
</foreach>
</select>
<select id="selectRootAndUser" resultMap="InstitutionAndUser"> <select id="selectRootAndUser" resultMap="InstitutionAndUser">
select i.*,u.usid,u.account,u.uname,u.institution_id from ts_institution i select i.*,u.usid,u.account,u.uname,u.institution_id from ts_institution i
left join ts_user u left join ts_user u
@@ -30,6 +30,7 @@
<where> <where>
<if test="name!=null"> <if test="name!=null">
p.name like concat(concat('%',#{name}),'%') p.name like concat(concat('%',#{name}),'%')
order by locate(#{name},p.name)
</if> </if>
</where> </where>
<if test=" null!= pageSize "> <if test=" null!= pageSize ">
@@ -37,6 +38,20 @@
</if> </if>
</select> </select>
<select id="countPositionAndRole" resultType="java.lang.Integer">
select count(1) from ts_position p
left join ts_position_role pr
on p.id=pr.position_id
left join ts_role r
on pr.role_id=r.id
<where>
<if test="name!=null">
p.name like concat(concat('%',#{name}),'%')
</if>
</where>
</select>
<select id="pageTotal" resultType="Long"> <select id="pageTotal" resultType="Long">
select count(1) as total from ts_position select count(1) as total from ts_position
</select> </select>
@@ -34,7 +34,11 @@
on u.usid=up.user_id on u.usid=up.user_id
left join ts_position p left join ts_position p
on up.position_id=p.id on up.position_id=p.id
where u.institution_id=#{TsUser.institutionId} where 1=1
<if test="TsUser.institutionId !=null and TsUser.institutionId!=''">
and u.institution_id=#{TsUser.institutionId}
</if>
<if test="TsUser.uname != null and TsUser.uname != '' "> <if test="TsUser.uname != null and TsUser.uname != '' ">
and u.uname like concat('%',#{TsUser.uname},'%') and u.uname like concat('%',#{TsUser.uname},'%')
</if> </if>
@@ -101,6 +101,8 @@ public class DicTypeEOServiceImpl extends ServiceImpl<DicTypeEODao,DicTypeEO> im
if(!StringUtils.isNotEmpty(dicTypeEO.getDicTypeCode())){ if(!StringUtils.isNotEmpty(dicTypeEO.getDicTypeCode())){
dicTypeEO.setDicTypeCode(UUIDUtils.randomUUID10()); dicTypeEO.setDicTypeCode(UUIDUtils.randomUUID10());
} }
}else {
dicTypeEO.setDicTypeCode(dicTypeEO.getDicTypeName());
} }
String id = UUIDUtils.randomUUID20(); String id = UUIDUtils.randomUUID20();
dicTypeEO.setId(id); dicTypeEO.setId(id);