Commit 85d8b05e authored by chenzhao's avatar chenzhao

infoDown

parent a0800a26
......@@ -57,8 +57,7 @@ public class AcceptanceRectificationOrderServiceImpl extends BaseService<Accepta
// private WorkflowImpl workflow;
@Autowired
private WorkFlowService workFlowService;
@Autowired
private CommonServiceImpl commonService;
@Autowired
private RedisUtils redisUtils;
@Resource (type = RedisLockUtil.class)
......
......@@ -52,8 +52,6 @@ public class AcceptanceServiceImpl implements IAcceptanceService {
private PeasantHouseholdMapper peasantHouseholdMapper;
@Autowired
private AcceptanceCheckItemMapper acceptanceCheckItemMapper;
@Autowired
private CommonServiceImpl commonService;
@Resource(type = RedisLockUtil.class)
private RedisLockUtil redisLockUtil;
......
......@@ -79,7 +79,7 @@ import java.util.zip.ZipOutputStream;
@Service
@Slf4j
public class CommonServiceImpl {
// @Autowired
// @Autowired
// private TaskV2FeignService taskV2FeignService;
@Autowired
private RedisUtils redisUtils;
......@@ -539,8 +539,8 @@ public class CommonServiceImpl {
}
public void downZiliao(String surveyInformationId, List<String> peasantHouseholdIds, String processInstanceId, HttpServletResponse response) throws IOException {
String fileName = "";
String redisKey = "";
String fileName = "";
String redisKey = "";
if (peasantHouseholdIds.size()>1){
redisKey = String.join(",", peasantHouseholdIds);
}else {
......@@ -552,7 +552,7 @@ public class CommonServiceImpl {
// 获取当前工作目录
Path rootDir = currentWorkingDir;
Path ziLiaoDir =rootDir.resolve("批量资料");
for (String peasantHouseholdId : peasantHouseholdIds) {
for (String peasantHouseholdId : peasantHouseholdIds) {
SurveyInfoAllDto returnDto = surveyInformationServiceImpl.querySurveyInfo(surveyInformationId, peasantHouseholdId, processInstanceId, null);
fileName = returnDto.getSurveyInformation().getOwnersName();
if (!redisKey.contains(",")){
......@@ -584,8 +584,8 @@ public class CommonServiceImpl {
System.out.println("模版文件所在目录是: " + templateDir);
Path tempDir = createUniqueDirectory(ziLiaoDir, returnDto.getSurveyInformation().getOwnersName());
String wenjianjia = tempDir.toString().replace("\\","/");
Path tempDir = createUniqueDirectory(ziLiaoDir, returnDto.getSurveyInformation().getOwnersName());
String wenjianjia = tempDir.toString().replace("\\","/");
try {
Files.createDirectories(tempDir); // 创建临时目录
System.out.println("Temporary directory created at: " + tempDir);
......@@ -662,21 +662,21 @@ public class CommonServiceImpl {
redisUtils.set(redisKey, MapBuilder.<String, Object>create()
.put("value", currentBili).build());
}
List<HygfRectificationOrder> areaOrdersCon =new ArrayList<>();
if (ObjectUtils.isNotEmpty(returnDto.getHygfOnGrid())) {
areaOrdersCon = Optional.ofNullable(returnDto.getPowerStationConstructionData().getAreaOrders())
.orElse(new ArrayList<>());
addNonNullList(areaOrdersCon, returnDto.getPowerStationConstructionData().getDesignOrders());
addNonNullList(areaOrdersCon, returnDto.getPowerStationConstructionData().getEngineeringOrders());
}
List<HygfRectificationOrder> areaOrdersCon =new ArrayList<>();
if (ObjectUtils.isNotEmpty(returnDto.getHygfOnGrid())) {
areaOrdersCon = Optional.ofNullable(returnDto.getPowerStationConstructionData().getAreaOrders())
.orElse(new ArrayList<>());
addNonNullList(areaOrdersCon, returnDto.getPowerStationConstructionData().getDesignOrders());
addNonNullList(areaOrdersCon, returnDto.getPowerStationConstructionData().getEngineeringOrders());
}
// 主方法或代码块
List<HygfRectificationOrder> areaOrders =new ArrayList<>();
if (ObjectUtils.isNotEmpty(returnDto.getHygfOnGrid())) {
List<HygfRectificationOrder> areaOrders =new ArrayList<>();
if (ObjectUtils.isNotEmpty(returnDto.getHygfOnGrid())) {
areaOrders = Optional.ofNullable(returnDto.getHygfOnGrid().getAreaOrders())
.orElse(new ArrayList<>());
addNonNullList(areaOrders, returnDto.getHygfOnGrid().getDesignOrders());
addNonNullList(areaOrders, returnDto.getHygfOnGrid().getEngineeringOrders());
}
.orElse(new ArrayList<>());
addNonNullList(areaOrders, returnDto.getHygfOnGrid().getDesignOrders());
addNonNullList(areaOrders, returnDto.getHygfOnGrid().getEngineeringOrders());
}
List<HygfRectificationOrder> areaOrdersAcc = new ArrayList<>();
if (ObjectUtils.isNotEmpty(returnDto.getAcceptanceCheck())){
areaOrdersAcc = Optional.ofNullable(returnDto.getAcceptanceCheck().getAreaOrders())
......@@ -687,8 +687,8 @@ public class CommonServiceImpl {
}
List<Future<?>> futures = new ArrayList<>();
String finalRedisKey = redisKey;
futures.add(executorService.submit(() -> {
String finalRedisKey = redisKey;
futures.add(executorService.submit(() -> {
try {
downloadAndZipImages(returnDto.getSurveyInformation(),"基本信息附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
......@@ -771,8 +771,8 @@ public class CommonServiceImpl {
e.printStackTrace();
}
}));
List<HygfRectificationOrder> finalAreaOrdersCon = areaOrdersCon;
futures.add(executorService.submit(() -> {
List<HygfRectificationOrder> finalAreaOrdersCon = areaOrdersCon;
futures.add(executorService.submit(() -> {
try {
downloadAndZipImages(finalAreaOrdersCon,"施工信息整改单附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
......@@ -800,8 +800,8 @@ public class CommonServiceImpl {
e.printStackTrace();
}
}));
List<HygfRectificationOrder> finalAreaOrders = areaOrders;
futures.add(executorService.submit(() -> {
List<HygfRectificationOrder> finalAreaOrders = areaOrders;
futures.add(executorService.submit(() -> {
try {
downloadAndZipImages(finalAreaOrders,"并网信息整改单附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
......@@ -829,8 +829,8 @@ public class CommonServiceImpl {
e.printStackTrace();
}
}));
List<HygfRectificationOrder> finalAreaOrdersAcc = areaOrdersAcc;
futures.add(executorService.submit(() -> {
List<HygfRectificationOrder> finalAreaOrdersAcc = areaOrdersAcc;
futures.add(executorService.submit(() -> {
try {
downloadAndZipImages(finalAreaOrdersAcc,"验收信息整改单附件",tempDir,urlPath);
if (!finalRedisKey.contains(",")){
......@@ -862,11 +862,11 @@ public class CommonServiceImpl {
}
// response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename="+returnDto.getSurveyInformation().getOwnersName()+".zip");
if (redisKey.contains(",")){
currentBili = currentBili + baifenbi;
redisUtils.set(redisKey,MapBuilder.<String, Object>create()
.put("value", currentBili).build());
}
if (redisKey.contains(",")){
currentBili = currentBili + baifenbi;
redisUtils.set(redisKey,MapBuilder.<String, Object>create()
.put("value", currentBili).build());
}
}
String encodedFilename = "";
......@@ -888,7 +888,7 @@ public class CommonServiceImpl {
cleanup(ziLiaoDir);
}
public void test (HttpServletResponse response) throws UnsupportedEncodingException {
public void test (HttpServletResponse response) throws UnsupportedEncodingException {
String fileName = "批量资料";
Path currentWorkingDir = Paths.get("");
// 获取当前工作目录
......@@ -900,9 +900,9 @@ public class CommonServiceImpl {
}
private void fillSheet(Sheet sheet, Object data) {
if (Objects.isNull(data)){
return;
}
if (Objects.isNull(data)){
return;
}
int startRow = 1;
for (int i = 0; i < sheet.getLastRowNum() + 1; i++) {
Row row = sheet.getRow(i);
......@@ -1396,13 +1396,13 @@ public class CommonServiceImpl {
// 计算ZIP文件的总大小
long totalSize = getTotalFileSize(folderPath);
double totalNum = (double) (totalSize/1024/1024);
if (totalNum > 500 ){
this.cleanup(folderPath);
response.setHeader("content-error", URLEncoder.encode("所选文件总大小不得超过500M,当前所选文件总大小为"+totalNum+"M", "UTF-8"));
response.setContentType("text/plain");
throw new BadRequest("所选文件总大小不得超过500M,当前所选文件总大小为"+totalNum+"M");
}
// response.setContentLengthLong((int) totalSize);
if (totalNum > 500 ){
this.cleanup(folderPath);
response.setHeader("content-error", URLEncoder.encode("所选文件总大小不得超过500M,当前所选文件总大小为"+totalNum+"M", "UTF-8"));
response.setContentType("text/plain");
throw new BadRequest("所选文件总大小不得超过500M,当前所选文件总大小为"+totalNum+"M");
}
// response.setContentLengthLong((int) totalSize);
addFolderToZip(zipFilePath, folderPath, zos,response);
} catch (IOException e) {
e.printStackTrace();
......@@ -1582,137 +1582,137 @@ public class CommonServiceImpl {
return fields;
}
void documentSpecialProcessing (Sheet sheet, int headerRow,int headerOneRow,int dataStartRow, String[] headersNames, String[] headers, String headerOne, List<Map<String, Object>> data){
// 创建表头样式
CellStyle headerStyle = sheet.getWorkbook().createCellStyle();
Font headerFont = sheet.getWorkbook().createFont();
headerFont.setBold(true); // 加粗字体
headerFont.setFontHeightInPoints((short) 12); // 字体大小
headerStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
headerStyle.setAlignment(HorizontalAlignment.CENTER); // 居中对齐
headerStyle.setFont(headerFont); // 设置字体样式
// 设置边框
headerStyle.setBorderTop(BorderStyle.THIN);
headerStyle.setBorderBottom(BorderStyle.THIN);
headerStyle.setBorderLeft(BorderStyle.THIN);
headerStyle.setBorderRight(BorderStyle.THIN);
// 写入表头
Row headerRowObjectOne = sheet.getRow(headerOneRow);
if (headerRowObjectOne == null) {
headerRowObjectOne = sheet.createRow(headerOneRow);
Cell cell = headerRowObjectOne.getCell(0);
if (cell == null) {
cell = headerRowObjectOne.createCell(0);
}
cell.setCellValue(headerOne);
cell.setCellStyle(headerStyle);
}
// 写入表头
Row headerRowObject = sheet.getRow(headerRow);
if (headerRowObject == null) {
headerRowObject = sheet.createRow(headerRow);
}
for (int i = 0; i < headersNames.length; i++) {
Cell headerCell = headerRowObject.getCell(i);
if (headerCell == null) {
headerCell = headerRowObject.createCell(i);
}
headerCell.setCellValue(headersNames[i]);
headerCell.setCellStyle(headerStyle);
}
// 从第四行开始填充数据
for (int dataIndex = 0; dataIndex < data.size(); dataIndex++) {
Row dataRow = sheet.createRow(dataStartRow + dataIndex);
Map<String, Object> result = (Map<String, Object>) data.get(dataIndex);
Map<String, Object> rowData = new HashMap<>();
if (result.containsKey("map")){
rowData = (Map<String, Object>)result.get("map");
}else {
rowData = result;
}
for (int i = 0; i < headersNames.length; i++) {
Cell dataCell = dataRow.createCell(i);
if (rowData.containsKey(headers[i])) {
Object value = rowData.get(headers[i]);
if (value instanceof List<?>) {
List<String> urls = (List<String>) value;
if (!urls.isEmpty()) {
try {
XSSFDrawing drawing = ((XSSFSheet) sheet).getDrawingPatriarch();
if (drawing == null) {
drawing = ((XSSFSheet) sheet).createDrawingPatriarch();
}
// 设置单元格为空
dataCell.setCellStyle(sheet.getWorkbook().createCellStyle());
dataCell.setCellType(CellType.STRING);
dataCell.setCellValue("");
// 计算第一个图片的位置
int colWidth = 0;
int rowHeight = 0;
int pictureIdx = -1;
for (int j = 0; j < urls.size(); j++) {
String url = urls.get(j);
InputStream inputStream = new URL(url).openStream();
pictureIdx = ((XSSFWorkbook) sheet.getWorkbook()).addPicture(inputStream, XSSFWorkbook.PICTURE_TYPE_JPEG);
// 输出调试信息
System.out.println("Picture index: " + pictureIdx);
// 创建图片对象
XSSFClientAnchor anchor = new XSSFClientAnchor(
0, 0, 0, 0, (short) i, dataIndex + dataStartRow,
(short) (i + colWidth / 100), dataIndex + dataStartRow + rowHeight / 100
);
Picture pict = drawing.createPicture(anchor, pictureIdx);
pict.resize();
// 计算图片的宽度和高度
int picWidth = 100; // 图片宽度百分比
int picHeight = 100; // 图片高度百分比
colWidth += picWidth;
rowHeight += picHeight;
}
// 检查是否需要合并单元格
if (colWidth > 100) {
// 合并单元格
sheet.addMergedRegion(new CellRangeAddress(dataIndex + dataStartRow, dataIndex + dataStartRow, i, i + (colWidth / 100) - 1));
}
// 调整单元格的宽度和高度
sheet.setColumnWidth(i, (colWidth * 256) / 100);
dataRow.setHeightInPoints(rowHeight);
} catch (Exception e) {
// 处理异常情况
System.err.println("Failed to download or insert images: " + value);
e.printStackTrace();
}
} else {
dataCell.setCellValue(""); // 假设所有数据都是字符串格式
}
} else if( value instanceof Date) {
String s = DateUtils.date2LongStr((Date) value);
dataCell.setCellValue(s);
}
else {
dataCell.setCellValue(null == value?"":value.toString()); // 假设所有数据都是字符串格式
}
} else {
dataCell.setCellValue(""); // 假设所有数据都是字符串格式
}
}
}
void documentSpecialProcessing (Sheet sheet, int headerRow,int headerOneRow,int dataStartRow, String[] headersNames, String[] headers, String headerOne, List<Map<String, Object>> data){
// 创建表头样式
CellStyle headerStyle = sheet.getWorkbook().createCellStyle();
Font headerFont = sheet.getWorkbook().createFont();
headerFont.setBold(true); // 加粗字体
headerFont.setFontHeightInPoints((short) 12); // 字体大小
headerStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
headerStyle.setAlignment(HorizontalAlignment.CENTER); // 居中对齐
headerStyle.setFont(headerFont); // 设置字体样式
// 设置边框
headerStyle.setBorderTop(BorderStyle.THIN);
headerStyle.setBorderBottom(BorderStyle.THIN);
headerStyle.setBorderLeft(BorderStyle.THIN);
headerStyle.setBorderRight(BorderStyle.THIN);
// 写入表头
Row headerRowObjectOne = sheet.getRow(headerOneRow);
if (headerRowObjectOne == null) {
headerRowObjectOne = sheet.createRow(headerOneRow);
Cell cell = headerRowObjectOne.getCell(0);
if (cell == null) {
cell = headerRowObjectOne.createCell(0);
}
cell.setCellValue(headerOne);
cell.setCellStyle(headerStyle);
}
// 写入表头
Row headerRowObject = sheet.getRow(headerRow);
if (headerRowObject == null) {
headerRowObject = sheet.createRow(headerRow);
}
for (int i = 0; i < headersNames.length; i++) {
Cell headerCell = headerRowObject.getCell(i);
if (headerCell == null) {
headerCell = headerRowObject.createCell(i);
}
headerCell.setCellValue(headersNames[i]);
headerCell.setCellStyle(headerStyle);
}
// 从第四行开始填充数据
for (int dataIndex = 0; dataIndex < data.size(); dataIndex++) {
Row dataRow = sheet.createRow(dataStartRow + dataIndex);
Map<String, Object> result = (Map<String, Object>) data.get(dataIndex);
Map<String, Object> rowData = new HashMap<>();
if (result.containsKey("map")){
rowData = (Map<String, Object>)result.get("map");
}else {
rowData = result;
}
for (int i = 0; i < headersNames.length; i++) {
Cell dataCell = dataRow.createCell(i);
if (rowData.containsKey(headers[i])) {
Object value = rowData.get(headers[i]);
if (value instanceof List<?>) {
List<String> urls = (List<String>) value;
if (!urls.isEmpty()) {
try {
XSSFDrawing drawing = ((XSSFSheet) sheet).getDrawingPatriarch();
if (drawing == null) {
drawing = ((XSSFSheet) sheet).createDrawingPatriarch();
}
// 设置单元格为空
dataCell.setCellStyle(sheet.getWorkbook().createCellStyle());
dataCell.setCellType(CellType.STRING);
dataCell.setCellValue("");
// 计算第一个图片的位置
int colWidth = 0;
int rowHeight = 0;
int pictureIdx = -1;
for (int j = 0; j < urls.size(); j++) {
String url = urls.get(j);
InputStream inputStream = new URL(url).openStream();
pictureIdx = ((XSSFWorkbook) sheet.getWorkbook()).addPicture(inputStream, XSSFWorkbook.PICTURE_TYPE_JPEG);
// 输出调试信息
System.out.println("Picture index: " + pictureIdx);
// 创建图片对象
XSSFClientAnchor anchor = new XSSFClientAnchor(
0, 0, 0, 0, (short) i, dataIndex + dataStartRow,
(short) (i + colWidth / 100), dataIndex + dataStartRow + rowHeight / 100
);
Picture pict = drawing.createPicture(anchor, pictureIdx);
pict.resize();
// 计算图片的宽度和高度
int picWidth = 100; // 图片宽度百分比
int picHeight = 100; // 图片高度百分比
colWidth += picWidth;
rowHeight += picHeight;
}
// 检查是否需要合并单元格
if (colWidth > 100) {
// 合并单元格
sheet.addMergedRegion(new CellRangeAddress(dataIndex + dataStartRow, dataIndex + dataStartRow, i, i + (colWidth / 100) - 1));
}
// 调整单元格的宽度和高度
sheet.setColumnWidth(i, (colWidth * 256) / 100);
dataRow.setHeightInPoints(rowHeight);
} catch (Exception e) {
// 处理异常情况
System.err.println("Failed to download or insert images: " + value);
e.printStackTrace();
}
} else {
dataCell.setCellValue(""); // 假设所有数据都是字符串格式
}
} else if( value instanceof Date) {
String s = DateUtils.date2LongStr((Date) value);
dataCell.setCellValue(s);
}
else {
dataCell.setCellValue(null == value?"":value.toString()); // 假设所有数据都是字符串格式
}
} else {
dataCell.setCellValue(""); // 假设所有数据都是字符串格式
}
}
}
//原始方法
// for (int dataIndex = 0; dataIndex < data.size(); dataIndex++) {
......@@ -1833,33 +1833,33 @@ public class CommonServiceImpl {
return null;
}
List<LinkedHashMap> flowLoggernew = new ArrayList<>();
try {
Map<String, Object> flowLoggerMap = workflowFeignClient.getFlowLogger(processInstanceId).getResult();
List<LinkedHashMap> flowLogger = (List<LinkedHashMap>) flowLoggerMap.get("flowLogger");
if (flowLogger.size() > 0) {
Collections.reverse(flowLogger);
}
for (LinkedHashMap linkedHashMap : flowLogger) {
if (linkedHashMap.get("operateDate") != null
&& !linkedHashMap.get("operateDate").toString().isEmpty()) {
LinkedHashMap linke = new LinkedHashMap();
linke.put("approvalStatue", linkedHashMap.get("approvalStatue").toString());
// 审核意见
List<LinkedHashMap> approvalSuggestion = (List<LinkedHashMap>) linkedHashMap
.get("approvalSuggestion");
if (approvalSuggestion != null && !approvalSuggestion.isEmpty()) {
linke.put("approvalSuggestion", approvalSuggestion.get(0).get("message"));
}
linke.put("taskName", linkedHashMap.get("taskName").toString());
linke.put("operator", linkedHashMap.get("operator").toString());
linke.put("operateDate", linkedHashMap.get("operateDate").toString());
flowLoggernew.add(linke);
try {
Map<String, Object> flowLoggerMap = workflowFeignClient.getFlowLogger(processInstanceId).getResult();
List<LinkedHashMap> flowLogger = (List<LinkedHashMap>) flowLoggerMap.get("flowLogger");
if (flowLogger.size() > 0) {
Collections.reverse(flowLogger);
}
for (LinkedHashMap linkedHashMap : flowLogger) {
if (linkedHashMap.get("operateDate") != null
&& !linkedHashMap.get("operateDate").toString().isEmpty()) {
LinkedHashMap linke = new LinkedHashMap();
linke.put("approvalStatue", linkedHashMap.get("approvalStatue").toString());
// 审核意见
List<LinkedHashMap> approvalSuggestion = (List<LinkedHashMap>) linkedHashMap
.get("approvalSuggestion");
if (approvalSuggestion != null && !approvalSuggestion.isEmpty()) {
linke.put("approvalSuggestion", approvalSuggestion.get(0).get("message"));
}
linke.put("taskName", linkedHashMap.get("taskName").toString());
linke.put("operator", linkedHashMap.get("operator").toString());
linke.put("operateDate", linkedHashMap.get("operateDate").toString());
flowLoggernew.add(linke);
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return flowLoggernew;
}
......@@ -1870,7 +1870,7 @@ public class CommonServiceImpl {
up5.eq(ConstructionRecords::getWorkOrderPowerStationId,workOrderPowerStationId);
up5.eq(ConstructionRecords::getWorkOrderId,workOrderId);
up5.orderByAsc(ConstructionRecords::getRecDate);
return constructionRecordsMapper.selectList(up5);
return constructionRecordsMapper.selectList(up5);
}
List<ConstructionGirdRecords> getConstructionRecordsBasic (String peasantHouseholdId) {
......
......@@ -91,8 +91,7 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
// WorkflowImpl workflow;
@Autowired
WorkFlowService workFlowService;
@Autowired
CommonServiceImpl commonService;
@Autowired
HouseholdContractMapper householdContractMapper;
@Resource (type = RedisLockUtil.class)
......
......@@ -140,8 +140,7 @@ public class SurveyInformationServiceImpl
// WorkflowImpl workflow;
@Autowired
WorkFlowService workFlowService;
@Autowired
CommonServiceImpl commonService;
@Autowired
HygfRectificationOrderServiceImpl rectificationOrderService;
private static final String PROCESSKEY = "ProcessEngineering";
......
......@@ -142,9 +142,6 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto,UnitInfo,UnitIn
@Autowired
WorkFlowService workFlowService;
@Autowired
@Lazy
CommonServiceImpl commonService;
@Autowired
AmosRequestContext amosRequestContext;
@Autowired
......
......@@ -129,8 +129,6 @@ public class WorkOrderServiceImpl extends BaseService<WorkOrderDto, WorkOrder, W
BasicGridAcceptanceServiceImpl basicGridAcceptanceService;
@Autowired
AcceptanceCheckServiceImpl acceptanceCheckService;
@Autowired
CommonServiceImpl commonService;
private static final String PROCESSKEY = "ProcessEngineering";
......
......@@ -47,8 +47,6 @@ public class TestController extends BaseController {
@Autowired
IndicatorDataMapper indicatorDataMapper;
@Autowired
CommonServiceImpl commonService;
@Autowired
HealthStatusIndicatorServiceImpl healthStatusIndicatorService;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment