Sfoglia il codice sorgente

1.水量信息:获取全部站点数据项改为获取用户当前站点
2.添加阀门设置规则

oppadmin 4 anni fa
parent
commit
c98bb2e2aa

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

@@ -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);
+        }
+    }
+
+}

+ 28 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayControlRuleMapper.java

@@ -0,0 +1,28 @@
+package com.bz.smart_city.dao.pay;
+
+import com.bz.smart_city.entity.pay.PayControlRule;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigInteger;
+import java.util.List;
+
+/**
+ * Created by ZJY on 2021-01-11 11:42
+ */
+@Mapper
+public interface PayControlRuleMapper {
+
+    Integer add(@Param("payControlRule")PayControlRule payControlRule);
+
+    List<PayControlRule>findList(@Param("name") String name,@Param("customerId") BigInteger customerId);
+
+    Integer edit(@Param("payControlRule")PayControlRule payControlRule);
+
+    Integer delete(@Param("id") String id);
+
+    //数据是否存在
+    List<PayControlRule>ExitsData(@Param("id") String id,@Param("name") String name,@Param("customerId") BigInteger customerId);
+
+
+}

+ 62 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayControlRule.java

@@ -0,0 +1,62 @@
+package com.bz.smart_city.entity.pay;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+
+/**
+ * Created by ZJY on 2021-01-11 11:08
+ */
+@Data
+@ApiModel(value = "阀控规则")
+public class PayControlRule {
+    @ApiModelProperty(example="1",notes = "主键ID,自动生成",position = 1)
+    private BigInteger id;
+
+    @ApiModelProperty(example="欠费关阀",notes = "规则描述",position = 2)
+    private String name;
+
+    @ApiModelProperty(example="欠费天数",notes = "判断条件",position = 3)
+    private String condition;
+
+    @ApiModelProperty(example=">",notes = "运算符",position = 4)
+    private String operator;
+
+    @ApiModelProperty(example="1",notes = "条件值",position = 5)
+    private String value;
+
+    @ApiModelProperty(example="1",notes = "执行动作,0关阀 1开阀",position = 6)
+    private String action;
+
+    @ApiModelProperty(example="元", notes="单位",position = 7)
+    private String unit;
+
+    @ApiModelProperty(example="1", notes="停用标志 0启用 1停用",position = 8)
+    private String disable;
+
+    @ApiModelProperty(example = "正常",notes = "备注",position = 9)
+    private String remarks;
+
+
+    @ApiModelProperty(example = "1",notes = "创建者",hidden = true)
+    private BigInteger createBy;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(example = "2020-04-17 00:00:00",notes = "创建时间",hidden = true)
+    private LocalDateTime createDate;
+    @ApiModelProperty(example = "1",notes = "修改者",hidden = true)
+    private BigInteger updateBy;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(example = "2020-04-18 00:00:00",notes = "修改时间",hidden = true)
+    private LocalDateTime updateDate;
+
+    @ApiModelProperty(example = "1",notes = "删除标记",hidden = true)
+    private String delFlag;
+    @ApiModelProperty(example = "1",notes = "站点ID",hidden = true)
+    private BigInteger siteId;
+    @ApiModelProperty(example = "1",notes = "水司ID",hidden = true)
+    private BigInteger customerId;
+}

+ 8 - 4
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/AmountWaterUsedAmountServiceImpl.java

@@ -79,7 +79,8 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
         LoginUser loginUser = UserUtil.getCurrentUser();
         PageHelper.startPage(pageNum, pageSize);
 
-        List<ProgramItem> programItems= UserUtil.getAllSiteProgramItems(loginUser);
+        //List<ProgramItem> programItems= UserUtil.getAllSiteProgramItems(loginUser);
+        List<ProgramItem> programItems= UserUtil.getCurrentSiteProgramItems(loginUser);
 
         List<AmountWaterUsedAmountDto> list = amountWaterUsedAmountMapper.getList(condition,loginUser.getCustomerId(),accountNumber,accountName,meterCode,address,
                 state,amountMin,amountMax,year,month,programItems,loginUser.getSiteId());
