【修改】 删除无用代码,新增docx4j代码读取docx文档
This commit is contained in:
@@ -3,7 +3,7 @@ package pc.exam.pp.module.exam.controller.admin.wps.vo.docx;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Schema(description = "考试模块 - PPT考点列表 Request VO")
|
@Schema(description = "考试模块 - Word考点列表 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class DocxListReqVO {
|
public class DocxListReqVO {
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Schema(description = "考试模块 - PPT考点信息 Response VO")
|
@Schema(description = "考试模块 - Word考点信息 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class DocxRespVO {
|
public class DocxRespVO {
|
||||||
|
|
||||||
@@ -23,17 +23,9 @@ public class DocxRespVO {
|
|||||||
|
|
||||||
private String chineseName;
|
private String chineseName;
|
||||||
|
|
||||||
private String dataType;
|
private String functions;
|
||||||
|
|
||||||
private Integer isText;
|
private String parameter;
|
||||||
|
|
||||||
private String valueList;
|
|
||||||
|
|
||||||
private Integer isTrue;
|
|
||||||
|
|
||||||
private Integer titleType;
|
|
||||||
|
|
||||||
private Integer isParameter;
|
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package pc.exam.pp.module.exam.controller.admin.wps.vo.docx;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Schema(description = "考试模块 - PPT考点创建/修改 Request VO")
|
@Schema(description = "考试模块 - Word考点创建/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class DocxSaveReqVO {
|
public class DocxSaveReqVO {
|
||||||
|
|
||||||
@@ -21,16 +21,8 @@ public class DocxSaveReqVO {
|
|||||||
|
|
||||||
private String chineseName;
|
private String chineseName;
|
||||||
|
|
||||||
private String dataType;
|
private String parameter;
|
||||||
|
|
||||||
private Integer isText;
|
private String functions;
|
||||||
|
|
||||||
private String valueList;
|
|
||||||
|
|
||||||
private Integer isTrue;
|
|
||||||
|
|
||||||
private Integer titleType;
|
|
||||||
|
|
||||||
private Integer isParameter;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,9 @@ public class ExamWpsDocx extends TenantBaseDO {
|
|||||||
private String title;
|
private String title;
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
private String chineseName;
|
private String chineseName;
|
||||||
private String dataType;
|
private String functions;
|
||||||
|
private String parameter;
|
||||||
private Integer status;
|
private Integer status;
|
||||||
private String valueList;
|
|
||||||
private Integer isTrue;
|
|
||||||
private Integer isText;
|
|
||||||
private Integer titleType;
|
|
||||||
private Integer isParameter;
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private List<ExamWpsDocx> children = new ArrayList<>();
|
private List<ExamWpsDocx> children = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.admin.AutoWps;
|
package pc.exam.pp.module.judgement.controller.admin.AutoWps;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||||
import pc.exam.pp.module.infra.controller.admin.file.vo.file.FileUploadReqVO;
|
import pc.exam.pp.module.infra.controller.admin.file.vo.file.FileUploadReqVO;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.AutoWps.vo.WpsDocxInfoVo;
|
import pc.exam.pp.module.judgement.controller.admin.AutoWps.vo.WpsDocxInfoVo;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsPptxJudgementDto;
|
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordJudgementDto;
|
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordReqDto;
|
|
||||||
import pc.exam.pp.module.judgement.service.wps_excel.JudgementWpsExcelService;
|
import pc.exam.pp.module.judgement.service.wps_excel.JudgementWpsExcelService;
|
||||||
import pc.exam.pp.module.judgement.service.wps_pptx.JudgementWpsPptxService;
|
import pc.exam.pp.module.judgement.service.wps_pptx.JudgementWpsPptxService;
|
||||||
import pc.exam.pp.module.judgement.service.wps_word.JudgementWpsWordService;
|
import pc.exam.pp.module.judgement.service.wps_word.JudgementWpsWordService;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_pptx.judgementVO.JudgementReqVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxInfoReqVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.DocxDataInfoVO;
|
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.DocxDataInfoVO;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.JudgementWordsVO;
|
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.JudgementWordsVO;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordInfoReqVo;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -44,13 +44,18 @@ public class AutoWpsController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定考点的数据
|
* 获取指定考点的数据
|
||||||
* @param wpsDocxInfoVos
|
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@PostMapping("/docxMaster")
|
@PostMapping(value = "/docxMaster", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public CommonResult<List<JudgementWordsVO>> docxMaster(@RequestBody List<WpsDocxInfoVo> wpsDocxInfoVos) throws Exception {
|
public CommonResult<List<JudgementWordsVO>> docxMaster(@RequestPart("data") String jsonData, @RequestPart("file") MultipartFile file) throws Exception {
|
||||||
return CommonResult.success(judgementWpsWordService.docxMaster(wpsDocxInfoVos));
|
// 手动解析JSON数组
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
List<WpsDocxInfoVo> wpsDocxInfoVos = objectMapper.readValue(
|
||||||
|
jsonData,
|
||||||
|
new TypeReference<List<WpsDocxInfoVo>>() {}
|
||||||
|
);
|
||||||
|
return CommonResult.success(judgementWpsWordService.docxMaster(wpsDocxInfoVos, file));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.admin.AutoWps.vo;
|
package pc.exam.pp.module.judgement.controller.admin.AutoWps.vo;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class WpsDocxInfoVo {
|
public class WpsDocxInfoVo {
|
||||||
@@ -20,6 +21,6 @@ public class WpsDocxInfoVo {
|
|||||||
// 考点代码
|
// 考点代码
|
||||||
private String examCode;
|
private String examCode;
|
||||||
|
|
||||||
// 文件路径 理论上都是一样的
|
// 方式方法
|
||||||
private String filePath;
|
private String method;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.admin.Browser;
|
//package pc.exam.pp.module.judgement.controller.admin.Browser;
|
||||||
|
//
|
||||||
|
//
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
//import org.springframework.web.bind.annotation.RestController;
|
||||||
import pc.exam.pp.module.judgement.controller.service.browser.IBrowserServerice;
|
//import pc.exam.pp.module.judgement.controller.service.browser.IBrowserServerice;
|
||||||
|
//
|
||||||
@RestController
|
//@RestController
|
||||||
@RequestMapping("/tool/Browser")
|
//@RequestMapping("/tool/Browser")
|
||||||
|
//
|
||||||
public class BrowserController {
|
//public class BrowserController {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IBrowserServerice browserServerice;
|
// private IBrowserServerice browserServerice;
|
||||||
/**
|
// /**
|
||||||
* 浏览器判分
|
// * 浏览器判分
|
||||||
* @return 得分
|
// * @return 得分
|
||||||
*/
|
// */
|
||||||
// @PostMapping("/run_judgement")
|
//// @PostMapping("/run_judgement")
|
||||||
// public CommonResult run_C_code() throws IOException {
|
//// public CommonResult run_C_code() throws IOException {
|
||||||
// return CommonResult.success(browserServerice.Judgement());
|
//// return CommonResult.success(browserServerice.Judgement());
|
||||||
// }
|
//// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -1,45 +1,45 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.admin.Mysql;
|
//package pc.exam.pp.module.judgement.controller.admin.Mysql;
|
||||||
|
//
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
//import org.springframework.web.bind.annotation.*;
|
||||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
//import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuPaperReqVo;
|
//import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuPaperReqVo;
|
||||||
import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlLocalService;
|
//import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlLocalService;
|
||||||
import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlServerice;
|
//import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlServerice;
|
||||||
|
//
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
//import java.math.BigDecimal;
|
||||||
import java.sql.SQLException;
|
//import java.sql.SQLException;
|
||||||
|
//
|
||||||
@RestController
|
//@RestController
|
||||||
@RequestMapping("/tool/Mysql")
|
//@RequestMapping("/tool/Mysql")
|
||||||
public class MysqlController {
|
//public class MysqlController {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IMysqlServerice mysqlServerice;
|
// private IMysqlServerice mysqlServerice;
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IMysqlLocalService mysqlLocalService;
|
// private IMysqlLocalService mysqlLocalService;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 删除 本地学生的连接和库
|
// * 删除 本地学生的连接和库
|
||||||
* @param tName
|
// * @param tName
|
||||||
* @throws Exception
|
// * @throws Exception
|
||||||
*/
|
// */
|
||||||
@GetMapping("/delMysqlConnect")
|
// @GetMapping("/delMysqlConnect")
|
||||||
public void get(@RequestParam("tName") String tName) throws Exception {
|
// public void get(@RequestParam("tName") String tName) throws Exception {
|
||||||
mysqlLocalService.delMysqlConnect(tName);
|
// mysqlLocalService.delMysqlConnect(tName);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mysql判分
|
|
||||||
* @return 得分
|
|
||||||
*/
|
|
||||||
// @PostMapping("/run_judgement")
|
|
||||||
// public CommonResult run_C_code() throws SQLException, IOException {
|
|
||||||
// return CommonResult.success(mysqlServerice.Judgement( ));
|
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
}
|
// * Mysql判分
|
||||||
|
// * @return 得分
|
||||||
|
// */
|
||||||
|
//// @PostMapping("/run_judgement")
|
||||||
|
//// public CommonResult run_C_code() throws SQLException, IOException {
|
||||||
|
//// return CommonResult.success(mysqlServerice.Judgement( ));
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.admin.Mysql;
|
//package pc.exam.pp.module.judgement.controller.admin.Mysql;
|
||||||
|
//
|
||||||
import jakarta.annotation.Resource;
|
//import jakarta.annotation.Resource;
|
||||||
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.RequestMapping;
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
//import org.springframework.web.bind.annotation.RestController;
|
||||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
//import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||||
import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlServerice;
|
//import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlServerice;
|
||||||
import pc.exam.pp.module.judgement.controller.service.mysql.testservice;
|
//import pc.exam.pp.module.judgement.controller.service.mysql.testservice;
|
||||||
|
//
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
//import java.sql.SQLException;
|
||||||
|
//
|
||||||
@RestController
|
//@RestController
|
||||||
@RequestMapping("/tool/Test")
|
//@RequestMapping("/tool/Test")
|
||||||
public class TestControler {
|
//public class TestControler {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private testservice testservice;
|
// private testservice testservice;
|
||||||
|
//
|
||||||
@PostMapping("/test")
|
// @PostMapping("/test")
|
||||||
public CommonResult run_C_code() {
|
// public CommonResult run_C_code() {
|
||||||
return CommonResult.success(testservice.test());
|
// return CommonResult.success(testservice.test());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package pc.exam.pp.module.judgement.controller.admin.Ps;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlServerice;
|
|
||||||
import pc.exam.pp.module.judgement.controller.service.ps.IPsService;
|
import pc.exam.pp.module.judgement.controller.service.ps.IPsService;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
|||||||
@@ -1,37 +1,37 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.admin.WindowFile;
|
//package pc.exam.pp.module.judgement.controller.admin.WindowFile;
|
||||||
|
//
|
||||||
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.RequestMapping;
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
//import org.springframework.web.bind.annotation.RestController;
|
||||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
//import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||||
import pc.exam.pp.module.judgement.controller.service.file.IFileServerice;
|
//import pc.exam.pp.module.judgement.controller.service.file.IFileServerice;
|
||||||
import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils;
|
//import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils;
|
||||||
|
//
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 文件操作题判分
|
// * 文件操作题判分
|
||||||
* rwb
|
// * rwb
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
@RestController
|
//@RestController
|
||||||
@RequestMapping("/tool/File")
|
//@RequestMapping("/tool/File")
|
||||||
public class WindowsFileController {
|
//public class WindowsFileController {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IFileServerice fileServerice;
|
// private IFileServerice fileServerice;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 文件操作题判分
|
// * 文件操作题判分
|
||||||
* @return 判分
|
// * @return 判分
|
||||||
*/
|
// */
|
||||||
// @PostMapping("/run_judgement")
|
//// @PostMapping("/run_judgement")
|
||||||
// public CommonResult run_file_point() throws IOException {
|
//// public CommonResult run_file_point() throws IOException {
|
||||||
// //"权值得分比重"
|
//// //"权值得分比重"
|
||||||
// return CommonResult.success(fileServerice.run_file_point());
|
//// return CommonResult.success(fileServerice.run_file_point());
|
||||||
// }
|
//// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -2,30 +2,15 @@ package pc.exam.pp.module.judgement.controller.admin.Wps;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.AutoWps.vo.WpsDocxInfoVo;
|
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsPptxJudgementDto;
|
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsPptxJudgementDto;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordJudgementDto;
|
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordReqDto;
|
|
||||||
import pc.exam.pp.module.judgement.service.wps_excel.JudgementWpsExcelService;
|
import pc.exam.pp.module.judgement.service.wps_excel.JudgementWpsExcelService;
|
||||||
import pc.exam.pp.module.judgement.service.wps_pptx.JudgementWpsPptxService;
|
import pc.exam.pp.module.judgement.service.wps_pptx.JudgementWpsPptxService;
|
||||||
import pc.exam.pp.module.judgement.service.wps_word.JudgementWpsWordService;
|
import pc.exam.pp.module.judgement.service.wps_word.JudgementWpsWordService;
|
||||||
//import pc.exam.pp.module.judgement.utils.wps_excel.vo.ExcelInfoReqVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.ExcelInfoReqVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.XlsxVO;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_all.XlsxAllDataReqVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_drawing.XlsxInfoVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_style.XlsxStyleVO;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_pptx.judgementVO.JudgementReqVo;
|
import pc.exam.pp.module.judgement.utils.wps_pptx.judgementVO.JudgementReqVo;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxInfoPointsVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxInfoReqVo;
|
import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxInfoReqVo;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxVO;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.JudgementWordsVO;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordInfoReqVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -49,10 +34,10 @@ public class WpsController {
|
|||||||
JudgementWpsExcelService judgementWpsExcelService;
|
JudgementWpsExcelService judgementWpsExcelService;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/docxMaster")
|
// @PostMapping("/docxMaster")
|
||||||
public CommonResult<List<JudgementWordsVO>> docxMaster(@RequestBody List<WpsDocxInfoVo> wpsDocxInfoVos) throws Exception {
|
// public CommonResult<List<JudgementWordsVO>> docxMaster(@RequestBody List<WpsDocxInfoVo> wpsDocxInfoVos) throws Exception {
|
||||||
return CommonResult.success(judgementWpsWordService.docxMaster(wpsDocxInfoVos));
|
// return CommonResult.success(judgementWpsWordService.docxMaster(wpsDocxInfoVos));
|
||||||
}
|
// }
|
||||||
// /**
|
// /**
|
||||||
// * wps word
|
// * wps word
|
||||||
// * @return 判分
|
// * @return 判分
|
||||||
|
|||||||
@@ -10,26 +10,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperFileDO;
|
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperInfoDO;
|
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperScoreDO;
|
import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperScoreDO;
|
||||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperQuMapper;
|
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperQuMapper;
|
||||||
import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper;
|
import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper;
|
||||||
import pc.exam.pp.module.exam.dal.mysql.student.StuScoreVo;
|
import pc.exam.pp.module.exam.dal.mysql.student.StuScoreVo;
|
||||||
import pc.exam.pp.module.exam.service.question.IExamQuestionService;
|
|
||||||
import pc.exam.pp.module.exam.service.stuPaperInfo.StuPaperInfoService;
|
|
||||||
import pc.exam.pp.module.exam.service.stuPaperScore.StuPaperScoreService;
|
import pc.exam.pp.module.exam.service.stuPaperScore.StuPaperScoreService;
|
||||||
import pc.exam.pp.module.exam.service.stu_paper_file.StuPaperFileService;
|
|
||||||
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuPaperReqVo;
|
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuPaperReqVo;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuPaperScoreInfoVo;
|
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuPaperScoreInfoVo;
|
||||||
//import pc.exam.pp.module.judgement.service.auto_tools.AutoToolsService;
|
|
||||||
import pc.exam.pp.module.judgement.service.c_programming.JudgementService;
|
|
||||||
import pc.exam.pp.module.judgement.service.wps_excel.JudgementWpsExcelService;
|
|
||||||
import pc.exam.pp.module.judgement.service.wps_pptx.JudgementWpsPptxService;
|
|
||||||
import pc.exam.pp.module.judgement.service.wps_word.JudgementWpsWordService;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -51,11 +39,6 @@ public class AutoToolsController {
|
|||||||
@Resource
|
@Resource
|
||||||
ExamQuestionMapper examQuestionMapper;
|
ExamQuestionMapper examQuestionMapper;
|
||||||
|
|
||||||
// @GetMapping("/get")
|
|
||||||
// public CommonResult<BigDecimal> get(StuPaperReqVo stuPaperReqVo) throws Exception {
|
|
||||||
// return autoToolsService.judgementScore(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId());
|
|
||||||
// }
|
|
||||||
|
|
||||||
@GetMapping("/getStuScoreInfo")
|
@GetMapping("/getStuScoreInfo")
|
||||||
@Operation(summary = "通过学生ID、试卷ID获取")
|
@Operation(summary = "通过学生ID、试卷ID获取")
|
||||||
public CommonResult<StuPaperScoreInfoVo> getStuScore(StuPaperReqVo stuPaperReqVo){
|
public CommonResult<StuPaperScoreInfoVo> getStuScore(StuPaperReqVo stuPaperReqVo){
|
||||||
@@ -76,9 +59,6 @@ public class AutoToolsController {
|
|||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
// 一条一条进行查询试题,防止顺序错乱
|
// 一条一条进行查询试题,防止顺序错乱
|
||||||
// for (String quId : quIds) {
|
|
||||||
// examQuestionList.add(examQuestionMapper.selectExamQuestionByQuId(quId));
|
|
||||||
// }
|
|
||||||
stuPaperScoreInfoVos.setExamQuestionList(examQuestionList);
|
stuPaperScoreInfoVos.setExamQuestionList(examQuestionList);
|
||||||
// 5、查询学生试卷分析
|
// 5、查询学生试卷分析
|
||||||
List<StuPaperScoreDO> scoreDOS = stuPaperScoreService.findByStuIDAndPaperId(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId());
|
List<StuPaperScoreDO> scoreDOS = stuPaperScoreService.findByStuIDAndPaperId(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId());
|
||||||
|
|||||||
@@ -1,176 +1,40 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.service.browser;
|
//package pc.exam.pp.module.judgement.controller.service.browser;
|
||||||
|
//
|
||||||
import jakarta.annotation.Resource;
|
//import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
//import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionAnswerMapper;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
//
|
||||||
import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionAnswerMapper;
|
//import java.io.BufferedWriter;
|
||||||
import pc.exam.pp.module.judgement.controller.utils.brower.BookmarkChecker;
|
//import java.io.FileWriter;
|
||||||
import pc.exam.pp.module.judgement.controller.utils.brower.BookmarkDeleter;
|
//import java.io.IOException;
|
||||||
import pc.exam.pp.module.exam.utils.file.GetDifferencesBetweenFolders;
|
//import java.time.LocalDateTime;
|
||||||
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
//import java.time.format.DateTimeFormatter;
|
||||||
import pc.exam.pp.module.judgement.utils.HtmlAppender;
|
//
|
||||||
|
//@Service
|
||||||
import java.io.BufferedWriter;
|
//public class BrowserServericeImpl implements IBrowserServerice {
|
||||||
import java.io.File;
|
// static String answerLogPath ; // 文件路径
|
||||||
import java.io.FileWriter;
|
// @Resource
|
||||||
import java.io.IOException;
|
// private ExamQuestionAnswerMapper examQuestionAnswerMapper;
|
||||||
import java.nio.file.Paths;
|
// private static final DateTimeFormatter formatter =
|
||||||
import java.time.LocalDateTime;
|
// DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
import java.time.format.DateTimeFormatter;
|
// //考生试题文件夹
|
||||||
import java.util.ArrayList;
|
//// static final String BASE_DIR = "D:/exam/4/";
|
||||||
import java.util.List;
|
// //谷歌浏览器
|
||||||
import java.util.Map;
|
// String chromeBookmarkPath = System.getenv("LOCALAPPDATA") + "\\Google\\Chrome\\User Data\\Default\\Bookmarks";
|
||||||
import java.util.stream.Collectors;
|
// /**
|
||||||
|
// * 将指定内容追加写入到指定文件中。
|
||||||
@Service
|
// *
|
||||||
public class BrowserServericeImpl implements IBrowserServerice {
|
// * @param filePath 文件路径
|
||||||
static String answerLogPath ; // 文件路径
|
// * @param content 要写入的内容
|
||||||
@Resource
|
// */
|
||||||
private ExamQuestionAnswerMapper examQuestionAnswerMapper;
|
// public static void appendToFile(String filePath, String content) {
|
||||||
private static final DateTimeFormatter formatter =
|
// try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true))) {
|
||||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
// String timestamp = LocalDateTime.now().format(formatter);
|
||||||
//考生试题文件夹
|
// String logLine = String.format("[%s] %s", timestamp, content);
|
||||||
// static final String BASE_DIR = "D:/exam/4/";
|
// writer.write(logLine);
|
||||||
//谷歌浏览器
|
// writer.newLine(); // 可选:添加换行符
|
||||||
String chromeBookmarkPath = System.getenv("LOCALAPPDATA") + "\\Google\\Chrome\\User Data\\Default\\Bookmarks";
|
// } catch (IOException e) {
|
||||||
@Override
|
// e.printStackTrace();
|
||||||
public SourceAndText Judgement(double score, File file, ExamQuestion question, String judgementStr) throws IOException {
|
|
||||||
//根据题目,查找考点
|
|
||||||
|
|
||||||
//得到该试题的得分点
|
|
||||||
//Net得分点 文件类型 文件名 考点权值
|
|
||||||
// 添加到文件夹 1
|
|
||||||
// 添加到收藏夹 2
|
|
||||||
// List<ExamQuestionAnswer> answerList=new ArrayList<>();
|
|
||||||
// answerList.add(new ExamQuestionAnswer("","","","","人民大学", "添加到文件夹 ", "1", "1"));
|
|
||||||
// answerList.add(new ExamQuestionAnswer("","","","","校情", "添加到文件夹", "1", "2"));
|
|
||||||
// answerList.add(new ExamQuestionAnswer("","","","","机构", "添加到文件夹", "1", "3"));
|
|
||||||
SourceAndText sourceAndText = new SourceAndText();
|
|
||||||
List<ExamQuestionAnswer> answerList = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(question.getQuId());
|
|
||||||
|
|
||||||
//判断如果类型为1,为添加到文件夹的html,后缀加 .html
|
|
||||||
// for (ExamQuestionAnswer answer : answerList) {
|
|
||||||
// if ("添加到文件夹".equals(answer.getContentIn())) {
|
|
||||||
// String fileName = answer.getContent();
|
|
||||||
// if (!fileName.endsWith(".html")) {
|
|
||||||
// answer.setContent(fileName + ".html");
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
//分为两点,1:文件夹-- 去考生文件夹去找 文件名
|
|
||||||
// 2:收藏夹--去浏览器去找 根据值 文件名 查找
|
|
||||||
// 找到后 —————— +权值 ,根据文件名删除
|
|
||||||
|
|
||||||
answerLogPath = file.getParent() + File.separator + "log.txt";
|
|
||||||
|
|
||||||
//根据路径,得到考生答题文件集合
|
|
||||||
Map<String, String> stuFiles = GetDifferencesBetweenFolders.listFilesAndFoldersWithAttributes(file.toPath());
|
|
||||||
|
|
||||||
|
|
||||||
// 输出学生提交的内容
|
|
||||||
// appendToFile(answerLogPath,"=== 学生提交内容(stu 目录) ===");
|
|
||||||
//
|
|
||||||
// stuFiles.forEach((key, value) -> appendToFile(answerLogPath,key + " -> " + value));
|
|
||||||
appendToFile(answerLogPath,"=== 学生提交内容得分点 ===");
|
|
||||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr,"=== 学生提交内容得分点 ===");
|
|
||||||
// 计算试题总分
|
|
||||||
int totalScore = answerList.stream()
|
|
||||||
.mapToInt(a -> Integer.parseInt(a.getScoreRate()))
|
|
||||||
.sum();
|
|
||||||
//这里指挥判断存在文件夹的得分点
|
|
||||||
SourceAndText studentScorePojo = compareStuAndTestFiles(answerList, stuFiles,score,totalScore,judgementStr);
|
|
||||||
double studentScore = studentScorePojo.getScore();
|
|
||||||
judgementStr = studentScorePojo.getText();
|
|
||||||
//判断收藏夹得分点
|
|
||||||
for (ExamQuestionAnswer examQuestionAnswer : answerList) {
|
|
||||||
int currentScore = Integer.parseInt(examQuestionAnswer.getScoreRate()); // 当前得分
|
|
||||||
|
|
||||||
if ( "添加到收藏夹".equals(examQuestionAnswer.getContentIn())){
|
|
||||||
String bookmarkNameToDelete = examQuestionAnswer.getContent();
|
|
||||||
//检查收藏夹是否有书签
|
|
||||||
boolean isCorrect = BookmarkChecker.bookmarkExists(chromeBookmarkPath, bookmarkNameToDelete);
|
|
||||||
if (isCorrect) {
|
|
||||||
//如果有 +权值
|
|
||||||
studentScore += currentScore;
|
|
||||||
|
|
||||||
|
|
||||||
// 计算该考点的权重得分并保留一位小数
|
|
||||||
double weightScore = ((double) currentScore / totalScore) * score;
|
|
||||||
String formattedWeightScore = String.format("%.1f", weightScore);
|
|
||||||
|
|
||||||
appendToFile(answerLogPath,"✅考点"+bookmarkNameToDelete + " -> 得分权值:" + currentScore+"-> 得分:"+formattedWeightScore);
|
|
||||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr,"✅考点"+bookmarkNameToDelete + " -> 得分权值:" + currentScore+"-> 得分:"+formattedWeightScore);
|
|
||||||
//删除此书签
|
|
||||||
BookmarkDeleter.deleteBookmarkByName(chromeBookmarkPath, bookmarkNameToDelete);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
appendToFile(answerLogPath,"❌考点"+bookmarkNameToDelete + " -> 得分权值:" + currentScore+"-> 得分:0");
|
|
||||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr,"❌考点"+bookmarkNameToDelete + " -> 得分权值:" + currentScore+"-> 得分:0");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算最终得分比例(保留两位小数)
|
|
||||||
double scoreRatio = totalScore == 0 ? 0 : (double) studentScore / totalScore;
|
|
||||||
|
|
||||||
double roundedScoreRatio = Math.round(scoreRatio * 100.0) / 100.0; // 四舍五入到2位小数
|
|
||||||
appendToFile(answerLogPath," 得分:"+roundedScoreRatio*score);
|
|
||||||
sourceAndText.setScore(roundedScoreRatio*score);
|
|
||||||
sourceAndText.setText(judgementStr);
|
|
||||||
return sourceAndText;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 对比学生提交内容与试题得分点
|
|
||||||
static SourceAndText compareStuAndTestFiles(List<ExamQuestionAnswer> answerList, Map<String, String> stuFiles,double score,int total, String judgementStr) {
|
|
||||||
int totalScore = 0; // 记录总得分
|
|
||||||
SourceAndText sourceAndText = new SourceAndText();
|
|
||||||
for (ExamQuestionAnswer answer : answerList) {
|
|
||||||
if ("添加到文件夹".equals(answer.getContentIn())) {
|
|
||||||
String filePath = answer.getContent(); // 试题文件路径
|
|
||||||
int currentScore = Integer.parseInt(answer.getScoreRate()); // 当前得分
|
|
||||||
boolean isCorrect = false;
|
|
||||||
// 如果学生提交中存在该文件,则得分
|
|
||||||
isCorrect = stuFiles.containsKey(filePath);
|
|
||||||
// 如果正确,则累加总分
|
|
||||||
if (isCorrect) {
|
|
||||||
totalScore += currentScore;
|
|
||||||
// 计算该考点的权重得分并保留一位小数
|
|
||||||
double weightScore = ((double) currentScore / total) * score;
|
|
||||||
String formattedWeightScore = String.format("%.1f", weightScore);
|
|
||||||
appendToFile(answerLogPath,"✅考点"+answer.getContent() + " -> 得分权值:" + answer.getScoreRate()+"-> 得分:"+formattedWeightScore);
|
|
||||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr,"✅考点"+answer.getContent() + " -> 得分权值:" + answer.getScoreRate()+"-> 得分:"+formattedWeightScore);
|
|
||||||
}else {
|
|
||||||
appendToFile(answerLogPath,"❌考点"+answer.getContent() + " -> 得分权值:" + answer.getScoreRate()+"-> 得分:0");
|
|
||||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr,"❌考点"+answer.getContent() + " -> 得分权值:" + answer.getScoreRate()+"-> 得分:0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//返回累加的得分点
|
|
||||||
sourceAndText.setScore(totalScore);
|
|
||||||
sourceAndText.setText(judgementStr);
|
|
||||||
return sourceAndText;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 将指定内容追加写入到指定文件中。
|
|
||||||
*
|
|
||||||
* @param filePath 文件路径
|
|
||||||
* @param content 要写入的内容
|
|
||||||
*/
|
|
||||||
public static void appendToFile(String filePath, String content) {
|
|
||||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true))) {
|
|
||||||
String timestamp = LocalDateTime.now().format(formatter);
|
|
||||||
String logLine = String.format("[%s] %s", timestamp, content);
|
|
||||||
writer.write(logLine);
|
|
||||||
writer.newLine(); // 可选:添加换行符
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.service.browser;
|
//package pc.exam.pp.module.judgement.controller.service.browser;
|
||||||
|
//
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
//import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
||||||
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
//import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
||||||
|
//
|
||||||
import java.io.File;
|
//import java.io.File;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
|
//
|
||||||
public interface IBrowserServerice {
|
//public interface IBrowserServerice {
|
||||||
SourceAndText Judgement(double score, File file, ExamQuestion question, String judgementStr) throws IOException;
|
//}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,142 +1,18 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.service.file;
|
//package pc.exam.pp.module.judgement.controller.service.file;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
|
||||||
import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionAnswerMapper;
|
|
||||||
import pc.exam.pp.module.exam.utils.file.GetDifferencesBetweenFolders;
|
|
||||||
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
|
||||||
import pc.exam.pp.module.judgement.utils.HtmlAppender;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class FileServericeImpl implements IFileServerice {
|
|
||||||
static String answerLogPath ; // 文件路径
|
|
||||||
@Resource
|
|
||||||
private ExamQuestionAnswerMapper examQuestionAnswerMapper;
|
|
||||||
private static final DateTimeFormatter formatter =
|
|
||||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
@Override
|
|
||||||
public SourceAndText run_file_point(double score, File file, ExamQuestion question, String judgementStr) throws IOException {
|
|
||||||
SourceAndText sourceAndText = new SourceAndText();
|
|
||||||
List<ExamQuestionAnswer> answerList = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(question.getQuId());
|
|
||||||
|
|
||||||
//todo 得到学生的考题答案
|
|
||||||
// List<ExamQuestionAnswer> answerList=new ArrayList<>();
|
|
||||||
// answerList.add(new ExamQuestionAnswer("","","","","HGACYL\\RLQM.MEM", "考察删除", "1", "1"));
|
|
||||||
// answerList.add(new ExamQuestionAnswer("","","","","TING\\XYU\\AUTOE.BAT", "考察删除", "1", "2"));
|
|
||||||
// answerList.add(new ExamQuestionAnswer("","","","","AHEWL\\KMENS", "考察名称", "1", "3"));
|
|
||||||
// answerList.add(new ExamQuestionAnswer("","","","","EDZK\\RONGHE.COM", "考察名称", "1", "4"));
|
|
||||||
// answerList.add(new ExamQuestionAnswer("","","","","HGACYL\\PLAY.MEM", "考察名称", "1", "5"));
|
|
||||||
// answerList.add(new ExamQuestionAnswer("","","","","WUE\\PB6.txt", "考察名称", "1", "6"));
|
|
||||||
|
|
||||||
|
|
||||||
File stuPath = file;
|
|
||||||
|
|
||||||
// 设置日志文件路径为file所在目录下的answerLogFile.txt
|
|
||||||
answerLogPath = file.getParent() + File.separator + "log.txt";
|
|
||||||
System.out.println(answerLogPath);
|
|
||||||
// 获取 stu 文件夹的内容
|
|
||||||
Map<String, String> stuFiles = GetDifferencesBetweenFolders.listFilesAndFoldersWithAttributes(stuPath.toPath());
|
|
||||||
|
|
||||||
// 输出学生提交的内容
|
|
||||||
// appendToFile(answerLogPath,"=== 学生提交内容(stu 目录) ===");
|
|
||||||
//
|
//
|
||||||
// stuFiles.forEach((key, value) -> appendToFile(answerLogPath,key + " -> " + value));
|
//import jakarta.annotation.Resource;
|
||||||
|
//import org.springframework.stereotype.Service;
|
||||||
// 计算试题总分
|
//import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionAnswerMapper;
|
||||||
int totalScore = answerList.stream()
|
//
|
||||||
.mapToInt(a -> Integer.parseInt(a.getScoreRate()))
|
//import java.time.format.DateTimeFormatter;
|
||||||
.sum();
|
//
|
||||||
appendToFile(answerLogPath,"=== 学生提交内容得分点 ===");
|
//
|
||||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "=== 学生提交内容得分点 ===");
|
//@Service
|
||||||
// 对比学生提交内容与试题得分点
|
//public class FileServericeImpl implements IFileServerice {
|
||||||
SourceAndText studentScorePojo = compareStuAndTestFiles(answerList, stuFiles,score,totalScore,judgementStr);
|
// static String answerLogPath ; // 文件路径
|
||||||
double studentScore = studentScorePojo.getScore();
|
// @Resource
|
||||||
judgementStr = studentScorePojo.getText();
|
// private ExamQuestionAnswerMapper examQuestionAnswerMapper;
|
||||||
//获取answerList里的所有sorcerate,和integer相除得到一个小于等于1的数
|
// private static final DateTimeFormatter formatter =
|
||||||
|
// DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
// 计算最终得分比例(保留两位小数)
|
//
|
||||||
double scoreRatio = totalScore == 0 ? 0 : (double) studentScore / totalScore;
|
//}
|
||||||
double roundedScoreRatio = Math.round(scoreRatio * 100.0) / 100.0; // 四舍五入到2位小数
|
|
||||||
appendToFile(answerLogPath,"得分:"+roundedScoreRatio*score);
|
|
||||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "得分:"+roundedScoreRatio*score);
|
|
||||||
sourceAndText.setScore(roundedScoreRatio*score);
|
|
||||||
sourceAndText.setText(judgementStr);
|
|
||||||
return sourceAndText;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 对比学生提交内容与试题得分点
|
|
||||||
static SourceAndText compareStuAndTestFiles(List<ExamQuestionAnswer> answerList, Map<String, String> stuFiles,double score,int total, String judgementStr) {
|
|
||||||
SourceAndText sourceAndText = new SourceAndText();
|
|
||||||
int totalScore = 0; // 记录总得分
|
|
||||||
for (ExamQuestionAnswer answer : answerList) {
|
|
||||||
String filePath = answer.getContent(); // 试题文件路径
|
|
||||||
String checkType = answer.getContentIn(); // 考察类型(考察删除 / 考察名称 / 考察属性)
|
|
||||||
int currentScore = Integer.parseInt(answer.getScoreRate()); // 当前得分
|
|
||||||
boolean isCorrect = false;
|
|
||||||
|
|
||||||
if ("考察删除".equals(checkType)) {
|
|
||||||
// 如果学生提交中不存在该文件,则得分
|
|
||||||
isCorrect = !stuFiles.containsKey(filePath);
|
|
||||||
} else if ("考察名称".equals(checkType)) {
|
|
||||||
// 如果学生提交中存在该文件,则得分
|
|
||||||
isCorrect = stuFiles.containsKey(filePath);
|
|
||||||
} else if ("考察属性".equals(checkType)) {
|
|
||||||
// 如果学生提交中存在该文件,且属性匹配,则得分
|
|
||||||
if (stuFiles.containsKey(filePath)) {
|
|
||||||
String studentAttrs = stuFiles.get(filePath); // 学生提交的属性
|
|
||||||
String expectedAttrs = answer.getAttribute(); // 试题中期望的属性
|
|
||||||
isCorrect = studentAttrs.equals(expectedAttrs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 如果正确,则累加总分
|
|
||||||
if (isCorrect) {
|
|
||||||
totalScore += currentScore;
|
|
||||||
// 计算该考点的权重得分并保留一位小数
|
|
||||||
double weightScore = ((double) currentScore / total) * score;
|
|
||||||
String formattedWeightScore = String.format("%.1f", weightScore);
|
|
||||||
appendToFile(answerLogPath,"✅"+answer.getContent() + " -> " + answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate()+"-> 得分:"+formattedWeightScore);
|
|
||||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ " + answer.getContent() + " -> " + answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate()+"-> 得分:"+formattedWeightScore);
|
|
||||||
}else {
|
|
||||||
appendToFile(answerLogPath,"❌"+answer.getContent() + " -> " + answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate()+"-> 得分:0");
|
|
||||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "❌ " + answer.getContent() + " -> " + answer.getContentIn() + " -> 得分权值:" + answer.getScoreRate()+"-> 得分:0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sourceAndText.setText(judgementStr);
|
|
||||||
sourceAndText.setScore(totalScore);
|
|
||||||
//返回累加的总分
|
|
||||||
return sourceAndText;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将指定内容追加写入到指定文件中。
|
|
||||||
*
|
|
||||||
* @param filePath 文件路径
|
|
||||||
* @param content 要写入的内容
|
|
||||||
*/
|
|
||||||
public static void appendToFile(String filePath, String content) {
|
|
||||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true))) {
|
|
||||||
String timestamp = LocalDateTime.now().format(formatter);
|
|
||||||
String logLine = String.format("[%s] %s", timestamp, content);
|
|
||||||
writer.write(logLine);
|
|
||||||
writer.newLine(); // 可选:添加换行符
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,20 +1,7 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.service.file;
|
//package pc.exam.pp.module.judgement.controller.service.file;
|
||||||
|
//
|
||||||
|
//
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
//public interface IFileServerice {
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
//
|
||||||
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
//
|
||||||
|
//}
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface IFileServerice {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SourceAndText run_file_point(double score, File file, ExamQuestion question, String judgementStr) throws IOException;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.service.mysql;
|
//package pc.exam.pp.module.judgement.controller.service.mysql;
|
||||||
|
//
|
||||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
//import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
//import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
||||||
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
//import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
||||||
|
//
|
||||||
import java.io.File;
|
//import java.io.File;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
//import java.sql.SQLException;
|
||||||
|
//
|
||||||
public interface IMysqlLocalService {
|
//public interface IMysqlLocalService {
|
||||||
SourceAndText Judgement(double sorce, File file, ExamQuestion examQuestion, String judgementStr) throws IOException, SQLException;
|
// SourceAndText Judgement(double sorce, File file, ExamQuestion examQuestion, String judgementStr) throws IOException, SQLException;
|
||||||
|
//
|
||||||
void delMysqlConnect(String tName);
|
// void delMysqlConnect(String tName);
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,20 +1,20 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.service.mysql;
|
//package pc.exam.pp.module.judgement.controller.service.mysql;
|
||||||
|
//
|
||||||
|
//
|
||||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
//import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
//import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
//import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
||||||
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
//import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
||||||
|
//
|
||||||
import java.io.File;
|
//import java.io.File;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
//import java.sql.SQLException;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
//import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
//
|
||||||
public interface IMysqlServerice {
|
//public interface IMysqlServerice {
|
||||||
SourceAndText Judgement(double sorce, File file, ExamQuestion examQuestion, String judgementStr) throws IOException, SQLException;
|
// SourceAndText Judgement(double sorce, File file, ExamQuestion examQuestion, String judgementStr) throws IOException, SQLException;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
////}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,23 +1,23 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.service.mysql;
|
//package pc.exam.pp.module.judgement.controller.service.mysql;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper;
|
|
||||||
import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class testServiceImpl implements testservice {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EndStuMonitorUtils endStuMonitorUtils;
|
|
||||||
@Override
|
|
||||||
public boolean test() {
|
|
||||||
|
|
||||||
|
|
||||||
// String s = endStuMonitorUtils.endStuMonitor("160", "2bf4510550e34d85a852394cea61b455");
|
|
||||||
//
|
//
|
||||||
// endStuMonitorUtils.endStuMonitor("160","2bf4510550e34d85a852394cea61b455",20.0);
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
return true;
|
//import org.springframework.stereotype.Service;
|
||||||
}
|
//import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper;
|
||||||
|
//import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils;
|
||||||
}
|
//
|
||||||
|
//@Service
|
||||||
|
//public class testServiceImpl implements testservice {
|
||||||
|
//
|
||||||
|
// @Autowired
|
||||||
|
// private EndStuMonitorUtils endStuMonitorUtils;
|
||||||
|
// @Override
|
||||||
|
// public boolean test() {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// String s = endStuMonitorUtils.endStuMonitor("160", "2bf4510550e34d85a852394cea61b455");
|
||||||
|
////
|
||||||
|
//// endStuMonitorUtils.endStuMonitor("160","2bf4510550e34d85a852394cea61b455",20.0);
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package pc.exam.pp.module.judgement.controller.service.mysql;
|
//package pc.exam.pp.module.judgement.controller.service.mysql;
|
||||||
|
//
|
||||||
public interface testservice {
|
//public interface testservice {
|
||||||
boolean test();
|
// boolean test();
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -2,16 +2,7 @@ package pc.exam.pp.module.judgement.service.wps_excel;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsPptxJudgementDto;
|
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsPptxJudgementDto;
|
||||||
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.XlsxVO;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_all.XlsxAllDataReqVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_drawing.XlsxInfoVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_style.XlsxStyleVO;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordVO;
|
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,18 +4,10 @@ package pc.exam.pp.module.judgement.service.wps_excel;
|
|||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
|
||||||
import pc.exam.pp.module.exam.utils.file.LogFileUtils;
|
|
||||||
import pc.exam.pp.module.infra.dal.dataobject.config.ConfigDO;
|
import pc.exam.pp.module.infra.dal.dataobject.config.ConfigDO;
|
||||||
import pc.exam.pp.module.infra.service.config.ConfigService;
|
import pc.exam.pp.module.infra.service.config.ConfigService;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsPptxJudgementDto;
|
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsPptxJudgementDto;
|
||||||
import pc.exam.pp.module.judgement.dal.mysql.wpsxlsx.WpsXlsxLinkMapper;
|
|
||||||
//import pc.exam.pp.module.judgement.service.auto_tools.AutoToolsService;
|
|
||||||
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
|
||||||
import pc.exam.pp.module.judgement.utils.HtmlAppender;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.WpsExcelUtils;
|
import pc.exam.pp.module.judgement.utils.wps_excel.WpsExcelUtils;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_drawing.XlsxInfoVo;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -25,9 +17,6 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class JudgementWpsExcelServiceImpl implements JudgementWpsExcelService {
|
public class JudgementWpsExcelServiceImpl implements JudgementWpsExcelService {
|
||||||
|
|
||||||
@Resource
|
|
||||||
WpsXlsxLinkMapper wpsXlsxLinkMapper;
|
|
||||||
|
|
||||||
// @Resource
|
// @Resource
|
||||||
// AutoToolsService autoToolsService;
|
// AutoToolsService autoToolsService;
|
||||||
|
|
||||||
|
|||||||
@@ -2,18 +2,12 @@ package pc.exam.pp.module.judgement.service.wps_pptx;
|
|||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
|
||||||
import pc.exam.pp.module.exam.utils.file.LogFileUtils;
|
|
||||||
import pc.exam.pp.module.infra.dal.dataobject.config.ConfigDO;
|
import pc.exam.pp.module.infra.dal.dataobject.config.ConfigDO;
|
||||||
import pc.exam.pp.module.infra.service.config.ConfigService;
|
import pc.exam.pp.module.infra.service.config.ConfigService;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsPptxJudgementDto;
|
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsPptxJudgementDto;
|
||||||
//import pc.exam.pp.module.judgement.service.auto_tools.AutoToolsService;
|
//import pc.exam.pp.module.judgement.service.auto_tools.AutoToolsService;
|
||||||
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
|
||||||
import pc.exam.pp.module.judgement.utils.HtmlAppender;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_pptx.JudgementWpsPPT;
|
import pc.exam.pp.module.judgement.utils.wps_pptx.JudgementWpsPPT;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_pptx.judgementVO.JudgementReqVo;
|
import pc.exam.pp.module.judgement.utils.wps_pptx.judgementVO.JudgementReqVo;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxInfoPointsVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxInfoReqVo;
|
import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxInfoReqVo;
|
||||||
import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO;
|
import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
import pc.exam.pp.module.system.service.user.AdminUserService;
|
import pc.exam.pp.module.system.service.user.AdminUserService;
|
||||||
@@ -21,7 +15,6 @@ import pc.exam.pp.module.system.service.user.AdminUserService;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|||||||
@@ -1,19 +1,11 @@
|
|||||||
package pc.exam.pp.module.judgement.service.wps_word;
|
package pc.exam.pp.module.judgement.service.wps_word;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
|
||||||
import pc.exam.pp.module.judgement.controller.admin.AutoWps.vo.WpsDocxInfoVo;
|
import pc.exam.pp.module.judgement.controller.admin.AutoWps.vo.WpsDocxInfoVo;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordJudgementDto;
|
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordReqDto;
|
|
||||||
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.DocxDataInfoVO;
|
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.DocxDataInfoVO;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.JudgementWordsVO;
|
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.JudgementWordsVO;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordInfoReqVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordVO;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,20 +15,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface JudgementWpsWordService {
|
public interface JudgementWpsWordService {
|
||||||
|
|
||||||
List<JudgementWordsVO> docxMaster(List<WpsDocxInfoVo> wpsDocxInfoVos) throws Exception;
|
List<JudgementWordsVO> docxMaster(List<WpsDocxInfoVo> wpsDocxInfoVos, MultipartFile file) throws Exception;
|
||||||
|
|
||||||
List<DocxDataInfoVO> docxDataInfo(MultipartFile file) throws Exception;
|
List<DocxDataInfoVO> docxDataInfo(MultipartFile file) throws Exception;
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 获取word文件内得考点及描述
|
|
||||||
// * @param path minio文件路径
|
|
||||||
// * @return 文件内得考点及描述
|
|
||||||
// * @throws Exception 异常
|
|
||||||
// */
|
|
||||||
// List<WordInfoReqVo> programmingWpsWord(String path) throws Exception;
|
|
||||||
//
|
|
||||||
// List<WpsWordJudgementDto> programmingInfo(List<WpsWordReqDto> wpsWordReqDtos) throws Exception;
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,36 +3,16 @@ package pc.exam.pp.module.judgement.service.wps_word;
|
|||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
|
||||||
import pc.exam.pp.module.exam.utils.file.LogFileUtils;
|
|
||||||
import pc.exam.pp.module.infra.dal.dataobject.config.ConfigDO;
|
|
||||||
import pc.exam.pp.module.infra.service.config.ConfigService;
|
import pc.exam.pp.module.infra.service.config.ConfigService;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.AutoWps.vo.WpsDocxInfoVo;
|
import pc.exam.pp.module.judgement.controller.admin.AutoWps.vo.WpsDocxInfoVo;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordChineseFunctionDto;
|
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordJudgementDto;
|
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordReqDto;
|
|
||||||
import pc.exam.pp.module.judgement.controller.admin.Wps.vo.WordListReqVO;
|
|
||||||
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
|
|
||||||
import pc.exam.pp.module.judgement.utils.HtmlAppender;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.DocxConversion;
|
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.DocxConversion;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.DocxMaster;
|
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.DocxMaster;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.DocxDataInfoVO;
|
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.DocxDataInfoVO;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.JudgementWordsVO;
|
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.JudgementWordsVO;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordInfoReqVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordVO;
|
|
||||||
import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO;
|
|
||||||
import pc.exam.pp.module.system.service.user.AdminUserService;
|
import pc.exam.pp.module.system.service.user.AdminUserService;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
|
public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
|
||||||
|
|
||||||
@@ -42,50 +22,27 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
|
|||||||
@Resource
|
@Resource
|
||||||
private AdminUserService userService;
|
private AdminUserService userService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定考点查询
|
||||||
|
* @param wpsDocxInfoVos 查询考点参数数组
|
||||||
|
* @param file 文件流
|
||||||
|
* @return 考点信息
|
||||||
|
* @throws Exception 异常
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<JudgementWordsVO> docxMaster(List<WpsDocxInfoVo> wpsDocxInfoVos) throws Exception {
|
public List<JudgementWordsVO> docxMaster(List<WpsDocxInfoVo> wpsDocxInfoVos, MultipartFile file) throws Exception {
|
||||||
return DocxMaster.docxMaster(wpsDocxInfoVos);
|
return DocxMaster.docxMaster(wpsDocxInfoVos, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询docx所有考点
|
||||||
|
* @param file 文件流
|
||||||
|
* @return 所有考点
|
||||||
|
* @throws Exception 异常
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<DocxDataInfoVO> docxDataInfo(MultipartFile file) throws Exception {
|
public List<DocxDataInfoVO> docxDataInfo(MultipartFile file) throws Exception {
|
||||||
return DocxConversion.DocxDataInfos(file);
|
return DocxConversion.DocxDataInfos(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public List<WordInfoReqVo> programmingWpsWord(String path) throws Exception {
|
|
||||||
// String pathName = "";
|
|
||||||
// String[] strPaht = path.split("/");
|
|
||||||
// // 1、获取文件临时下载路径
|
|
||||||
// ConfigDO config = configService.getConfigByKey("file_down_wps_word_path");
|
|
||||||
// AdminUserDO user = userService.getUser(getLoginUserId());
|
|
||||||
//// Path paths = Paths.get(config.getValue() + "\\" + user.getId());
|
|
||||||
//// if (Files.exists(paths)) {
|
|
||||||
//// pathName = config.getValue() + "\\" + user.getId() + "\\" + strPaht[strPaht.length - 1];
|
|
||||||
//// } else {
|
|
||||||
// // 2、下载文件并返回文件完整路径
|
|
||||||
// pathName = autoToolsService.downloadStudentFile(path, config.getValue() + "\\" + user.getId());
|
|
||||||
//// }
|
|
||||||
// // 4、docx文件读取并返回考点及说明信息
|
|
||||||
// List<WordInfoReqVo> margins = WpsWordUtils.wpWord(pathName);
|
|
||||||
// // 5、已经读取完得考点删除源文件
|
|
||||||
//// File file = new File(pathName);
|
|
||||||
//// file.delete();
|
|
||||||
// return margins;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public List<WpsWordJudgementDto> programmingInfo(List<WpsWordReqDto> wordReqDto) throws Exception {
|
|
||||||
//// List<WpsWordChineseFunctionDto> functionList = new ArrayList<>();
|
|
||||||
//// for (String function : wordReqDto.getFunction()) {
|
|
||||||
//// WpsWordChineseFunctionDto functionDto = new WpsWordChineseFunctionDto();
|
|
||||||
//// functionDto.setFunction(function);
|
|
||||||
//// WpsWordLinkDO wpsWordLinkDO = wpsWordLinkMapper.selectByNodeFunction(function);
|
|
||||||
//// functionDto.setChineseName(wpsWordLinkDO.getToChinese());
|
|
||||||
//// functionList.add(functionDto);
|
|
||||||
//// }
|
|
||||||
// List<WpsWordJudgementDto> judgementDtos = WpsWordUtils.getWordInfo(wordReqDto);
|
|
||||||
// return judgementDtos;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ import pc.exam.pp.module.judgement.utils.wps_excel.vo.*;
|
|||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_chart.ChartTypeEntry;
|
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_chart.ChartTypeEntry;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_drawing.XlsxInfoVo;
|
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_drawing.XlsxInfoVo;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_drawing.XlsxDrawingSheetVo;
|
import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_drawing.XlsxDrawingSheetVo;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxInfoReqVo;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordInfoReqVo;
|
|
||||||
|
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|||||||
@@ -4,13 +4,10 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|||||||
import org.apache.xmlbeans.XmlCursor;
|
import org.apache.xmlbeans.XmlCursor;
|
||||||
import org.apache.xmlbeans.XmlObject;
|
import org.apache.xmlbeans.XmlObject;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.WpsWordNameSpaces;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.XmlUtil;
|
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.DocxDataInfoVO;
|
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.DocxDataInfoVO;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordInfoReqVo;
|
import pc.exam.pp.module.judgement.utils.wps_word.utils.WpsWordNameSpaces;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.vo.WordSecondInfoVo;
|
import pc.exam.pp.module.judgement.utils.wps_word.utils.XmlUtil;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -32,6 +29,7 @@ public class DocxConversion {
|
|||||||
|
|
||||||
String xmlString = XmlUtil.getDocumentXml(document);
|
String xmlString = XmlUtil.getDocumentXml(document);
|
||||||
String namespace = WpsWordNameSpaces.getNameSpace(xmlString);
|
String namespace = WpsWordNameSpaces.getNameSpace(xmlString);
|
||||||
|
|
||||||
XmlObject docXml = document.getDocument();
|
XmlObject docXml = document.getDocument();
|
||||||
// 1、获取文档段落W:P标签得数量,判断出一个有多少段
|
// 1、获取文档段落W:P标签得数量,判断出一个有多少段
|
||||||
XmlCursor wpCursor = docXml.newCursor();
|
XmlCursor wpCursor = docXml.newCursor();
|
||||||
@@ -41,7 +39,6 @@ public class DocxConversion {
|
|||||||
// 段落
|
// 段落
|
||||||
String firstIdWp = getStringRandom();
|
String firstIdWp = getStringRandom();
|
||||||
setWordDataInfo(firstIdWp, "", "段落", "w:p", "", false, dataInfoVOS);
|
setWordDataInfo(firstIdWp, "", "段落", "w:p", "", false, dataInfoVOS);
|
||||||
List<WordSecondInfoVo> wordSecondWp = new ArrayList<>();
|
|
||||||
while (wpCursor.toNextSelection()) {
|
while (wpCursor.toNextSelection()) {
|
||||||
wpIndex ++;
|
wpIndex ++;
|
||||||
// 段落属性
|
// 段落属性
|
||||||
@@ -73,7 +70,6 @@ public class DocxConversion {
|
|||||||
int wSectPrIndex = 0;
|
int wSectPrIndex = 0;
|
||||||
String firstIdSectPr = getStringRandom();
|
String firstIdSectPr = getStringRandom();
|
||||||
setWordDataInfo(firstIdSectPr, "", "页面", "w:sectPr", "", false, dataInfoVOS);
|
setWordDataInfo(firstIdSectPr, "", "页面", "w:sectPr", "", false, dataInfoVOS);
|
||||||
List<WordSecondInfoVo> wordSecondWSectPr = new ArrayList<>();
|
|
||||||
while (wSectPrCursor.toNextSelection()) {
|
while (wSectPrCursor.toNextSelection()) {
|
||||||
wSectPrIndex ++;
|
wSectPrIndex ++;
|
||||||
String secondIdSectPr = getStringRandom();
|
String secondIdSectPr = getStringRandom();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart;
|
|||||||
import org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart;
|
import org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart;
|
||||||
import org.docx4j.w14.CTWordContentPart;
|
import org.docx4j.w14.CTWordContentPart;
|
||||||
import org.docx4j.wml.*;
|
import org.docx4j.wml.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import pc.exam.pp.module.judgement.controller.admin.AutoWps.vo.WpsDocxInfoVo;
|
import pc.exam.pp.module.judgement.controller.admin.AutoWps.vo.WpsDocxInfoVo;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.paragraph.Convert;
|
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.paragraph.Convert;
|
||||||
@@ -32,6 +33,7 @@ import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.JudgementWordsVO;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@@ -43,18 +45,31 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class DocxMaster {
|
public class DocxMaster {
|
||||||
|
|
||||||
public static List<JudgementWordsVO> docxMaster(List<WpsDocxInfoVo> wpsDocxInfoVos) throws Docx4JException, InvalidFormatException, IOException, JAXBException, XmlException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
/**
|
||||||
|
*
|
||||||
|
* @param wpsDocxInfoVos 考点参数
|
||||||
|
* @param file 文件流
|
||||||
|
* @return
|
||||||
|
* @throws Docx4JException
|
||||||
|
* @throws InvalidFormatException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws JAXBException
|
||||||
|
* @throws XmlException
|
||||||
|
* @throws NoSuchMethodException
|
||||||
|
* @throws InvocationTargetException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
*/
|
||||||
|
public static List<JudgementWordsVO> docxMaster(List<WpsDocxInfoVo> wpsDocxInfoVos, MultipartFile file) throws Docx4JException, InvalidFormatException, IOException, JAXBException, XmlException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||||
|
|
||||||
// 一共分为 段落, 页面,图形
|
// 一共分为 段落, 页面,图形
|
||||||
String firstDuanLuoId = Convert.getStringRandom();
|
String firstDuanLuoId = Convert.getStringRandom();
|
||||||
String firstYeMianId = Convert.getStringRandom();
|
String firstYeMianId = Convert.getStringRandom();
|
||||||
String firstTuXingId = Convert.getStringRandom();
|
String firstTuXingId = Convert.getStringRandom();
|
||||||
|
|
||||||
List<JudgementWordsVO> judgementWordsVOS = new ArrayList<>();
|
List<JudgementWordsVO> judgementWordsVOS = new ArrayList<>();
|
||||||
// 1、获取想要判断的文件地址
|
// 1、获取想要判断的文件地址(文件流)
|
||||||
String path = wpsDocxInfoVos.get(0).getFilePath();
|
InputStream inputStream = file.getInputStream();
|
||||||
// 2、Docx转换对象
|
// 2、Docx转换对象
|
||||||
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File(path));
|
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(inputStream);
|
||||||
List<Object> paragraphs = wordMLPackage.getMainDocumentPart().getContent();
|
List<Object> paragraphs = wordMLPackage.getMainDocumentPart().getContent();
|
||||||
// 2-1、样式对象
|
// 2-1、样式对象
|
||||||
StyleDefinitionsPart stylePart = wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart();
|
StyleDefinitionsPart stylePart = wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart();
|
||||||
@@ -62,6 +77,7 @@ public class DocxMaster {
|
|||||||
NumberingDefinitionsPart ndp = wordMLPackage.getMainDocumentPart().getNumberingDefinitionsPart();
|
NumberingDefinitionsPart ndp = wordMLPackage.getMainDocumentPart().getNumberingDefinitionsPart();
|
||||||
// 2-3、节对象
|
// 2-3、节对象
|
||||||
List<SectionWrapper> sections = wordMLPackage.getDocumentModel().getSections();
|
List<SectionWrapper> sections = wordMLPackage.getDocumentModel().getSections();
|
||||||
|
wordMLPackage.getHeaderFooterPolicy().getDefaultFooter();
|
||||||
for (WpsDocxInfoVo wpsDocxInfoVo : wpsDocxInfoVos) {
|
for (WpsDocxInfoVo wpsDocxInfoVo : wpsDocxInfoVos) {
|
||||||
// 参数实例化
|
// 参数实例化
|
||||||
// 大类名称
|
// 大类名称
|
||||||
@@ -74,7 +90,9 @@ public class DocxMaster {
|
|||||||
String examName = wpsDocxInfoVo.getExamName();
|
String examName = wpsDocxInfoVo.getExamName();
|
||||||
// 考点代码
|
// 考点代码
|
||||||
String examCode = wpsDocxInfoVo.getExamCode();
|
String examCode = wpsDocxInfoVo.getExamCode();
|
||||||
|
// 方式方法
|
||||||
|
String method = wpsDocxInfoVo.getMethod();
|
||||||
|
String docxFunction = firstName + "#" + indexParm + "#" + function + "#" + examName + "#" + examCode + "#" + method;
|
||||||
// 创建一个索引ID,跟参数中index进行匹配
|
// 创建一个索引ID,跟参数中index进行匹配
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (Object obj : paragraphs) {
|
for (Object obj : paragraphs) {
|
||||||
@@ -89,14 +107,35 @@ public class DocxMaster {
|
|||||||
// 查询出具体想要查询哪个段落的数据
|
// 查询出具体想要查询哪个段落的数据
|
||||||
// 目标对象
|
// 目标对象
|
||||||
Paragraphs paragraphsFunction = new Paragraphs();
|
Paragraphs paragraphsFunction = new Paragraphs();
|
||||||
|
// 获取参数中类型的定义
|
||||||
|
String[] methods = method.split("@");
|
||||||
|
List<Class<?>> classList = new ArrayList<>();
|
||||||
|
for (String met : methods) {
|
||||||
|
if (met.equals("P")) {
|
||||||
|
classList.add(P.class);
|
||||||
|
}
|
||||||
|
if (met.equals("StyleDefinitionsPart")) {
|
||||||
|
classList.add(StyleDefinitionsPart.class);
|
||||||
|
}
|
||||||
|
if (met.equals("NumberingDefinitionsPart")) {
|
||||||
|
classList.add(NumberingDefinitionsPart.class);
|
||||||
|
}
|
||||||
|
if (met.equals("SectionWrapper")) {
|
||||||
|
classList.add(SectionWrapper.class);
|
||||||
|
}
|
||||||
|
if (met.equals("WordprocessingMLPackage")) {
|
||||||
|
classList.add(WordprocessingMLPackage.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
// 参数类型列表(按方法声明顺序)
|
// 参数类型列表(按方法声明顺序)
|
||||||
Class<?>[] paramTypes = {P.class, StyleDefinitionsPart.class};
|
// Class<?>[] paramTypes = classList.toArray(new Class<?>[0]);
|
||||||
|
Class<?>[] paramTypes = {P.class, WordprocessingMLPackage.class};
|
||||||
// 带参数的方法调用示例
|
// 带参数的方法调用示例
|
||||||
Method methodWithArgs = paragraphsFunction.getClass().getMethod(function, paramTypes);
|
Method methodWithArgs = paragraphsFunction.getClass().getMethod(function, paramTypes);
|
||||||
// 实际参数值
|
// 实际参数值
|
||||||
Object[] arguments = {paragraph, stylePart};
|
Object[] arguments = {paragraph, stylePart};
|
||||||
String value = (String) methodWithArgs.invoke(obj, arguments);
|
String value = (String) methodWithArgs.invoke(obj, arguments);
|
||||||
judgementWordsVOS = setJudgementWord(judgementWordsVOS, examCode + "@" + value, firstName + examName + value);
|
judgementWordsVOS = setJudgementWord(judgementWordsVOS, docxFunction + "@" + value, firstName + examName + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package pc.exam.pp.module.judgement.utils.wps_word.docx4j.paragraph;
|
package pc.exam.pp.module.judgement.utils.wps_word.docx4j.paragraph;
|
||||||
|
|
||||||
import jakarta.xml.bind.JAXBElement;
|
import jakarta.xml.bind.JAXBElement;
|
||||||
|
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||||
import org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart;
|
import org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart;
|
||||||
import org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart;
|
import org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart;
|
||||||
import org.docx4j.wml.*;
|
import org.docx4j.wml.*;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.DocxSetInfo;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment;
|
||||||
import pc.exam.pp.module.judgement.utils.wps_word.docx4j.vo.JudgementWordsVO;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author REN
|
* @author REN
|
||||||
@@ -53,7 +52,7 @@ public class Paragraphs {
|
|||||||
return Convert.convertJc(style.getPPr().getOutlineLvl().getVal().toString());
|
return Convert.convertJc(style.getPPr().getOutlineLvl().getVal().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "正文";
|
||||||
}
|
}
|
||||||
/// 段落格式(缩进) 左缩进 磅
|
/// 段落格式(缩进) 左缩进 磅
|
||||||
public static String getParagraphIndLeft(P paragraph, StyleDefinitionsPart stylePart) {
|
public static String getParagraphIndLeft(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
@@ -140,7 +139,23 @@ public class Paragraphs {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 段落格式(间距) 段前
|
/// 段落格式(间距) 段前行
|
||||||
|
public static String getParagraphSpacingBeforeLines(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
if (pPr != null && pPr.getSpacing() != null) {
|
||||||
|
return pPr.getSpacing().getBeforeLines().toString();
|
||||||
|
}
|
||||||
|
if (pPr != null && pPr.getPStyle() != null && stylePart != null) {
|
||||||
|
String styleId = pPr.getPStyle().getVal();
|
||||||
|
Style style = stylePart.getStyleById(styleId);
|
||||||
|
if (style != null && style.getPPr() != null && style.getPPr().getSpacing() != null) {
|
||||||
|
PPrBase.Spacing spacing = style.getPPr().getSpacing();
|
||||||
|
return spacing.getBeforeLines().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
/// 段落格式(间距) 段前磅
|
||||||
public static String getParagraphSpacingBefore(P paragraph, StyleDefinitionsPart stylePart) {
|
public static String getParagraphSpacingBefore(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
PPr pPr = paragraph.getPPr();
|
PPr pPr = paragraph.getPPr();
|
||||||
if (pPr != null && pPr.getSpacing() != null) {
|
if (pPr != null && pPr.getSpacing() != null) {
|
||||||
@@ -156,7 +171,7 @@ public class Paragraphs {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
/// 段落格式(间距) 段后
|
/// 段落格式(间距) 段后磅
|
||||||
public static String getParagraphSpacingAfter(P paragraph, StyleDefinitionsPart stylePart) {
|
public static String getParagraphSpacingAfter(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
PPr pPr = paragraph.getPPr();
|
PPr pPr = paragraph.getPPr();
|
||||||
if (pPr != null && pPr.getSpacing() != null) {
|
if (pPr != null && pPr.getSpacing() != null) {
|
||||||
@@ -172,6 +187,24 @@ public class Paragraphs {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 段落格式(间距) 段后行
|
||||||
|
public static String getParagraphSpacingAfterLines(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
if (pPr != null && pPr.getSpacing() != null) {
|
||||||
|
return pPr.getSpacing().getAfterLines().toString();
|
||||||
|
}
|
||||||
|
if (pPr != null && pPr.getPStyle() != null && stylePart != null) {
|
||||||
|
String styleId = pPr.getPStyle().getVal();
|
||||||
|
Style style = stylePart.getStyleById(styleId);
|
||||||
|
if (style != null && style.getPPr() != null && style.getPPr().getSpacing() != null) {
|
||||||
|
PPrBase.Spacing spacing = style.getPPr().getSpacing();
|
||||||
|
return spacing.getAfterLines().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/// 段落格式(间距) 间距
|
/// 段落格式(间距) 间距
|
||||||
public static String getParagraphSpacingLine(P paragraph, StyleDefinitionsPart stylePart) {
|
public static String getParagraphSpacingLine(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
PPr pPr = paragraph.getPPr();
|
PPr pPr = paragraph.getPPr();
|
||||||
@@ -349,78 +382,268 @@ public class Paragraphs {
|
|||||||
return "未知";
|
return "未知";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 段落-边框
|
// 段落边框 样式
|
||||||
// public static List<JudgementWordsVO> getParagraphBorder(P paragraph, StyleDefinitionsPart stylePart, List<JudgementWordsVO> judgementWordsVOS, int betoLong, String firstId) {
|
public static String getParagraphBorderStyle(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
// if (paragraph == null) {
|
// 先查询自身段落数据
|
||||||
// return judgementWordsVOS;
|
PPr pPr = paragraph.getPPr();
|
||||||
// }
|
if (pPr != null && pPr.getPBdr() != null) {
|
||||||
// String name = "【第" + betoLong + "段】";
|
PPrBase.PBdr border = pPr.getPBdr();
|
||||||
// String parentId = Convert.getStringRandom();
|
// 上边框
|
||||||
// // 先查询自身段落数据
|
CTBorder top = border.getTop();
|
||||||
// PPr pPr = paragraph.getPPr();
|
// 下边框
|
||||||
// if (pPr != null && pPr.getPBdr() != null) {
|
CTBorder bottom = border.getBottom();
|
||||||
// PPrBase.PBdr border = pPr.getPBdr();
|
// 左边框
|
||||||
// String topName = "【】【】";
|
CTBorder left = border.getLeft();
|
||||||
// Convert.printBorder("上边框", border.getTop());
|
// 右边框
|
||||||
// Convert.printBorder("下边框", border.getBottom());
|
CTBorder right = border.getRight();
|
||||||
// Convert.printBorder("左边框", border.getLeft());
|
// 判断上下左右边框是否一致
|
||||||
// Convert.printBorder("右边框", border.getRight());
|
if (top.getVal().value().equals(bottom.getVal().value()) && top.getVal().value().equals(left.getVal().value()) && top.getVal().value().equals(right.getVal().value())) {
|
||||||
// Convert.printBorder("内横线", border.getBetween());
|
// 说明样式一样
|
||||||
// Convert.printBorder("内竖线", border.getBar());
|
return top.getVal().value();
|
||||||
// }
|
} else {
|
||||||
// }
|
// 说明样式不一样
|
||||||
|
return top.getVal().value() + "-" + bottom.getVal().value() + "-" + left.getVal().value() + "-" + right.getVal().value();
|
||||||
// 段落-底纹
|
}
|
||||||
public static void getParagraphShd(P paragraph, StyleDefinitionsPart stylePart) {
|
|
||||||
if (paragraph == null) {
|
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 段落边框 - 颜色
|
||||||
|
public static String getParagraphBorderColor(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
// 先查询自身段落数据
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
if (pPr != null && pPr.getPBdr() != null) {
|
||||||
|
PPrBase.PBdr border = pPr.getPBdr();
|
||||||
|
// 上边框
|
||||||
|
CTBorder top = border.getTop();
|
||||||
|
// 下边框
|
||||||
|
CTBorder bottom = border.getBottom();
|
||||||
|
// 左边框
|
||||||
|
CTBorder left = border.getLeft();
|
||||||
|
// 右边框
|
||||||
|
CTBorder right = border.getRight();
|
||||||
|
// 判断上下左右边框是否一致
|
||||||
|
if (top.getColor().equals(bottom.getColor()) && top.getColor().equals(left.getColor()) && top.getColor().equals(right.getColor())) {
|
||||||
|
// 说明样式一样
|
||||||
|
return top.getColor();
|
||||||
|
} else {
|
||||||
|
// 说明样式不一样
|
||||||
|
return top.getColor() + "-" + bottom.getColor() + "-" + left.getColor() + "-" + right.getColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 段落边框 - 宽度
|
||||||
|
public static String getParagraphBorderSize(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
// 先查询自身段落数据
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
if (pPr != null && pPr.getPBdr() != null) {
|
||||||
|
PPrBase.PBdr border = pPr.getPBdr();
|
||||||
|
// 上边框
|
||||||
|
CTBorder top = border.getTop();
|
||||||
|
// 下边框
|
||||||
|
CTBorder bottom = border.getBottom();
|
||||||
|
// 左边框
|
||||||
|
CTBorder left = border.getLeft();
|
||||||
|
// 右边框
|
||||||
|
CTBorder right = border.getRight();
|
||||||
|
// 判断上下左右边框是否一致
|
||||||
|
if (top.getSz().toString().equals(bottom.getSz().toString()) && top.getSz().toString().equals(left.getSz().toString()) && top.getSz().toString().equals(right.getSz().toString())) {
|
||||||
|
// 说明样式一样
|
||||||
|
return top.getSz().toString();
|
||||||
|
} else {
|
||||||
|
// 说明样式不一样
|
||||||
|
return top.getSz().toString() + "-" + bottom.getSz().toString() + "-" + left.getSz().toString() + "-" + right.getSz().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 段落底纹 - 填充颜色
|
||||||
|
public static String getParagraphShdFillColor(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
// 先查询自身段落数据
|
// 先查询自身段落数据
|
||||||
PPr pPr = paragraph.getPPr();
|
PPr pPr = paragraph.getPPr();
|
||||||
if (pPr != null && pPr.getShd() != null) {
|
if (pPr != null && pPr.getShd() != null) {
|
||||||
CTShd shd = pPr.getShd();
|
CTShd shd = pPr.getShd();
|
||||||
System.out.println("图案样式 (val): " + shd.getVal()); // 如 clear, solid, nil
|
return shd.getFill();
|
||||||
System.out.println("图案颜色 (color): " + shd.getColor()); // 图案颜色(文字上的线)
|
}
|
||||||
System.out.println("填充颜色 (fill): " + shd.getFill()); // 背景色(段落底色)
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 段落底纹 - 图案样式
|
||||||
|
public static String getParagraphShdStyle(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
// 先查询自身段落数据
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
if (pPr != null && pPr.getShd() != null) {
|
||||||
|
CTShd shd = pPr.getShd();
|
||||||
|
return shd.getVal().value();
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 段落底纹 - 图案颜色
|
||||||
|
public static String getParagraphShdStyleColor(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
// 先查询自身段落数据
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
if (pPr != null && pPr.getShd() != null) {
|
||||||
|
CTShd shd = pPr.getShd();
|
||||||
|
return shd.getColor();
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 首字下沉 - 是否存在
|
||||||
|
public static String getParagraphDropCapIsTrue(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
if (pPr != null && pPr.getFramePr() != null) {
|
||||||
|
return "是";
|
||||||
|
} else {
|
||||||
|
return "否";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 段落-首字下沉
|
|
||||||
public static void getParagraphDropCap(P paragraph, StyleDefinitionsPart stylePart) {
|
|
||||||
if (paragraph == null) {
|
// 首字下沉 - 首字位置
|
||||||
return ;
|
public static String getParagraphDropCapLocation(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
}
|
|
||||||
PPr pPr = paragraph.getPPr();
|
PPr pPr = paragraph.getPPr();
|
||||||
if (pPr != null && pPr.getFramePr() != null) {
|
if (pPr != null && pPr.getFramePr() != null) {
|
||||||
CTFramePr framePr = pPr.getFramePr();
|
CTFramePr framePr = pPr.getFramePr();
|
||||||
System.out.println("---- 首字下沉 ----");
|
|
||||||
System.out.println("存在首字下沉: 是");
|
|
||||||
|
|
||||||
if (framePr.getDropCap() != null) {
|
if (framePr.getDropCap() != null) {
|
||||||
System.out.println("首字位置 (dropCap): " + framePr.getDropCap().value()); // drop | none | margin
|
return framePr.getDropCap().value(); // drop | none | margin
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 首字下沉 - 行数
|
||||||
|
public static String getParagraphDropCapLine(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
if (pPr != null && pPr.getFramePr() != null) {
|
||||||
|
CTFramePr framePr = pPr.getFramePr();
|
||||||
if (framePr.getLines() != null) {
|
if (framePr.getLines() != null) {
|
||||||
System.out.println("下沉行数 (lines): " + framePr.getLines().intValue());
|
return String.valueOf(framePr.getLines().intValue()); // twips
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 首字下沉 - 距正文
|
||||||
|
public static String getParagraphDropCapHSpace(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
if (pPr != null && pPr.getFramePr() != null) {
|
||||||
|
CTFramePr framePr = pPr.getFramePr();
|
||||||
if (framePr.getHSpace() != null) {
|
if (framePr.getHSpace() != null) {
|
||||||
System.out.println("距正文 (hSpace): " + framePr.getHSpace().intValue()); // twips
|
return String.valueOf(framePr.getHSpace().intValue()); // twips
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 首字下沉 - 字体
|
||||||
|
public static String getParagraphDropCapFont(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
if (pPr != null && pPr.getFramePr() != null) {
|
||||||
// 获取首字字体
|
// 获取首字字体
|
||||||
String fontName = Convert.getFirstRunFont(paragraph);
|
String fontName = Convert.getFirstRunFont(paragraph);
|
||||||
if (fontName != null) {
|
if (fontName != null) {
|
||||||
System.out.println("字体: " + fontName);
|
return fontName;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
System.out.println("不存在首字下沉");
|
|
||||||
}
|
}
|
||||||
|
return "未知";
|
||||||
}
|
}
|
||||||
// 段落-分栏
|
|
||||||
public static void getParagraphCols(P paragraph, StyleDefinitionsPart stylePart) {
|
// 分栏 - 栏数
|
||||||
if (paragraph == null) {
|
// public static String getParagraphCols(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
return ;
|
// PPr pPr = paragraph.getPPr();
|
||||||
|
// SectPr sectPr = null;
|
||||||
|
// sectPr = pPr.getSectPr();
|
||||||
|
// // 优先取段落自身的节属性
|
||||||
|
// if (pPr != null && pPr.getSectPr() != null) {
|
||||||
|
// sectPr = pPr.getSectPr();
|
||||||
|
// }
|
||||||
|
// // 或最后一个段落中会有一个节结束的SectPr
|
||||||
|
// if (sectPr == null && paragraph.getContent().size() > 0) {
|
||||||
|
// Object lastObj = paragraph.getContent().get(paragraph.getContent().size() - 1);
|
||||||
|
// if (lastObj instanceof JAXBElement && ((JAXBElement<?>) lastObj).getValue() instanceof SectPr) {
|
||||||
|
// sectPr = (SectPr) ((JAXBElement<?>) lastObj).getValue();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (sectPr != null && sectPr.getCols() != null) {
|
||||||
|
// CTColumns cols = sectPr.getCols();
|
||||||
|
// return String.valueOf(cols.getNum().intValue());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return "未知";
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static String getParagraphCols(P paragraph, WordprocessingMLPackage wordMLPackage) {
|
||||||
|
// 1. 首先检查段落自身的节属性
|
||||||
|
if (paragraph.getPPr() != null && paragraph.getPPr().getSectPr() != null) {
|
||||||
|
CTColumns cols = paragraph.getPPr().getSectPr().getCols();
|
||||||
|
if (cols != null && cols.getNum() != null) {
|
||||||
|
return String.valueOf(cols.getNum().intValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2. 检查段落内容中是否有节属性
|
||||||
|
for (Object content : paragraph.getContent()) {
|
||||||
|
if (content instanceof JAXBElement) {
|
||||||
|
Object value = ((JAXBElement<?>) content).getValue();
|
||||||
|
if (value instanceof SectPr) {
|
||||||
|
CTColumns cols = ((SectPr) value).getCols();
|
||||||
|
if (cols != null && cols.getNum() != null) {
|
||||||
|
return String.valueOf(cols.getNum().intValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 向后查找后续段落中的节属性
|
||||||
|
Body body = wordMLPackage.getMainDocumentPart().getJaxbElement().getBody();
|
||||||
|
boolean foundCurrent = false;
|
||||||
|
|
||||||
|
for (Object obj : body.getContent()) {
|
||||||
|
if (obj instanceof P) {
|
||||||
|
P p = (P) obj;
|
||||||
|
|
||||||
|
// 找到当前段落后才开始查找
|
||||||
|
if (p == paragraph) {
|
||||||
|
foundCurrent = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundCurrent) {
|
||||||
|
// 检查后续段落的节属性
|
||||||
|
if (p.getPPr() != null && p.getPPr().getSectPr() != null) {
|
||||||
|
CTColumns cols = p.getPPr().getSectPr().getCols();
|
||||||
|
if (cols != null && cols.getNum() != null) {
|
||||||
|
return String.valueOf(cols.getNum().intValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查后续段落内容中的节属性
|
||||||
|
for (Object content : p.getContent()) {
|
||||||
|
if (content instanceof JAXBElement) {
|
||||||
|
Object value = ((JAXBElement<?>) content).getValue();
|
||||||
|
if (value instanceof SectPr) {
|
||||||
|
CTColumns cols = ((SectPr) value).getCols();
|
||||||
|
if (cols != null && cols.getNum() != null) {
|
||||||
|
return String.valueOf(cols.getNum().intValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 如果都没找到,返回默认值(如"1"表示单栏)
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分栏 - 分隔线
|
||||||
|
public static String getParagraphColIsSep(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
PPr pPr = paragraph.getPPr();
|
PPr pPr = paragraph.getPPr();
|
||||||
SectPr sectPr = null;
|
SectPr sectPr = null;
|
||||||
sectPr = pPr.getSectPr();
|
sectPr = pPr.getSectPr();
|
||||||
@@ -439,21 +662,110 @@ public class Paragraphs {
|
|||||||
|
|
||||||
if (sectPr != null && sectPr.getCols() != null) {
|
if (sectPr != null && sectPr.getCols() != null) {
|
||||||
CTColumns cols = sectPr.getCols();
|
CTColumns cols = sectPr.getCols();
|
||||||
|
return cols.isSep() ? "是" : "否";
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分栏 - 各栏间距
|
||||||
|
public static String getParagraphColSpace(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
SectPr sectPr = null;
|
||||||
|
sectPr = pPr.getSectPr();
|
||||||
|
// 优先取段落自身的节属性
|
||||||
|
if (pPr != null && pPr.getSectPr() != null) {
|
||||||
|
sectPr = pPr.getSectPr();
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("---- 分栏信息 ----");
|
// 或最后一个段落中会有一个节结束的SectPr
|
||||||
System.out.println("栏数: " + (cols.getNum() != null ? cols.getNum().intValue() : "未设置"));
|
if (sectPr == null && paragraph.getContent().size() > 0) {
|
||||||
System.out.println("是否栏宽相等 (equalWidth): " + (cols.isEqualWidth() ? "是" : "否"));
|
Object lastObj = paragraph.getContent().get(paragraph.getContent().size() - 1);
|
||||||
System.out.println("是否有分隔线 (sep): " + (cols.isSep() ? "是" : "否"));
|
if (lastObj instanceof JAXBElement && ((JAXBElement<?>) lastObj).getValue() instanceof SectPr) {
|
||||||
|
sectPr = (SectPr) ((JAXBElement<?>) lastObj).getValue();
|
||||||
if (cols.getCol() != null && !cols.getCol().isEmpty()) {
|
|
||||||
int index = 1;
|
|
||||||
for (CTColumn col : cols.getCol()) {
|
|
||||||
System.out.println("第 " + index + " 栏宽度 (twips): " + col.getW());
|
|
||||||
System.out.println("第 " + index + " 栏间距 (twips): " + col.getSpace());
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sectPr != null && sectPr.getCols() != null) {
|
||||||
|
CTColumns cols = sectPr.getCols();
|
||||||
|
if (cols.getCol() != null && !cols.getCol().isEmpty()) {
|
||||||
|
int index = 1;
|
||||||
|
String value = "";
|
||||||
|
for (CTColumn col : cols.getCol()) {
|
||||||
|
value += "第 " + index + " 栏间距 (twips): " + col.getSpace() + " ";
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
// 分栏 - 各栏宽度
|
||||||
|
public static String getParagraphColW(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
SectPr sectPr = null;
|
||||||
|
sectPr = pPr.getSectPr();
|
||||||
|
// 优先取段落自身的节属性
|
||||||
|
if (pPr != null && pPr.getSectPr() != null) {
|
||||||
|
sectPr = pPr.getSectPr();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 或最后一个段落中会有一个节结束的SectPr
|
||||||
|
if (sectPr == null && paragraph.getContent().size() > 0) {
|
||||||
|
Object lastObj = paragraph.getContent().get(paragraph.getContent().size() - 1);
|
||||||
|
if (lastObj instanceof JAXBElement && ((JAXBElement<?>) lastObj).getValue() instanceof SectPr) {
|
||||||
|
sectPr = (SectPr) ((JAXBElement<?>) lastObj).getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sectPr != null && sectPr.getCols() != null) {
|
||||||
|
CTColumns cols = sectPr.getCols();
|
||||||
|
if (cols.getCol() != null && !cols.getCol().isEmpty()) {
|
||||||
|
int index = 1;
|
||||||
|
String value = "";
|
||||||
|
for (CTColumn col : cols.getCol()) {
|
||||||
|
value += "第 " + index + " 栏宽度 (twips): " + col.getW() + " ";
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分栏 - 栏宽相等
|
||||||
|
public static String getParagraphColEqualWidth(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
SectPr sectPr = null;
|
||||||
|
sectPr = pPr.getSectPr();
|
||||||
|
// 优先取段落自身的节属性
|
||||||
|
if (pPr != null && pPr.getSectPr() != null) {
|
||||||
|
sectPr = pPr.getSectPr();
|
||||||
|
}
|
||||||
|
// 或最后一个段落中会有一个节结束的SectPr
|
||||||
|
if (sectPr == null && paragraph.getContent().size() > 0) {
|
||||||
|
Object lastObj = paragraph.getContent().get(paragraph.getContent().size() - 1);
|
||||||
|
if (lastObj instanceof JAXBElement && ((JAXBElement<?>) lastObj).getValue() instanceof SectPr) {
|
||||||
|
sectPr = (SectPr) ((JAXBElement<?>) lastObj).getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sectPr != null && sectPr.getCols() != null) {
|
||||||
|
CTColumns cols = sectPr.getCols();
|
||||||
|
return cols.isEqualWidth() ? "是" : "否";
|
||||||
|
}
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 中文版式 - 双行合一
|
||||||
|
public static String getParagraphCNBidi(P paragraph, StyleDefinitionsPart stylePart) {
|
||||||
|
PPr pPr = paragraph.getPPr();
|
||||||
|
if (pPr.getTextAlignment() != null) {
|
||||||
|
PPrBase.TextAlignment textAlignment = pPr.getTextAlignment();
|
||||||
|
if (textAlignment.getVal() != null &&
|
||||||
|
textAlignment.getVal().equals(STTextAlignment.CENTER)) {
|
||||||
|
return "是";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "否";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
package pc.exam.pp.module.judgement.utils.wps_word;
|
package pc.exam.pp.module.judgement.utils.wps_word.utils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public class WpsWordNameSpaces {
|
public class WpsWordNameSpaces {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package pc.exam.pp.module.judgement.utils.wps_word;
|
package pc.exam.pp.module.judgement.utils.wps_word.utils;
|
||||||
|
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.apache.xmlbeans.XmlObject;
|
import org.apache.xmlbeans.XmlObject;
|
||||||
|
|||||||
Reference in New Issue
Block a user