“zhifk” 2 rokov pred
rodič
commit
e9ffc472bc

+ 90 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/MetadataClassification.java

@@ -0,0 +1,90 @@
+package org.springblade.business.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+/**
+ * 元数据容器
+ * **/
+@Data
+@TableName("u_metadata_classification")
+@EqualsAndHashCode(callSuper = true)
+public class MetadataClassification extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * 主键id
+     */
+    private Long id;
+    /**
+     * 租户ID
+     */
+    @ApiModelProperty(value = "租户ID")
+    private String tenantId;
+
+    @ApiModelProperty("合同段ID")
+    private String contractId;
+
+    /**
+     * 元数据项
+     */
+    @ApiModelProperty(value = "元数据项")
+    private String containerName;
+
+    /**
+     * 编号
+     */
+    @ApiModelProperty(value = "编号")
+    private String code;
+    /**
+     * 字段数据类型
+     */
+    @ApiModelProperty(value = "字段数据类型")
+    private String fieldType;
+
+    /**
+     * 容器类型
+     */
+    @ApiModelProperty(value = "容器类型")
+    private Integer containerType;
+
+    /**
+     * 捕获方式
+     */
+    @ApiModelProperty(value = "捕获方式")
+    private Integer captureMode;
+
+    /**
+     * 是否必选
+     */
+    @ApiModelProperty(value = "是否必选")
+    private Integer mandatoryType;
+
+    /**
+     * 文件存储类型
+     */
+    @ApiModelProperty(value = "文件存储类型")
+    private String fileStorageType;
+
+    /**
+     * 容器实体表名称
+     */
+    @ApiModelProperty(value = "容器实体表名称")
+    private String containerInitTabName;
+
+    /**
+     * 实体表字段名
+     */
+    @ApiModelProperty(value = "实体表字段名")
+    private String fieldKey;
+
+    /**
+     * 排序
+     */
+    @ApiModelProperty(value = "排序")
+    private Integer sort;
+
+}

+ 80 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/MetadataController.java

@@ -0,0 +1,80 @@
+package org.springblade.business.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import org.springblade.business.entity.MetadataClassification;
+import org.springblade.business.mapper.MetadataClassificationMapper;
+import org.springblade.business.service.IMetadataClassificationService;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.validation.Valid;
+import java.util.Map;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/metadata")
+@Api(value = "元数据容器", tags = "元数据容器接口")
+public class MetadataController extends BladeController {
+    private final IMetadataClassificationService iMetadataClassificationService;
+    private final MetadataClassificationMapper metadataClassificationMapper;
+
+
+    @GetMapping("/classification/detail")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "元数据容器分类详情", notes = "传入分类类型")
+    public R<IPage<MetadataClassification>> classificationDetail(@ApiIgnore @RequestParam Map<String, Object> log, Query query) {
+        IPage<MetadataClassification> page = iMetadataClassificationService.page(Condition.getPage(query), Condition.getQueryWrapper(log, MetadataClassification.class));
+        return R.data(page);
+    }
+
+    @PostMapping("/classification/submit")
+    @ApiOperationSupport(order = 2)
+    @ApiOperation(value = "元数据新增或修改", notes = "传入MetadataClassification")
+    public R<Object> classificationSubmit(@RequestBody MetadataClassification obj) {
+        return R.status(iMetadataClassificationService.classificationSubmit(obj));
+    }
+
+    /**
+     * 删除
+     */
+    @PostMapping("/remove")
+    @ApiOperationSupport(order = 3)
+    @ApiOperation(value = "逻辑删除", notes = "传入ids")
+    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+        return R.status(iMetadataClassificationService.deleteLogic(Func.toLongList(ids)));
+    }
+
+    /**
+     * 设置分类
+     */
+    @PostMapping("/allocation")
+    @ApiOperationSupport(order = 4)
+    @ApiOperation(value = "设置分类", notes = "传入ids")
+    public R allocation(@ApiParam(value = "主键集合", required = true) @RequestParam String ids,@RequestParam String type) {
+        return R.status(iMetadataClassificationService.updateMetadataBytype(Func.toLongList(ids),type));
+    }
+
+    /**
+     * 查看没有设置当前分类的元数据容器
+     */
+    @GetMapping("/allocation/detail")
+    @ApiOperationSupport(order = 5)
+    @ApiOperation(value = "元数据容器分类详情", notes = "传入分类类型")
+    public R<IPage<MetadataClassification>> allocationDetail(@ApiIgnore @RequestParam String fileStorage, Query query) {
+        QueryWrapper<MetadataClassification> metadata = new QueryWrapper<>();
+        metadata.lambda().ne(MetadataClassification :: getFileStorageType,fileStorage).eq(MetadataClassification::getIsDeleted,0);
+        IPage<MetadataClassification> page = iMetadataClassificationService.page(Condition.getPage(query), metadata);
+        return R.data(page);
+    }
+}

