Browse Source

加入查询阀控记录接口

oppadmin 4 năm trước cách đây
mục cha
commit
c25eb1d185

+ 142 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayControlRecordController.java

@@ -0,0 +1,142 @@
+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.dto.pay.PayControlRecordDto;
+import com.bz.smart_city.entity.pay.PayControlRecord;
+import com.bz.smart_city.service.pay.PayControlRecordService;
+import io.swagger.annotations.Api;
+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.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+
+/**
+ * Created by ZJY on 2021-01-18 9:09
+ */
+@RestController
+@RequestMapping("PayControlRecord")
+@Api(tags = "计费系统-阀控记录")
+public class PayControlRecordController {
+
+    @Autowired
+    PayControlRecordService payControlRecordService;
+
+
+    @GetMapping("/findList")
+    @ApiOperation(value="查询阀控记录,分页",notes=",分页")
+    public AjaxMessage<List<PayControlRecord>> findList(
+            @ApiParam(value = "用户ID", required = false) @RequestParam(required = false) String accountId,
+            @ApiParam(value = "水表ID", required = false) @RequestParam(required = false) String meterId,
+            @ApiParam(value = "阀控规则", required = false) @RequestParam(required = false) String controlRuleId,
+            @ApiParam(value = "操作类型 0关阀 1开阀", required = false) @RequestParam(required = false) String type,
+            @ApiParam(value = "操作结果 0执行中 1成功 2失败", required = false) @RequestParam(required = false) String result,
+            @ApiParam(value = "阀门状态  0关阀 1开阀 2异常", required = false) @RequestParam(required = false) String state,
+            @ApiParam(value = "开始时间yyyyMMdd", required = false) @RequestParam(required = false) String beginTime,
+            @ApiParam(value = "结束时间yyyyMMdd", required = false) @RequestParam(required = false) String endTime
+    ){
+        try {
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+            PayControlRecordDto payControlRecordDto = new PayControlRecordDto();
+
+            if(StringUtils.isNotBlank(accountId)){
+                payControlRecordDto.setAccountId(new BigInteger(accountId));
+            }
+
+            if(StringUtils.isNotBlank(meterId)){
+                payControlRecordDto.setMeterId(new BigInteger(meterId));
+            }
+            if(StringUtils.isNotBlank(controlRuleId)){
+                payControlRecordDto.setControlRuleId(new Integer(controlRuleId));
+            }
+            if(StringUtils.isNotBlank(type)){
+                payControlRecordDto.setType(new Integer(type));
+            }
+            if(StringUtils.isNotBlank(result)){
+                payControlRecordDto.setResult(new Integer(result));
+            }
+            if(StringUtils.isNotBlank(state)){
+                payControlRecordDto.setResult(new Integer(state));
+            }
+            if(StringUtils.isNotBlank(beginTime)){
+                beginTime = beginTime +"000000";
+                payControlRecordDto.setBeginTime( LocalDateTime.parse(beginTime,df));
+            }
+            if(StringUtils.isNotBlank(endTime)){
+                endTime = endTime + "235959";
+                payControlRecordDto.setEndTime(LocalDateTime.parse(endTime, df));
+            }
+
+            List<PayControlRecord> payControlRecordList = payControlRecordService.findList(payControlRecordDto);
+            return new AjaxMessage<>(ResultStatus.OK,payControlRecordList);
+        }
+        catch (Exception ex){
+            return  new AjaxMessage<>(-99,ex.getMessage(),null);
+        }
+    }
+
+    @GetMapping("/findPage")
+    @ApiOperation(value="查询阀控记录,分页",notes="查询阀控记录,分页")
+    public AjaxMessage<Pagination<PayControlRecord>> findPage(
+            @ApiParam(value = "用户ID", required = false) @RequestParam(required = false) String accountId,
+            @ApiParam(value = "水表ID", required = false) @RequestParam(required = false) String meterId,
+            @ApiParam(value = "阀控规则", required = false) @RequestParam(required = false) String controlRuleId,
+            @ApiParam(value = "操作类型 0关阀 1开阀", required = false) @RequestParam(required = false) String type,
+            @ApiParam(value = "操作结果 0执行中 1成功 2失败", required = false) @RequestParam(required = false) String result,
+            @ApiParam(value = "阀门状态  0关阀 1开阀 2异常", required = false) @RequestParam(required = false) String state,
+            @ApiParam(value = "开始时间yyyyMMdd", required = false) @RequestParam(required = false) String beginTime,
+            @ApiParam(value = "结束时间yyyyMMdd", required = false) @RequestParam(required = false) String endTime,
+            @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 {
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+            PayControlRecordDto payControlRecordDto = new PayControlRecordDto();
+
+            if(StringUtils.isNotBlank(accountId)){
+                payControlRecordDto.setAccountId(new BigInteger(accountId));
+            }
+
+            if(StringUtils.isNotBlank(meterId)){
+                payControlRecordDto.setMeterId(new BigInteger(meterId));
+            }
+            if(StringUtils.isNotBlank(controlRuleId)){
+                payControlRecordDto.setControlRuleId(new Integer(controlRuleId));
+            }
+            if(StringUtils.isNotBlank(type)){
+                payControlRecordDto.setType(new Integer(type));
+            }
+            if(StringUtils.isNotBlank(result)){
+                payControlRecordDto.setResult(new Integer(result));
+            }
+            if(StringUtils.isNotBlank(state)){
+                payControlRecordDto.setResult(new Integer(state));
+            }
+            if(StringUtils.isNotBlank(beginTime)){
+                beginTime = beginTime +"000000";
+                payControlRecordDto.setBeginTime( LocalDateTime.parse(beginTime,df));
+            }
+            if(StringUtils.isNotBlank(endTime)){
+                endTime = endTime + "235959";
+                payControlRecordDto.setEndTime(LocalDateTime.parse(endTime, df));
+            }
+
+            Pagination<PayControlRecord> payControlRecordPagination = payControlRecordService.findPage(payControlRecordDto,pageNum,pageSize);
+            return new AjaxMessage<>(ResultStatus.OK,payControlRecordPagination);
+        }
+        catch (Exception ex){
+            return  new AjaxMessage<>(-99,ex.getMessage(),null);
+        }
+    }
+
+}

