Merge branch 'test' of https://git.will-way.cn/zgty/zt-qms into test
This commit is contained in:
@@ -29,6 +29,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode DATA_FORM_NOT_EXISTS = new ErrorCode(1_032_001_000, "通用数据不存在");
|
ErrorCode DATA_FORM_NOT_EXISTS = new ErrorCode(1_032_001_000, "通用数据不存在");
|
||||||
ErrorCode DATA_FORM_EMPTY_COLLECTION_ID = new ErrorCode(1_032_001_000, "未指定数据集ID");
|
ErrorCode DATA_FORM_EMPTY_COLLECTION_ID = new ErrorCode(1_032_001_000, "未指定数据集ID");
|
||||||
ErrorCode DICTIONARY_BUSINESS_NOT_EXISTS = new ErrorCode(1_032_001_000, "业务参数字典不存在");
|
ErrorCode DICTIONARY_BUSINESS_NOT_EXISTS = new ErrorCode(1_032_001_000, "业务参数字典不存在");
|
||||||
|
ErrorCode DATA_TEMPLATE_NOT_EXISTS = new ErrorCode(1_032_001_000, "表单设计器模板不存在");
|
||||||
ErrorCode DICTIONARY_BUSINESS_DATA_MORE_THAN_ONE = new ErrorCode(1_032_001_000, "业务参数字典[数据]key重名,请联系管理员处理!");
|
ErrorCode DICTIONARY_BUSINESS_DATA_MORE_THAN_ONE = new ErrorCode(1_032_001_000, "业务参数字典[数据]key重名,请联系管理员处理!");
|
||||||
ErrorCode DICTIONARY_BUSINESS_CATEGORY_MORE_THAN_ONE = new ErrorCode(1_032_001_000, "业务参数字典[分类]key重名,请联系管理员处理!");
|
ErrorCode DICTIONARY_BUSINESS_CATEGORY_MORE_THAN_ONE = new ErrorCode(1_032_001_000, "业务参数字典[分类]key重名,请联系管理员处理!");
|
||||||
ErrorCode DICTIONARY_BUSINESS_CLASSIFY_DUPLICATE = new ErrorCode(1_032_001_000, "分类名称重复,请重新输入");
|
ErrorCode DICTIONARY_BUSINESS_CLASSIFY_DUPLICATE = new ErrorCode(1_032_001_000, "分类名称重复,请重新输入");
|
||||||
|
|||||||
@@ -0,0 +1,140 @@
|
|||||||
|
package com.zt.plat.module.qms.common.data.controller.admin;
|
||||||
|
|
||||||
|
import com.zt.plat.module.qms.common.data.controller.vo.*;
|
||||||
|
import com.zt.plat.module.qms.common.data.dal.dataobject.DataCollectionDO;
|
||||||
|
import com.zt.plat.module.qms.core.constant.DataTypeConstant;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import jakarta.validation.*;
|
||||||
|
import jakarta.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||||
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
import com.zt.plat.module.qms.common.data.dal.dataobject.DataTemplateDO;
|
||||||
|
import com.zt.plat.module.qms.common.data.service.DataTemplateService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 表单设计器模板")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/qms/common/data/data-template")
|
||||||
|
@Validated
|
||||||
|
public class DataTemplateController implements BusinessControllerMarker {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DataTemplateService dataTemplateService;
|
||||||
|
|
||||||
|
@PostMapping("/create-temp-data")
|
||||||
|
@Operation(summary = "创建临时数据")
|
||||||
|
public CommonResult<DataTemplateRespVO> createTempData(@Valid @RequestBody DataTemplateSaveReqVO vo) {
|
||||||
|
vo.setCancelFlag("-1");
|
||||||
|
vo.setNodeType(DataTypeConstant.DATA_TYPE_DATA);
|
||||||
|
vo.setVersion(1);
|
||||||
|
return success(dataTemplateService.createDataTemplate(vo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/saveData")
|
||||||
|
@Operation(summary = "保存数据")
|
||||||
|
@PreAuthorize("@ss.hasPermission('qms:data-template:create')")
|
||||||
|
public CommonResult<String> saveData(@Valid @RequestBody DataTemplateSaveReqVO createReqVO) {
|
||||||
|
return dataTemplateService.saveData(createReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/saveClassify")
|
||||||
|
@Operation(summary = "保存分类")
|
||||||
|
@PreAuthorize("@ss.hasPermission('qms:data-template:create')")
|
||||||
|
public CommonResult<DataTemplateRespVO> saveClassify(@Valid @RequestBody DataTemplateSaveReqVO createReqVO) {
|
||||||
|
return dataTemplateService.saveClassify(createReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建表单设计器模板")
|
||||||
|
@PreAuthorize("@ss.hasPermission('qms:data-template:create')")
|
||||||
|
public CommonResult<DataTemplateRespVO> createDataTemplate(@Valid @RequestBody DataTemplateSaveReqVO createReqVO) {
|
||||||
|
return success(dataTemplateService.createDataTemplate(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新表单设计器模板")
|
||||||
|
@PreAuthorize("@ss.hasPermission('qms:data-template:update')")
|
||||||
|
public CommonResult<Boolean> updateDataTemplate(@Valid @RequestBody DataTemplateSaveReqVO updateReqVO) {
|
||||||
|
dataTemplateService.updateDataTemplate(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除表单设计器模板")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('qms:data-template:delete')")
|
||||||
|
public CommonResult<Boolean> deleteDataTemplate(@RequestParam("id") Long id) {
|
||||||
|
dataTemplateService.deleteDataTemplate(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete-list")
|
||||||
|
@Parameter(name = "ids", description = "编号", required = true)
|
||||||
|
@Operation(summary = "批量删除表单设计器模板")
|
||||||
|
@PreAuthorize("@ss.hasPermission('qms:data-template:delete')")
|
||||||
|
public CommonResult<Boolean> deleteDataTemplateList(@RequestBody BatchDeleteReqVO req) {
|
||||||
|
dataTemplateService.deleteDataTemplateListByIds(req.getIds());
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得表单设计器模板")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('qms:data-template:query')")
|
||||||
|
public CommonResult<DataTemplateRespVO> getDataTemplate(@RequestParam("id") Long id) {
|
||||||
|
DataTemplateDO dataTemplate = dataTemplateService.getDataTemplate(id);
|
||||||
|
return success(BeanUtils.toBean(dataTemplate, DataTemplateRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得表单设计器模板分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('qms:data-template:query')")
|
||||||
|
public CommonResult<PageResult<DataTemplateRespVO>> getDataTemplatePage(@Valid DataTemplatePageReqVO pageReqVO) {
|
||||||
|
PageResult<DataTemplateDO> pageResult = dataTemplateService.getDataTemplatePage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, DataTemplateRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get-tree-data")
|
||||||
|
@Operation(summary = "查询分类树")
|
||||||
|
public CommonResult<List<DataTemplateRespVO>> getTreeData() {
|
||||||
|
List<DataTemplateDO> list = dataTemplateService.getTreeData();
|
||||||
|
return success(BeanUtils.toBean(list, DataTemplateRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出表单设计器模板 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('qms:data-template:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportDataTemplateExcel(@Valid DataTemplatePageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<DataTemplateDO> list = dataTemplateService.getDataTemplatePage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "表单设计器模板.xls", "数据", DataTemplateRespVO.class,
|
||||||
|
BeanUtils.toBean(list, DataTemplateRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.zt.plat.module.qms.common.data.controller.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 表单设计器模板分页 Request VO")
|
||||||
|
@Data
|
||||||
|
public class DataTemplatePageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "上级id", example = "14825")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
@Schema(description = "主数据id,用于版本识别", example = "12080")
|
||||||
|
private Long mainId;
|
||||||
|
|
||||||
|
@Schema(description = "id路径")
|
||||||
|
private String idPath;
|
||||||
|
|
||||||
|
@Schema(description = "名称", example = "张三")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "节点类型,字典:qms_tree_node_type,category-分类;data-表单", example = "2")
|
||||||
|
private String nodeType;
|
||||||
|
|
||||||
|
@Schema(description = "数据键")
|
||||||
|
private String dataKey;
|
||||||
|
|
||||||
|
@Schema(description = "版本")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
@Schema(description = "是否最新版本,默认显示最新版本")
|
||||||
|
private String currentFlag;
|
||||||
|
|
||||||
|
@Schema(description = "禁用状态,0-启用;1-禁用")
|
||||||
|
private String cancelFlag;
|
||||||
|
|
||||||
|
@Schema(description = "排序号")
|
||||||
|
private Integer sortNo;
|
||||||
|
|
||||||
|
@Schema(description = "其他配置")
|
||||||
|
private String customConfig;
|
||||||
|
|
||||||
|
@Schema(description = "模板内容")
|
||||||
|
private String formContent;
|
||||||
|
|
||||||
|
@Schema(description = "移动端模板内容")
|
||||||
|
private String mobileContent;
|
||||||
|
|
||||||
|
@Schema(description = "所属部门")
|
||||||
|
private String systemDepartmentCode;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package com.zt.plat.module.qms.common.data.controller.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 表单设计器模板 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class DataTemplateRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "10340")
|
||||||
|
@ExcelProperty("主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "上级id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14825")
|
||||||
|
@ExcelProperty("上级id")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
@Schema(description = "主数据id,用于版本识别", requiredMode = Schema.RequiredMode.REQUIRED, example = "12080")
|
||||||
|
@ExcelProperty("主数据id,用于版本识别")
|
||||||
|
private Long mainId;
|
||||||
|
|
||||||
|
@Schema(description = "id路径", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("id路径")
|
||||||
|
private String idPath;
|
||||||
|
|
||||||
|
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||||
|
@ExcelProperty("名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "节点类型,字典:qms_tree_node_type,category-分类;data-表单", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
|
@ExcelProperty("节点类型,字典:qms_tree_node_type,category-分类;data-表单")
|
||||||
|
private String nodeType;
|
||||||
|
|
||||||
|
@Schema(description = "数据键", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("数据键")
|
||||||
|
private String dataKey;
|
||||||
|
|
||||||
|
@Schema(description = "版本", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("版本")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
@Schema(description = "是否最新版本,默认显示最新版本", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("是否最新版本,默认显示最新版本")
|
||||||
|
private String currentFlag;
|
||||||
|
|
||||||
|
@Schema(description = "禁用状态,0-启用;1-禁用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("禁用状态,0-启用;1-禁用")
|
||||||
|
private String cancelFlag;
|
||||||
|
|
||||||
|
@Schema(description = "排序号")
|
||||||
|
@ExcelProperty("排序号")
|
||||||
|
private Integer sortNo;
|
||||||
|
|
||||||
|
@Schema(description = "其他配置")
|
||||||
|
@ExcelProperty("其他配置")
|
||||||
|
private String customConfig;
|
||||||
|
|
||||||
|
@Schema(description = "模板内容")
|
||||||
|
@ExcelProperty("模板内容")
|
||||||
|
private String formContent;
|
||||||
|
|
||||||
|
@Schema(description = "移动端模板内容")
|
||||||
|
@ExcelProperty("移动端模板内容")
|
||||||
|
private String mobileContent;
|
||||||
|
|
||||||
|
@Schema(description = "所属部门")
|
||||||
|
@ExcelProperty("所属部门")
|
||||||
|
private String systemDepartmentCode;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.zt.plat.module.qms.common.data.controller.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 表单设计器模板新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class DataTemplateSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "10340")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "上级id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14825")
|
||||||
|
@NotNull(message = "上级id不能为空")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
@Schema(description = "主数据id,用于版本识别", requiredMode = Schema.RequiredMode.REQUIRED, example = "12080")
|
||||||
|
@NotNull(message = "主数据id,用于版本识别不能为空")
|
||||||
|
private Long mainId;
|
||||||
|
|
||||||
|
@Schema(description = "id路径", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "id路径不能为空")
|
||||||
|
private String idPath;
|
||||||
|
|
||||||
|
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||||
|
@NotEmpty(message = "名称不能为空")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "节点类型,字典:qms_tree_node_type,category-分类;data-表单", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
|
@NotEmpty(message = "节点类型,字典:qms_tree_node_type,category-分类;data-表单不能为空")
|
||||||
|
private String nodeType;
|
||||||
|
|
||||||
|
@Schema(description = "数据键", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "数据键不能为空")
|
||||||
|
private String dataKey;
|
||||||
|
|
||||||
|
@Schema(description = "版本", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "版本不能为空")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
@Schema(description = "是否最新版本,默认显示最新版本", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "是否最新版本,默认显示最新版本不能为空")
|
||||||
|
private String currentFlag;
|
||||||
|
|
||||||
|
@Schema(description = "禁用状态,0-启用;1-禁用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "禁用状态,0-启用;1-禁用不能为空")
|
||||||
|
private String cancelFlag;
|
||||||
|
|
||||||
|
@Schema(description = "排序号")
|
||||||
|
private Integer sortNo;
|
||||||
|
|
||||||
|
@Schema(description = "其他配置")
|
||||||
|
private String customConfig;
|
||||||
|
|
||||||
|
@Schema(description = "模板内容")
|
||||||
|
private String formContent;
|
||||||
|
|
||||||
|
@Schema(description = "移动端模板内容")
|
||||||
|
private String mobileContent;
|
||||||
|
|
||||||
|
@Schema(description = "所属部门")
|
||||||
|
private String systemDepartmentCode;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
//==============扩展字段===============
|
||||||
|
@Schema(description = "是否创建新版本")
|
||||||
|
private String newVersionFlag;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package com.zt.plat.module.qms.common.data.dal.dataobject;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
|
||||||
|
/**
|
||||||
|
* 表单设计器模板 DO
|
||||||
|
*
|
||||||
|
* @author 后台管理
|
||||||
|
*/
|
||||||
|
@TableName("t_dat_tmpl")
|
||||||
|
@KeySequence("t_dat_tmpl_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
/**
|
||||||
|
* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO
|
||||||
|
*/
|
||||||
|
public class DataTemplateDO extends BusinessBaseDO {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 上级id
|
||||||
|
*/
|
||||||
|
@TableField("PRN_ID")
|
||||||
|
private Long parentId;
|
||||||
|
/**
|
||||||
|
* 主数据id,用于版本识别
|
||||||
|
*/
|
||||||
|
@TableField("MAIN_ID")
|
||||||
|
private Long mainId;
|
||||||
|
/**
|
||||||
|
* id路径
|
||||||
|
*/
|
||||||
|
@TableField("ID_PATH")
|
||||||
|
private String idPath;
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
@TableField("NAME")
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 节点类型,字典:qms_tree_node_type,category-分类;data-表单
|
||||||
|
*/
|
||||||
|
@TableField("NDE_TP")
|
||||||
|
private String nodeType;
|
||||||
|
/**
|
||||||
|
* 数据键
|
||||||
|
*/
|
||||||
|
@TableField("DAT_KY")
|
||||||
|
private String dataKey;
|
||||||
|
/**
|
||||||
|
* 版本
|
||||||
|
*/
|
||||||
|
@TableField("VER")
|
||||||
|
private Integer version;
|
||||||
|
/**
|
||||||
|
* 是否最新版本,默认显示最新版本
|
||||||
|
*/
|
||||||
|
@TableField("CRNT_FLG")
|
||||||
|
private String currentFlag;
|
||||||
|
/**
|
||||||
|
* 禁用状态,0-启用;1-禁用
|
||||||
|
*/
|
||||||
|
@TableField("CNL_FLG")
|
||||||
|
private String cancelFlag;
|
||||||
|
/**
|
||||||
|
* 排序号
|
||||||
|
*/
|
||||||
|
@TableField("SRT_NO")
|
||||||
|
private Integer sortNo;
|
||||||
|
/**
|
||||||
|
* 其他配置
|
||||||
|
*/
|
||||||
|
@TableField("CST_CFG")
|
||||||
|
private String customConfig;
|
||||||
|
/**
|
||||||
|
* 模板内容
|
||||||
|
*/
|
||||||
|
@TableField("FORM_CNTT")
|
||||||
|
private String formContent;
|
||||||
|
/**
|
||||||
|
* 移动端模板内容
|
||||||
|
*/
|
||||||
|
@TableField("MOB_CNTT")
|
||||||
|
private String mobileContent;
|
||||||
|
/**
|
||||||
|
* 所属部门
|
||||||
|
*/
|
||||||
|
@TableField("SYS_DEPT_CD")
|
||||||
|
private String systemDepartmentCode;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@TableField("RMK")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.zt.plat.module.qms.common.data.dal.mapper;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.zt.plat.module.qms.common.data.controller.vo.DataTemplatePageReqVO;
|
||||||
|
import com.zt.plat.module.qms.common.data.dal.dataobject.DataTemplateDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单设计器模板 Mapper
|
||||||
|
*
|
||||||
|
* @author 后台管理
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DataTemplateMapper extends BaseMapperX<DataTemplateDO> {
|
||||||
|
|
||||||
|
default PageResult<DataTemplateDO> selectPage(DataTemplatePageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<DataTemplateDO>()
|
||||||
|
.eqIfPresent(DataTemplateDO::getParentId, reqVO.getParentId())
|
||||||
|
.eqIfPresent(DataTemplateDO::getIdPath, reqVO.getIdPath())
|
||||||
|
.likeIfPresent(DataTemplateDO::getName, reqVO.getName())
|
||||||
|
.eqIfPresent(DataTemplateDO::getNodeType, reqVO.getNodeType())
|
||||||
|
.eqIfPresent(DataTemplateDO::getDataKey, reqVO.getDataKey())
|
||||||
|
.eqIfPresent(DataTemplateDO::getVersion, reqVO.getVersion())
|
||||||
|
.eqIfPresent(DataTemplateDO::getCurrentFlag, reqVO.getCurrentFlag())
|
||||||
|
.eqIfPresent(DataTemplateDO::getCancelFlag, reqVO.getCancelFlag())
|
||||||
|
.eqIfPresent(DataTemplateDO::getSortNo, reqVO.getSortNo())
|
||||||
|
.eqIfPresent(DataTemplateDO::getCustomConfig, reqVO.getCustomConfig())
|
||||||
|
.eqIfPresent(DataTemplateDO::getFormContent, reqVO.getFormContent())
|
||||||
|
.eqIfPresent(DataTemplateDO::getMobileContent, reqVO.getMobileContent())
|
||||||
|
.eqIfPresent(DataTemplateDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
||||||
|
.eqIfPresent(DataTemplateDO::getRemark, reqVO.getRemark())
|
||||||
|
.betweenIfPresent(DataTemplateDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(DataTemplateDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package com.zt.plat.module.qms.common.data.service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
|
import com.zt.plat.module.qms.common.data.controller.vo.*;
|
||||||
|
import com.zt.plat.module.qms.common.data.dal.dataobject.DataCollectionDO;
|
||||||
|
import com.zt.plat.module.qms.common.data.dal.dataobject.DataTemplateDO;
|
||||||
|
import jakarta.validation.*;
|
||||||
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单设计器模板 Service 接口
|
||||||
|
*
|
||||||
|
* @author 后台管理
|
||||||
|
*/
|
||||||
|
public interface DataTemplateService {
|
||||||
|
|
||||||
|
DataTemplateDO getLatestDataByKey(String key);
|
||||||
|
|
||||||
|
/*获取分类树数据*/
|
||||||
|
List<DataTemplateDO> getTreeData();
|
||||||
|
|
||||||
|
//保存数据集
|
||||||
|
CommonResult<String> saveData(@Valid DataTemplateSaveReqVO createReqVO);
|
||||||
|
CommonResult<String> saveDataWithNewVersion(@Valid DataTemplateSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
//保存分类
|
||||||
|
CommonResult<DataTemplateRespVO> saveClassify(@Valid DataTemplateSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
//更新后代节点路径-递归调用
|
||||||
|
CommonResult<String> updateAllIdPath(Long parentId, Integer level);
|
||||||
|
|
||||||
|
List<DataTemplateDO> listByParId(Long parId);
|
||||||
|
/**
|
||||||
|
* 创建表单设计器模板
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
DataTemplateRespVO createDataTemplate(@Valid DataTemplateSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新表单设计器模板
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateDataTemplate(@Valid DataTemplateSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除表单设计器模板
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteDataTemplate(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除表单设计器模板
|
||||||
|
*
|
||||||
|
* @param ids 编号
|
||||||
|
*/
|
||||||
|
void deleteDataTemplateListByIds(List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得表单设计器模板
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 表单设计器模板
|
||||||
|
*/
|
||||||
|
DataTemplateDO getDataTemplate(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得表单设计器模板分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 表单设计器模板分页
|
||||||
|
*/
|
||||||
|
PageResult<DataTemplateDO> getDataTemplatePage(DataTemplatePageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,230 @@
|
|||||||
|
package com.zt.plat.module.qms.common.data.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.zt.plat.framework.common.exception.ServiceException;
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
|
import com.zt.plat.module.qms.common.data.controller.vo.*;
|
||||||
|
import com.zt.plat.module.qms.common.data.dal.dataobject.DataTemplateDO;
|
||||||
|
import com.zt.plat.module.qms.common.data.dal.dataobject.DataTemplateDO;
|
||||||
|
import com.zt.plat.module.qms.core.constant.DataTypeConstant;
|
||||||
|
import com.zt.plat.module.qms.enums.ErrorCodeConstants;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.zt.plat.module.qms.common.data.dal.dataobject.DataTemplateDO;
|
||||||
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import com.zt.plat.module.qms.common.data.dal.mapper.DataTemplateMapper;
|
||||||
|
|
||||||
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单设计器模板 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 后台管理
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class DataTemplateServiceImpl implements DataTemplateService {
|
||||||
|
|
||||||
|
private int id_path_update_level_limit = 7;
|
||||||
|
@Resource private DataTemplateMapper dataTemplateMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataTemplateDO getLatestDataByKey(String key) {
|
||||||
|
LambdaQueryWrapper<DataTemplateDO> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(DataTemplateDO::getDataKey, key);
|
||||||
|
query.eq(DataTemplateDO::getCurrentFlag, "1");
|
||||||
|
query.orderByDesc(DataTemplateDO::getUpdateTime);
|
||||||
|
query.last("limit 1");
|
||||||
|
return dataTemplateMapper.selectOne(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<String> saveData(DataTemplateSaveReqVO reqV) {
|
||||||
|
String newVersionFlag = reqV.getNewVersionFlag();
|
||||||
|
if("1".equals(newVersionFlag))
|
||||||
|
return saveDataWithNewVersion(reqV);
|
||||||
|
Long id = reqV.getId();
|
||||||
|
DataTemplateDO backData = this.getDataTemplate(id);
|
||||||
|
if(backData.getCancelFlag() == null || backData.getCancelFlag().equals("-1")){
|
||||||
|
reqV.setCancelFlag("0");
|
||||||
|
reqV.setCurrentFlag("1");
|
||||||
|
reqV.setMainId( id);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateDataTemplate(reqV);
|
||||||
|
return CommonResult.success("保存成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<String> saveDataWithNewVersion(DataTemplateSaveReqVO createReqVO) {
|
||||||
|
DataTemplateDO dataTemplate = BeanUtils.toBean(createReqVO, DataTemplateDO.class);
|
||||||
|
dataTemplate.setCurrentFlag("0");
|
||||||
|
dataTemplateMapper.updateById(dataTemplate);
|
||||||
|
|
||||||
|
//创建新版本
|
||||||
|
Integer version = dataTemplate.getVersion();
|
||||||
|
if(version != null)
|
||||||
|
version ++;
|
||||||
|
else
|
||||||
|
version = 1;
|
||||||
|
dataTemplate.setId(null);
|
||||||
|
dataTemplate.setVersion(version);
|
||||||
|
dataTemplate.setCurrentFlag("1");
|
||||||
|
dataTemplate.setMainId(createReqVO.getMainId());
|
||||||
|
dataTemplateMapper.insert(dataTemplate);
|
||||||
|
|
||||||
|
return CommonResult.success("保存成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<DataTemplateRespVO> saveClassify(DataTemplateSaveReqVO entity) {
|
||||||
|
if(ObjectUtils.isEmpty(entity.getParentId()))
|
||||||
|
entity.setParentId(0L);
|
||||||
|
Long parentId = entity.getParentId();
|
||||||
|
//检查同一层级下是否重名
|
||||||
|
List<DataTemplateDO> checkList = listByParId(parentId);
|
||||||
|
boolean duplicate = false;
|
||||||
|
DataTemplateDO duplicateEntity = checkList.stream().filter(e->e.getName().equals(entity.getName())).findFirst().orElse(null);
|
||||||
|
if(duplicateEntity != null && !duplicateEntity.getId().equals(entity.getId()))
|
||||||
|
duplicate = true;
|
||||||
|
if(duplicate)
|
||||||
|
throw new ServiceException(ErrorCodeConstants.DATA_COLLECTION_CLASSIFY_DUPLICATE);
|
||||||
|
entity.setNodeType(DataTypeConstant.DATA_TYPE_CATEGORY);
|
||||||
|
Long id = entity.getId();
|
||||||
|
DataTemplateDO dataTemplate = BeanUtils.toBean(entity, DataTemplateDO.class);
|
||||||
|
if(ObjectUtils.isEmpty(id)){
|
||||||
|
dataTemplateMapper.insert(dataTemplate);
|
||||||
|
id = dataTemplate.getId();
|
||||||
|
}
|
||||||
|
DataTemplateDO backData = this.getDataTemplate(id);
|
||||||
|
Long parentId_ = backData.getParentId();
|
||||||
|
//检查parId,避免父节点设置为本节点的后代节点
|
||||||
|
if(parentId_.equals(id))
|
||||||
|
throw new ServiceException(ErrorCodeConstants.DATA_COLLECTION_CLASSIFY_PARENT_ERROR);
|
||||||
|
String idPath = getIdPath(dataTemplate);
|
||||||
|
int curIdIndex = idPath.indexOf("/" + id.toString() + "/");
|
||||||
|
int parIdIndex = idPath.indexOf("/" + parentId.toString() + "/");
|
||||||
|
if(curIdIndex <= parIdIndex)
|
||||||
|
throw new ServiceException(ErrorCodeConstants.DATA_COLLECTION_CLASSIFY_PARENT_ERROR);
|
||||||
|
dataTemplate.setIdPath(idPath);
|
||||||
|
|
||||||
|
//更新后代节点路径
|
||||||
|
updateAllIdPath(id, 1);
|
||||||
|
dataTemplateMapper.updateById(dataTemplate);
|
||||||
|
return CommonResult.success(BeanUtils.toBean(dataTemplate, DataTemplateRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<String> updateAllIdPath(Long parentId, Integer level) {
|
||||||
|
if(level > id_path_update_level_limit)
|
||||||
|
return CommonResult.success("更新完成(超出层数限制:"+id_path_update_level_limit+")");
|
||||||
|
List<DataTemplateDO> list = listByParId(parentId);
|
||||||
|
DataTemplateDO parEntity = this.getDataTemplate(parentId);
|
||||||
|
if(list.isEmpty())
|
||||||
|
return CommonResult.success("");
|
||||||
|
String parIdPath = "/0/";
|
||||||
|
if(parEntity != null)
|
||||||
|
parIdPath = parEntity.getIdPath();
|
||||||
|
for(DataTemplateDO entity : list){
|
||||||
|
entity.setIdPath(parIdPath + "/" + entity.getId() + "/");
|
||||||
|
dataTemplateMapper.updateById( entity);
|
||||||
|
updateAllIdPath(entity.getId(),level+1);
|
||||||
|
}
|
||||||
|
return CommonResult.success("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DataTemplateDO> getTreeData() {
|
||||||
|
LambdaQueryWrapper<DataTemplateDO> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(DataTemplateDO::getNodeType, DataTypeConstant.DATA_TYPE_CATEGORY);
|
||||||
|
query.orderByAsc(DataTemplateDO::getSortNo);
|
||||||
|
return dataTemplateMapper.selectList(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DataTemplateDO> listByParId(Long parId) {
|
||||||
|
LambdaQueryWrapper<DataTemplateDO> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(DataTemplateDO::getParentId, parId);
|
||||||
|
query.ne(DataTemplateDO::getCancelFlag, -1);
|
||||||
|
return dataTemplateMapper.selectList(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getIdPath(DataTemplateDO entity){
|
||||||
|
String parIdPath = "";
|
||||||
|
if(ObjectUtils.isEmpty(entity.getParentId()) || 0L == entity.getParentId())
|
||||||
|
parIdPath = "/0/";
|
||||||
|
DataTemplateDO parEntity = this.getDataTemplate(entity.getParentId());
|
||||||
|
if(parEntity != null){
|
||||||
|
parIdPath = parEntity.getIdPath();
|
||||||
|
}
|
||||||
|
return parIdPath + entity.getId() + "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataTemplateRespVO createDataTemplate(DataTemplateSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
DataTemplateDO dataTemplate = BeanUtils.toBean(createReqVO, DataTemplateDO.class);
|
||||||
|
dataTemplateMapper.insert(dataTemplate);
|
||||||
|
// 返回
|
||||||
|
return BeanUtils.toBean(dataTemplate, DataTemplateRespVO.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDataTemplate(DataTemplateSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateDataTemplateExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
DataTemplateDO updateObj = BeanUtils.toBean(updateReqVO, DataTemplateDO.class);
|
||||||
|
dataTemplateMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDataTemplate(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateDataTemplateExists(id);
|
||||||
|
// 删除
|
||||||
|
dataTemplateMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteDataTemplateListByIds(List<Long> ids) {
|
||||||
|
// 校验存在
|
||||||
|
validateDataTemplateExists(ids);
|
||||||
|
// 删除
|
||||||
|
dataTemplateMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateDataTemplateExists(List<Long> ids) {
|
||||||
|
List<DataTemplateDO> list = dataTemplateMapper.selectByIds(ids);
|
||||||
|
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||||
|
throw exception(DATA_TEMPLATE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateDataTemplateExists(Long id) {
|
||||||
|
if (dataTemplateMapper.selectById(id) == null) {
|
||||||
|
throw exception(DATA_TEMPLATE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataTemplateDO getDataTemplate(Long id) {
|
||||||
|
return dataTemplateMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<DataTemplateDO> getDataTemplatePage(DataTemplatePageReqVO pageReqVO) {
|
||||||
|
return dataTemplateMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.zt.plat.module.qms.common.data.dal.mapper.DataTemplateMapper">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||||
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
|
-->
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user