|
@@ -0,0 +1,390 @@
|
|
|
|
|
+package cn.start.tz.module.pressure2.controller.appapi.dynamictb;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.core.io.file.FileNameUtil;
|
|
|
|
|
+import cn.start.tz.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
|
+import cn.start.tz.framework.common.pojo.CommonResult;
|
|
|
|
|
+import cn.start.tz.framework.common.pojo.PageParam;
|
|
|
|
|
+import cn.start.tz.framework.common.pojo.PageResult;
|
|
|
|
|
+import cn.start.tz.framework.common.util.object.BeanUtils;
|
|
|
|
|
+import cn.start.tz.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
+import cn.start.tz.module.infra.api.file.FileApi;
|
|
|
|
|
+import cn.start.tz.module.infra.api.file.dto.FileRepsDTO;
|
|
|
|
|
+import cn.start.tz.module.pressure2.controller.admin.boilerconnectrecordreport.vo.BoilerConnectRecordReportPageReqVO;
|
|
|
|
|
+import cn.start.tz.module.pressure2.controller.admin.dynamictb.vo.*;
|
|
|
|
|
+import cn.start.tz.module.pressure2.controller.admin.dynamictbins.vo.CreateInstantiateWithRuleVO;
|
|
|
|
|
+import cn.start.tz.module.pressure2.dal.dataobject.boilerconnectrecordreport.BoilerConnectRecordReportDO;
|
|
|
|
|
+import cn.start.tz.module.pressure2.dal.dataobject.dynamictb.DynamicTbDO;
|
|
|
|
|
+import cn.start.tz.module.pressure2.service.boilerconnectrecordreport.BoilerConnectRecordReportService;
|
|
|
|
|
+import cn.start.tz.module.pressure2.service.dynamicOF.IDynamicOFService;
|
|
|
|
|
+import cn.start.tz.module.pressure2.service.dynamicOFData.IDynamicOFData;
|
|
|
|
|
+import cn.start.tz.module.pressure2.service.dynamictb.DynamicTbService;
|
|
|
|
|
+import cn.start.tz.module.pressure2.util.OFDataUtils;
|
|
|
|
|
+import cn.start.tz.module.pressure2.util.office.ConfigServiceImpl;
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
+import com.onlyoffice.manager.settings.SettingsManager;
|
|
|
|
|
+import com.onlyoffice.model.documenteditor.Callback;
|
|
|
|
|
+import com.onlyoffice.model.documenteditor.Config;
|
|
|
|
|
+import com.onlyoffice.service.documenteditor.callback.CallbackService;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
+import jakarta.annotation.Resource;
|
|
|
|
|
+import jakarta.annotation.security.PermitAll;
|
|
|
|
|
+import jakarta.servlet.http.HttpServletRequest;
|
|
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
|
+import jakarta.validation.Valid;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
+
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.UUID;
|
|
|
|
|
+
|
|
|
|
|
+import static cn.start.tz.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
|
|
+import static cn.start.tz.framework.apilog.core.enums.OperateTypeEnum.IMPORT;
|
|
|
|
|
+import static cn.start.tz.framework.common.pojo.CommonResult.success;
|
|
|
|
|
+
|
|
|
|
|
+@Tag(name = "管理后台 - 承压动态报表表单")
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/pressure2/dynamic-tb")
|
|
|
|
|
+@Validated
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+public class AppapiDynamicTbController {
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private DynamicTbService dynamicTbService;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private BoilerConnectRecordReportService boilerConnectRecordReportService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ ConfigServiceImpl configService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ OFDataUtils ofDataUtils;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ FileApi fileApi;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IDynamicOFService iDynamicOFService;
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/create")
|
|
|
|
|
+ @Operation(summary = "创建承压动态报表表单")
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:create')")
|
|
|
|
|
+ public CommonResult<String> createDynamicTb(@Valid @RequestBody DynamicTbSaveReqVO createReqVO) {
|
|
|
|
|
+ String tbId=dynamicTbService.createDynamicTb(createReqVO);
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ CommonResult<FileRepsDTO> fileCR = fileApi.getFileRepsDTO(createReqVO.getFormPath());
|
|
|
|
|
+ if(fileCR!=null && fileCR.getData()!=null) {
|
|
|
|
|
+ String mes=iDynamicOFService.saveOF(createReqVO.getFormPath(), fileCR.getData().getName(),tbId);
|
|
|
|
|
+ log.info("createDynamicTb,触发保存pdf:{}",mes);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ex){
|
|
|
|
|
+ log.info("createDynamicTb,触发保存pdf失败:{}",ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return success(tbId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PutMapping("/update")
|
|
|
|
|
+ @Operation(summary = "更新承压动态报表表单")
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:update')")
|
|
|
|
|
+ public CommonResult<Boolean> updateDynamicTb(@Valid @RequestBody DynamicTbSaveReqVO updateReqVO) {
|
|
|
|
|
+ dynamicTbService.updateDynamicTb(updateReqVO);
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ CommonResult<FileRepsDTO> fileCR = fileApi.getFileRepsDTO(updateReqVO.getFormPath());
|
|
|
|
|
+ if(fileCR!=null && fileCR.getData()!=null) {
|
|
|
|
|
+ String mes=iDynamicOFService.saveOF(updateReqVO.getFormPath(), fileCR.getData().getName(),updateReqVO.getId());
|
|
|
|
|
+ log.info("updateDynamicTb,触发保存pdf:{}",mes);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ex){
|
|
|
|
|
+ log.info("updateDynamicTb,触发保存pdf失败:{}",ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return success(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @DeleteMapping("/delete")
|
|
|
|
|
+ @Operation(summary = "删除承压动态报表表单")
|
|
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:delete')")
|
|
|
|
|
+ public CommonResult<Boolean> deleteDynamicTb(@RequestParam("id") String id) {
|
|
|
|
|
+ dynamicTbService.deleteDynamicTb(id);
|
|
|
|
|
+ return success(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/get")
|
|
|
|
|
+ @Operation(summary = "获得承压动态报表表单")
|
|
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:query')")
|
|
|
|
|
+ public CommonResult<DynamicTbRespVO> getDynamicTb(@RequestParam("id") String id) {
|
|
|
|
|
+ return success(dynamicTbService.getDynamicTb(id));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/page")
|
|
|
|
|
+ @Operation(summary = "获得承压动态报表表单分页")
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:query')")
|
|
|
|
|
+ public CommonResult<PageResult<DynamicTbRespVO>> getDynamicTbPage(@Valid DynamicTbPageReqVO pageReqVO) {
|
|
|
|
|
+ PageResult<DynamicTbDO> pageResult = dynamicTbService.getDynamicTbPage(pageReqVO);
|
|
|
|
|
+ pageResult.getList().forEach(dynamicTbDO -> {
|
|
|
|
|
+ dynamicTbDO.setCopyConfig(null);
|
|
|
|
|
+ });
|
|
|
|
|
+ return success(BeanUtils.toBean(pageResult, DynamicTbRespVO.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/page/inspectionNature")
|
|
|
|
|
+ @Operation(summary = "获得承压动态报表表单分页")
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:query')")
|
|
|
|
|
+ public CommonResult<PageResult<BoilerConnectRecordReportDO>> getDynamicTbPageInspection(@Valid DynamicTbPageReqVO pageReqVO) {
|
|
|
|
|
+
|
|
|
|
|
+ //PageResult<DynamicTbDO> pageResult = dynamicTbService.getDynamicTbPage(pageReqVO);
|
|
|
|
|
+ //使用项目模板
|
|
|
|
|
+ BoilerConnectRecordReportPageReqVO pageReqVO1 = new BoilerConnectRecordReportPageReqVO();
|
|
|
|
|
+ pageReqVO1.setPageSize(pageReqVO.getPageSize());
|
|
|
|
|
+ pageReqVO1.setPageNo(pageReqVO.getPageNo());
|
|
|
|
|
+ pageReqVO1.setProjectName(pageReqVO.getName());
|
|
|
|
|
+ pageReqVO1.setStatus("1");
|
|
|
|
|
+ PageResult<BoilerConnectRecordReportDO> pageResult = boilerConnectRecordReportService.getBoilerConnectRecordReportPage(pageReqVO1);
|
|
|
|
|
+
|
|
|
|
|
+// PageResult<ReportTemplateRespVO> pageResult1 = new PageResult<>();
|
|
|
|
|
+// List<ReportTemplateRespVO> list = new ArrayList<>();
|
|
|
|
|
+// pageResult.getList().forEach(item -> {
|
|
|
|
|
+// ReportTemplateRespVO reportTemplateRespVO = new ReportTemplateRespVO();
|
|
|
|
|
+// reportTemplateRespVO.setId(item.getId());
|
|
|
|
|
+// reportTemplateRespVO.setName(item.getProjectName());
|
|
|
|
|
+// reportTemplateRespVO.setType("0");
|
|
|
|
|
+// list.add(reportTemplateRespVO);
|
|
|
|
|
+// });
|
|
|
|
|
+//
|
|
|
|
|
+// pageResult1.setList(list);
|
|
|
|
|
+// pageResult1.setTotal(pageResult.getTotal());
|
|
|
|
|
+
|
|
|
|
|
+ return success(pageResult);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/getTbCols")
|
|
|
|
|
+ @Operation(summary = "获得承压动态报表表单字段明细")
|
|
|
|
|
+ //@PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:query')")
|
|
|
|
|
+ public CommonResult<List<DynamicTbColsVO>> getTbCols(@Valid DynamicTbColReqVO TbReqVO) {
|
|
|
|
|
+ List<DynamicTbColsVO> listResult = dynamicTbService.getDtCols(TbReqVO);
|
|
|
|
|
+ return success(listResult);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/export-excel")
|
|
|
|
|
+ @Operation(summary = "导出承压动态报表表单 Excel")
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:export')")
|
|
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
|
|
+ public void exportDynamicTbExcel(@Valid DynamicTbPageReqVO pageReqVO,
|
|
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
+ List<DynamicTbDO> list = dynamicTbService.getDynamicTbPage(pageReqVO).getList();
|
|
|
|
|
+ list.forEach(dynamicTbDO -> {
|
|
|
|
|
+ dynamicTbDO.setCopyConfig(null);
|
|
|
|
|
+ });
|
|
|
|
|
+ // 导出 Excel
|
|
|
|
|
+ ExcelUtils.write(response, "承压动态报表表单.xls", "数据", DynamicTbRespVO.class,
|
|
|
|
|
+ BeanUtils.toBean(list, DynamicTbRespVO.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/createOfficeToken")
|
|
|
|
|
+ @Operation(summary = "获得onlyoffice的Token")
|
|
|
|
|
+ @PermitAll
|
|
|
|
|
+ //@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
+ //@PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:query')")
|
|
|
|
|
+ public CommonResult<Config> createOfficeToken(OfficeConfigVO configVO) {
|
|
|
|
|
+
|
|
|
|
|
+ Config config=configService.createConfig(configVO);
|
|
|
|
|
+
|
|
|
|
|
+ return success(config);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/getOfficeDoc")
|
|
|
|
|
+ @Operation(summary = "获得OfficeDoc文件")
|
|
|
|
|
+ @Parameter(name = "fileId", description = "文件ID", required = true, example = "000xxx1")
|
|
|
|
|
+ @PermitAll
|
|
|
|
|
+ //@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
+ //@PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:query')")
|
|
|
|
|
+ public ResponseEntity<org.springframework.core.io.Resource> getOfficeDoc(@RequestParam("fileId") String fileId) {
|
|
|
|
|
+ org.springframework.core.io.Resource resource=null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ /*
|
|
|
|
|
+ ResponseEntity.ok()
|
|
|
|
|
+ .contentType("")
|
|
|
|
|
+ .header(HttpHeaders.CONTENT_DISPOSITION,
|
|
|
|
|
+ "attachment; filename=\"" + resource.getFilename() + "\"")
|
|
|
|
|
+ .body(resource);*/
|
|
|
|
|
+ return null;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ @GetMapping("/convertServerFileToPdf")
|
|
|
|
|
+ @Operation(summary = "获得OfficePDF文件地址")
|
|
|
|
|
+ @PermitAll
|
|
|
|
|
+ public CommonResult<Config> convertServerFileToPdf(@RequestParam("filePath") String filePath,@RequestParam("refId") String refId,@RequestParam("isNew") Boolean isNew) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ CommonResult<FileRepsDTO> fileCR = fileApi.getFileRepsDTO(filePath);
|
|
|
|
|
+ FileRepsDTO fileDTO=fileCR.getData();
|
|
|
|
|
+ OfficeConfigVO configVO=new OfficeConfigVO();
|
|
|
|
|
+
|
|
|
|
|
+ String fpdFilePath="";
|
|
|
|
|
+
|
|
|
|
|
+ if(isNew){
|
|
|
|
|
+ fpdFilePath=UUID.randomUUID().toString()+".pdf";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fpdFilePath=filePath;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String pdfUrl=configService.convertServerFileToPdf(fileDTO.getUrl(),fileDTO.getName(),fpdFilePath);
|
|
|
|
|
+
|
|
|
|
|
+ if(StringUtils.isBlank(pdfUrl)){
|
|
|
|
|
+ return success(null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String title=FileNameUtil.getPrefix(fileDTO.getName());
|
|
|
|
|
+ if(isNew){
|
|
|
|
|
+ String fileNewName=title+".pdf";
|
|
|
|
|
+ iDynamicOFService.saveOFToServer(fileNewName,pdfUrl,refId,fpdFilePath);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ configVO.setUrl(pdfUrl);
|
|
|
|
|
+ configVO.setFileType("pdf");
|
|
|
|
|
+ configVO.setDocumentType("PDF");
|
|
|
|
|
+ configVO.setTitle(title);
|
|
|
|
|
+ configVO.setKey(fpdFilePath);
|
|
|
|
|
+ configVO.setPm_edit(true);
|
|
|
|
|
+ configVO.setPm_fillForms(false);
|
|
|
|
|
+ configVO.setRefId(refId);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Config config=configService.createConfig(configVO);
|
|
|
|
|
+
|
|
|
|
|
+ return success(config);
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.info("convertServerFileToPdf,报错:{}",e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/getDynamicOFData")
|
|
|
|
|
+ @PermitAll
|
|
|
|
|
+ @Operation(summary = "获得动态表单的数值")
|
|
|
|
|
+ public CommonResult<JSONObject> getDynamicOFData(@RequestBody JSONObject jsonObject) {
|
|
|
|
|
+
|
|
|
|
|
+ String serviceName = jsonObject.getString("serviceName");
|
|
|
|
|
+
|
|
|
|
|
+ if(StringUtils.isNotBlank(serviceName)){
|
|
|
|
|
+ IDynamicOFData ofData= ofDataUtils.getFindOFService(serviceName);
|
|
|
|
|
+ if(ofData!=null){
|
|
|
|
|
+ JSONObject result=ofData.getOFData(jsonObject);
|
|
|
|
|
+ return success(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/getDynamicOFDataByVO")
|
|
|
|
|
+ @PermitAll
|
|
|
|
|
+ @Operation(summary = "获得动态表单的数值")
|
|
|
|
|
+ public CommonResult<JSONObject> getDynamicOFDataByVO(@RequestBody CreateInstantiateWithRuleVO ruleVO) {
|
|
|
|
|
+
|
|
|
|
|
+ String serviceName = ruleVO.getServiceName();
|
|
|
|
|
+
|
|
|
|
|
+ if(StringUtils.isNotBlank(serviceName)){
|
|
|
|
|
+ IDynamicOFData ofData= ofDataUtils.getFindOFService(serviceName);
|
|
|
|
|
+ if(ofData!=null){
|
|
|
|
|
+ JSONObject result=ofData.getOfDataByVO(ruleVO);
|
|
|
|
|
+ return success(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SettingsManager settingsManager;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CallbackService callbackService;
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("track")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @Operation(summary = "onlyoffice 回调接口")
|
|
|
|
|
+ @PermitAll
|
|
|
|
|
+ public String track(final HttpServletRequest request, // track file changes
|
|
|
|
|
+ @RequestParam(value = "fileName",required = false) final String fileName,
|
|
|
|
|
+ @RequestParam(value ="userAddress",required = false) final String userAddress,
|
|
|
|
|
+ @RequestBody final Callback body){
|
|
|
|
|
+
|
|
|
|
|
+ Callback callback;
|
|
|
|
|
+ try {
|
|
|
|
|
+ byte[] bBody=request.getInputStream().readAllBytes();
|
|
|
|
|
+ String bodyString =new String(bBody, StandardCharsets.UTF_8);
|
|
|
|
|
+ JSONObject jBody=JSON.parseObject(bodyString);
|
|
|
|
|
+ //String bodyString = JSON.toJSONString(body); // write the request body to the object mapper as a string
|
|
|
|
|
+ log.info("track,文件回调内容:{}",bodyString);
|
|
|
|
|
+ if (bodyString.isEmpty()) { // if the request body is empty, an error occurs
|
|
|
|
|
+ throw new RuntimeException("{\"error\":1,\"message\":\"Request payload is empty\"}");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String authorizationHeader = request.getHeader(settingsManager.getSecurityHeader());
|
|
|
|
|
+ callback = callbackService.verifyCallback(body, authorizationHeader);
|
|
|
|
|
+
|
|
|
|
|
+ callbackService.processCallback(callback, jBody.getString("userdata"));
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ String message = e.getMessage();
|
|
|
|
|
+ if (!message.contains("\"error\":1")) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return message;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return "{\"error\":\"0\"}";
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/serverFileSave")
|
|
|
|
|
+ @Operation(summary = "触发文件保存命令")
|
|
|
|
|
+ @PermitAll
|
|
|
|
|
+ public CommonResult<String> serverFileSave(@RequestParam("filePath") String filePath,@RequestParam("fileName") String fileName,@RequestParam("tdId") String tdId){
|
|
|
|
|
+
|
|
|
|
|
+ String msg=iDynamicOFService.saveOF(filePath,fileName,tdId);
|
|
|
|
|
+
|
|
|
|
|
+ return success(msg);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/export-zip")
|
|
|
|
|
+ @Operation(summary = "导出模板数据为 ZIP 压缩包")
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:export')")
|
|
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
|
|
+ public void exportZip(@Valid @RequestBody DynamicTbExportReqVO reqVO,
|
|
|
|
|
+ HttpServletResponse response) throws Exception {
|
|
|
|
|
+ byte[] zipBytes = dynamicTbService.exportZip(reqVO.getIds());
|
|
|
|
|
+ // 设置响应头,返回 zip 文件
|
|
|
|
|
+ response.setContentType("application/zip");
|
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=\"dynamic_tb_export.zip\"");
|
|
|
|
|
+ response.getOutputStream().write(zipBytes);
|
|
|
|
|
+ response.getOutputStream().flush();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/import-zip")
|
|
|
|
|
+ @Operation(summary = "从 ZIP 压缩包导入模板数据")
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermission('pressure2:dynamic-tb:import')")
|
|
|
|
|
+ @ApiAccessLog(operateType = IMPORT)
|
|
|
|
|
+ public CommonResult<Boolean> importZip(@RequestParam("file") MultipartFile file) throws Exception {
|
|
|
|
|
+ dynamicTbService.importZip(file.getBytes());
|
|
|
|
|
+ return success(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|