+ 0 - 3
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayControlRuleController.java

@@ -128,7 +128,4 @@ public class PayControlRuleController {
             return  new AjaxMessage<>(-99,ex.getMessage(),null);
         }
     }
-
-
-
 }

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayControlRecordMapper.java

@@ -1,5 +1,6 @@
 package com.bz.smart_city.dao.pay;
 
+import com.bz.smart_city.dto.pay.PayControlRecordDto;
 import com.bz.smart_city.entity.pay.PayControlRecord;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -16,5 +17,5 @@ public interface PayControlRecordMapper {
     Integer add(@Param("payControlRecord")PayControlRecord payControlRecord);
 
     //查询
-    List<PayControlRecord> findList(@Param("payControlRecord")PayControlRecord payControlRecord);
+    List<PayControlRecord> findList(@Param("payControlRecordDto") PayControlRecordDto payControlRecordDto);
 }

+ 25 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayControlRecordDto.java

@@ -0,0 +1,25 @@
+package com.bz.smart_city.dto.pay;
+
+import com.bz.smart_city.entity.pay.PayControlRecord;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * Created by ZJY on 2021-01-18 9:25
+ */
+@Data
+@ApiModel(value = "阀控查询条件")
+public class PayControlRecordDto extends PayControlRecord {
+
+    @ApiModelProperty(value = "开始时间",  hidden = true)
+    @JsonIgnore
+    private LocalDateTime beginTime;
+    @ApiModelProperty(value = "结束时间",  hidden = true)
+    @JsonIgnore
+    private LocalDateTime endTime;
+}

+ 39 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayControlRecordServiceImpl.java

@@ -0,0 +1,39 @@
+package com.bz.smart_city.service.impl.pay;
+
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.dao.pay.PayControlRecordMapper;
+import com.bz.smart_city.dto.LoginUser;
+import com.bz.smart_city.dto.pay.PayControlRecordDto;
+import com.bz.smart_city.entity.pay.PayControlRecord;
+import com.bz.smart_city.service.pay.PayControlRecordService;
+import com.github.pagehelper.PageHelper;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * Created by ZJY on 2021-01-18 9:11
+ */
+@Service
+public class PayControlRecordServiceImpl implements PayControlRecordService {
+
+    @Resource
+    PayControlRecordMapper payControlRecordMapper;
+
+    @Override
+    public List<PayControlRecord> findList(PayControlRecordDto payControlRecordDto)
+    {
+        return payControlRecordMapper.findList(payControlRecordDto);
+    }
+
+    @Override
+    public Pagination<PayControlRecord> findPage(PayControlRecordDto payControlRecordDto, int pageNum, int pageSize)
+    {
+        //LoginUser loginUser = UserUtil.getCurrentUser();
+        PageHelper.startPage(pageNum,pageSize);
+        List<PayControlRecord> payControlRecordList = payControlRecordMapper.findList(payControlRecordDto);
+        return new  Pagination<>(payControlRecordList);
+    }
+}

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayControlRuleServiceImpl.java

