Explorar el Código

数据项管理更新

ZhuDeKang hace 6 meses
padre
commit
c4a3153985

+ 98 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/controller/MdDataItemController.java

@@ -0,0 +1,98 @@
+package com.ruoyi.interfaces.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.interfaces.domain.MdDataItem;
+import com.ruoyi.interfaces.service.IMdDataItemService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 数据项Controller
+ * 
+ * @author ruoyi
+ * @date 2025-07-25
+ */
+@RestController
+@RequestMapping("/data/item")
+public class MdDataItemController extends BaseController
+{
+    @Autowired
+    private IMdDataItemService mdDataItemService;
+
+    /**
+     * 查询数据项列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(MdDataItem mdDataItem)
+    {
+        startPage();
+        List<MdDataItem> list = mdDataItemService.selectMdDataItemList(mdDataItem);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出数据项列表
+     */
+    @Log(title = "数据项", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, MdDataItem mdDataItem)
+    {
+        List<MdDataItem> list = mdDataItemService.selectMdDataItemList(mdDataItem);
+        ExcelUtil<MdDataItem> util = new ExcelUtil<MdDataItem>(MdDataItem.class);
+        util.exportExcel(response, list, "数据项数据");
+    }
+
+    /**
+     * 获取数据项详细信息
+     */
+    @GetMapping(value = "/{dataId}")
+    public AjaxResult getInfo(@PathVariable("dataId") String dataId)
+    {
+        return success(mdDataItemService.selectMdDataItemByDataId(dataId));
+    }
+
+    /**
+     * 新增数据项
+     */
+    @Log(title = "数据项", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody MdDataItem mdDataItem)
+    {
+        return toAjax(mdDataItemService.insertMdDataItem(mdDataItem));
+    }
+
+    /**
+     * 修改数据项
+     */
+    @Log(title = "数据项", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody MdDataItem mdDataItem)
+    {
+        return toAjax(mdDataItemService.updateMdDataItem(mdDataItem));
+    }
+
+    /**
+     * 删除数据项
+     */
+    @Log(title = "数据项", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{dataIds}")
+    public AjaxResult remove(@PathVariable String[] dataIds)
+    {
+        return toAjax(mdDataItemService.deleteMdDataItemByDataIds(dataIds));
+    }
+}

+ 1 - 1
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/controller/PtServiceController.java

@@ -77,7 +77,7 @@ public class PtServiceController extends BaseController {
         }
         return AjaxResult.success();
     }