+ 20 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/MetadataClassificationMapper.java

@@ -0,0 +1,20 @@
+package org.springblade.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.business.entity.MetadataClassification;
+import org.springblade.business.entity.TrialContainerClassification;
+
+import java.util.HashMap;
+import java.util.List;
+
+public interface MetadataClassificationMapper extends BaseMapper<MetadataClassification> {
+
+
+    MetadataClassification classificationDetail(@Param("type") Integer type);
+    void alterTabFiled(@Param("tabName") String containerInitTabName, @Param("fieldName") String initTabFieldName, @Param("fieldType") String fieldType, @Param("fieldLength") Integer fieldLength);
+    void updateFiledType(@Param("tabName") String containerInitTabName, @Param("fieldName") String initTabFieldName, @Param("fieldType") String fieldType, @Param("fieldLength") Integer fieldLength);
+    MetadataClassification selectMetadaOne(@Param("containerName") String containerName,@Param("code") String code,@Param("fieldKey") String fieldKey,@Param("id") Long id);
+
+    void updateMetadataBytype(@Param("ids") List<Long> ids, @Param("type") String type);
+}

+ 78 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/MetadataClassificationMapper.xml

@@ -0,0 +1,78 @@
+<?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="org.springblade.business.mapper.MetadataClassificationMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="ResultEntityMap" type="org.springblade.business.entity.MetadataClassification">
+        <result column="id" property="id"/>
+        <result column="container_name" property="containerName"/>
+        <result column="field_type" property="fieldType"/>
+        <result column="code" property="code"/>
+        <result column="container_type" property="containerType"/>
+        <result column="capture_mode" property="captureMode"/>
+        <result column="mandatory_type" property="mandatoryType"/>
+        <result column="file_storage_type" property="fileStorageType"/>
+        <result column="field_key" property="fieldKey"/>
+        <result column="container_init_tab_name" property="containerInitTabName"/>
+        <result column="sort" property="sort"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_dept" property="createDept"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="status" property="status"/>
+        <result column="is_deleted" property="isDeleted"/>
+    </resultMap>
+
+    <insert id="insertData">
+        insert into ${tabName}(id,field_calibration_time,${fieldKeys}) values(${id},#{time},${fieldValues})
+    </insert>
+
+    <update id="updateFiledType">
+        alter table ${tabName} MODIFY ${fieldName} ${fieldType}(${fieldLength})
+    </update>
+
+    <update id="alterTabFiled">
+        alter table ${tabName} add column ${fieldName} ${fieldType}(${fieldLength})
+    </update>
+
+
+    <update id="deleteTableField">
+        alter table ${tabName} drop column ${fieldName}
+    </update>
+
+    <update id="updateData">
+        update ${tabName} set field_calibration_time = #{time}
+        <if test="values != null and values != '' ">${values}</if>
+        where id = ${id}
+    </update>
+
+    <delete id="removeData">
+        delete from ${tabName} where id in
+        <foreach collection="ids" item="ids" index="ids" open="(" separator="," close=")">
+            ${ids}
+        </foreach>
+    </delete>
+
+    <select id="selectTabDataAll" resultType="java.util.HashMap">
+        select * from ${tabName} order by id
+    </select>
+
+    <select id="selectLikeByFieldKey" resultType="java.util.HashMap">
+        select * from ${tabName} where ${fieldKey} like concat('%',#{queryValue},'%') order by id limit ${current},${size}
+    </select>
+
+    <select id="classificationDetail" resultMap="ResultEntityMap">
+        select * from u_metadata_classification where file_storage_type = #{type} order by create_time desc
+    </select>
+    <select id="selectMetadaOne" resultMap="ResultEntityMap">
+        select * from u_metadata_classification where (container_name = #{containerName} or code = #{code} or field_key = #{fieldKey} )
+        <if test="id != null and id != '' ">and id != #{id} </if>
+        order by create_time desc limit 1
+    </select>
+
+    <update id="updateMetadataBytype">
+        update u_metadata_classification set file_storage_type = CONCAT(file_storage_type, ',', #{type})
+        where id in(${ids}) and locate(#{type},file_storage_type) = 0
+    </update>
+</mapper>

+ 17 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/IMetadataClassificationService.java

@@ -0,0 +1,17 @@
+package org.springblade.business.service;
+
+
+import org.springblade.business.entity.MetadataClassification;
+import org.springblade.core.mp.base.BaseService;
+
+import java.util.List;
+
+public interface IMetadataClassificationService extends BaseService<MetadataClassification> {
+
+
+    MetadataClassification classificationDetail(Integer type);
+
+    boolean classificationSubmit(MetadataClassification obj);
+
+    boolean updateMetadataBytype(List<Long> ids,String type);
+}

+ 96 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/MetadataClassificationServiceImpl.java

@@ -0,0 +1,96 @@
+package org.springblade.business.service.impl;
+
+
+import lombok.AllArgsConstructor;
+import org.springblade.business.dto.TrialContainerClassificationDTO;
+
+import org.springblade.business.entity.MetadataClassification;
+import org.springblade.business.mapper.MetadataClassificationMapper;
+import org.springblade.business.service.IMetadataClassificationService;
+
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.constant.BladeConstant;
+import org.springblade.core.tool.utils.ObjectUtil;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+@Service
+@AllArgsConstructor
+public class MetadataClassificationServiceImpl
+        extends BaseServiceImpl<MetadataClassificationMapper, MetadataClassification>
+        implements IMetadataClassificationService {
+
+
+    @Override
+    public MetadataClassification classificationDetail(Integer type) {
+        return baseMapper.classificationDetail(type);
+    }
+    @Override
+    public boolean classificationSubmit(MetadataClassification obj) {
+
+        try {
+            BladeUser user = AuthUtil.getUser();
+//            obj.setFileStorageType("");
+
+            if(ObjectUtil.isEmpty(obj.getId())){
+                MetadataClassification metadataClassification = baseMapper.selectMetadaOne(obj.getContainerName(), obj.getCode(),
+                        "file_key_" + obj.getCode().toLowerCase(),null);
+                if(metadataClassification != null){
+                    return false;
+                }
+                obj.setId(SnowFlakeUtil.getId());
+                obj.setCreateUser(user.getUserId());
+                obj.setCreateTime(new Date());
+                obj.setTenantId(user.getTenantId());
+                obj.setIsDeleted(BladeConstant.DB_NOT_DELETED);
+                obj.setContainerInitTabName("u_metadata_file");
+                obj.setFieldKey("file_key_"+obj.getCode().toLowerCase());
+
+                String filetype = "varchar";
+                Integer fileLength = 255;
+                if(obj.getFieldType().equals("1")){
+                    filetype = "varchar";
+                }else if(obj.getFieldType().equals("4")){
+                    filetype = "datetime";
+                    fileLength = 6;
+                }
+                int insert = baseMapper.insert(obj);
+                baseMapper.alterTabFiled(obj.getContainerInitTabName(),obj.getFieldKey(),filetype,fileLength);
+            }else{
+                MetadataClassification metadataClassification = baseMapper.selectMetadaOne(obj.getContainerName(), obj.getCode(),
+                        "file_key_" + obj.getCode().toLowerCase(),obj.getId());
+                if(metadataClassification != null){
+                    return false;
+                }
+                String filetype = "varchar";
+                Integer fileLength = 255;
+                if(obj.getFieldType().equals("1")){
+                    filetype = "varchar";
+                }else if(obj.getFieldType().equals("4")){
+                    filetype = "datetime";
+                    fileLength = 6;
+                }
+                obj.setUpdateTime(new Date());
+                obj.setUpdateUser(user.getUserId());
+                baseMapper.updateById(obj);
+                baseMapper.updateFiledType(obj.getContainerInitTabName(),obj.getFieldKey(),filetype,fileLength);
+            }
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    @Override
+    public boolean updateMetadataBytype(List<Long> ids, String type) {
+        baseMapper.updateMetadataBytype(ids,type);
+        return false;
+    }
+}