Przeglądaj źródła

新增 获取阀门未配置的水肥要素接口

zhaiyifei 8 miesięcy temu
rodzic
commit
c66a03db42

+ 24 - 4
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/controller/IotDeviceSfController.java

@@ -105,7 +105,7 @@ public class IotDeviceSfController extends BaseController {
     }
 
     /**
-     * 新增泵类要素
+     * 新增要素
      * 该接口用于添加新的泵类要素,接收相关参数并调用通用设备功能服务进行处理。
      *
      * @param reqVo 包含设备添加请求的参数,包括设备标识(devBid)等
@@ -113,12 +113,12 @@ public class IotDeviceSfController extends BaseController {
      * @throws ValidateException 如果设备标识(devBid)无效,则抛出ValidateException异常
      */
     @Transactional(rollbackFor = Exception.class)
-    @PostMapping("/pump/add")
-    public AjaxResult pumpAdd(@RequestBody IotSfElementfactorAddReqVo reqVo){
+    @PostMapping("/ele/add")
+    public AjaxResult elementAdd(@RequestBody IotSfElementfactorAddReqVo reqVo){
         ValidateUtil.validateDevBid(reqVo.getDevBid());
         IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
         iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
-        iotDeviceBaseFunReqVo.setMethodName("pumpAdd");
+        iotDeviceBaseFunReqVo.setMethodName("elementAdd");
         iotDeviceBaseFunReqVo.setParam(reqVo);
         int status = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
         return toAjax(status);
@@ -160,6 +160,25 @@ public class IotDeviceSfController extends BaseController {
         return iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
     }
 
+
+    /**
+     * 获取灌区设备已存在的元素列表
+     * 该接口用于根据请求参数获取已存在的元素列表,并返回相关数据。
+     *
+     * @param reqVo 请求参数,包含设备标识devBid等信息
+     * @return 返回TableDataInfo对象,包含元素列表数据
+     * @throws IllegalArgumentException 如果reqVo中的devBid为空,则抛出异常
+     */
+    @GetMapping("/group/already/list")
+    public TableDataInfo getGroupAlreadyElementList(IotSfElementfactorListReqVo reqVo){
+        ValidateUtil.validateDevBid(reqVo.getDevBid());
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("getGroupAlreadyElementList");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        return iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+    }
+
     /**
      * 获取未配置的电磁阀元素列表
      *
@@ -176,4 +195,5 @@ public class IotDeviceSfController extends BaseController {
         iotDeviceBaseFunReqVo.setParam(reqVo);
         return iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
     }
+
 }

+ 67 - 3
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/service/IIotSfCommService.java

@@ -107,12 +107,12 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
     }
 
     /**
-     * 新增泵类要素
+     * 新增要素
      * 该接口用于添加新的泵类要素,接收相关参数并调用通用设备功能服务进行处理。
      *
      * @param reqVo 包含设备添加请求的参数,包括设备标识(devBid)等
      */
-    public int pumpAdd(IotSfElementfactorAddReqVo reqVo) {
+    public int elementAdd(IotSfElementfactorAddReqVo reqVo) {
         String devBid = reqVo.getDevBid();
         if (StringUtils.isEmpty(devBid)) {
             throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
@@ -141,7 +141,7 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
 
         IotSfElementfactorListReqVo reqVo1 = new IotSfElementfactorListReqVo();
         reqVo1.setDevBid(devBid);
-        List<IotSfElementfactor> elementList = iotSfElementfactorService.selectIotSfElementfactorListByPump(reqVo1);
+        List<IotSfElementfactor> elementList = iotSfElementfactorService.selectIotSfElementfactorList(reqVo1);
         Set<String> sfCodeSet = new HashSet<>();
         for (IotSfElementfactor element : elementList) {
             if(StringUtils.isNotEmpty(element.getSfCode())){
@@ -188,6 +188,38 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
     }
 
     /**
+     * 获取灌区设备已存在的元素列表
+     *
+     * @param reqVo 请求对象,包含设备标识等信息
+     * @return TableDataInfo 包含响应码、消息、数据和总数
+     * @throws IotBizException 抛出业务异常,包含错误码和错误信息
+     */
+    public TableDataInfo getGroupAlreadyElementList(IotSfElementfactorListReqVo reqVo) {
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(ErrorCode.SUCCESS.getCode());
+        rspData.setMsg(ErrorCode.SUCCESS.getMessage());
+        rspData.setData(new ArrayList<>());
+        rspData.setTotal(0);
+
+        String devBid = reqVo.getDevBid();
+        if (StringUtils.isEmpty(devBid)) {
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
+        }
+
+        IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
+        if (findDevice == null) {
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
+        }
+
+        List<IotSfElementfactorAlreadyListResVo> resVoList = iotSfElementfactorService.getGroupAlreadyElementList(reqVo);
+        if (resVoList != null && !resVoList.isEmpty()){
+            rspData.setData(resVoList);
+            rspData.setTotal(resVoList.size());
+        }
+        return rspData;
+    }
+
+    /**
      * 获取未配置的电磁阀元素列表
      *
      * @param reqVo 请求参数,包含设备标识(devBid)等筛选条件
@@ -207,4 +239,36 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
         return null;
     }
 
+    /**
+     * 获取灌区设备已存在的元素列表
+     *
+     * @param reqVo 请求对象,包含设备标识等信息
+     * @return TableDataInfo 包含响应码、消息、数据和总数
+     * @throws IotBizException 抛出业务异常,包含错误码和错误信息
+     */
+    public TableDataInfo getValveAlreadyElementList(IotSfElementfactorListReqVo reqVo) {
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(ErrorCode.SUCCESS.getCode());
+        rspData.setMsg(ErrorCode.SUCCESS.getMessage());
+        rspData.setData(new ArrayList<>());
+        rspData.setTotal(0);
+
+        String devBid = reqVo.getDevBid();
+        if (StringUtils.isEmpty(devBid)) {
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
+        }
+
+        IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
+        if (findDevice == null) {
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
+        }
+
+        List<IotSfElementfactorAlreadyListResVo> resVoList = iotSfElementfactorService.getValveAlreadyElementList(reqVo);
+        if (resVoList != null && !resVoList.isEmpty()){
+            rspData.setData(resVoList);
+            rspData.setTotal(resVoList.size());
+        }
+        return rspData;
+    }
+
 }

+ 16 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/IIotSfElementfactorService.java

@@ -83,5 +83,21 @@ public interface IIotSfElementfactorService {
      */
 
     public List<IotSfElementfactorAlreadyListResVo> getPumpAlreadyElementList(IotSfElementfactorListReqVo reqVo);
+
+    /**
+     * 查询灌区已配置要素列表
+     * @param reqVo
+     * @return
+     */
+
+    public List<IotSfElementfactorAlreadyListResVo> getGroupAlreadyElementList(IotSfElementfactorListReqVo reqVo);
+
+    /**
+     * 查询电磁阀已配置要素列表
+     * @param reqVo
+     * @return
+     */
+
+    public List<IotSfElementfactorAlreadyListResVo> getValveAlreadyElementList(IotSfElementfactorListReqVo reqVo);
 }
 

+ 29 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotSfElementfactorServiceImpl.java

@@ -169,4 +169,33 @@ public class IotSfElementfactorServiceImpl implements IIotSfElementfactorService
         List<IotSfElementfactor> elementfactorList = selectIotSfElementfactorListByPump(reqVo);
         return getAlreadyElementList(elementfactorList);
     }
+
+    /**
+     * 查询灌区已配置要素列表
+     *
+     * @param reqVo
+     * @return
+     */
+    @Override
+    public List<IotSfElementfactorAlreadyListResVo> getGroupAlreadyElementList(IotSfElementfactorListReqVo reqVo) {
+        List<String> sfTypeList = new ArrayList<>();
+        sfTypeList.add(EnumSfElementType.GROUP.getCode());
+        sfTypeList.add(EnumSfElementType.SOLENOID_VALVE.getCode());
+        reqVo.setSfTypeList(sfTypeList);
+
+        List<IotSfElementfactor> elementfactorList = selectIotSfElementfactorList(reqVo);
+        return getAlreadyElementList(elementfactorList);
+    }
+
+    /**
+     * 查询电磁阀已配置要素列表
+     *
+     * @param reqVo
+     * @return
+     */
+    @Override
+    public List<IotSfElementfactorAlreadyListResVo> getValveAlreadyElementList(IotSfElementfactorListReqVo reqVo) {
+        List<IotSfElementfactor> elementfactorList = selectIotSfElementfactorListByValve(reqVo);
+        return getAlreadyElementList(elementfactorList);
+    }
 }

+ 3 - 3
src/main/resources/mapper/IotSfElementfactorMapper.xml

@@ -6,19 +6,19 @@
 
     <select id="selectIotSfElementfactorList" parameterType="com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfElementfactorListReqVo"
             resultType="com.yunfeiyun.agmp.iot.common.domain.IotSfElementfactor" >
-        SELECT sf.id, sf.sfBid, sf.sfType, sf.sfCode, sf.sfName, sf.sfDisplayname, sf.sfParentBid, sf.sfSequence,
+        SELECT sf.id, sf.sfBid, sf.devBid, sf.sfType, sf.sfCode, sf.sfName, sf.sfDisplayname, sf.sfParentBid, sf.sfSequence,
             sf.tid, sf.sfCreatedDate, sf.sfCreator, sf.sfModifieddate, sf.sfModifier
         FROM IotSfElementfactor AS sf
         <where>
-            tid = #{tid}
+            sf.tid = #{tid}
             <if test="sfBid!= null and sfBid!= ''"> and sf.sfBid = #{sfBid}</if>
             <if test="sfType!= null and sfType!= ''"> and sf.sfType = #{sfType}</if>
+            <if test="devBid != null and devBid != ''"> and sf.devBid = #{devBid}</if>
             <if test="sfCode!= null and sfCode!= ''"> and sf.sfCode = #{sfCode}</if>
             <if test="sfName!= null and sfName!= ''"> and sf.sfName like concat('%', #{sfName}, '%')</if>
             <if test="sfDisplayname!= null and sfDisplayname!= ''"> and sf.sfDisplayname like concat('%', #{sfDisplayname}, '%')</if>
             <if test="sfParentBid!= null and sfParentBid!= ''"> and sf.sfParentBid = #{sfParentBid}</if>
             <if test="sfSequence!= null and sfSequence!= ''"> and sf.sfSequence = #{sfSequence}</if>
-            <if test="tid!= null and tid!= ''"> and sf.tid = #{tid}</if>
             <if test="sfCreatedDate!= null and sfCreatedDate!= ''"> and sf.sfCreatedDate = #{sfCreatedDate}</if>
             <if test="sfCreator!= null and sfCreator!= ''"> and sf.sfCreator = #{sfCreator}</if>
             <if test="sfModifieddate!= null and sfModifieddate!= ''"> and sf.sfModifieddate = #{sfModifieddate}</if>