-
+    
     @ApiOperation("数据列表")
     @RequestMapping(value = "/cate_list", method = RequestMethod.GET)
     public List<SysCate> list(String tabName) {

+ 190 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/domain/MdDataItem.java

@@ -0,0 +1,190 @@
+package com.ruoyi.interfaces.domain;
+
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 数据项对象 md_data_item
+ *
+ * @author ruoyi
+ * @date 2025-07-25
+ */
+public class MdDataItem extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 序号
+     */
+    private String dataId;
+
+    /**
+     * 数据项分类序号
+     */
+    @Excel(name = "数据项分类序号")
+    private String cateId;
+
+    /**
+     * 字段名称
+     */
+    @Excel(name = "字段名称")
+    private String itemName;
+
+    /**
+     * 英文名称
+     */
+    @Excel(name = "英文名称")
+    private String itemEn;
+
+    /**
+     * 字段数据项类型
+     */
+    @Excel(name = "字段数据项类型")
+    private String itemTp;
+
+    /**
+     * 字段数据类型
+     */
+    @Excel(name = "字段数据类型")
+    private String itemDataTp;
+
+    /**
+     * 默认值
+     */
+    @Excel(name = "默认值")
+    private String itemDefaultVal;
+
+    /**
+     * 数据单位
+     */
+    @Excel(name = "数据单位")
+    private String itemUnit;
+
+    /**
+     * 备注
+     */
+    @Excel(name = "备注")
+    private String itemNotes;
+
+    /**
+     * 编辑时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "编辑时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date modifyby;
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date createby;
+
+    public Date getCreateby() {
+        return createby;
+    }
+
+    public void setCreateby(Date createby) {
+        this.createby = createby;
+    }
+
+    public void setDataId(String dataId) {
+        this.dataId = dataId;
+    }
+
+    public String getDataId() {
+        return dataId;
+    }
+
+    public void setCateId(String cateId) {
+        this.cateId = cateId;
+    }
+
+    public String getCateId() {
+        return cateId;
+    }
+
+    public void setItemName(String itemName) {
+        this.itemName = itemName;
+    }
+
+    public String getItemName() {
+        return itemName;
+    }
+
+    public void setItemEn(String itemEn) {
+        this.itemEn = itemEn;
+    }
+
+    public String getItemEn() {
+        return itemEn;
+    }
+
+    public void setItemTp(String itemTp) {
+        this.itemTp = itemTp;
+    }
+
+    public String getItemTp() {
+        return itemTp;
+    }
+
+    public void setItemDataTp(String itemDataTp) {
+        this.itemDataTp = itemDataTp;
+    }
+
+    public String getItemDataTp() {
+        return itemDataTp;
+    }
+
+    public void setItemDefaultVal(String itemDefaultVal) {
+        this.itemDefaultVal = itemDefaultVal;
+    }
+
+    public String getItemDefaultVal() {
+        return itemDefaultVal;
+    }
+
+    public void setItemUnit(String itemUnit) {
+        this.itemUnit = itemUnit;
+    }
+
+    public String getItemUnit() {
+        return itemUnit;
+    }
+
+    public void setItemNotes(String itemNotes) {
+        this.itemNotes = itemNotes;
+    }
+
+    public String getItemNotes() {
+        return itemNotes;
+    }
+
+    public void setModifyby(Date modifyby) {
+        this.modifyby = modifyby;
+    }
+
+    public Date getModifyby() {
+        return modifyby;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("dataId", getDataId())
+                .append("cateId", getCateId())
+                .append("itemName", getItemName())
+                .append("itemEn", getItemEn())
+                .append("itemTp", getItemTp())
+                .append("itemDataTp", getItemDataTp())
+                .append("itemDefaultVal", getItemDefaultVal())
+                .append("itemUnit", getItemUnit())
+                .append("itemNotes", getItemNotes())
+                .append("createby", getCreateby())
+                .append("modifyby", getModifyby())
+                .toString();
+    }
+}

+ 65 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/mapper/MdDataItemMapper.java

@@ -0,0 +1,65 @@
+package com.ruoyi.interfaces.mapper;
+
+import java.util.List;
+
+import com.ruoyi.common.annotation.DataSource;
+import com.ruoyi.common.enums.DataSourceType;
+import com.ruoyi.interfaces.domain.MdDataItem;
+
+/**
+ * 数据项Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2025-07-25
+ */
+@DataSource(DataSourceType.SLAVE)
+public interface MdDataItemMapper 
+{
+    /**
+     * 查询数据项
+     * 
+     * @param dataId 数据项主键
+     * @return 数据项
+     */
+    public MdDataItem selectMdDataItemByDataId(String dataId);
+
+    /**
+     * 查询数据项列表
+     * 
+     * @param mdDataItem 数据项
+     * @return 数据项集合
+     */
+    public List<MdDataItem> selectMdDataItemList(MdDataItem mdDataItem);
+
+    /**
+     * 新增数据项
+     * 
+     * @param mdDataItem 数据项
+     * @return 结果
+     */
+    public int insertMdDataItem(MdDataItem mdDataItem);
+
+    /**
+     * 修改数据项
+     * 
+     * @param mdDataItem 数据项
+     * @return 结果
+     */
+    public int updateMdDataItem(MdDataItem mdDataItem);
+
+    /**
+     * 删除数据项
+     * 
+     * @param dataId 数据项主键
+     * @return 结果
+     */
+    public int deleteMdDataItemByDataId(String dataId);
+
+    /**
+     * 批量删除数据项
+     * 
+     * @param dataIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteMdDataItemByDataIds(String[] dataIds);
+}

+ 61 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/IMdDataItemService.java

@@ -0,0 +1,61 @@
+package com.ruoyi.interfaces.service;
+
+import java.util.List;
+import com.ruoyi.interfaces.domain.MdDataItem;
+
+/**
+ * 数据项Service接口
+ * 
+ * @author ruoyi
+ * @date 2025-07-25
+ */
+public interface IMdDataItemService 
+{
+    /**
+     * 查询数据项
+     * 
+     * @param dataId 数据项主键
+     * @return 数据项
+     */
+    public MdDataItem selectMdDataItemByDataId(String dataId);
+
+    /**
+     * 查询数据项列表
+     * 
+     * @param mdDataItem 数据项
+     * @return 数据项集合
+     */
+    public List<MdDataItem> selectMdDataItemList(MdDataItem mdDataItem);
+
+    /**
+     * 新增数据项
+     * 
+     * @param mdDataItem 数据项
+     * @return 结果
+     */
+    public int insertMdDataItem(MdDataItem mdDataItem);
+
+    /**
+     * 修改数据项
+     * 
+     * @param mdDataItem 数据项
+     * @return 结果
+     */
+    public int updateMdDataItem(MdDataItem mdDataItem);
+
+    /**
+     * 批量删除数据项
+     * 
+     * @param dataIds 需要删除的数据项主键集合
+     * @return 结果
+     */
+    public int deleteMdDataItemByDataIds(String[] dataIds);
+
+    /**
+     * 删除数据项信息
+     * 
+     * @param dataId 数据项主键
+     * @return 结果
+     */
+    public int deleteMdDataItemByDataId(String dataId);
+}

+ 99 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/impl/MdDataItemServiceImpl.java

@@ -0,0 +1,99 @@
+package com.ruoyi.interfaces.service.impl;
+
+import java.util.List;
+
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.uuid.IdUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.interfaces.mapper.MdDataItemMapper;
+import com.ruoyi.interfaces.domain.MdDataItem;
+import com.ruoyi.interfaces.service.IMdDataItemService;
+
+/**
+ * 数据项Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2025-07-25
+ */
+@Service
+public class MdDataItemServiceImpl implements IMdDataItemService 
+{
+    @Autowired
+    private MdDataItemMapper mdDataItemMapper;
+
+    /**
+     * 查询数据项
+     * 
+     * @param dataId 数据项主键
+     * @return 数据项
+     */
+    @Override
+    public MdDataItem selectMdDataItemByDataId(String dataId)
+    {
+        return mdDataItemMapper.selectMdDataItemByDataId(dataId);
+    }
+
+    /**
+     * 查询数据项列表
+     * 
+     * @param mdDataItem 数据项
+     * @return 数据项
+     */
+    @Override
+    public List<MdDataItem> selectMdDataItemList(MdDataItem mdDataItem)
+    {
+        return mdDataItemMapper.selectMdDataItemList(mdDataItem);
+    }
+
+    /**
+     * 新增数据项
+     * 
+     * @param mdDataItem 数据项
+     * @return 结果
+     */
+    @Override
+    public int insertMdDataItem(MdDataItem mdDataItem)
+    {
+        mdDataItem.setDataId(IdUtils.fastUUID());
+        mdDataItem.setCreateby(DateUtils.getNowDate());
+        return mdDataItemMapper.insertMdDataItem(mdDataItem);
+    }
+
+    /**
+     * 修改数据项
+     * 
+     * @param mdDataItem 数据项
+     * @return 结果
+     */
+    @Override
+    public int updateMdDataItem(MdDataItem mdDataItem)
+    {
+        mdDataItem.setModifyby(DateUtils.getNowDate());
+        return mdDataItemMapper.updateMdDataItem(mdDataItem);
+    }
+
+    /**
+     * 批量删除数据项
+     * 
+     * @param dataIds 需要删除的数据项主键
+     * @return 结果
+     */
+    @Override
+    public int deleteMdDataItemByDataIds(String[] dataIds)
+    {
+        return mdDataItemMapper.deleteMdDataItemByDataIds(dataIds);
+    }
+
+    /**
+     * 删除数据项信息
+     * 
+     * @param dataId 数据项主键
+     * @return 结果
+     */
+    @Override
+    public int deleteMdDataItemByDataId(String dataId)
+    {
+        return mdDataItemMapper.deleteMdDataItemByDataId(dataId);
+    }
+}

+ 103 - 0
ruoyi-api-patform/src/main/resources/mapper/interfaces/MdDataItemMapper.xml

@@ -0,0 +1,103 @@
+<?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.ruoyi.interfaces.mapper.MdDataItemMapper">
+
+    <resultMap type="com.ruoyi.interfaces.domain.MdDataItem" id="MdDataItemResult">
+        <result property="dataId"    column="DATA_ID"    />
+        <result property="cateId"    column="CATE_ID"    />
+        <result property="itemName"    column="ITEM_NAME"    />
+        <result property="itemEn"    column="ITEM_EN"    />
+        <result property="itemTp"    column="ITEM_TP"    />
+        <result property="itemDataTp"    column="ITEM_DATA_TP"    />
+        <result property="itemDefaultVal"    column="ITEM_DEFAULT_VAL"    />
+        <result property="itemUnit"    column="ITEM_UNIT"    />
+        <result property="itemNotes"    column="ITEM_NOTES"    />
+        <result property="createby"    column="CREATEBY"    />
+        <result property="modifyby"    column="MODIFYBY"    />
+    </resultMap>
+
+    <sql id="selectMdDataItemVo">
+        select DATA_ID, CATE_ID, ITEM_NAME, ITEM_EN, ITEM_TP, ITEM_DATA_TP, ITEM_DEFAULT_VAL, ITEM_UNIT, ITEM_NOTES, CREATEBY, MODIFYBY from md_data_item
+    </sql>
+
+    <select id="selectMdDataItemList" parameterType="com.ruoyi.interfaces.domain.MdDataItem" resultMap="MdDataItemResult">
+        <include refid="selectMdDataItemVo"/>
+        <where>
+            <if test="cateId != null  and cateId != ''"> and CATE_ID = #{cateId}</if>
+            <if test="itemName != null  and itemName != ''"> and ITEM_NAME like concat('%', #{itemName}, '%')</if>
+            <if test="itemEn != null  and itemEn != ''"> and ITEM_EN = #{itemEn}</if>
+            <if test="itemTp != null  and itemTp != ''"> and ITEM_TP = #{itemTp}</if>
+            <if test="itemDataTp != null  and itemDataTp != ''"> and ITEM_DATA_TP = #{itemDataTp}</if>
+            <if test="itemDefaultVal != null  and itemDefaultVal != ''"> and ITEM_DEFAULT_VAL = #{itemDefaultVal}</if>
+            <if test="itemUnit != null  and itemUnit != ''"> and ITEM_UNIT = #{itemUnit}</if>
+            <if test="itemNotes != null  and itemNotes != ''"> and ITEM_NOTES = #{itemNotes}</if>
+            <if test="createby != null "> and CREATEBY = #{createby}</if>
+            <if test="modifyby != null "> and MODIFYBY = #{modifyby}</if>
+        </where>
+    </select>
+
+    <select id="selectMdDataItemByDataId" parameterType="String" resultMap="MdDataItemResult">
+        <include refid="selectMdDataItemVo"/>
+        where DATA_ID = #{dataId}
+    </select>
+
+    <insert id="insertMdDataItem" parameterType="com.ruoyi.interfaces.domain.MdDataItem">
+        insert into md_data_item
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="dataId != null">DATA_ID,</if>
+            <if test="cateId != null">CATE_ID,</if>
+            <if test="itemName != null">ITEM_NAME,</if>
+            <if test="itemEn != null">ITEM_EN,</if>
+            <if test="itemTp != null">ITEM_TP,</if>
+            <if test="itemDataTp != null">ITEM_DATA_TP,</if>
+            <if test="itemDefaultVal != null">ITEM_DEFAULT_VAL,</if>
+            <if test="itemUnit != null">ITEM_UNIT,</if>
+            <if test="itemNotes != null">ITEM_NOTES,</if>
+            <if test="createby != null">CREATEBY,</if>
+            <if test="modifyby != null">MODIFYBY,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="dataId != null">#{dataId},</if>
+            <if test="cateId != null">#{cateId},</if>
+            <if test="itemName != null">#{itemName},</if>
+            <if test="itemEn != null">#{itemEn},</if>
+            <if test="itemTp != null">#{itemTp},</if>
+            <if test="itemDataTp != null">#{itemDataTp},</if>
+            <if test="itemDefaultVal != null">#{itemDefaultVal},</if>
+            <if test="itemUnit != null">#{itemUnit},</if>
+            <if test="itemNotes != null">#{itemNotes},</if>
+            <if test="createby != null">#{createby},</if>
+            <if test="modifyby != null">#{modifyby},</if>
+        </trim>
+    </insert>
+
+    <update id="updateMdDataItem" parameterType="com.ruoyi.interfaces.domain.MdDataItem">
+        update md_data_item
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="cateId != null">CATE_ID = #{cateId},</if>
+            <if test="itemName != null">ITEM_NAME = #{itemName},</if>
+            <if test="itemEn != null">ITEM_EN = #{itemEn},</if>
+            <if test="itemTp != null">ITEM_TP = #{itemTp},</if>
+            <if test="itemDataTp != null">ITEM_DATA_TP = #{itemDataTp},</if>
+            <if test="itemDefaultVal != null">ITEM_DEFAULT_VAL = #{itemDefaultVal},</if>
+            <if test="itemUnit != null">ITEM_UNIT = #{itemUnit},</if>
+            <if test="itemNotes != null">ITEM_NOTES = #{itemNotes},</if>
+            <if test="createby != null">CREATEBY = #{createby},</if>
+            <if test="modifyby != null">MODIFYBY = #{modifyby},</if>
+        </trim>
+        where DATA_ID = #{dataId}
+    </update>
+
+    <delete id="deleteMdDataItemByDataId" parameterType="String">
+        delete from md_data_item where DATA_ID = #{dataId}
+    </delete>
+
+    <delete id="deleteMdDataItemByDataIds" parameterType="String">
+        delete from md_data_item where DATA_ID in
+        <foreach item="dataId" collection="array" open="(" separator="," close=")">
+            #{dataId}
+        </foreach>
+    </delete>
+</mapper>