瀏覽代碼

1首页客户概况

Xiaojh 4 年之前
父節點
當前提交
6d95ca5683

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

@@ -0,0 +1,44 @@
+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.commom.util.UserUtil;
+import com.bz.smart_city.dto.LoginUser;
+import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
+import com.bz.smart_city.dto.pay.PayChargeSurveyDto;
+import com.bz.smart_city.entity.pay.archives.CustomerListInfo;
+import com.bz.smart_city.service.pay.PayChargeSurveyService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.math.BigInteger;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.List;
+
+@Controller
+@ResponseBody
+@RequestMapping("/survey")
+@Api(tags = "计费系统-首页概览")
+public class PayChargeSurveyController {
+
+    @Autowired
+    private PayChargeSurveyService payChargeSurveyService;
+
+    @PostMapping("/accountSurvey")
+    @ApiOperation(value = "计费系统-客户概览")
+    public AjaxMessage<PayChargeSurveyDto> accountSurvey(){
+
+        PayChargeSurveyDto payChargeSurveyDto = payChargeSurveyService.accountSurvey();
+
+        return new AjaxMessage<PayChargeSurveyDto>(ResultStatus.OK, payChargeSurveyDto);
+    }
+}

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

@@ -21,6 +21,10 @@ public interface BaseClosingAccountInfoMapper {
                                                    @Param("siteId")BigInteger siteId,@Param("customerId") BigInteger customerId,
                                                    @Param("state")Integer state);
 
+    public List<BaseClosingAccountInfoDto> getListNumber(@Param("year") Integer year, @Param("month") Integer month,
+                                                   @Param("siteId")BigInteger siteId,@Param("customerId") BigInteger customerId,
+                                                   @Param("state")Integer state);
+
     public int insert(@Param("baseClosingAccountInfoDto") BaseClosingAccountInfoDto baseClosingAccountInfoDto);
 
     public int update(@Param("baseClosingAccountInfoDto") BaseClosingAccountInfoDto baseClosingAccountInfoDto);

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

