| 
					
				 | 
			
			
				@@ -0,0 +1,132 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package com.bz.smart_city.controller.pay; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.bz.smart_city.commom.model.AjaxMessage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.bz.smart_city.commom.model.Pagination; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.bz.smart_city.commom.model.ResultStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.bz.smart_city.entity.pay.PayControlRule; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.bz.smart_city.service.pay.PayControlRuleService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import io.swagger.annotations.Api; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import io.swagger.annotations.ApiModelProperty; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import io.swagger.annotations.ApiOperation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import io.swagger.annotations.ApiParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.validation.annotation.Validated; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * Created by ZJY on 2021-01-11 10:44 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@RestController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@RequestMapping("PayControlRule") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Api(tags = "阀门设置") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class PayControlRuleController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    PayControlRuleService payControlRuleService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PostMapping("add") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApiModelProperty(value = "添加阀控规则",notes = "添加阀控规则") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public AjaxMessage add( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @ApiParam(value = "阀控规则",required = true) @RequestBody(required = true) @Validated PayControlRule payControlRule 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(StringUtils.isBlank(payControlRule.getName())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new Exception("阀控规则名称不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(StringUtils.isBlank(payControlRule.getCondition())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new Exception("阀控规则判断条件不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(StringUtils.isBlank(payControlRule.getOperator())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new Exception("阀控规则运算符不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(StringUtils.isBlank(payControlRule.getValue())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new Exception("阀控规则条件值不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(StringUtils.isBlank(payControlRule.getAction())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new Exception("阀控规则执行操作不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Integer result = payControlRuleService.add(payControlRule); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(result != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(result == 1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return new AjaxMessage(ResultStatus.OK); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return new AjaxMessage(ResultStatus.ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        catch (Exception ex){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return  new AjaxMessage<>(-99,ex.getMessage(),null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PostMapping("edit") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApiModelProperty(value = "编辑阀控规则",notes = "编辑阀控规则") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public AjaxMessage edit( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @ApiParam(value = "阀控规则",required = true) @RequestBody(required = true) @Validated PayControlRule payControlRule 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(payControlRule.getId() == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new Exception("阀控规则ID不能为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Integer result = payControlRuleService.edit(payControlRule); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(result != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(result == 1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return new AjaxMessage(ResultStatus.OK); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return new AjaxMessage(ResultStatus.ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        catch (Exception ex){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return  new AjaxMessage<>(-99,ex.getMessage(),null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @GetMapping("findList") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApiModelProperty(value = "查询阀控规则",notes = "查询阀控规则") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public AjaxMessage<List<PayControlRule>> findList( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @ApiParam(value = "阀控规则名称",required = false) @RequestBody(required = false) String name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<PayControlRule> payControlRules = payControlRuleService.findList(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return new AjaxMessage<>(ResultStatus.OK,payControlRules); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        catch (Exception ex){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return  new AjaxMessage<>(-99,ex.getMessage(),null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @GetMapping("/findPage") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApiOperation(value="查询阀控规则,分页",notes=",分页") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public AjaxMessage<Pagination<PayControlRule>> findPage( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @ApiParam(value = "阀控规则名称", required = false) @RequestParam(required = false) String name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @ApiParam(value = "条数,非必传,默认15条", required = false, defaultValue = "15") @RequestParam(required = false, defaultValue = "15") int pageSize 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Pagination<PayControlRule> payControlRules = payControlRuleService.findPage(name,pageNum,pageSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return new AjaxMessage<>(ResultStatus.OK,payControlRules); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        catch (Exception ex){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return  new AjaxMessage<>(-99,ex.getMessage(),null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @GetMapping("/delete") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApiOperation(value = "删除阀控规则",notes = "删除阀控规则") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public AjaxMessage delete( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @ApiParam(value = "id",required = true) @RequestParam(required = true) String id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Integer result = payControlRuleService.delete(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(result != null && result >0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return new AjaxMessage<>(ResultStatus.OK); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return new AjaxMessage<>(ResultStatus.ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        catch (Exception ex){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return  new AjaxMessage<>(-99,ex.getMessage(),null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |