From a2d76a5828e94da19b800640a58e213766ef7c50 Mon Sep 17 00:00:00 2001 From: lizhengwei <171332584@qq.com> Date: Fri, 13 Feb 2026 16:40:22 +0800 Subject: [PATCH] =?UTF-8?q?h5=20=E5=8A=A8=E6=80=81=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/api/vo/FormPrintConfigVO.java | 8 +- .../form/mybatis/entity/FormPrintConfig.java | 10 - .../mybatis/mapper/FormFieldDictMapper.java | 1 - .../mapper/FormPrintConfigMapper.xml | 2 - .../ruoyi-form/booksflow-form-service/pom.xml | 4 + .../controller/FormPrintConfigController.java | 32 ++-- .../form/service/FormDictService.java | 73 ++++--- .../form/service/FormFieldDictService.java | 36 ++-- .../form/service/FormPrintConfigService.java | 178 +++++------------- .../booksflow/form/service/FormService.java | 4 +- .../docs/http/FormPrintConfigController.http | 6 +- 11 files changed, 118 insertions(+), 236 deletions(-) diff --git a/ruoyi-modules/ruoyi-form/booksflow-form-api/src/main/java/com/pcloud/booksflow/form/api/vo/FormPrintConfigVO.java b/ruoyi-modules/ruoyi-form/booksflow-form-api/src/main/java/com/pcloud/booksflow/form/api/vo/FormPrintConfigVO.java index 6c279b480..123d032c0 100644 --- a/ruoyi-modules/ruoyi-form/booksflow-form-api/src/main/java/com/pcloud/booksflow/form/api/vo/FormPrintConfigVO.java +++ b/ruoyi-modules/ruoyi-form/booksflow-form-api/src/main/java/com/pcloud/booksflow/form/api/vo/FormPrintConfigVO.java @@ -47,12 +47,6 @@ public class FormPrintConfigVO implements Serializable { @ApiModelProperty(value = "fileType") private String fileType; - @ApiModelProperty(value = "fileUrlAi") - private String fileUrlAi; - - @ApiModelProperty(value = "fileWpsId") - private String fileWpsId; - private Long createdBy; private Long updatedBy; @@ -61,4 +55,4 @@ public class FormPrintConfigVO implements Serializable { private String ext; -} \ No newline at end of file +} diff --git a/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/java/com/pcloud/booksflow/form/mybatis/entity/FormPrintConfig.java b/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/java/com/pcloud/booksflow/form/mybatis/entity/FormPrintConfig.java index b422b7f85..5f0824f97 100644 --- a/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/java/com/pcloud/booksflow/form/mybatis/entity/FormPrintConfig.java +++ b/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/java/com/pcloud/booksflow/form/mybatis/entity/FormPrintConfig.java @@ -98,16 +98,6 @@ public class FormPrintConfig implements Serializable { */ private String fileType; - /** - * file_wps_id - */ - private String fileWpsId; - - /** - * AI模板文件url - */ - private String fileUrlAi; - /** * 模板文件url */ diff --git a/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/java/com/pcloud/booksflow/form/mybatis/mapper/FormFieldDictMapper.java b/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/java/com/pcloud/booksflow/form/mybatis/mapper/FormFieldDictMapper.java index 85ecf84b2..3a3a2620a 100644 --- a/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/java/com/pcloud/booksflow/form/mybatis/mapper/FormFieldDictMapper.java +++ b/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/java/com/pcloud/booksflow/form/mybatis/mapper/FormFieldDictMapper.java @@ -3,7 +3,6 @@ package com.pcloud.booksflow.form.mybatis.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.pcloud.booksflow.form.api.dto.DictCodesDTO; import com.pcloud.booksflow.form.mybatis.entity.FormFieldDict; -import com.pcloud.booksflow.form.mybatis.entity.FormFieldDictExample; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/resources/mapper/FormPrintConfigMapper.xml b/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/resources/mapper/FormPrintConfigMapper.xml index b48c4e03d..769084e10 100644 --- a/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/resources/mapper/FormPrintConfigMapper.xml +++ b/ruoyi-modules/ruoyi-form/booksflow-form-mapper/src/main/resources/mapper/FormPrintConfigMapper.xml @@ -22,8 +22,6 @@ - - diff --git a/ruoyi-modules/ruoyi-form/booksflow-form-service/pom.xml b/ruoyi-modules/ruoyi-form/booksflow-form-service/pom.xml index b600f7c43..c5ecb19c5 100644 --- a/ruoyi-modules/ruoyi-form/booksflow-form-service/pom.xml +++ b/ruoyi-modules/ruoyi-form/booksflow-form-service/pom.xml @@ -39,6 +39,10 @@ org.dromara ruoyi-common-json + + org.dromara + ruoyi-common-oss + diff --git a/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/controller/FormPrintConfigController.java b/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/controller/FormPrintConfigController.java index 34a6b7e0c..85f1dcee8 100644 --- a/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/controller/FormPrintConfigController.java +++ b/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/controller/FormPrintConfigController.java @@ -6,12 +6,11 @@ import com.pcloud.booksflow.form.api.dto.FormPrintConfigModeDTO; import com.pcloud.booksflow.form.api.dto.FormPrintConfigUploadDTO; import com.pcloud.booksflow.form.api.dto.FormPrintDTO; import com.pcloud.booksflow.form.api.vo.FormPrintConfigVO; -import com.pcloud.booksflow.form.mybatis.entity.FormPrintConfigTpl; +import com.pcloud.booksflow.form.mybatis.entity.FormPrintConfig; import com.pcloud.booksflow.form.service.FormPrintConfigService; -import com.pcloud.common.dto.ResponseDto; -import com.pcloud.common.entity.UploadResultInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.dromara.common.oss.entity.UploadResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -39,8 +38,8 @@ public class FormPrintConfigController { */ @ApiOperation("创建或更新表单打印配置") @PostMapping("/createOrUpdate") - public ResponseDto createOrUpdate(@Validated @RequestBody FormPrintConfigDTO dto) { - return new ResponseDto<>(formPrintConfigService.createOrUpdate(dto)); + public FormPrintConfig createOrUpdate(@Validated @RequestBody FormPrintConfigDTO dto) { + return formPrintConfigService.createOrUpdate(dto); } @@ -52,8 +51,8 @@ public class FormPrintConfigController { */ @ApiOperation("更新模式") @PostMapping("updateMode") - public ResponseDto updateMode(@Validated @RequestBody FormPrintConfigModeDTO dto) { - return new ResponseDto<>(formPrintConfigService.updateMode(dto)); + public Integer updateMode(@Validated @RequestBody FormPrintConfigModeDTO dto) { + return formPrintConfigService.updateMode(dto); } /** @@ -64,28 +63,21 @@ public class FormPrintConfigController { */ @ApiOperation("根据表单ID获取表单打印配置") @GetMapping("/get") - public ResponseDto getByFormId(@RequestParam Long formId) { - return new ResponseDto<>(formPrintConfigService.getByFormId(formId)); + public FormPrintConfigVO getByFormId(@RequestParam Long formId) { + return formPrintConfigService.getByFormId(formId); } - @ApiOperation("ai解析word") - @GetMapping("/aiParsesWord") - public ResponseDto aiParsesWord(@RequestParam Long formId) { - return new ResponseDto<>(formPrintConfigService.aiParsesWord(formId)); - } - @ApiOperation("上传word模板") @PostMapping("uploadFile") - public ResponseDto updateFile(@Validated @RequestBody FormPrintConfigUploadDTO dto) { - formPrintConfigService.createOrUpdate(dto); - return new ResponseDto<>(); + public Long updateFile(@Validated @RequestBody FormPrintConfigUploadDTO dto) { + return formPrintConfigService.createOrUpdate(dto); } @ApiOperation("获取打印url") @PostMapping("print") - public ResponseDto print(@Validated @RequestBody FormPrintDTO dto) throws IOException { - return new ResponseDto<>(formPrintConfigService.print(dto)); + public UploadResult print(@Validated @RequestBody FormPrintDTO dto) throws IOException { + return formPrintConfigService.print(dto); } diff --git a/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormDictService.java b/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormDictService.java index 0f10f3a18..692454fbd 100644 --- a/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormDictService.java +++ b/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormDictService.java @@ -2,13 +2,14 @@ package com.pcloud.booksflow.form.service; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.pcloud.booksflow.form.api.dto.FormDictDTO; import com.pcloud.booksflow.form.mybatis.entity.FormDict; import com.pcloud.booksflow.form.mybatis.entity.FormDictExample; import com.pcloud.booksflow.form.mybatis.entity.FormFieldDict; import com.pcloud.booksflow.form.mybatis.mapper.FormDictMapper; -import com.pcloud.booksflow.form.mybatis.mapper.FormDictMapperExt; import com.pcloud.booksflow.form.mybatis.mapper.FormFieldDictMapper; import com.pcloud.booksflow.form.utils.UserUtils; import com.pcloud.common.exceptions.BizException; @@ -74,7 +75,7 @@ public class FormDictService extends ServiceImpl { * @return 表单字典对象 */ public FormDict getById(Long id) { - return baseMapper.selectByPrimaryKey(id); + return baseMapper.selectById(id); } /** @@ -98,7 +99,7 @@ public class FormDictService extends ServiceImpl { entity.setDeleted(1); entity.setUpdatedBy(UserUtils.getUserId()); entity.setUpdateTime(new Date()); - return baseMapper.updateByPrimaryKeySelective(entity); + return baseMapper.updateById(entity); } /** @@ -108,12 +109,12 @@ public class FormDictService extends ServiceImpl { * @return 表单字典列表 */ public List listByName(String name) { - FormDictExample example = new FormDictExample(); - FormDictExample.Criteria criteria = example.createCriteria().andDeletedEqualTo(0); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(FormDict::getDeleted, 0); if (name != null && !name.isEmpty()) { - criteria.andNameLike(name + "%"); + queryWrapper.likeRight(FormDict::getName, name); } - return baseMapper.selectByExample(example); + return baseMapper.selectList(queryWrapper); } /** @@ -126,21 +127,21 @@ public class FormDictService extends ServiceImpl { * @return 分页结果 */ public PageBeanNew listByNameAndCode(String name, String code, Integer currentPage, Integer numPerPage) { - FormDictExample example = new FormDictExample(); - FormDictExample.Criteria criteria = example.createCriteria().andDeletedEqualTo(0); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(FormDict::getDeleted, 0) + .orderByDesc(FormDict::getId); if (StrUtil.isNotBlank(name)) { - criteria.andNameLike("%" + name + "%"); + queryWrapper.like(FormDict::getName, name); } if (StrUtil.isNotBlank(code)) { - criteria.andCodeLike("%" + code + "%"); + queryWrapper.like(FormDict::getCode, code); } - example.setOrderByClause("id desc"); - int count = (int) baseMapper.countByExample(example); - List records = baseMapper.selectByExampleWithPaging(example, currentPage * numPerPage, numPerPage); - return new PageBeanNew<>(currentPage, numPerPage, count, records); + Page page = new Page<>(currentPage, numPerPage); + Page result = baseMapper.selectPage(page, queryWrapper); + return new PageBeanNew<>(currentPage, numPerPage, (int) result.getTotal(), result.getRecords()); } /** @@ -151,33 +152,30 @@ public class FormDictService extends ServiceImpl { * @return 表单字典对象 */ private long countByCode(String code, Long notId) { - FormDictExample example = new FormDictExample(); - FormDictExample.Criteria criteria = example.createCriteria() - .andCodeEqualTo(code) - .andDeletedEqualTo(0); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(FormDict::getCode, code) + .eq(FormDict::getDeleted, 0); if (notId != null) { - criteria.andIdNotEqualTo(notId); + queryWrapper.ne(FormDict::getId, notId); } - return baseMapper.countByExample(example); + return baseMapper.selectCount(queryWrapper); } private long countByName(String name, Long notId) { - FormDictExample example = new FormDictExample(); - FormDictExample.Criteria criteria = example.createCriteria() - .andNameEqualTo(name) - .andDeletedEqualTo(0); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(FormDict::getName, name) + .eq(FormDict::getDeleted, 0); if (notId != null) { - criteria.andIdNotEqualTo(notId); + queryWrapper.ne(FormDict::getId, notId); } - return baseMapper.countByExample(example); + return baseMapper.selectCount(queryWrapper); } public List list(List configTypes) { - FormDictExample example = new FormDictExample(); - example.createCriteria() - .andCodeIn(configTypes) - .andDeletedEqualTo(0); - return baseMapper.selectByExample(example); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .in(FormDict::getCode, configTypes) + .eq(FormDict::getDeleted, 0); + return baseMapper.selectList(queryWrapper); } @Transactional @@ -185,7 +183,7 @@ public class FormDictService extends ServiceImpl { for (FormDict dict : dicts) { dict.setId(null); } - return baseMapper.batchInsert(dicts); + return baseMapper.insertBatchSomeColumn(dicts); } /** @@ -197,11 +195,10 @@ public class FormDictService extends ServiceImpl { if(codes == null || codes.isEmpty()){ return new HashSet<>(); } - FormDictExample example = new FormDictExample(); - example.createCriteria() - .andCodeIn(new ArrayList<>(codes)) - .andDeletedEqualTo(0); - List list = baseMapper.selectByExample(example); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .in(FormDict::getCode, new ArrayList<>(codes)) + .eq(FormDict::getDeleted, 0); + List list = baseMapper.selectList(queryWrapper); if (list.isEmpty()) { return codes; } diff --git a/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormFieldDictService.java b/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormFieldDictService.java index 17513ade4..b19ee1194 100644 --- a/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormFieldDictService.java +++ b/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormFieldDictService.java @@ -95,7 +95,7 @@ public class FormFieldDictService extends ServiceImpl dicts = formFieldDictMapperExt.selectByExampleWithBLOBs(example); + List dicts = baseMapper.selectByExampleWithBLOBs(example); //level参数过滤 if (level != null) { final int _l; @@ -119,11 +119,11 @@ public class FormFieldDictService extends ServiceImpl page(String configType, String queryStr, Integer status, Integer currentPage, Integer numPerPage) { //查询 顶级节点 FormFieldDictExample example = getTopExample(configType, status); - int count = (int) formFieldDictMapperExt.countByExampleExt(example, queryStr); + int count = (int) baseMapper.countByExampleExt(example, queryStr); if (count == 0) { return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>()); } - List records = formFieldDictMapperExt.selectByExampleWithPagingBLOBs(example, currentPage * numPerPage, numPerPage, queryStr); + List records = baseMapper.selectByExampleWithPagingBLOBs(example, currentPage * numPerPage, numPerPage, queryStr); if (CollUtil.isEmpty(records)) { return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>()); } @@ -147,7 +147,7 @@ public class FormFieldDictService extends ServiceImpl(); } List allChildren = new ArrayList<>(); - List directChildren = formFieldDictMapperExt.selectByExampleWithBLOBs(getFormFieldDictExample(configType, status, parentIds)); + List directChildren = baseMapper.selectByExampleWithBLOBs(getFormFieldDictExample(configType, status, parentIds)); if (!directChildren.isEmpty()) { allChildren.addAll(directChildren); @@ -205,7 +205,7 @@ public class FormFieldDictService extends ServiceImpl pids, Integer status, int depth, Long userId) { @@ -276,7 +276,7 @@ public class FormFieldDictService extends ServiceImpl children = formFieldDictMapperExt.selectByExample(example); + List children = baseMapper.selectByExample(example); if (children.isEmpty()) { log.debug("没有找到子节点,结束递归"); return; @@ -292,7 +292,7 @@ public class FormFieldDictService extends ServiceImpl dependentDicts = formFieldDictMapperExt.selectByExample(example); + List dependentDicts = baseMapper.selectByExample(example); if (!dependentDicts.isEmpty()) { String sss = ""; for (FormFieldDict item : dependentDicts) { @@ -341,7 +341,7 @@ public class FormFieldDictService extends ServiceImpl dicts = formFieldDictMapperExt.selectByExampleWithBLOBs(example); + List dicts = baseMapper.selectByExampleWithBLOBs(example); if (dicts == null) { return new ArrayList<>(); @@ -367,7 +367,7 @@ public class FormFieldDictService extends ServiceImpl(configTypes)) .andDeletedEqualTo(0); example.setOrderByClause("sort_order asc,name asc"); - List dicts = formFieldDictMapperExt.selectByExampleWithBLOBs(example); + List dicts = baseMapper.selectByExampleWithBLOBs(example); Map> result = dicts.stream() .collect( @@ -536,7 +536,7 @@ public class FormFieldDictService extends ServiceImpl dicts = formFieldDictMapperExt.selectByExampleWithBLOBs(example); + List dicts = baseMapper.selectByExampleWithBLOBs(example); return BeanUtil.copyToList(dicts, FormFieldDictVO.class); } @@ -555,7 +555,7 @@ public class FormFieldDictService extends ServiceImpl data = formFieldDictMapperExt.getByCodes(list); + List data = baseMapper.getByCodes(list); if (CollUtil.isEmpty(data)) { return new HashMap<>(); } @@ -590,7 +590,7 @@ public class FormFieldDictService extends ServiceImpl { @Autowired private FormService formService; @@ -56,31 +47,22 @@ public class FormPrintConfigService { * @param dto 表单打印配置对象 * @return 创建或更新后的表单打印配置对象 */ - public FormPrintConfigTpl createOrUpdate(FormPrintConfigDTO dto) { + public FormPrintConfig createOrUpdate(FormPrintConfigDTO dto) { // 创建操作 - FormPrintConfig config = getEntityByFormId(dto.getFormId()); - FormPrintConfigTpl entity = new FormPrintConfigTpl(); - if (config != null) { + FormPrintConfig entity = getEntityByFormId(dto.getFormId()); + if (entity != null) { // 更新操作 BeanUtil.copyProperties(dto, entity, "printFields"); - if (dto.getPrintFields() != null) { - entity.setPrintFields(JsonUtils.serialize(dto.getPrintFields())); - } else { - entity.setPrintFields("[]"); - } entity.setUpdatedBy(UserUtils.getUserId()); entity.setUpdateTime(new Date()); - formPrintConfigMapperExt.updateByPrimaryKeySelective(entity); + entity.setId(entity.getId()); + baseMapper.updateById(entity); } else { + entity = new FormPrintConfig(); BeanUtil.copyProperties(dto, entity, "printFields"); - if (dto.getPrintFields() != null) { - entity.setPrintFields(JsonUtils.serialize(dto.getPrintFields())); - } else { - entity.setPrintFields("[]"); - } entity.setCreatedBy(UserUtils.getUserId()); entity.setCreateTime(new Date()); - formPrintConfigMapperExt.insertSelective(entity); + baseMapper.insert(entity); } return entity; } @@ -96,7 +78,7 @@ public class FormPrintConfigService { example.createCriteria() .andFormIdEqualTo(formId); example.setOrderByClause("id desc"); - List formPrintConfigs = formPrintConfigMapperExt.selectByExampleWithBLOBs(example); + List formPrintConfigs = formPrintConfigMapperExt.selectByExampleWithBLOBs(example); if (!formPrintConfigs.isEmpty()) { return BeanUtil.copyProperties(formPrintConfigs.get(0), FormPrintConfigVO.class); } else { @@ -104,12 +86,12 @@ public class FormPrintConfigService { } } - public FormPrintConfigTpl getEntityByFormId(Long formId) { + public FormPrintConfig getEntityByFormId(Long formId) { FormPrintConfigExample example = new FormPrintConfigExample(); example.createCriteria() .andFormIdEqualTo(formId); example.setOrderByClause("id desc"); - List formPrintConfigs = formPrintConfigMapperExt.selectByExampleWithBLOBs(example); + List formPrintConfigs = formPrintConfigMapperExt.selectByExampleWithBLOBs(example); if (!formPrintConfigs.isEmpty()) { return formPrintConfigs.get(0); } else { @@ -131,7 +113,7 @@ public class FormPrintConfigService { return getByFormId(form.getId()); } - public FormPrintConfigTpl getEntityByFormCode(String formCode) { + public FormPrintConfig getEntityByFormCode(String formCode) { Form form = formService.getByCode(formCode); if (form == null) { return null; @@ -140,12 +122,12 @@ public class FormPrintConfigService { } public int updateMode(FormPrintConfigModeDTO dto) { - FormPrintConfigTpl entity = new FormPrintConfigTpl(); - FormPrintConfigTpl config = getEntityByFormId(dto.getFormId()); + FormPrintConfig entity = new FormPrintConfig(); + FormPrintConfig config = getEntityByFormId(dto.getFormId()); if (config != null) { entity.setId(config.getId()); entity.setMode(dto.getMode()); - return formPrintConfigMapperExt.updateByPrimaryKeySelective(entity); + return baseMapper.updateByPrimaryKeySelective(entity); } else { entity.setMode(dto.getMode()); entity.setCreatedBy(UserUtils.getUserId()); @@ -154,98 +136,30 @@ public class FormPrintConfigService { } } - public void createOrUpdate(FormPrintConfigUploadDTO dto) { + public Long createOrUpdate(FormPrintConfigUploadDTO dto) { // 创建操作 Long userId = UserUtils.getUserId(); - FormPrintConfigTpl upEntity = new FormPrintConfigTpl(); - FormPrintConfigTpl _config = getEntityByFormId(dto.getFormId()); + FormPrintConfig upEntity = new FormPrintConfig(); + FormPrintConfig _config = getEntityByFormId(dto.getFormId()); if (_config != null) { // 更新操作 BeanUtil.copyProperties(dto, upEntity); upEntity.setId(_config.getId()); upEntity.setUpdatedBy(userId); upEntity.setUpdateTime(new Date()); - formPrintConfigMapperExt.updateByPrimaryKeySelective(upEntity); + baseMapper.updateById(upEntity); } else { BeanUtil.copyProperties(dto, upEntity); upEntity.setCreatedBy(userId); upEntity.setCreateTime(new Date()); - formPrintConfigMapperExt.insertSelective(upEntity); - } - - //更新fileWpsId - FormPrintConfig newConfig = getEntityByFormId(dto.getFormId()); - if (StringUtil.isNotBlank(newConfig.getFileUrl())) { - updateFileWpsId(userId, newConfig); + baseMapper.insert(upEntity); } + return upEntity.getId(); } - - public Integer updateFileWpsId(Long userId, FormPrintConfig entity) { - if (!"docx".equals(entity.getFileType())) { - throw new ServiceException("请上传docx文件"); - } - CreateFileRequest rq = new CreateFileRequest(); - rq.setFileUrl(entity.getFileUrl()); - rq.setFileName(entity.getFileName()); - rq.setFileSize(entity.getFileSize()); - rq.setFileType(entity.getFileType()); - rq.setUserPermission(buildWpsFileUserPermission(userId)); - CreateFileResponse fileRecord = wpsWebOfficeService.createFileRecord(userId, rq); - String fileId = fileRecord.getFileId(); - - Map map = new HashMap<>(); - map.put("formFields", null);//TODO 待开发 - map.put("fileUrl", entity.getFileUrl()); - WorkflowRequestBody requestBody = WorkflowRequestBody.builder() - .user("auto").inputs(map).build(); - CompletionResponse response = difyClient.workflowsRunBlocking("*******", requestBody); - log.info("dify response: {}", response); - - //更新 - FormPrintConfigTpl upEntity = new FormPrintConfigTpl(); - upEntity.setId(entity.getId()); - upEntity.setFileWpsId(fileId); - return formPrintConfigMapperExt.updateByPrimaryKeySelective(upEntity); - } - - - public Integer aiParsesWord(Long formId) { - Long userId = UserUtils.getUserId(); - FormPrintConfig _entity = getEntityByFormId(formId); - String fileUrl = _entity.getFileUrl(); - CreateFileRequest request = new CreateFileRequest(); - request.setFileUrl(fileUrl); - request.setFileType(_entity.getFileType()); - CreateFileResponse fileRecord = wpsWebOfficeService.createFileRecord(userId, request); - String fileId = fileRecord.getFileId(); - - //更新 - FormPrintConfigTpl upEntity = new FormPrintConfigTpl(); - upEntity.setId(_entity.getId()); - upEntity.setFileWpsId(fileId); - return formPrintConfigMapperExt.updateByPrimaryKeySelective(upEntity); - } - - private UserPermission buildWpsFileUserPermission(Long userId) { - return UserPermission - .builder() - .userId(Convert.toStr(userId)) - .read(true) - .update(true) - .download(true) - .rename(false) - .history(false) - .copy(true) - .print(true) - .saveAs(true) - .comment(true) - .build(); - } - - public UploadResultInfo print(FormPrintDTO dto) throws IOException { + public UploadResult print(FormPrintDTO dto) throws IOException { FormPrintConfig config = null; - if (StringUtil.isNotBlank(dto.getFormCode())) { + if (StringUtils.isNotBlank(dto.getFormCode())) { config = getEntityByFormCode(dto.getFormCode()); } else if (dto.getFormId() != null) { config = getEntityByFormId(dto.getFormId()); @@ -253,30 +167,28 @@ public class FormPrintConfigService { if (config == null) { throw new ServiceException("未找到打印配置"); } - if (StringUtil.isBlank(config.getFileWpsId())) { - throw new ServiceException("未找到wpsId打印文件"); - } String fileName = config.getFileName(); String fileType = config.getFileType(); - if (StringUtil.isBlank(fileName)) { + if (StringUtils.isBlank(fileName)) { throw new ServiceException("未找到文件名"); } - if (StringUtil.isBlank(fileType)) { + if (StringUtils.isBlank(fileType)) { throw new ServiceException("未找到文件类型"); } if (!fileType.trim().equalsIgnoreCase("docx")) { throw new ServiceException("只支持docx文件"); } - String exportUrl = wpsWebOfficeService.getExportUrl(config.getFileWpsId()); - - byte[] bytes = FileUtils.downloadByteFromUrl(exportUrl); - try (WordTemplateProcessor processor = new WordTemplateProcessor(new ByteArrayInputStream(bytes))) { - processor.push(dto.getData()); - XWPFDocument docx = processor.getDocx(); - try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { - docx.write(baos); - return OssUtils.uploadFileByte(baos.toByteArray(), fileName, fileType); - } - } + OssClient storage = OssFactory.instance(); +// storage.download(config.getFileUrl()) +// +// try (WordTemplateProcessor processor = new WordTemplateProcessor(new ByteArrayInputStream(bytes))) { +// processor.push(dto.getData()); +// XWPFDocument docx = processor.getDocx(); +// try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { +// docx.write(baos); +// return storage.upload(file, suffix); +// } +// } + return null; } } diff --git a/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormService.java b/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormService.java index 306b6ff83..6d65f79b7 100644 --- a/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormService.java +++ b/ruoyi-modules/ruoyi-form/booksflow-form-service/src/main/java/com/pcloud/booksflow/form/service/FormService.java @@ -5,7 +5,7 @@ import com.pcloud.booksflow.form.api.constant.BaseConstant; import com.pcloud.booksflow.form.mybatis.entity.*; import com.pcloud.booksflow.form.mybatis.mapper.FormMapperExt; import com.pcloud.booksflow.form.utils.TenantHelper; -import com.pcloud.common.exceptions.BizException; +import org.dromara.common.core.exception.ServiceException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -37,7 +37,7 @@ public class FormService { throw new ServiceException("名称已存在: " + form.getName()); } form.setId(null); - formMapperExt.insertSelective(form); + formMapper.insert(form); return form; } diff --git a/ruoyi-modules/ruoyi-form/docs/http/FormPrintConfigController.http b/ruoyi-modules/ruoyi-form/docs/http/FormPrintConfigController.http index f7f469f21..5ffc848fa 100644 --- a/ruoyi-modules/ruoyi-form/docs/http/FormPrintConfigController.http +++ b/ruoyi-modules/ruoyi-form/docs/http/FormPrintConfigController.http @@ -38,10 +38,6 @@ GET {{baseUrl}}/form-print-config/get?formId=1 Token: {{token}} -### updateTplFileWpsId -GET {{baseUrl}}form-print-config/updateTplFileWpsId?formPrintConfigTplId=1 -Token: {{token}} - ### form-print-config/print POST {{baseUrl}}form-print-config/print @@ -62,4 +58,4 @@ Token: {{token}} { "ys":"4","ks": "开数4"} ] } -} \ No newline at end of file +}