@@ -92,7 +93,8 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
     Integer amountMin,Integer amountMax, HttpServletResponse httpServletResponse)
     {
         LoginUser loginUser = UserUtil.getCurrentUser();
-        List<ProgramItem> programItems= UserUtil.getAllSiteProgramItems(loginUser);
+        //List<ProgramItem> programItems= UserUtil.getAllSiteProgramItems(loginUser);
+        List<ProgramItem> programItems= UserUtil.getCurrentSiteProgramItems(loginUser);
         List<AmountWaterUsedAmountDto> list = amountWaterUsedAmountMapper.getList(condition,loginUser.getCustomerId(),accountNumber,accountName,meterCode,address,
                 state,amountMin,amountMax,year,month,programItems,loginUser.getSiteId());
         String title = "水量信息";
@@ -157,7 +159,8 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
         if(review ==1){
             year = baseClosingAccountInfoDto.getYear();
             month = baseClosingAccountInfoDto.getMonth();
-            List<ProgramItem> programItems = UserUtil.getAllSiteProgramItems(loginUser);
+            //List<ProgramItem> programItems = UserUtil.getAllSiteProgramItems(loginUser);
+            List<ProgramItem> programItems= UserUtil.getCurrentSiteProgramItems(loginUser);
             idList = amountWaterUsedAmountMapper.getIds(condition,loginUser.getCustomerId(),null,null,null,null,
                     1,amountMin,amountMax,year,month,programItems,loginUser.getSiteId());
         }else{
@@ -217,7 +220,8 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
         if(baseClosingAccountInfoDto!=null) {
             year = baseClosingAccountInfoDto.getYear();
             month = baseClosingAccountInfoDto.getMonth();
-            List<ProgramItem> programItems = UserUtil.getAllSiteProgramItems(loginUser);
+            //List<ProgramItem> programItems = UserUtil.getAllSiteProgramItems(loginUser);
+            List<ProgramItem> programItems= UserUtil.getCurrentSiteProgramItems(loginUser);
             List<String> idList = amountWaterUsedAmountMapper.getIds(condition, loginUser.getCustomerId(), null, null, null, null,
                     1, amountMin, amountMax, year, month, programItems, loginUser.getSiteId());
             result = idList.size();

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

@@ -0,0 +1,100 @@
+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.PayControlRuleMapper;
+import com.bz.smart_city.dto.LoginUser;
+import com.bz.smart_city.entity.pay.PayControlRule;
+import com.bz.smart_city.service.pay.PayControlRuleService;
+import com.github.pagehelper.PageHelper;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * Created by ZJY on 2021-01-11 11:32
+ */
+@Service
+public class PayControlRuleServiceImpl implements PayControlRuleService {
+
+    @Resource
+    PayControlRuleMapper payControlRuleMapper;
+    @Override
+    public Integer add(PayControlRule payControlRule){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        if(ExitsData(null,payControlRule.getName(),new BigInteger(String.valueOf(loginUser.getCustomerId()))))
+            throw new ServiceException(-99,"该阀控规则已存在!");
+
+        payControlRule.setSiteId(new BigInteger(String.valueOf(loginUser.getSiteId())));
+        payControlRule.setCustomerId(new BigInteger(String.valueOf(loginUser.getCustomerId())));
+
+        payControlRule.setCreateBy(new BigInteger(String.valueOf(loginUser.getId())));
+        payControlRule.setCreateDate(LocalDateTime.now());
+        payControlRule.setUpdateBy(new BigInteger(String.valueOf(loginUser.getId())));
+        payControlRule.setUpdateDate(LocalDateTime.now());
+        payControlRule.setDelFlag("0");
+
+        Integer result = payControlRuleMapper.add(payControlRule);
+        return  result;
+    }
+
+    @Override
+    public List<PayControlRule>findList(String name){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        BigInteger customerId = new BigInteger(String.valueOf(loginUser.getCustomerId()));
+        return payControlRuleMapper.findList(name,customerId);
+    }
+
+    @Override
+    public Pagination<PayControlRule> findPage(String name, int pageNum, int pageSize){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        BigInteger customerId = new BigInteger(String.valueOf(loginUser.getCustomerId()));
+
+        PageHelper.startPage(pageNum,pageSize);
+        List<PayControlRule> payControlRules = payControlRuleMapper.findList(name,customerId);
+        return new  Pagination<>(payControlRules);
+    }
+
+    @Override
+    public Integer edit(PayControlRule payControlRule){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        if(ExitsData(null,payControlRule.getName(),new BigInteger(String.valueOf(loginUser.getCustomerId()))))
+            throw new ServiceException(-99,"该阀控规则已存在!");
+
+        Integer result = payControlRuleMapper.edit(payControlRule);
+        return  result;
+    }
+
+    @Override
+    public Integer delete(String id){
+        return payControlRuleMapper.delete(id);
+    }
+
+    /**
+     * 判断数据是否存在
+     * @param id
+     * @param name 规则名称
+     * @return true数据存在 false数据不存在
+     */
+    public boolean ExitsData(String id,String name,BigInteger customerId){
+        if(id != null){
+            List<PayControlRule> payControlRules = payControlRuleMapper.ExitsData(id,null,customerId );
+            if(payControlRules != null)
+                return true;
+        }
+
+        if(name != null){
+            List<PayControlRule> payControlRules = payControlRuleMapper.ExitsData(null,name,customerId);
+            if(payControlRules != null)
+                return true;
+        }
+
+        return false;
+    }
+
+
+}

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

@@ -0,0 +1,24 @@
+package com.bz.smart_city.service.pay;
+
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.entity.pay.PayControlRule;
+
+import java.util.List;
+
+/**
+ * Created by ZJY on 2021-01-11 11:32
+ */
+public interface PayControlRuleService {
+
+    //添加规则
+    Integer add(PayControlRule payControlRule);
+
+    //查询规则
+    List<PayControlRule> findList(String name);
+
+    Pagination<PayControlRule> findPage(String name, int pageNum, int pageSize);
+
+    Integer edit(PayControlRule payControlRule);
+
+    Integer delete(String id);
+}

+ 3 - 1
smart-city-platform/src/main/resources/mapper/pay/AmountWaterUsedAmountMapper.xml

@@ -88,7 +88,9 @@
 			<if test="programItems != null and programItems.size() != 0">
 				and
 				<foreach collection="programItems" item="item" open="(" separator=" or " close=")">
-						a.${item.dimensionCode} = #{item.dimensionValue}
+                    <if test="item.dimensionId == 10">
+                        a.${item.dimensionCode} = #{item.dimensionValue}
+                    </if>
 
 				</foreach>
 			</if>

+ 116 - 0
smart-city-platform/src/main/resources/mapper/pay/PayControlRuleMapper.xml

@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.bz.smart_city.dao.pay.PayControlRuleMapper">
+    <insert id="add" useGeneratedKeys="true" keyColumn="id">
+        insert into
+        pay_control_rule(
+        name,
+        condition,
+        operator,
+        value,
+        action,
+        unit,
+        disable,
+        create_by,
+        create_date,
+        update_by,
+        update_date,
+        remarks,
+        del_flag,
+        site_id,
+        customer_id
+        )
+        values (
+        #{payControlRule.name,jdbcType=VARCHAR},
+        #{payControlRule.condition,jdbcType=VARCHAR},
+        #{payControlRule.operator,jdbcType=VARCHAR},
+        #{payControlRule.value,jdbcType=VARCHAR},
+        #{payControlRule.action,jdbcType=VARCHAR},
+        #{payControlRule.unit,jdbcType=VARCHAR},
+        #{payControlRule.disable,jdbcType=VARCHAR},
+
+        #{paySysDict.createBy,jdbcType=BIGINT},
+        #{paySysDict.createDate,jdbcType=TIMESTAMP},
+        #{paySysDict.updateBy,jdbcType=BIGINT},
+        #{paySysDict.updateDate,jdbcType=TIMESTAMP},
+        #{paySysDict.remarks,jdbcType=VARCHAR},
+        #{paySysDict.delFlag,jdbcType=VARCHAR},
+        #{paySysDict.siteId,jdbcType=BIGINT},
+        #{paySysDict.customerId,jdbcType=BIGINT}
+        )
+    </insert>
+
+    <select id="findList" resultType="com.bz.smart_city.entity.pay.PayControlRule">
+        select
+            id,
+            name,
+            condition,
+            operator,
+            value,
+            action,
+            unit,
+            disable,
+            create_by,
+            create_date,
+            update_by,
+            update_date,
+            remarks,
+            del_flag,
+            site_id,
+            customer_id
+        from pay_control_rule
+        <where>
+            del_flag = 0 and customer_id = #{customerId}
+            <if test="name != null"> and name = #{name}</if>
+        </where>
+    </select>
+
+    <select id="ExitsData" resultType="com.bz.smart_city.entity.pay.PayControlRule">
+        select
+            id,
+            name,
+            condition,
+            operator,
+            value,
+            action,
+            unit,
+            disable,
+            create_by,
+            create_date,
+            update_by,
+            update_date,
+            remarks,
+            del_flag,
+            site_id,
+            customer_id
+        from pay_control_rule
+        <where>
+            del_flag = 0 and customer_id = #{customerId}
+            <if test="id != null"> and id = #{id}</if>
+            <if test="name != null"> and name = #{name}</if>
+        </where>
+
+    </select>
+
+    <delete id="delete">
+        update pay_control_rule set del_flag = 1 where id = #{id,jdbcType=INTEGER}
+    </delete>
+
+    <update id="edit">
+        update pay_control_rule
+        set
+            <if test="payControlRule.name != null and  payControlRule.name != ''"> name = #{payControlRule.name},</if>
+            <if test="payControlRule.condition != null and payControlRule.condition != ''"> condition = #{payControlRule.condition},</if>
+            <if test="payControlRule.value != null and payControlRule.value != ''"> value = #{payControlRule.value},</if>
+            <if test="payControlRule.operator != null and payControlRule.operator != ''"> operator = #{payControlRule.operator},</if>
+            <if test="payControlRule.action != null and payControlRule.action != ''"> action = #{payControlRule.action},</if>
+            <if test="payControlRule.unit != null"> unit = #{payControlRule.unit},</if>
+            <if test="payControlRule.disable != null"> disable = {payControlRule.disable},</if>
+            <if test="payControlRule.updateBy != null"> update_by = #{payControlRule.updateBy},</if>
+            <if test="payControlRule.updateDate != null"> update_date = #{payControlRule.updateDate},</if>
+            <if test="payControlRule.remarks != null"> remarks = #{payControlRule.remarks},</if>
+            <if test="payControlRule.delFlag != null"> del_flag = #{payControlRule.delFlag}</if>
+
+        where id = #{payControlRule.id}
+    </update>
+</mapper>