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()); } } @@ -106,8 +106,8 @@ public AjaxResult edit(@RequestBody ArdAlarmpointsWell ardAlarmpointsWell) { try { return toAjax(ardAlarmpointsWellService.updateArdAlarmpointsWell(ardAlarmpointsWell)); } catch (DuplicateKeyException e) { return AjaxResult.error("井号重复"); } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } ard-work/src/main/java/com/ruoyi/alarmpoints/well/mapper/ArdAlarmpointsWellMapper.java
@@ -1,6 +1,7 @@ package com.ruoyi.alarmpoints.well.mapper; import java.util.List; import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell; import com.ruoyi.common.annotation.DataScope; @@ -11,8 +12,7 @@ * @author 刘苏义 * @date 2023-03-07 */ public interface ArdAlarmpointsWellMapper { public interface ArdAlarmpointsWellMapper { /** * 查询井管理 * @@ -20,6 +20,7 @@ * @return 井管理 */ public ArdAlarmpointsWell selectArdAlarmpointsWellById(String id); /** * 查询井管理 * @@ -27,6 +28,7 @@ * @return 井管理 */ public ArdAlarmpointsWell selectArdAlarmpointsWellByWellId(String wellId); /** * 查询井管理 * @@ -34,6 +36,7 @@ * @return */ public List selectArdAlarmpointsWellByWellIdLike(ArdAlarmpointsWell ardAlarmpointsWell); /** * 查询井管理列表 * @@ -73,4 +76,14 @@ * @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
@@ -67,13 +67,16 @@ <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="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> @@ -189,4 +192,9 @@ #{id} </foreach> </delete> <select id="checkWellIdExists" resultType="boolean"> SELECT COUNT(*) FROM ard_alarmpoints_well WHERE well_id = #{wellId} </select> </mapper>