@@ -0,0 +1,36 @@
+package com.bz.smart_city.dao.pay;
+
+import com.bz.smart_city.dto.pay.PayChangePeriodDto;
+import com.bz.smart_city.entity.pay.PayAccountSurvey;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.List;
+
+@Mapper
+public interface PayChargeSurveyMapper {
+
+    public Integer getAccountCount();
+
+    public PayAccountSurvey getlastNumber(@Param("year")Integer year, @Param("month")Integer month,
+                                          @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
+    public Integer getAccountNumber(@Param("startDate") String startDate, @Param("endDate")String endDate,
+                                    @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
+    public Integer getMeterNumber (@Param("startDate") String startDate, @Param("endDate")String endDate,
+                                   @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
+    public Integer getCustomerNumber(@Param("startDate") String startDate, @Param("endDate")String endDate,
+                                     @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
+    public void insertAccountNumber(PayAccountSurvey payAccountSurvey);
+
+    public List<PayChangePeriodDto> getAccountList(@Param("endDate") String endDate, @Param("startDate")String startDate,
+                                                   @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
+    public PayAccountSurvey getlastAccount(@Param("periodDate")String startDate,
+                                           @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+}

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

@@ -0,0 +1,20 @@
+package com.bz.smart_city.dto.pay;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel("最近一年统计DTO")
+public class PayChangePeriodDto {
+    @ApiModelProperty(value = "客户总数")
+    private Integer accountNumber;
+    @ApiModelProperty(value = "水表总数")
+    private Integer meterNumber;
+    @ApiModelProperty(value = "开户总数")
+    private Integer customerNumber;
+    @ApiModelProperty(value = "年")
+    private String year;
+    @ApiModelProperty(value = "月")
+    private Integer month;
+}

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

@@ -0,0 +1,34 @@
+package com.bz.smart_city.dto.pay;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@ApiModel("客户概况DTO")
+public class PayChargeSurveyDto {
+    //汇总
+    @ApiModelProperty(value = "客户总数")
+    private Integer accountNumber;
+    @ApiModelProperty(value = "较上月")
+    private String lastAccountRate;
+    @ApiModelProperty(value = "水表总数")
+    private Integer meterNumber;
+    @ApiModelProperty(value = "较上月")
+    private String lastMeterRate;
+    @ApiModelProperty(value = "开户总数")
+    private Integer customerNumber;
+    @ApiModelProperty(value = "较上月")
+    private String lastCustomerRate;
+
+    //饼状图
+    @ApiModelProperty(value = "开户率")
+    private String customerRate;
+
+    //统计折线图
+    @ApiModelProperty(value = "折线图-按月")
+    private List<PayChangePeriodDto> list;
+
+}

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

@@ -0,0 +1,53 @@
+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;
+
+@Data
+@ApiModel("客户概况表")
+public class PayAccountSurvey {
+    @ApiModelProperty(value = "id", position = 1)
+    private String id;
+    @ApiModelProperty(value = "客户总数", position = 2)
+    private Integer accountNumber;
+    @ApiModelProperty(value = "上月客户总数", position = 3)
+    private Integer lastAccountNumber;
+    @ApiModelProperty(value = "水表总数", position = 4)
+    private Integer meterNumber;
+    @ApiModelProperty(value = "上月水表总数", position = 5)
+    private Integer lastMeterNumber;
+    @ApiModelProperty(value = "开户总数", position = 6)
+    private Integer customerNumber;
+    @ApiModelProperty(value = "上月开户总数", position = 7)
+    private Integer lastCustomerNumber;
+    @ApiModelProperty(value = "账期年", position = 8)
+    private Integer year;
+    @ApiModelProperty(value = "账期月", position = 9)
+    private Integer month;
+    @ApiModelProperty(value = "账期", position = 9)
+    private LocalDateTime periodDate;
+    @ApiModelProperty(value = "创建者", hidden = true)
+    private String createBy;
+    @ApiModelProperty(value = "修改者", hidden = true)
+    private String updateBy;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间", hidden = true)
+    private LocalDateTime createDate = LocalDateTime.now();
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间", hidden = true)
+    private LocalDateTime updateDate = LocalDateTime.now();
+    @ApiModelProperty(value = "备注", hidden = true)
+    private String remarks;
+    @ApiModelProperty(value = "删除标识", hidden = true)
+    private String delFlag;
+    @ApiModelProperty(value = "站点ID", hidden = true)
+    private BigInteger siteId;
+    @ApiModelProperty(value = "水司ID", hidden = true)
+    private BigInteger customerId;
+
+}

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

@@ -0,0 +1,49 @@
+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.BigDecimal;
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel("收费统计表")
+public class PayChargeSurvey {
+    @ApiModelProperty(value = "id", position = 1)
+    private BigInteger id;
+    @ApiModelProperty(value = "应收总额", position = 2)
+    private BigDecimal receivableNumber;
+    @ApiModelProperty(value = "实收总额", position = 3)
+    private BigDecimal receivedNumber;
+    @ApiModelProperty(value = "预存总额", position = 4)
+    private BigDecimal rechargeNumber;
+    @ApiModelProperty(value = "欠费总额", position = 5)
+    private BigDecimal debtNumber;
+    @ApiModelProperty(value = "账期年", position = 6)
+    private String year;
+    @ApiModelProperty(value = "账期月", position = 7)
+    private String month;
+    @ApiModelProperty(value = "创建者", hidden = true)
+    private BigInteger createBy;
+    @ApiModelProperty(value = "修改者", hidden = true)
+    private BigInteger updateBy;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间", hidden = true)
+    private LocalDateTime createDate = LocalDateTime.now();
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间", hidden = true)
+    private LocalDateTime updateDate = LocalDateTime.now();
+    @ApiModelProperty(value = "备注", hidden = true)
+    private String remarks;
+    @ApiModelProperty(value = "删除标识", hidden = true)
+    private String delFlag;
+    @ApiModelProperty(value = "站点ID", hidden = true)
+    private BigInteger siteId;
+    @ApiModelProperty(value = "水司ID", hidden = true)
+    private BigInteger customerId;
+
+
+}

+ 87 - 6
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/BaseClosingAccountInfoServiceImpl.java

@@ -4,22 +4,23 @@ 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.commom.util.UserUtil;
+import com.bz.smart_city.commom.util.Util;
 import com.bz.smart_city.dao.pay.BaseClosingAccountInfoMapper;
 import com.bz.smart_city.dao.pay.PayBaseConfigMapper;
+import com.bz.smart_city.dao.pay.PayChargeSurveyMapper;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
 import com.bz.smart_city.dto.pay.PayBaseConfigDto;
-import com.bz.smart_city.entity.pay.PayBaseConfig;
+import com.bz.smart_city.entity.pay.PayAccountSurvey;
 import com.bz.smart_city.service.pay.BaseClosingAccountInfoService;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.ibatis.annotations.Param;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigInteger;
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.Date;
 import java.util.List;
 
@@ -34,6 +35,8 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
     private BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
     @Resource
     private PayBaseConfigMapper baseConfigMapper;
+    @Resource
+    private PayChargeSurveyMapper payChargeSurveyMapper;
 
     @Override
     public Pagination<BaseClosingAccountInfoDto> getList(Integer year, Integer month, Integer pageNum, Integer pageSize) {
@@ -110,12 +113,28 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
             }
         }
         if (isOk) {
-
+            //1.先判断客户概况表是否存在记录,如果不存在则按账期月去卡旧数据的客户总数、水表总数、开户总数
+            //2.根据历史账期对旧数据进行入库保存
+            //查看记录表是否已经存在数据,为NULL则代表没有存在历史数据
+            Integer count = payChargeSurveyMapper.getAccountCount();
+            if(count <= 0){
+                //按账期月卡旧数据
+                List<BaseClosingAccountInfoDto> list = baseClosingAccountInfoMapper.getListNumber(null,null,
+                        BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()),null);
+                for (int i=0; i<list.size(); i++){
+                    int state = list.get(i).getState();
+                    if(state == 1){
+                        //把历史结账数据存进去,但不包含本期未结账的
+                        this.insertAccountNumber(list.get(i).getYear(),list.get(i).getMonth());
+                    }
+                }
+            }else if(count > 0){
+                //存储本期未结账数据
+                this.insertAccountNumber(year,month);
+            }
 
             // 更新本账期
-
             String msg2 = year + "年" + String.format("%02d", month) + "月已经结账";
-
             baseClosingAccountInfoDto.setEndTime(new Date());
             baseClosingAccountInfoDto.setRemarks(msg2);
             baseClosingAccountInfoDto.setState(1);
@@ -149,6 +168,68 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
         return message;
     }
 
+    public void insertAccountNumber(Integer year,Integer month){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        String start = year+"-"+(String.format("%02d",month))+"-01";
+        String end = year+"-"+(String.format("%02d",month))+"-31";
+
+        //查询上月总数
+        Integer lastYear = null;
+        Integer lastMonth = null;
+        if(month == 1){
+            lastYear = year-1;
+            lastMonth = 12;
+        }else{
+            lastYear = year;
+            lastMonth = month -1;
+        }
+
+        //根据账期查找历史客户数(仅统计状态为欠费与正常的客户总数之和)
+        Integer accountNumber = payChargeSurveyMapper.getAccountNumber
+                (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+        //根据账期查找历史水表数(仅统计状态为已开户的水表总数)
+        Integer meterNumber = payChargeSurveyMapper.getMeterNumber
+                (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+        //根据账期查找历史开户数(仅统计状态为正常的开户总数)
+        Integer customerNumber = payChargeSurveyMapper.getCustomerNumber
+                (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+
+        PayAccountSurvey lastAccount = payChargeSurveyMapper.getlastNumber(lastYear,lastMonth,
+                BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+
+        PayAccountSurvey account = new PayAccountSurvey();
+        if(lastAccount != null){
+            //上月总数赋值
+            account.setLastAccountNumber(lastAccount.getAccountNumber() != null ? lastAccount.getAccountNumber() : 0);
+            account.setLastMeterNumber(lastAccount.getMeterNumber() != null ? lastAccount.getMeterNumber() : 0);
+            account.setLastCustomerNumber(lastAccount.getCustomerNumber() != null ? lastAccount.getCustomerNumber() : 0);
+        }else{
+            account.setLastAccountNumber( 0);
+            account.setLastMeterNumber( 0);
+            account.setLastCustomerNumber( 0);
+        }
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        LocalDateTime ldt = LocalDateTime.parse(start+" 00:00:00",df);
+        account.setPeriodDate(ldt);
+        account.setId(Util.createUUIDId());
+        account.setAccountNumber(accountNumber);
+        account.setMeterNumber(meterNumber);
+        account.setCustomerNumber(customerNumber);
+        account.setYear(year);
+        account.setMonth(month);
+        account.setDelFlag("0");
+        account.setRemarks("");
+        account.setCreateBy(loginUser.getCreateBy());
+        account.setCreateDate(LocalDateTime.now());
+        account.setUpdateBy(loginUser.getCreateBy());
+        account.setUpdateDate(LocalDateTime.now());
+        account.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
+        account.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
+        //保存记录
+        payChargeSurveyMapper.insertAccountNumber(account);
+    }
+
     @Override
     public List<BaseClosingAccountInfoDto> getList(Integer year, Integer month) {
         LoginUser loginUser = UserUtil.getCurrentUser();

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

@@ -0,0 +1,169 @@
+package com.bz.smart_city.service.impl.pay;
+
+import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.dao.pay.BaseClosingAccountInfoMapper;
+import com.bz.smart_city.dao.pay.PayChargeSurveyMapper;
+import com.bz.smart_city.dto.LoginUser;
+import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
+import com.bz.smart_city.dto.pay.PayChangePeriodDto;
+import com.bz.smart_city.dto.pay.PayChargeSurveyDto;
+import com.bz.smart_city.entity.pay.PayAccountSurvey;
+import com.bz.smart_city.service.pay.PayChargeSurveyService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+@Slf4j
+@Service
+public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
+
+    @Resource
+    private PayChargeSurveyMapper payChargeSurveyMapper;
+
+    @Resource
+    private BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
+
+
+    public Integer getAccountCount(){
+        return payChargeSurveyMapper.getAccountCount();
+    }
+
+    public static void main(String[] args) {
+      try {
+          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//格式化为年月日
+          Calendar startDate = Calendar.getInstance();//起始年月
+          startDate.setTime(sdf.parse("2020-07-01"));
+          startDate.add(Calendar.YEAR, -1); //月份减1;
+          startDate.add(Calendar.MONTH, -1); //月份减1;
+
+          Date lastStartMonth = startDate.getTime(); //结果
+          String lastStart = sdf.format(lastStartMonth);
+          System.out.println("时间:"+lastStart);
+      }catch (Exception e) {
+          e.printStackTrace();
+      }
+    }
+
+    /**
+     * 客户概况
+     * @return payChargeSurveyDto
+     */
+    public PayChargeSurveyDto accountSurvey(){
+        PayChargeSurveyDto payChargeSurveyDto = new PayChargeSurveyDto();
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        DecimalFormat df = new DecimalFormat("0.0");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//格式化为年月日
+        BigInteger siteId = BigInteger.valueOf(loginUser.getSiteId());
+        BigInteger customerId = BigInteger.valueOf(loginUser.getCustomerId());
+        try {
+            //1.获取客户总数跟较上月比率
+            /***********************************时间计算*****************************************/
+            //获取当前账期
+            List<BaseClosingAccountInfoDto> list = baseClosingAccountInfoMapper.getList(null,null,
+                    siteId,customerId,null);
+            String startPeriod = list.get(0).getYear()+"-"+String.format("%02d", list.get(0).getMonth())+"-01";
+            String endPeriod = list.get(0).getYear()+"-"+String.format("%02d", list.get(0).getMonth())+"-31";
+
+            //取上一账期时间
+            Calendar startDate = Calendar.getInstance();//起始年月
+            Calendar enddate = Calendar.getInstance();//起始年月
+            startDate.setTime(sdf.parse(startPeriod));
+            startDate.add(Calendar.MONTH, -1); //月份减1;
+            enddate.setTime(sdf.parse(endPeriod));
+            enddate.add(Calendar.MONTH, -1); //月份减1;
+
+            Date lastStartMonth = startDate.getTime(); //结果
+            Date laseEndMonth = enddate.getTime();
+            String lastStart = sdf.format(lastStartMonth);
+            String lastEnd = sdf.format(laseEndMonth);
+            //System.out.println("当前账期:"+period+";上一账期:"+lastPeriod);
+
+            //上一账期汇总
+            PayAccountSurvey accountSurvey = payChargeSurveyMapper.getlastAccount(lastStart,siteId,customerId);
+
+            //客户总数计算
+            //当前账期以内客户总数
+            Integer sumAccount = payChargeSurveyMapper.getAccountNumber(null,endPeriod,siteId,customerId);
+            //当前账期客户总数
+            Integer sumCurrentAccount = payChargeSurveyMapper.getAccountNumber(startPeriod,endPeriod,siteId,customerId);
+            //上一期客户数
+            Integer sumLastAccount = accountSurvey != null && accountSurvey.getAccountNumber() != null ? accountSurvey.getAccountNumber() : 0;
+            //客户总数较上月比率
+            String lastAccountRate = "";
+            float num =(float)((sumCurrentAccount - sumLastAccount)/(sumLastAccount != null && sumLastAccount != 0 ? sumLastAccount : 1)*100);
+            lastAccountRate = df.format(num);
+            //赋值客户总数跟上月比率
+            payChargeSurveyDto.setAccountNumber(sumAccount);
+            payChargeSurveyDto.setLastAccountRate(lastAccountRate);
+
+
+            //水表总数计算
+            //当前账期以内的水表总数
+            Integer sumMeter = payChargeSurveyMapper.getMeterNumber(null,endPeriod,siteId,customerId);
+            //当前账期水表数
+            Integer sumCurrentMeter = payChargeSurveyMapper.getMeterNumber(startPeriod,endPeriod,siteId,customerId);
+            //上一期水表数
+            Integer sumLastMeter = accountSurvey != null && accountSurvey.getMeterNumber() != null ? accountSurvey.getMeterNumber() :0;
+            //水表总数较上月比率
+            String lastMeterRate = "";
+            num =(float)((sumCurrentMeter - sumLastMeter)/(sumLastMeter != null && sumLastMeter != 0 ? sumLastMeter : 1)*100);
+            lastMeterRate = df.format(num);
+            //赋值水表总数跟上月比率
+            payChargeSurveyDto.setMeterNumber(sumMeter);
+            payChargeSurveyDto.setLastMeterRate(lastMeterRate);
+
+
+            //开户总数计算
+            Integer sumCustomer = payChargeSurveyMapper.getCustomerNumber(null,endPeriod,siteId,customerId);
+            //当前账期开户数
+            Integer sumCurrentCustomer = payChargeSurveyMapper.getCustomerNumber(startPeriod,endPeriod,siteId,customerId);
+            //上一账期开户数
+            Integer sumLastCustomer = accountSurvey != null && accountSurvey.getCustomerNumber() != null ? accountSurvey.getCustomerNumber() : 0;
+            //水表总数较上月比率
+            String lastCusstomerRate = "";
+            num =(float)((sumCurrentCustomer - sumLastCustomer)/(sumLastCustomer != null && sumLastCustomer != 0 ? sumLastCustomer : 1)*100);
+            lastCusstomerRate = df.format(num);
+            //赋值开户总数跟上月比率
+            payChargeSurveyDto.setCustomerNumber(sumCustomer);
+            payChargeSurveyDto.setLastCustomerRate(lastCusstomerRate);
+
+
+            //开户率
+            String customerRate = "";
+            num =(float)(sumCurrentCustomer/(sumCurrentMeter != null && sumCurrentMeter != 0 ? sumCurrentMeter : 1)*100);
+            customerRate = df.format(num);
+            payChargeSurveyDto.setCustomerRate(customerRate);
+
+
+            //折线图统计,取最近一年
+            Calendar lately = Calendar.getInstance();//起始年月
+            lately.setTime(sdf.parse(startPeriod));
+            lately.add(Calendar.YEAR, -1); //年份减1;
+            lately.add(Calendar.MONTH, -1); //月份减1;
+            Date latelyDay = lately.getTime(); //结果
+            String latelyDate = sdf.format(latelyDay);
+            List<PayChangePeriodDto> accoutList = payChargeSurveyMapper.getAccountList(startPeriod,latelyDate,siteId,customerId);
+            PayChangePeriodDto periodDto = new PayChangePeriodDto();
+            List<PayChangePeriodDto> accountList2 = new ArrayList<PayChangePeriodDto>();
+            periodDto.setYear(list.get(0).getYear()+"");
+            periodDto.setMonth(list.get(0).getMonth());
+            periodDto.setAccountNumber(sumCurrentAccount);
+            periodDto.setCustomerNumber(sumCurrentCustomer);
+            periodDto.setMeterNumber(sumCurrentMeter);
+            accountList2.add(periodDto);
+            accountList2.addAll(accoutList);
+            payChargeSurveyDto.setList(accountList2);
+            //System.out.println("时间:"+latelyDate);
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
+        return payChargeSurveyDto;
+    }
+}

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

@@ -0,0 +1,9 @@
+package com.bz.smart_city.service.pay;
+
+import com.bz.smart_city.dto.pay.PayChargeSurveyDto;
+
+public interface PayChargeSurveyService {
+    public Integer getAccountCount();
+
+    public PayChargeSurveyDto accountSurvey();
+}

+ 1 - 1
smart-city-platform/src/main/resources/application.properties

@@ -1,2 +1,2 @@
 #开发环境:dev  测试环境:sit  线上环境:prd  演示环境:uat
-spring.profiles.active=sit
+spring.profiles.active=dev

+ 190 - 0
smart-city-platform/src/main/resources/mapper/pay/PayChargeSurveyMapper.xml

@@ -0,0 +1,190 @@
+<?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.PayChargeSurveyMapper">
+
+    <select id="getAccountCount" resultType="java.lang.Integer">
+        select count(a.id) from pay_account_survey a
+    </select>
+
+    <select id="getlastNumber" resultType="com.bz.smart_city.entity.pay.PayAccountSurvey">
+        select
+            a.account_number as "accountNumber",
+            a.meter_number as "meterNumber",
+            a.customer_number as "customerNumber"
+        from pay_account_survey a
+        <where>
+            <if test="year != null">
+                and a.year =#{year}
+            </if>
+            <if test="month != null">
+                and a.month =#{month}
+            </if>
+            <if test="siteId != null">
+                and a.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and a.customer_id =#{customerId}
+            </if>
+        </where>
+    </select>
+
+    <select id="getAccountNumber" resultType="java.lang.Integer">
+        select
+            count(1)
+        from pay_base_account
+        <where>
+            state != '3'
+            <if test="startDate != null and startDate != ''">
+                and convert(create_date,DATETIME) &gt;=#{startDate}
+            </if>
+            <if test="endDate != null and endDate != ''">
+                and convert(create_date,DATETIME) &lt;=#{endDate}
+            </if>
+            <if test="siteId != null">
+                and site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and customer_id =#{customerId}
+            </if>
+            order by create_date asc
+        </where>
+    </select>
+
+    <select id="getMeterNumber" resultType="java.lang.Integer">
+        select
+            count(de.id)
+        from sc_device de
+        left join pay_base_customerandmeterrela customer  on de.account_id = customer.account_id
+        <where>
+            customer.businessstate = '1'
+            <if test="startDate != null and startDate != ''">
+                and convert(de.date_create,DATETIME) &gt;=#{startDate}
+            </if>
+            <if test="endDate != null and endDate != ''">
+                and convert(de.date_create,DATETIME) &lt;=#{endDate}
+            </if>
+            <if test="siteId != null">
+                and customer.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and customer.customer_id =#{customerId}
+            </if>
+        </where>
+    </select>
+
+    <select id="getCustomerNumber" resultType="java.lang.Integer">
+        select
+            count(customer.id)
+        from pay_base_customerandmeterrela customer
+        <where>
+            customer.businessstate = '1'
+            <if test="startDate != null and startDate != ''">
+                and convert(customer.create_date,DATETIME) &gt;=#{startDate}
+            </if>
+            <if test="endDate != null and endDate != ''">
+                and convert(customer.create_date,DATETIME) &lt;=#{endDate}
+            </if>
+            <if test="siteId != null">
+                and customer.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and customer.customer_id =#{customerId}
+            </if>
+        </where>
+    </select>
+
+    <insert id="insertAccountNumber">
+        insert into pay_account_survey
+        (
+            id,
+            account_number,
+            last_account_number,
+            meter_number,
+            last_meter_number,
+            customer_number,
+            last_customer_number,
+            site_id,
+            customer_id,
+            create_by,
+            create_date,
+            update_by,
+            update_date,
+            remarks,
+            del_flag,
+            year,
+            month,
+            period_date
+        )
+        values
+        (
+            #{id},
+            #{accountNumber},
+            #{lastAccountNumber},
+            #{meterNumber},
+            #{lastMeterNumber},
+            #{customerNumber},
+            #{lastCustomerNumber},
+            #{siteId},
+            #{customerId},
+            #{createBy},
+            #{createDate},
+            #{updateBy},
+            #{updateDate},
+            #{remarks},
+            #{delFlag},
+            #{year},
+            #{month},
+            #{periodDate}
+        )
+    </insert>
+
+    <select id="getAccountList" resultType="com.bz.smart_city.dto.pay.PayChangePeriodDto">
+        select
+            a.account_number as 'accountNumber',
+            a.meter_number as 'meterNumber',
+            a.customer_Number as 'customerNumber',
+            a.year as 'year',
+            a.month as 'month'
+        from pay_account_survey a
+        <where>
+            <if test="startDate != null">
+                and CONVERT( a.period_date, DATETIME ) >=#{startDate}
+            </if>
+            <if test="endDate != null">
+                and CONVERT( a.period_date, DATETIME ) &lt;=#{endDate}
+            </if>
+            <if test="siteId != null">
+                and a.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and a.customer_id =#{customerId}
+            </if>
+        </where>
+        ORDER BY a.period_date desc
+    </select>
+
+    <select id="getlastAccount" resultType="com.bz.smart_city.entity.pay.PayAccountSurvey">
+        select
+            a.id as "id",
+            a.account_number as "accountNumber",
+            a.last_account_number as "lastAccountNumber",
+            a.meter_number as "meterNumber",
+            a.last_meter_number as "lastMeterNumber",
+            a.customer_number as "customerNumber",
+            a.last_customer_number as "lastCustomerNumber",
+            a.year as "year",
+            a.month as "month"
+        from pay_account_survey a
+        <where>
+            <if test="periodDate != null">
+                and CONVERT( a.period_date, DATETIME ) =#{periodDate}
+            </if>
+            <if test="siteId != null">
+                and a.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and a.customer_id =#{customerId}
+            </if>
+        </where>
+    </select>
+</mapper>

+ 24 - 0
smart-city-platform/src/main/resources/mapper/pay/baseClosingAccountInfoMapper.xml

@@ -59,6 +59,30 @@
         </where>
 		ORDER BY a.create_date desc
     </select>
+    <select id="getListNumber" resultType="com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto">
+        SELECT
+        <include refid="baseClosingaccountinfoColumns"/>
+        FROM pay_base_closingaccountinfo a
+        <include refid="baseClosingaccountinfoJoins"/>
+        <where>
+			<if test="state != null">
+				and a.state=#{state}
+			</if>
+            <if test="siteId != null">
+                and a.site_id=#{siteId}
+            </if>
+            <if test="customerId != null">
+                and a.customer_id=#{customerId}
+            </if>
+            <if test="year != null">
+                and a.year=#{year}
+            </if>
+            <if test="month != null">
+                and a.month=#{month}
+            </if>
+        </where>
+		ORDER BY a.create_date asc
+    </select>
 
 
     <insert id="insert">