ard-work/src/main/java/com/ruoyi/alarmpoints/well/controller/ArdAlarmpointsWellController.java
@@ -91,8 +91,8 @@ public AjaxResult add(@RequestBody ArdAlarmpointsWell ardAlarmpointsWell) { try { return toAjax(ardAlarmpointsWellService.insertArdAlarmpointsWell(ardAlarmpointsWell)); } catch (DuplicateKeyException e) { return AjaxResult.error("井号重复"); } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } @@ -105,9 +105,9 @@ @ApiOperation("修改井") public AjaxResult edit(@RequestBody ArdAlarmpointsWell ardAlarmpointsWell) { try { return toAjax(ardAlarmpointsWellService.updateArdAlarmpointsWell(ardAlarmpointsWell)); } catch (DuplicateKeyException e) { return AjaxResult.error("井号重复"); return toAjax(ardAlarmpointsWellService.updateArdAlarmpointsWell(ardAlarmpointsWell)); } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } ard-work/src/main/java/com/ruoyi/alarmpoints/well/mapper/ArdAlarmpointsWellMapper.java
@@ -1,25 +1,26 @@ package com.ruoyi.alarmpoints.well.mapper; import java.util.List; import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell; import com.ruoyi.common.annotation.DataScope; /** * 井管理Mapper接口 * * * @author 刘苏义 * @date 2023-03-07 */ public interface ArdAlarmpointsWellMapper { public interface ArdAlarmpointsWellMapper { /** * 查询井管理 * * * @param id 井管理主键 * @return 井管理 */ public ArdAlarmpointsWell selectArdAlarmpointsWellById(String id); /** * 查询井管理 * @@ -27,6 +28,7 @@ * @return 井管理 */ public ArdAlarmpointsWell selectArdAlarmpointsWellByWellId(String wellId); /** * 查询井管理 * @@ -34,9 +36,10 @@ * @return */ public List selectArdAlarmpointsWellByWellIdLike(ArdAlarmpointsWell ardAlarmpointsWell); /** * 查询井管理列表 * * * @param ardAlarmpointsWell 井管理 * @return 井管理集合 */ @@ -44,7 +47,7 @@ /** * 新增井管理 * * * @param ardAlarmpointsWell 井管理 * @return 结果 */ @@ -52,7 +55,7 @@ /** * 修改井管理 * * * @param ardAlarmpointsWell 井管理 * @return 结果 */ @@ -60,7 +63,7 @@ /** * 删除井管理 * * * @param id 井管理主键 * @return 结果 */ @@ -68,9 +71,19 @@ /** * 批量删除井管理 * * * @param ids 需要删除的数据主键集合 * @return 结果 */ public int deleteArdAlarmpointsWellByIds(String[] ids); /** * 核对井号是否唯一 * * @param wellId 需要核对的井号 * @return 结果 */ public boolean checkWellIdExists(String wellId); } ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java
@@ -13,10 +13,12 @@ import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.bean.BeanValidators; import com.ruoyi.common.utils.spring.SpringUtils; import lombok.ToString; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.validation.Validator; @@ -85,7 +87,13 @@ * @return 结果 */ @Override @Transactional public int insertArdAlarmpointsWell(ArdAlarmpointsWell ardAlarmpointsWell) { boolean wellIdExists = ardAlarmpointsWellMapper.checkWellIdExists(ardAlarmpointsWell.getWellId()); if(wellIdExists) { throw new RuntimeException("井号已存在"); } ardAlarmpointsWell.setUserId(SecurityUtils.getUserId()); ardAlarmpointsWell.setCreateBy(SecurityUtils.getUsername()); ardAlarmpointsWell.setCreateTime(DateUtils.getNowDate()); @@ -99,7 +107,13 @@ * @return 结果 */ @Override @Transactional public int updateArdAlarmpointsWell(ArdAlarmpointsWell ardAlarmpointsWell) { boolean wellIdExists = ardAlarmpointsWellMapper.checkWellIdExists(ardAlarmpointsWell.getWellId()); if(wellIdExists) { throw new RuntimeException("井号已存在"); } ardAlarmpointsWell.setUpdateBy(SecurityUtils.getUsername()); ardAlarmpointsWell.setUpdateTime(DateUtils.getNowDate()); return ardAlarmpointsWellMapper.updateArdAlarmpointsWell(ardAlarmpointsWell); ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml
@@ -66,18 +66,21 @@ <where> <if test="wellId != null and wellId != ''">and c.well_id = #{wellId}</if> <if test="wellNumber != null and wellNumber != ''">and c.well_number = #{wellNumber}</if> <if test="userId != null and userId != ''"> and c.user_id = #{userId}</if> <if test="deptId != null "> and (c.dept_id = #{deptId} OR c.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE cast(#{deptId} as varchar) = any(string_to_array(ancestors,',')) ))</if> <if test="userId != null and userId != ''">and c.user_id = #{userId}</if> <if test="deptId != null ">and (c.dept_id = #{deptId} OR c.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE cast(#{deptId} as varchar) = any(string_to_array(ancestors,',')) )) </if> <!-- 数据范围过滤 --> ${params.dataScope} </where> </select> <select id="selectArdAlarmpointsWellByWellIdLike" parameterType="ArdAlarmpointsWell" resultMap="ArdAlarmpointsWellResult"> <select id="selectArdAlarmpointsWellByWellIdLike" parameterType="ArdAlarmpointsWell" resultMap="ArdAlarmpointsWellResult"> <include refid="selectArdAlarmpointsWellVo"/> <where> <if test="id != null and id != ''">and c.id = #{id}</if> <if test="wellId != null and wellId != ''"> and well_id like ('%${wellId}%')</if> <if test="wellId != null and wellId != ''">and well_id like ('%${wellId}%')</if> <!-- 数据范围过滤 --> ${params.dataScope} </where> @@ -174,7 +177,7 @@ <if test="updateTime != null">update_time = #{updateTime},</if> <if test="cameraId != null">camera_id = #{cameraId},</if> </trim> where id = #{id} where id = #{id} </update> <delete id="deleteArdAlarmpointsWellById" parameterType="String"> @@ -189,4 +192,9 @@ #{id} </foreach> </delete> <select id="checkWellIdExists" resultType="boolean"> SELECT COUNT(*) FROM ard_alarmpoints_well WHERE well_id = #{wellId} </select> </mapper>