Browse Source

对接调整

车车 1 year ago
parent
commit
dd8a6213af

+ 18 - 0
ktg-iscs/src/main/java/com/ktg/iscs/controller/IsHardwareTypeController.java

@@ -1,6 +1,7 @@
 package com.ktg.iscs.controller;
 
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ktg.common.annotation.Log;
 import com.ktg.common.core.controller.BaseController;
 import com.ktg.common.enums.BusinessType;
@@ -53,6 +54,23 @@ public class IsHardwareTypeController extends BaseController
         return CommonResult.success(BeanUtils.toBean(list, IsHardwareTypeVO.class));
     }
 
+    @ApiOperation("查询硬件类型-分页")
+    @Parameters({
+            @Parameter(name = "page", description = "page"),
+            @Parameter(name = "hardwareTypeName", description = "类型名称"),
+            @Parameter(name = "hardwareTypeName", description = "类型名称"),
+            @Parameter(name = "enableFlag", description = "是否启用(Y-N)")
+    })
+    @GetMapping("/getIsHardwareTypePage")
+    public CommonResult<Page<IsHardwareType>> getIsHardwareTypePage(Page<IsHardwareType> page, GetListDTO getListDTO)
+    {
+        Page<IsHardwareType> result = isHardwareTypeService.page(page, Wrappers.<IsHardwareType>lambdaQuery()
+                .like(StringUtils.isNotBlank(getListDTO.getHardwareTypeName()), IsHardwareType::getHardwareTypeName, getListDTO.getHardwareTypeName())
+                .like(StringUtils.isNotBlank(getListDTO.getHardwareTypeCode()), IsHardwareType::getHardwareTypeCode, getListDTO.getHardwareTypeCode())
+                .eq(StringUtils.isNotBlank(getListDTO.getEnableFlag()), IsHardwareType::getEnableFlag, getListDTO.getEnableFlag()));
+        return CommonResult.success(result);
+    }
+
     /**
      * 导出硬件类型列表
      */

+ 4 - 4
ktg-iscs/src/main/java/com/ktg/iscs/domain/IsHardware.java

@@ -89,22 +89,22 @@ public class IsHardware extends BaseBean
     /** 可用次数 */
     @Schema(description = "可用次数")
     @Excel(name = "可用次数")
-    private Long availableTimes;
+    private Integer availableTimes;
 
     /** 已用次数 */
     @Schema(description = "已用次数")
     @Excel(name = "已用次数")
-    private Long usedTimes;
+    private Integer usedTimes;
 
     /** 可用寿命 */
     @Schema(description = "可用寿命")
     @Excel(name = "可用寿命")
-    private Long availableLife;
+    private Integer availableLife;
 
     /** 已用寿命 */
     @Schema(description = "已用寿命")
     @Excel(name = "已用寿命")
-    private Long usedLife;
+    private Integer usedLife;
 
     /** 删除标志(0代表存在 2代表删除) */
     @Schema(description = "删除标志(0代表存在 2代表删除)")

+ 4 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/IsHardwareType.java

@@ -47,6 +47,10 @@ public class IsHardwareType extends BaseBean
     @Excel(name = "是否启用")
     private String enableFlag;
 
+    @Schema(description = "层级")
+    @Excel(name = "层级")
+    private String level;
+
     /** 删除标志(0代表存在 2代表删除) */
     @Schema(description = "删除标志(0代表存在 2代表删除)")
     private String delFlag;

+ 27 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/dto/hardware/HardwareAutomaticDTO.java

@@ -0,0 +1,27 @@
+package com.ktg.iscs.domain.dto.hardware;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * 更新硬件使用次数/寿命/在线状态
+ *
+ * @author cgj
+ * @date 2024-10-16
+ */
+@Data
+public class HardwareAutomaticDTO
+{
+    @Schema(description = "主键id")
+    private Long id;
+
+    @Schema(description = "硬件状态")
+    private String status;
+
+    @Schema(description = "已用次数")
+    private Integer usedTimes;
+
+    @Schema(description = "已用寿命")
+    private Integer usedLife;
+
+}

+ 9 - 0
ktg-iscs/src/main/java/com/ktg/iscs/service/IIsHardwareService.java

@@ -2,6 +2,7 @@ package com.ktg.iscs.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ktg.iscs.domain.IsHardware;
+import com.ktg.iscs.domain.dto.hardware.HardwareAutomaticDTO;
 
 import java.util.List;
 
@@ -70,4 +71,12 @@ public interface IIsHardwareService extends IService<IsHardware>
      * @return 结果
      */
     String importHardware(List<IsHardware> hardwareList, Boolean isUpdateSupport, String operName);
+
+    /**
+     * 更新硬件使用次数/寿命/在线状态,硬件在使用后或者定时任务更新数据
+     *
+     * @param dto 硬件
+     * @return 结果
+     */
+    Boolean insertIsHardware(HardwareAutomaticDTO dto);
 }

+ 19 - 0
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsHardwareServiceImpl.java

@@ -5,12 +5,14 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ktg.common.core.text.Convert;
 import com.ktg.iscs.domain.IsHardware;
+import com.ktg.iscs.domain.dto.hardware.HardwareAutomaticDTO;
 import com.ktg.iscs.mapper.IsHardwareMapper;
 import com.ktg.iscs.service.IIsHardwareService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -144,4 +146,21 @@ public class IsHardwareServiceImpl extends ServiceImpl<IsHardwareMapper, IsHardw
         }
         return String.format("操作用户:%s,导入完成,成功 %d 条,失败 %d 条。", operName, successCount, failureCount);
     }