@@ -3,10 +3,12 @@ package com.bz.smart_city.service.impl.pay;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.dao.pay.PayControlRecordMapper;
 import com.bz.smart_city.dao.pay.PayControlRuleMapper;
 import com.bz.smart_city.dao.pay.PayRechargeaccountMapper;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.PayRechargeaccountDto;
+import com.bz.smart_city.entity.pay.PayControlRecord;
 import com.bz.smart_city.entity.pay.PayControlRule;
 import com.bz.smart_city.service.pay.PayControlRuleService;
 import com.github.pagehelper.PageHelper;
@@ -81,6 +83,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
         return payControlRuleMapper.delete(id);
     }
 
+
     /**
      * 判断数据是否存在
      * @param id

+ 19 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayControlRecordService.java

@@ -0,0 +1,19 @@
+package com.bz.smart_city.service.pay;
+
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.dto.pay.PayControlRecordDto;
+import com.bz.smart_city.entity.pay.PayControlRecord;
+
+import java.util.List;
+
+/**
+ * Created by ZJY on 2021-01-18 9:10
+ */
+public interface PayControlRecordService {
+
+    //查询阀控记录
+    List<PayControlRecord> findList(PayControlRecordDto payControlRecordDto);
+
+    Pagination<PayControlRecord> findPage(PayControlRecordDto payControlRecordDto,int pageNum, int pageSize);
+
+}

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayControlRuleService.java

@@ -1,6 +1,7 @@
 package com.bz.smart_city.service.pay;
 
 import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.entity.pay.PayControlRecord;
 import com.bz.smart_city.entity.pay.PayControlRule;
 
 import java.util.List;
@@ -21,4 +22,5 @@ public interface PayControlRuleService {
     Integer edit(PayControlRule payControlRule);
 
     Integer delete(String id);
+
 }

+ 9 - 7
smart-city-platform/src/main/resources/mapper/pay/PayControlRecordMapper.xml

@@ -22,13 +22,15 @@
         left join pay_control_rule pcrule on pcr.control_rule_id = pcrule.id
         <where>
             del_flag = 0
-            <if test="payControlRecord.id != null"> and pcr.id = #{payControlRecord.id}</if>
-            <if test="payControlRecord.accountId != null"> and pcr.account_id = #{payControlRecord.accountId}</if>
-            <if test="payControlRecord.meterId != null"> and pcr.meter_id = #{payControlRecord.meterId}</if>
-            <if test="payControlRecord.controlRuleId != null"> and pcr.control_rule_id = #{payControlRecord.controlRuleId}</if>
-            <if test="payControlRecord.type != null"> and pcr.type = #{payControlRecord.type}</if>
-            <if test="payControlRecord.result != null"> and pcr.result = #{payControlRecord.result}</if>
-            <if test="payControlRecord.state != null"> and pcr.state = #{payControlRecord.state}</if>
+            <if test="payControlRecordDto.id != null"> and pcr.id = #{payControlRecordDto.id}</if>
+            <if test="payControlRecordDto.accountId != null"> and pcr.account_id = #{payControlRecordDto.accountId}</if>
+            <if test="payControlRecordDto.meterId != null"> and pcr.meter_id = #{payControlRecordDto.meterId}</if>
+            <if test="payControlRecordDto.controlRuleId != null"> and pcr.control_rule_id = #{payControlRecordDto.controlRuleId}</if>
+            <if test="payControlRecordDto.type != null"> and pcr.type = #{payControlRecordDto.type}</if>
+            <if test="payControlRecordDto.result != null"> and pcr.result = #{payControlRecordDto.result}</if>
+            <if test="payControlRecordDto.state != null"> and pcr.state = #{payControlRecordDto.state}</if>
+            <if test="payControlRecordDto.beginTime != null"> and pcr.updateDate >= #{payControlRecordDto.beginTime,jdbcType=TIMESTAMP}</if>
+            <if test="payControlRecordDto.endTime != null"> and pcr.updateDate &lt;= #{payControlRecordDto.endTime,jdbcType=TIMESTAMP}</if>
         </where>
     </select>