zhitan-admin/src/main/java/com/zhitan/web/controller/model/DaqTemplateController.java
@@ -70,9 +70,12 @@ boolean isExist = daqTemplateService.dapHasExist(daqTemplate.getCode(), daqTemplate.getDeviceType()); if (isExist) { return AjaxResult.error("相同设备类型下的参数编码不能重复!"); } else { return toAjax(daqTemplateService.insertDaqTemplate(daqTemplate)); } boolean isCodeExist = daqTemplateService.dapCodeHasExist(daqTemplate.getGatewayKey(), daqTemplate.getDeviceType()); if (isCodeExist) { return AjaxResult.error("相同设备类型下的采集参数编码不能重复!"); } return toAjax(daqTemplateService.insertDaqTemplate(daqTemplate)); } /** @@ -85,11 +88,13 @@ boolean isExist = daqTemplateService.dapHasExist(daqTemplate); if (isExist) { return AjaxResult.error("相同设备类型下的参数编码不能重复!"); } else { return toAjax(daqTemplateService.updateDaqTemplate(daqTemplate)); } boolean isCodeExist = daqTemplateService.dapCodeHasExist(daqTemplate); if (isCodeExist) { return AjaxResult.error("相同设备类型下的采集参数编码不能重复!"); } return toAjax(daqTemplateService.updateDaqTemplate(daqTemplate)); } /** * 删除采集参数模板 */ zhitan-system/src/main/java/com/zhitan/model/domain/DaqTemplate.java
@@ -25,6 +25,8 @@ @Excel(name = "参数编码") private String code; @Excel(name = "采集编码") private String gatewayKey; /** * 参数名称 */ @@ -90,4 +92,12 @@ public void setUnit(String unit) { this.unit = unit; } public String getGatewayKey() { return gatewayKey; } public void setGatewayKey(String gatewayKey) { this.gatewayKey = gatewayKey; } } zhitan-system/src/main/java/com/zhitan/model/mapper/DaqTemplateMapper.java
@@ -65,6 +65,9 @@ int dapHasExistWhenUpdate(@Param("id") String id, @Param("code") String code, @Param("deviceType") String deviceType); int dapCodeHasExist(@Param("kay") String key, @Param("deviceType") String deviceType); int dapCodeHasExistWhenUpdate(@Param("id") String id, @Param("key") String code, @Param("deviceType") String deviceType); /** * 查询指标模板信息 * zhitan-system/src/main/java/com/zhitan/model/service/IDaqTemplateService.java
@@ -74,6 +74,15 @@ boolean dapHasExist(DaqTemplate daqTemplate); /** * 查询相同设备类型下是否有重复的编码 * * @param code 参数编码 * @param deviceType 设备类型 * @return 是否存在 */ boolean dapCodeHasExist(String code, String deviceType); boolean dapCodeHasExist(DaqTemplate daqTemplate); /** * 查询指标模板 * * @return 结果 zhitan-system/src/main/java/com/zhitan/model/service/impl/DaqTemplateServiceImpl.java
@@ -114,6 +114,17 @@ return count > 0; } @Override public boolean dapCodeHasExist(String key, String deviceType) { int count = daqTemplateMapper.dapHasExist(key, deviceType); return count > 0; } @Override public boolean dapCodeHasExist(DaqTemplate daqTemplate) { int count = daqTemplateMapper.dapHasExistWhenUpdate(daqTemplate.getId(), daqTemplate.getGatewayKey(), daqTemplate.getDeviceType()); return count > 0; } /** * 查询指标模板 * zhitan-system/src/main/resources/mapper/model/DaqTemplateMapper.xml
@@ -10,10 +10,11 @@ <result property="name" column="name"/> <result property="deviceType" column="device_type"/> <result property="unit" column="unit"/> <result property="gatewayKey" column="gateway_key"/> </resultMap> <sql id="selectDaqTemplateVo"> select id, code, name, device_type, unit select id, code, name, device_type, unit, gateway_key from daq_template </sql> @@ -44,6 +45,19 @@ AND device_type = #{deviceType} AND id != #{id} </select> <select id="dapCodeHasExist" resultType="java.lang.Integer"> SELECT COUNT(*) FROM daq_template WHERE gateway_key = #{key} AND device_type = #{deviceType} </select> <select id="dapCodeHasExistWhenUpdate" resultType="java.lang.Integer"> SELECT COUNT(*) FROM daq_template WHERE gateway_key = #{key} AND device_type = #{deviceType} AND id != #{id} </select> <select id="listTemplate" resultType="com.zhitan.model.domain.DaqTemplate"> <include refid="selectDaqTemplateVo"/> </select> @@ -56,6 +70,7 @@ <if test="name != null and name != ''">name,</if> <if test="deviceType != null and deviceType != ''">device_type,</if> <if test="unit != null and unit != ''">unit,</if> <if test="gatewayKey != null and gatewayKey != ''">gateway_key,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null and id != ''">#{id},</if> @@ -63,6 +78,7 @@ <if test="name != null and name != ''">#{name},</if> <if test="deviceType != null and deviceType != ''">#{deviceType},</if> <if test="unit != null and unit != ''">#{unit},</if> <if test="gatewayKey != null and gatewayKey != ''">#{gatewayKey},</if> </trim> </insert> @@ -73,6 +89,7 @@ <if test="name != null and name != ''">name = #{name},</if> <if test="deviceType != null and deviceType != ''">device_type = #{deviceType},</if> <if test="unit != null and unit != ''">unit = #{unit},</if> <if test="gatewayKey != null and gatewayKey != ''">gateway_key = #{gatewayKey},</if> </trim> where id = #{id} </update>