+
+    @Override
+    public Boolean insertIsHardware(HardwareAutomaticDTO dto) {
+        // 断言判断
+        Assert.notNull(dto.getId(), "id不可为空!");
+        if (StringUtils.isBlank(dto.getStatus())
+                || dto.getUsedTimes() != null
+                || dto.getUsedLife() != null) {
+            update(Wrappers.<IsHardware>lambdaUpdate()
+                    .eq(IsHardware::getId, dto.getId())
+                    .set(StringUtils.isBlank(dto.getStatus()), IsHardware::getStatus, dto.getStatus())
+                    .set(dto.getUsedTimes() != null, IsHardware::getUsedTimes, dto.getUsedTimes())
+                    .set(dto.getUsedLife() != null, IsHardware::getUsedLife, dto.getUsedLife())
+                    .set(IsHardware::getUpdateTime, new Date()));
+        }
+        return true;
+    }
 }

+ 5 - 3
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsHardwareTypeServiceImpl.java

@@ -67,14 +67,16 @@ public class IsHardwareTypeServiceImpl extends ServiceImpl<IsHardwareTypeMapper,
     @Override
     public int insertIsHardwareType(IsHardwareType isHardwareType)
     {
-        isHardwareType.setHardwareTypeCode(autoCodeUtil.genSerialCode(UserConstants.HARDWARE_TYPE_CODE,null));
-        if(isHardwareType.getParentTypeId()!= null){
+        if (StringUtils.isBlank(isHardwareType.getHardwareTypeCode())) {
+            isHardwareType.setHardwareTypeCode(autoCodeUtil.genSerialCode(UserConstants.HARDWARE_TYPE_CODE,null));
+        }
+        /*if(isHardwareType.getParentTypeId()!= null){
             IsHardwareType parent = getOne(Wrappers.<IsHardwareType>lambdaQuery()
                     .eq(IsHardwareType::getId, isHardwareType.getParentTypeId()));
             if(StringUtils.isNotNull(parent)){
                 isHardwareType.setAncestors(parent.getAncestors()+","+parent.getId());
             }
-        }
+        }*/
         isHardwareType.setCreateTime(DateUtils.getNowDate());
         return isHardwareTypeMapper.insertIsHardwareType(isHardwareType);
     }

+ 16 - 11
ktg-iscs/src/main/resources/mapper/IsHardwareTypeMapper.xml

@@ -1,9 +1,9 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ktg.iscs.mapper.IsHardwareTypeMapper">
-    
+
     <resultMap type="IsHardwareType" id="IsHardwareTypeResult">
         <result property="id"    column="id"    />
         <result property="hardwareTypeCode"    column="hardware_type_code"    />
@@ -17,28 +17,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="createTime"    column="create_time"    />
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
+        <result property="level"    column="level"    />
     </resultMap>
 
     <sql id="selectIsHardwareTypeVo">
-        select id, hardware_type_code, hardware_type_name, parent_type_id, ancestors, enable_flag, remark, del_flag, create_by, create_time, update_by, update_time from is_hardware_type
+        select id, hardware_type_code, hardware_type_name, parent_type_id, ancestors, enable_flag, remark, del_flag, create_by, create_time, update_by, update_time, level from is_hardware_type
     </sql>
 
     <select id="selectIsHardwareTypeList" parameterType="IsHardwareType" resultMap="IsHardwareTypeResult">
         <include refid="selectIsHardwareTypeVo"/>
-        <where>  
+        <where>
             <if test="hardwareTypeCode != null  and hardwareTypeCode != ''"> and hardware_type_code = #{hardwareTypeCode}</if>
             <if test="hardwareTypeName != null  and hardwareTypeName != ''"> and hardware_type_name like concat('%', #{hardwareTypeName}, '%')</if>
             <if test="parentTypeId != null "> and parent_type_id = #{parentTypeId}</if>
             <if test="ancestors != null  and ancestors != ''"> and ancestors = #{ancestors}</if>
             <if test="enableFlag != null  and enableFlag != ''"> and enable_flag = #{enableFlag}</if>
+            <if test="level != null  and level != ''"> and level = #{level}</if>
         </where>
     </select>
-    
+
     <select id="selectIsHardwareTypeById" parameterType="Long" resultMap="IsHardwareTypeResult">
         <include refid="selectIsHardwareTypeVo"/>
         where id = #{id}
     </select>
-        
+
     <insert id="insertIsHardwareType" parameterType="IsHardwareType" useGeneratedKeys="true" keyProperty="id">
         insert into is_hardware_type
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -53,7 +55,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
-         </trim>
+            <if test="level != null">level,</if>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="hardwareTypeCode != null and hardwareTypeCode != ''">#{hardwareTypeCode},</if>
             <if test="hardwareTypeName != null and hardwareTypeName != ''">#{hardwareTypeName},</if>
@@ -66,7 +69,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
-         </trim>
+            <if test="level != null">#{level},</if>
+        </trim>
     </insert>
 
     <update id="updateIsHardwareType" parameterType="IsHardwareType">
@@ -83,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="level != null">level = #{level},</if>
         </trim>
         where id = #{id}
     </update>
@@ -92,9 +97,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteIsHardwareTypeByIds" parameterType="String">
-        delete from is_hardware_type where id in 
+        delete from is_hardware_type where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-</mapper>
+</mapper>