Jelajahi Sumber

修复 水肥机删除灌区异常的问题

zhaiyifei 8 bulan lalu
induk
melakukan
48cd726bd7

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

@@ -145,7 +145,7 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
      * @param reqVo 请求对象,包含了要删除的元素信息
      * @return 返回删除结果,返回值为0表示删除成功,非0表示删除失败
      */
-    public int elementDelete(IotSfElementfactor reqVo) {
+    public int elementDelete(String sfBid) {
         // 由具体子类实现
         return 0;
     }

+ 11 - 6
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/service/impl/IotRunHaoSfServiceImpl.java

@@ -690,11 +690,16 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
      * @return 返回删除结果,返回值为0表示删除成功,非0表示删除失败
      */
     @Override
-    public int elementDelete(IotSfElementfactor reqVo) {
-        String sfBid = reqVo.getSfBid();
-        String sfType = reqVo.getSfType();
-        String devBid = reqVo.getDevBid();
-        String sfCode = reqVo.getSfCode();
+    public int elementDelete(String sfBid) {
+
+        IotSfElementfactor elementfactor = iotSfElementfactorService.selectIotSfElementfactorBySfBid(sfBid);
+        if(elementfactor == null){
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "参数异常,设备不存在");
+        }
+
+        String sfType = elementfactor.getSfType();
+        String devBid = elementfactor.getDevBid();
+        String sfCode = elementfactor.getSfCode();
         IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(devBid);
 
         Map<String, String> params = new HashMap<>();
@@ -704,7 +709,7 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
             throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备未采集数据");
         }
         JSONObject sfdataContent = iotRunHaoSfdata.getSfdataContent();
-        if(RunHaoSfElementUtil.isAutoRunning(sfdataContent)){
+        if(Boolean.TRUE.equals(RunHaoSfElementUtil.isAutoRunning(sfdataContent))){
             throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "灌溉中,请先停止灌溉");
         }