Browse Source

1修改首页

Xiaojh 4 years ago
parent
commit
640878b8ca

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

@@ -38,6 +38,9 @@ public interface PayChargeSurveyMapper {
     public BigDecimal getCurrentTran(@Param("year")Integer year,@Param("month")Integer month,
             @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
 
+    public BigDecimal getReceivedCurrent(@Param("year")Integer year,@Param("month")Integer month,
+                                         @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
     public List<PayTransactionSurvey> getPayAmountList(@Param("year")Integer year,@Param("month")Integer month,
                                                  @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
 
@@ -46,6 +49,9 @@ public interface PayChargeSurveyMapper {
     public List<PayTransactionSurvey> getCurrentTranRocord(@Param("year")Integer year,@Param("month")Integer month,
                                 @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
 
+    public List<PayTransactionSurvey> getCurrentReceived(@Param("year")Integer year,@Param("month")Integer month,
+                                      @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
     public PayTransactionSurvey getLastTranRocord(@Param("year")Integer year,@Param("month")Integer month,
                                                   @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
 
@@ -66,11 +72,17 @@ public interface PayChargeSurveyMapper {
     public BigDecimal getAmountMonth(@Param("year")Integer year,@Param("month")Integer month,
                                      @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
 
+    public BigDecimal getAmountMonthSurvey(@Param("year")Integer year,@Param("month")Integer month,
+                                     @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
     public void insertAmount(PayAmountSurvey payAmountSurvey);
 
     public BigDecimal getAmountInfo(@Param("startDate")String startDate,@Param("endDate")String endDate,
                                     @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
 
+    public BigDecimal getAmountSureyInfo(@Param("startDate")String startDate,@Param("endDate")String endDate,
+                                         @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
     public List<PayAmountSurveyListDto> getAmountGroupList(@Param("year")Integer year,@Param("month")Integer month,
                                                            @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
 }

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayTransactionSurveyDto.java

@@ -14,7 +14,7 @@ public class PayTransactionSurveyDto {
     private BigDecimal incomeNumber;
     @ApiModelProperty(value = "较上月比率")
     private String lastIncomeRate;
-    @ApiModelProperty(value = "收入较上月 0下降 1新增")
+    @ApiModelProperty(value = "收入较上月 0下降 1新增 2持平或除数为0")
     private Integer lastIncomeIsUp;
 
     @ApiModelProperty(value = "现金")

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

@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.Date;
@@ -83,6 +84,8 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
         boolean isOk = true;
         Integer year = baseClosingAccountInfoDto.getYear();
         Integer month  = baseClosingAccountInfoDto.getMonth();
+        Date startTime = baseClosingAccountInfoDto.getStartTime();
+        Date endTime = new Date();
         LoginUser loginUser = UserUtil.getCurrentUser();
         // 判断结账参数,进行结账校验
         String msg = "结账失败:<br/>";
@@ -129,7 +132,7 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
                     int state = list.get(i).getState();
                     /*if(state == 1){*/
                         //把历史结账数据存进去,但不包含本期未结账的
-                        this.insertAccountNumber(list.get(i).getYear(),list.get(i).getMonth());
+                        this.insertAccountNumber(list.get(i).getYear(),list.get(i).getMonth(),list.get(i).getStartTime(),list.get(i).getEndTime());
                         //历史交易数据
                         this.insertTransaction(list.get(i).getYear(),list.get(i).getMonth());
                         //历史交易数据
@@ -140,7 +143,7 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
                 }
             }else if(count > 0){
                 //存储本期未结账数据
-                this.insertAccountNumber(year,month);
+                this.insertAccountNumber(year,month,startTime,endTime);
                 //本期交易未结账数据
                 this.insertTransaction(year,month);
                 //本期交易数据
@@ -150,8 +153,8 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
             }
 
             // 更新本账期
-            String msg2 = year + "年" + String.format("%02d", month) + "月已经结账";
-            baseClosingAccountInfoDto.setEndTime(new Date());
+            /*String msg2 = year + "年" + String.format("%02d", month) + "月已经结账";
+            baseClosingAccountInfoDto.setEndTime(endTime);
             baseClosingAccountInfoDto.setRemarks(msg2);
             baseClosingAccountInfoDto.setState(1);
             baseClosingAccountInfoDto.setUpdateBy(BigInteger.valueOf(loginUser.getId()));
@@ -174,7 +177,7 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
                 baseClosingAccountInfoDto.setMonth(1);
             }
             baseClosingAccountInfoDto.setName(baseClosingAccountInfoDto.getYear()+"年"+String.format("%02d", baseClosingAccountInfoDto.getMonth())+"月");
-            this.add(baseClosingAccountInfoDto);
+            this.add(baseClosingAccountInfoDto);*/
         }else{
             message.setStatus(-707);
             message.setMsg(msg);
@@ -183,8 +186,14 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
     }
 
     //添加客户概况信息
-    public void insertAccountNumber(Integer year,Integer month){
+    public void insertAccountNumber(Integer year,Integer month,Date startTime,Date endTime){
         LoginUser loginUser = UserUtil.getCurrentUser();
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
+        endTime = endTime != null ? endTime : new Date();
+        String strarDate = "";
+        String endDate = "";
+        strarDate = format.format(startTime);
+        endDate = format.format(endTime);
 
         String start = year+"-"+(String.format("%02d",month))+"-01";
         String end = year+"-"+(String.format("%02d",month))+"-31";
@@ -203,13 +212,13 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
 
             //根据账期查找历史客户数(仅统计状态为欠费与正常的客户总数之和)
             Integer accountNumber = payChargeSurveyMapper.getAccountNumber
-                    (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+                    (strarDate,endDate,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
             //根据账期查找历史水表数(仅统计状态为已开户的水表总数)
             Integer meterNumber = payChargeSurveyMapper.getMeterNumber
-                    (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+                    (strarDate,endDate,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
             //根据账期查找历史开户数(仅统计状态为正常的开户总数)
             Integer customerNumber = payChargeSurveyMapper.getCustomerNumber
-                    (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+                    (strarDate,endDate,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
 
             //上一账期汇总
             PayAccountSurvey lastAccount = payChargeSurveyMapper.getlastNumber(lastYear,lastMonth,
@@ -277,19 +286,30 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
             //根据账期查找历史数据(现金、微信支付、支付宝、银行)
             BigDecimal bigDecimalStr = new BigDecimal("0.0");
             BigDecimal cuttentAmount = payChargeSurveyMapper.getCurrentTran(year,month,siteId,customerId);
+            BigDecimal receivedCurrent = payChargeSurveyMapper.getReceivedCurrent(year,month,siteId,customerId);
+            cuttentAmount = cuttentAmount.add(receivedCurrent);
             cuttentAmount = cuttentAmount != null ? cuttentAmount : bigDecimalStr;
             //上一账期
             BigDecimal lastAmount = payChargeSurveyMapper.getCurrentTran(lastYear,lastMonth,siteId,customerId);
+            BigDecimal lastCurrent = payChargeSurveyMapper.getReceivedCurrent(lastYear,lastMonth,siteId,customerId);
+            lastAmount = lastAmount.add(lastCurrent);
             lastAmount = lastAmount != null ? lastAmount : bigDecimalStr;
             //当前账期按支付方式划分
             List<PayTransactionSurvey> tranList = payChargeSurveyMapper.getPayAmountList(year,month,siteId,customerId);
+            List<PayTransactionSurvey> receList = payChargeSurveyMapper.getCurrentReceived(year,month,siteId,customerId);
+
             //上一账期按支付方式划分
             List<PayTransactionSurvey> lasttranList = payChargeSurveyMapper.getPayAmountList(lastYear,lastMonth,siteId,customerId);
+            List<PayTransactionSurvey> lastreceList = payChargeSurveyMapper.getCurrentReceived(lastYear,lastMonth,siteId,customerId);
 
             BigDecimal cashIncome = bigDecimalStr;//现金
             BigDecimal wechatIncome = bigDecimalStr;//微信
             BigDecimal alipayIncome = bigDecimalStr;//支付宝
             BigDecimal bankIncome = bigDecimalStr;//银行
+            BigDecimal rececashIncome = bigDecimalStr;//现金
+            BigDecimal recewechatIncome = bigDecimalStr;//微信支付
+            BigDecimal recealipayIncome = bigDecimalStr; //支付宝
+            BigDecimal recebankIncome = bigDecimalStr;//银行
             //当前账期
             for(int i=0; i<tranList.size(); i++){
                 Integer payway = tranList.get(i).getPayway();
@@ -307,16 +327,43 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
                     cashIncome = tranList.get(i).getIncomeNumber();
                 }
             }
+            for(int i=0; i<receList.size(); i++){
+                Integer payway = receList.get(i).getPayway();
+                if(payway == 1){
+                    //支付宝
+                    recealipayIncome = receList.get(i).getIncomeNumber();
+                }else if(payway == 2){
+                    //微信
+                    recewechatIncome = receList.get(i).getIncomeNumber();
+                }else if (payway == 3) {
+                    //银行
+                    recebankIncome = receList.get(i).getIncomeNumber();
+                }else if (payway == 4) {
+                    //现金
+                    rececashIncome = receList.get(i).getIncomeNumber();
+                }
+            }
+            alipayIncome = alipayIncome.add(recealipayIncome);
+            wechatIncome = wechatIncome.add(recewechatIncome);
+            bankIncome = bankIncome.add(recebankIncome);
+            cashIncome = cashIncome.add(rececashIncome);
+
             transactionSurver.setIncomeNumber(cuttentAmount);
             transactionSurver.setLastIncomeNumber(lastAmount);
             transactionSurver.setAlipayIncome(alipayIncome);
             transactionSurver.setWechatIncome(wechatIncome);
             transactionSurver.setBankIncome(bankIncome);
             transactionSurver.setCashIncome(cashIncome);
+
             BigDecimal lastAlipayIncome = bigDecimalStr;
             BigDecimal lastWechatIncome = bigDecimalStr;
             BigDecimal lastBankIncome = bigDecimalStr;
             BigDecimal lastCashIncome = bigDecimalStr;
+
+            BigDecimal recelastAlipayIncome = bigDecimalStr;
+            BigDecimal recelastWechatIncome = bigDecimalStr;
+            BigDecimal recelastBankIncome = bigDecimalStr;
+            BigDecimal recelastCashIncome = bigDecimalStr;
             //上一账期
             for(int i=0; i<lasttranList.size(); i++){
                 Integer payway = lasttranList.get(i).getPayway();
@@ -334,6 +381,28 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
                     lastCashIncome = lasttranList.get(i).getIncomeNumber();
                 }
             }
+
+            for(int i=0; i<lastreceList.size(); i++){
+                Integer payway = lastreceList.get(i).getPayway();
+                if(payway == 1){
+                    //支付宝
+                    recelastAlipayIncome = lastreceList.get(i).getIncomeNumber();
+                }else if(payway == 2){
+                    //微信
+                    recelastWechatIncome = lastreceList.get(i).getIncomeNumber();
+                }else if (payway == 3) {
+                    //银行
+                    recelastBankIncome = lastreceList.get(i).getIncomeNumber();
+                }else if (payway == 4) {
+                    //现金
+                    recelastCashIncome = lastreceList.get(i).getIncomeNumber();
+                }
+            }
+            lastAlipayIncome = lastAlipayIncome.add(recelastAlipayIncome);
+            lastWechatIncome = lastWechatIncome.add(recelastWechatIncome);
+            lastBankIncome = lastBankIncome.add(recelastBankIncome);
+            lastCashIncome = lastCashIncome.add(recelastCashIncome);
+
             transactionSurver.setLastAlipayIncome(lastCashIncome);
             transactionSurver.setLastWechatIncome(lastWechatIncome);
             transactionSurver.setLastBankIncome(lastBankIncome);

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

@@ -5,18 +5,17 @@ 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.*;
-import com.bz.smart_city.entity.pay.PayAccountSurvey;
-import com.bz.smart_city.entity.pay.PayChargeSurvey;
-import com.bz.smart_city.entity.pay.PayFeeSuevey;
-import com.bz.smart_city.entity.pay.PayTransactionSurvey;
+import com.bz.smart_city.entity.pay.*;
 import com.bz.smart_city.service.pay.PayChargeSurveyService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.record.Record;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -55,12 +54,17 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
           String a = df.format(income);
           System.out.println("收入费率:"+a);*/
 
-          String a = "-90.89";
+          /*String a = "-90.89";
           String b = "90.89";
 
           String a1 = a.split("-")[1];
           String b1 = b.split("-")[1];
-          System.out.println("带负数转换:"+a1+";不带负数转换:"+b1);
+          System.out.println("带负数转换:"+a1+";不带负数转换:"+b1);*/
+          /*BigDecimal bigDecima1 = new BigDecimal("194.60");
+          BigDecimal bigDecima2 = new BigDecimal("600.00");
+          BigDecimal divide = bigDecima2.subtract(bigDecima1).divide(bigDecima1,3, RoundingMode.HALF_UP);*/
+
+          //BigDecimal divide = bigDecima1 .divide(bigDecima2,2, RoundingMode.HALF_UP);
       }catch (Exception e) {
           e.printStackTrace();
       }
@@ -93,41 +97,31 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
                 a.setMonth(month);
                 list.add(a);
             }
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
+            Date startTime = list.get(0).getStartTime();
+            String dateStart = format.format(startTime);
+            String dateEnd = format.format(new Date());
+
             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);
+            String lastDate = list.get(1).getYear()+"-"+String.format("%02d", list.get(1).getMonth())+"-01";
+            PayAccountSurvey accountSurvey = payChargeSurveyMapper.getlastAccount(null,siteId,customerId);
 
             //客户总数计算
             //当前账期以内客户总数
             Integer sumAccount = payChargeSurveyMapper.getAccountNumber(null,endPeriod,siteId,customerId);
             //当前账期客户总数
-            Integer sumCurrentAccount = payChargeSurveyMapper.getAccountNumber(startPeriod,endPeriod,siteId,customerId);
+            Integer sumCurrentAccount = payChargeSurveyMapper.getAccountNumber(dateStart,dateEnd,siteId,customerId);
             //上一期客户数
             Integer sumLastAccount = accountSurvey != null && accountSurvey.getAccountNumber() != null ? accountSurvey.getAccountNumber() : 0;
             //客户总数较上月比率
             String lastAccountRate = "0.0";
-            float num =(float)((sumCurrentAccount - sumLastAccount)/(sumLastAccount != null && sumLastAccount != 0 ? sumLastAccount : 1)*100);
-            lastAccountRate = df.format(num);
-
-            Integer lastAccountIsUp = num > 0  ? 1 : 0;
-            //截取字符串
-            lastAccountRate = lastAccountRate.contains("-") ? lastAccountRate.split("-")[1] : lastAccountRate;
+            RecordInfo info = this.calculationRate(sumAccount,sumLastAccount);
+            float num =info.getCount();
+            Integer lastAccountIsUp = info.getIsUp();
+            lastAccountRate = info.getRate();
 
             //赋值客户总数跟上月比率
             payChargeSurveyDto.setLastAccountIsUp(lastAccountIsUp);
@@ -139,16 +133,16 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
             //当前账期以内的水表总数
             Integer sumMeter = payChargeSurveyMapper.getMeterNumber(null,endPeriod,siteId,customerId);
             //当前账期水表数
-            Integer sumCurrentMeter = payChargeSurveyMapper.getMeterNumber(startPeriod,endPeriod,siteId,customerId);
+            Integer sumCurrentMeter = payChargeSurveyMapper.getMeterNumber(dateStart,dateEnd,siteId,customerId);
             //上一期水表数
             Integer sumLastMeter = accountSurvey != null && accountSurvey.getMeterNumber() != null ? accountSurvey.getMeterNumber() :0;
             //水表总数较上月比率
             String lastMeterRate = "0.0";
-            num =(float)((sumCurrentMeter - sumLastMeter)/(sumLastMeter != null && sumLastMeter != 0 ? sumLastMeter : 1)*100);
-            lastMeterRate = df.format(num);
-            Integer lastMeterIsUp = num > 0  ? 1 : 0;
+            info = this.calculationRate(sumCurrentMeter,sumLastMeter);
+            num =info.getCount();
+            Integer lastMeterIsUp = info.getIsUp();
             //截取字符串
-            lastMeterRate = lastMeterRate.contains("-") ? lastMeterRate.split("-")[1] : lastMeterRate;
+            lastMeterRate = info.getRate();
             //赋值水表总数跟上月比率
             payChargeSurveyDto.setLastMeterIsUp(lastMeterIsUp);
             payChargeSurveyDto.setMeterNumber(sumMeter != null ? sumMeter : 0);
@@ -158,16 +152,16 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
             //开户总数计算
             Integer sumCustomer = payChargeSurveyMapper.getCustomerNumber(null,endPeriod,siteId,customerId);
             //当前账期开户数
-            Integer sumCurrentCustomer = payChargeSurveyMapper.getCustomerNumber(startPeriod,endPeriod,siteId,customerId);
+            Integer sumCurrentCustomer = payChargeSurveyMapper.getCustomerNumber(dateStart,dateEnd,siteId,customerId);
             //上一账期开户数
             Integer sumLastCustomer = accountSurvey != null && accountSurvey.getCustomerNumber() != null ? accountSurvey.getCustomerNumber() : 0;
             //水表总数较上月比率
             String lastCusstomerRate = "0.0";
-            num =(float)((sumCurrentCustomer - sumLastCustomer)/(sumLastCustomer != null && sumLastCustomer != 0 ? sumLastCustomer : 1)*100);
-            lastCusstomerRate = df.format(num);
-            Integer lastCustomerIsUp = num > 0  ? 1 : 0;
+            info = this.calculationRate(sumCurrentCustomer,sumLastCustomer);
+            num =info.getCount();
+            Integer lastCustomerIsUp = info.getIsUp();
             //截取字符串
-            lastCusstomerRate = lastCusstomerRate.contains("-") ? lastCusstomerRate.split("-")[1] : lastCusstomerRate;
+            lastCusstomerRate = info.getRate();
             //赋值开户总数跟上月比率
             payChargeSurveyDto.setLastCustomerIsUp(lastCustomerIsUp);
             payChargeSurveyDto.setCustomerNumber(sumCustomer != null ? sumCustomer : 0);
@@ -176,7 +170,7 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
 
             //开户率
             String customerRate = "0.0";
-            num =(float)(sumCurrentCustomer/(sumCurrentMeter != null && sumCurrentMeter != 0 ? sumCurrentMeter : 1)*100);
+            num =((float)sumCustomer/(sumMeter != null && sumMeter != 0 ? sumMeter : 1)*100);
             customerRate = df.format(num);
             customerRate = customerRate.contains("-") ? customerRate.split("-")[1] : customerRate;
             payChargeSurveyDto.setCustomerRate(customerRate != null && customerRate != "" ? customerRate : "0.0");
@@ -215,13 +209,13 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
                     lastYear = lastYear;
                     lastMonth = number;
                 }
-                PayChangePeriodDto info = new PayChangePeriodDto();
-                info.setYear(lastYear);
-                info.setMonth(lastMonth);
-                info.setMeterNumber(0);
-                info.setCustomerNumber(0);
-                info.setAccountNumber(0);
-                pList.add(info);
+                PayChangePeriodDto pinfo = new PayChangePeriodDto();
+                pinfo.setYear(lastYear);
+                pinfo.setMonth(lastMonth);
+                pinfo.setMeterNumber(0);
+                pinfo.setCustomerNumber(0);
+                pinfo.setAccountNumber(0);
+                pList.add(pinfo);
             }
             accountList2.addAll(pList);
             payChargeSurveyDto.setList(accountList2);
@@ -271,6 +265,11 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
             BigDecimal wechatIncome = defc;//微信支付
             BigDecimal alipayIncome = defc; //支付宝
             BigDecimal bankIncome = defc;//银行
+
+            BigDecimal rececashIncome = defc;//现金
+            BigDecimal recewechatIncome = defc;//微信支付
+            BigDecimal recealipayIncome = defc; //支付宝
+            BigDecimal recebankIncome = defc;//银行
             Integer lastYear = null;
             Integer lastMonth = null;
             if(Integer.valueOf(month) == 1){
@@ -285,6 +284,7 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
             if((year.equals(list.get(0).getYear())) && (month.equals(list.get(0).getMonth()))){
                 //当前账期查询交易明细表
                 List<PayTransactionSurvey> tranList = payChargeSurveyMapper.getCurrentTranRocord(year,month,siteId,customerId);
+                List<PayTransactionSurvey> receList = payChargeSurveyMapper.getCurrentReceived(year,month,siteId,customerId);
                 for(int i=0; i<tranList.size(); i++){
                     Integer payway = tranList.get(i).getPayway();
                     if(payway == 1){
@@ -301,6 +301,26 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
                         cashIncome = tranList.get(i).getIncomeNumber();
                     }
                 }
+                for(int i=0; i<receList.size(); i++){
+                    Integer payway = receList.get(i).getPayway();
+                    if(payway == 1){
+                        //支付宝
+                        recealipayIncome = receList.get(i).getIncomeNumber();
+                    }else if(payway == 2){
+                        //微信
+                        recewechatIncome = receList.get(i).getIncomeNumber();
+                    }else if (payway == 3) {
+                        //银行
+                        recebankIncome = receList.get(i).getIncomeNumber();
+                    }else if (payway == 4) {
+                        //现金
+                        rececashIncome = receList.get(i).getIncomeNumber();
+                    }
+                }
+                alipayIncome = alipayIncome.add(recealipayIncome);
+                wechatIncome = wechatIncome.add(recewechatIncome);
+                bankIncome = bankIncome.add(recebankIncome);
+                cashIncome = cashIncome.add(rececashIncome);
                 BigDecimal currentIncome = alipayIncome.add(wechatIncome).add(bankIncome).add(cashIncome);//当前账期收入总数
                 //查找上月收入
                 PayTransactionSurvey lastTran = payChargeSurveyMapper.getLastTranRocord(lastYear,lastMonth,siteId,customerId);
@@ -332,7 +352,6 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
         return payTransactionSurveyDto;
     }
 
-
     //计算交易比率
     public PayTransactionSurveyDto tranCompute(PayTransactionSurvey transactionSurver){
         PayTransactionSurveyDto payTransactionSurveyDto = new PayTransactionSurveyDto();
@@ -360,49 +379,50 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
         try {
             BigDecimal currentIncome = transactionSurver.getIncomeNumber();//本月收入总数
             BigDecimal lastIncome = transactionSurver.getLastIncomeNumber();//上月收入总数
-            BigDecimal income = currentIncome.subtract(lastIncome).divide((lastIncome != null && lastIncome.compareTo(BigDecimal.ZERO)==1 ? lastIncome : defb),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
-            String lastIncomeRate = "0.0";
-            lastIncomeRate = df.format(income);
-            Integer lastIncomeIsUp = income.compareTo(BigDecimal.ZERO) == 1 ? 1 : 0;
-            //截取字符串
-            lastIncomeRate = lastIncomeRate.contains("-") ? lastIncomeRate.split("-")[1] : lastIncomeRate;
+
+            RecordInfo info = this.calculationRate(currentIncome,lastIncome);
+            BigDecimal income = info.getIncome();
+            String lastIncomeRate = info.getRate();
+            Integer lastIncomeIsUp = info.getIsUp();
+
 
             //按支付方式
             cashIncome = transactionSurver.getCashIncome();//本账期现金收入
             lastcashIncome = transactionSurver.getLastCashIncome();//上期现金收入
+
             wechatIncome = transactionSurver.getWechatIncome();//本账期微信
             lastwechatIncome = transactionSurver.getLastWechatIncome();//上期微信
+
             alipayIncome = transactionSurver.getAlipayIncome();//本账期支付宝
             lastalipayIncome = transactionSurver.getLastAlipayIncome();//上期支付宝
+
             bankIncome = transactionSurver.getBankIncome();//本账期银行
             lastbankIncome = transactionSurver.getLastBankIncome();//上期银行
+
+
+            info = this.calculationRate(cashIncome,lastcashIncome);
             //现金
-            income = cashIncome.subtract(lastcashIncome).divide((lastcashIncome != null && lastcashIncome.compareTo(BigDecimal.ZERO)==1 ? lastcashIncome : defb),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
-            lastCashRate = df.format(income);
-            Integer lastCashIsUp = income.compareTo(BigDecimal.ZERO) == 1 ? 1 : 0;
-            //截取字符串
-            lastCashRate = lastCashRate.contains("-") ? lastCashRate.split("-")[1] : lastCashRate;
+            income = info.getIncome();
+            lastCashRate = info.getRate();
+            Integer lastCashIsUp = info.getIsUp();
 
             //微信
-            income = wechatIncome.subtract(lastwechatIncome).divide((lastwechatIncome != null && lastwechatIncome.compareTo(BigDecimal.ZERO)==1 ? lastwechatIncome : defb),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
-            lastWechatRate = df.format(income);
-            Integer lastWechatIsUp = income.compareTo(BigDecimal.ZERO) == 1 ? 1 : 0;
-            //截取字符串
-            lastWechatRate = lastWechatRate.contains("-") ? lastWechatRate.split("-")[1] : lastWechatRate;
+            info = this.calculationRate(wechatIncome,lastwechatIncome);
+            income = info.getIncome();
+            Integer lastWechatIsUp = info.getIsUp();
+            lastWechatRate = info.getRate();
 
             //支付宝
-            income = alipayIncome.subtract(lastalipayIncome).divide((lastalipayIncome != null && lastalipayIncome.compareTo(BigDecimal.ZERO)==1 ? lastalipayIncome : defb), 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
-            lastAlipayRate = df.format(income);
-            Integer lastAlipayIsUp = income.compareTo(BigDecimal.ZERO) == 1 ? 1 : 0;
-            //截取字符串
-            lastAlipayRate = lastAlipayRate.contains("-") ? lastAlipayRate.split("-")[1] : lastAlipayRate;
+            info = this.calculationRate(alipayIncome,lastalipayIncome);
+            income = info.getIncome();
+            Integer lastAlipayIsUp = info.getIsUp();
+            lastAlipayRate = info.getRate();
 
             //银行
-            income = bankIncome.subtract(lastbankIncome).divide((lastbankIncome != null && lastbankIncome.compareTo(BigDecimal.ZERO)==1 ? lastbankIncome : defb),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
-            lastBankRate = df.format(income);
-            Integer lastBankIsUp = income.compareTo(BigDecimal.ZERO) == 1 ? 1 : 0;
-            //截取字符串
-            lastBankRate = lastBankRate.contains("-") ? lastBankRate.split("-")[1] : lastBankRate;
+            info = this.calculationRate(bankIncome,lastbankIncome);
+            income = info.getIncome();
+            Integer lastBankIsUp = info.getIsUp();
+            lastBankRate = info.getRate();
 
             //饼状态占比率
             BigDecimal current = alipayIncome.add(wechatIncome).add(bankIncome).add(cashIncome);
@@ -410,16 +430,16 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
             String alipayRate = "0.0";
             String wechatRate = "0.0";
             String bankRate = "0.0";
-            income = cashIncome.divide((current != null && current.compareTo(BigDecimal.ZERO)==1 ? current : defb),2, BigDecimal.ROUND_HALF_UP);
+            income = cashIncome.divide((current != null && current.compareTo(BigDecimal.ZERO)==1 ? current : defb),3, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
             CashRate = df.format(income);
 
-            income = alipayIncome.divide((current != null && current.compareTo(BigDecimal.ZERO)==1 ? current : defb),2, BigDecimal.ROUND_HALF_UP);
+            income = alipayIncome.divide((current != null && current.compareTo(BigDecimal.ZERO)==1 ? current : defb),3, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
             alipayRate = df.format(income);
 
-            income = wechatIncome.divide((current != null && current.compareTo(BigDecimal.ZERO)==1 ? current : defb),2, BigDecimal.ROUND_HALF_UP);
+            income = wechatIncome.divide((current != null && current.compareTo(BigDecimal.ZERO)==1 ? current : defb),3, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
             wechatRate = df.format(income);
 
-            income = bankIncome.divide((current != null && current.compareTo(BigDecimal.ZERO)==1 ? current : defb),2, BigDecimal.ROUND_HALF_UP);
+            income = bankIncome.divide((current != null && current.compareTo(BigDecimal.ZERO)==1 ? current : defb),3, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
             bankRate = df.format(income);
 
             //收入总数
@@ -454,7 +474,6 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
         return payTransactionSurveyDto;
     }
 
-
     /**
      * 收费概况
      * @return
@@ -568,13 +587,6 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
             //上一账期
             Integer lastYear = null;
             Integer lastMonth = null;
-            if(Integer.valueOf(month) == 1){
-                lastYear = year-1;
-                lastMonth = 12;
-            }else{
-                lastYear = year;
-                lastMonth = month -1;
-            }
 
             //先获取本年度结算水量(按自然年)
             Calendar date = Calendar.getInstance();
@@ -589,31 +601,61 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
             //去年同一时间累计用水量
             startDate = (currentYear - 1)+"-"+"01";
             endDate = (currentYear - 1)+"-"+String.format("%02d",month);
-            BigDecimal lastAmount = payChargeSurveyMapper.getAmountInfo(startDate,endDate,siteId,customerId);
+
+            //明天任务,查询汇总表
+            BigDecimal lastAmount = payChargeSurveyMapper.getAmountSureyInfo(startDate+" 00:00:00",endDate+" 00:00:00",siteId,customerId);
+            //BigDecimal lastAmount = payChargeSurveyMapper.getAmountInfo(startDate,endDate,siteId,customerId);
             //计算年同比 = 当前总数-去年同期总数│/去年同期总数
             String lastYearRate = "0.0";
-            BigDecimal number  = currentAmount.subtract(lastAmount).divide((lastAmount != null && lastAmount.compareTo(BigDecimal.ZERO)==1 ? lastAmount : defb),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
-            //0下降  1商社
-            Integer lastYearIsUp = number.compareTo(BigDecimal.ZERO) == 1 ? 1 : 0;
-            //保留一位小数
-            lastYearRate = df.format(number);
-            //截取字符串
-            lastYearRate = lastYearRate.contains("-") ? lastYearRate.split("-")[1] : lastYearRate;
+            Integer lastYearIsUp = 0;
+            BigDecimal number = defc;
+            //上期总数大于0则计算
+            if(lastAmount.compareTo(BigDecimal.ZERO) == 1){
+                if(currentAmount.subtract(lastAmount).compareTo(BigDecimal.ZERO) == 0){
+                    //本期减上期持平显示→
+                    lastYearIsUp = 2;
+                    lastYearRate = "→";
+                }else{
+                    number  = currentAmount.subtract(lastAmount).divide((lastAmount != null && lastAmount.compareTo(BigDecimal.ZERO)==1 ? lastAmount : defb),3, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
+                    lastYearIsUp = number.compareTo(BigDecimal.ZERO) == 1 ? 1 : 0;
+                    //保留一位小数
+                    lastYearRate = df.format(number);
+                    //截取字符串
+                    lastYearRate = lastYearRate.contains("-") ? lastYearRate.split("-")[1] : lastYearRate;
+                }
+            }else{
+                //小于=0不计算增长率
+                //0下降  1上升 2不计算
+                lastYearIsUp = 2;
+                lastYearRate = "-";
+            }
 
             //计算月
             //当前月
             BigDecimal currentMAmount = payChargeSurveyMapper.getAmountMonth(year,month,siteId,customerId);
             //去年同月
-            BigDecimal lastMAmount = payChargeSurveyMapper.getAmountMonth((year-1),month,siteId,customerId);
-            //计算月同比 = 当前总数-上月同期总数│/去年同期总数
-            number  = currentMAmount.subtract(lastMAmount).divide((lastMAmount != null && lastMAmount.compareTo(BigDecimal.ZERO)==1 ? lastMAmount : defb),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
-            //0下降  1商社
-            Integer lastMonthIsUp = number.compareTo(BigDecimal.ZERO) == 1 ? 1 : 0;
-            //保留一位小数
+            BigDecimal lastMAmount = payChargeSurveyMapper.getAmountMonthSurvey((year-1),month,siteId,customerId);
+            Integer lastMonthIsUp = 0;
             String lastMonthRate = "0.0";
-            lastMonthRate = df.format(number);
-            //截取字符串
-            lastMonthRate = lastMonthRate.contains("-") ? lastMonthRate.split("-")[1] : lastMonthRate;
+            if(lastMAmount.compareTo(BigDecimal.ZERO) == 1){
+                if(currentMAmount.subtract(lastMAmount).compareTo(BigDecimal.ZERO) == 0){
+                    lastMonthIsUp = 2;
+                    lastMonthRate = "→";
+                }else{
+                    //计算月同比 = 当前总数-上月同期总数│/去年同期总数
+                    number  = currentMAmount.subtract(lastMAmount).divide((lastMAmount != null && lastMAmount.compareTo(BigDecimal.ZERO)==1 ? lastMAmount : defb),3, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
+                    //0下降  1商社
+                    lastMonthIsUp = number.compareTo(BigDecimal.ZERO) == 1 ? 1 : 0;
+                    //保留一位小数
+                    lastMonthRate = df.format(number);
+                    //截取字符串
+                    lastMonthRate = lastMonthRate.contains("-") ? lastMonthRate.split("-")[1] : lastMonthRate;
+                }
+            }else{
+                lastMonthIsUp = 2;
+                lastMonthRate = "-";
+            }
+
 
             //最近一年数据
             List<PayAmountSurveyListDto> cList = new ArrayList<PayAmountSurveyListDto>();
@@ -660,7 +702,88 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
         return payAmountSurveyDto;
     }
 
+    /**
+     * 计算较上月 Integer
+     * @param currentAmount
+     * @param lastAmount
+     * @return
+     */
+    public RecordInfo calculationRate(Integer currentAmount ,Integer lastAmount){
+        RecordInfo info = new RecordInfo();
+        Integer lastIncomeIsUp = 0;
+        String lastIncomeRate = "-";
+        BigDecimal income = new BigDecimal("0.0");
+        DecimalFormat df = new DecimalFormat("0.0");
+        float num = 0;
+        try {
+            if(lastAmount >0){
+                if(currentAmount - lastAmount <=0){
+                    //本期减上期持平显示→
+                    lastIncomeIsUp = 2;
+                    lastIncomeRate = "→";
+                }else{
+                    num =((float)(currentAmount - lastAmount)/(lastAmount != null && lastAmount != 0 ? lastAmount : 1)*100);
+                    lastIncomeRate = df.format(num);
+                    Integer lastCustomerIsUp = num > 0  ? 1 : 0;
+                    //截取字符串
+                    lastIncomeRate = lastIncomeRate.contains("-") ? lastIncomeRate.split("-")[1] : lastIncomeRate;
+                }
+            }else{
+                //小于=0不计算增长率
+                //0下降  1上升 2不计算
+                lastIncomeIsUp = 2;
+                lastIncomeRate = "-";
+            }
+            info.setCount(num);
+            info.setIsUp(lastIncomeIsUp);
+            info.setRate(lastIncomeRate);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return info;
+    }
 
-
+    /**
+     *  计算较上月 BigDecimal
+     * @param currentIncome
+     * @param lastIncome
+     * @return
+     */
+    public RecordInfo calculationRate(BigDecimal currentIncome,BigDecimal lastIncome){
+        RecordInfo info = new RecordInfo();
+        Integer lastIncomeIsUp = 0;
+        String lastIncomeRate = "-";
+        BigDecimal income = new BigDecimal("0.0");
+        BigDecimal defc = new BigDecimal("0.0");
+        BigDecimal defb = new BigDecimal("1.0");
+        DecimalFormat df = new DecimalFormat("0.0");
+        try{
+            if(lastIncome.compareTo(BigDecimal.ZERO) == 1){
+                if(currentIncome.subtract(lastIncome).compareTo(BigDecimal.ZERO) == 0){
+                    //本期减上期持平显示→
+                    lastIncomeIsUp = 2;
+                    lastIncomeRate = "→";
+                }else{
+                    income  = currentIncome.subtract(lastIncome).divide((lastIncome != null && lastIncome.compareTo(BigDecimal.ZERO)==1 ? lastIncome : defb),3, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
+                    lastIncomeIsUp = income.compareTo(BigDecimal.ZERO) == 1 ? 1 : 0;
+                    //保留一位小数
+                    lastIncomeRate = df.format(income);
+                    //截取字符串
+                    lastIncomeRate = lastIncomeRate.contains("-") ? lastIncomeRate.split("-")[1] : lastIncomeRate;
+                }
+            }else{
+                //小于=0不计算增长率
+                //0下降  1上升 2不计算
+                lastIncomeIsUp = 2;
+                lastIncomeRate = "-";
+            }
+            info.setIncome(income);
+            info.setIsUp(lastIncomeIsUp);
+            info.setRate(lastIncomeRate);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return info;
+    }
 
 }

+ 127 - 36
smart-city-platform/src/main/resources/mapper/pay/PayChargeSurveyMapper.xml

@@ -51,24 +51,28 @@
     </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
+        select count(1)
+        from  sc_device scd
+        left join sc_install_list scinstall on scd.id = scinstall.device_id  and scinstall.customer_id=#{customerId}
+        left JOIN sc_device_type sdt on sdt.id = scd.device_type
+        left join sc_device_manufacturer sdm on sdm.id = sdt.manufacturer_id and sdm.`status`=1
+        left join pay_base_account pba on pba.id = scd.account_id  and pba.site_id=#{siteId} and pba.customer_id=#{customerId}
+        left join pay_base_customerandmeterrela ppr on ppr.metercode = scd.metercode and ppr.site_id=#{siteId} and ppr.customer_id=#{customerId}
+        left join
+        (SELECT a.watermeter_id,a.reading FROM pay_amount_waterusedamount_day AS a,
+        (SELECT b.watermeter_id, MAX(b.read_date) AS read_date FROM pay_amount_waterusedamount_day AS b
+        where b.reading is not null and b.customer_id=#{customerId} and b.site_id=#{siteId}
+        GROUP BY b.watermeter_id)
+        AS c WHERE a.watermeter_id=c.watermeter_id AND a.read_date = c.read_date)  rd on rd.watermeter_id = scd.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}
+            scd.customer_id =#{customerId} and scd.account_id is not null
+            <if test="startDate != null">
+                and scinstall.date_create &gt;=#{startDate}
             </if>
-            <if test="customerId != null">
-                and customer.customer_id =#{customerId}
+            <if test="endDate != null">
+                and scinstall.date_create &lt;=#{endDate}
             </if>
+            and(scinstall.is_accepted = 1 or scinstall.is_accepted = 2)
         </where>
     </select>
 
@@ -165,15 +169,9 @@
 
     <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"
+            IFNULL(sum(a.account_number),0) as "accountNumber",
+            IFNULL(sum(a.meter_number),0) as "meterNumber",
+            IFNULL(sum(a.customer_number),0) as "customerNumber"
         from pay_account_survey a
         <where>
             <if test="periodDate != null">
@@ -190,11 +188,35 @@
 
     <select id="getCurrentTran" resultType="java.math.BigDecimal">
         select
-            sum(transamount)
+            IFNULL(sum(transamount),0)
         from pay_pay_transactiondetails a
         <where>
             <!-- 排除退款跟预存抵扣-->
-            a.state =  1 and a.payway != 5
+            a.state =  1 and canceledrecord_id is null and iscanceled = 0
+            and (a.payway = 1 or a.payway = 2 or a.payway=3 or a.payway = 4)
+            <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>
+    </select>
+
+    <select id="getReceivedCurrent" resultType="java.math.BigDecimal">
+        select
+            IFNULL(sum(receivedamount),0)
+        from pay_pay_received a
+        <where>
+            <!-- 排除退款跟预存抵扣-->
+            canceledrecord_id is null and iscanceled = 0
+            and (a.payway = 1 or a.payway = 2 or a.payway=3 or a.payway = 4)
             <if test="siteId != null">
                 and a.site_id =#{siteId}
             </if>
@@ -220,7 +242,7 @@
             payway
         from pay_pay_transactiondetails a
         <where>
-            a.payway != 5 and a.state =  1
+            a.payway != 5 and a.state =  1 and canceledrecord_id is null and iscanceled = 0
             <if test="year != null">
                 and a.year =#{year}
             </if>
@@ -292,15 +314,42 @@
 
     <select id="getCurrentTranRocord" resultType="com.bz.smart_city.entity.pay.PayTransactionSurvey">
         select
-        case when a.payway =  1 then sum(transamount)
-        when a.payway = 2 then sum(transamount)
-        when a.payway = 3 then sum(transamount)
-        when a.payway = 4 then sum(transamount)
-        end as "incomeNumber",
-        payway as "payway"
+            case when a.payway =  1 then sum(transamount)
+            when a.payway = 2 then sum(transamount)
+            when a.payway = 3 then sum(transamount)
+            when a.payway = 4 then sum(transamount)
+            end as "incomeNumber",
+            payway as "payway"
         from pay_pay_transactiondetails a
         <where>
-            a.payway != 5 and a.state =  1
+            a.payway != 5 and a.state =  1 and canceledrecord_id is null and iscanceled = 0
+            <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>
+        GROUP BY a.payway
+    </select>
+
+    <select id="getCurrentReceived" resultType="com.bz.smart_city.entity.pay.PayTransactionSurvey">
+        select
+            case when a.payway =  1 then sum(receivedamount)
+            when a.payway = 2 then sum(receivedamount)
+            when a.payway = 3 then sum(receivedamount)
+            when a.payway = 4 then sum(receivedamount)
+            end as "incomeNumber",
+            payway as "payway"
+        from pay_pay_received a
+        <where>
+            a.payway != 5 and a.state =  1 and canceledrecord_id is null and iscanceled = 0
             <if test="year != null">
                 and a.year =#{year}
             </if>
@@ -370,8 +419,12 @@
     </select>
 
     <select id="getSumReceived" resultType="java.math.BigDecimal">
-        select IFNULL(sum(payamount),0) from pay_pay_received a
+        select IFNULL(sum(receivedamount),0) from pay_pay_received a
         <where>
+            a.payway != 5
+            AND a.state = 1
+            AND canceledrecord_id IS NULL
+            AND iscanceled = 0
             <if test="year != null">
                 and a.year =#{year}
             </if>
@@ -390,7 +443,7 @@
     <select id="getSumPrestore" resultType="java.math.BigDecimal">
         select IFNULL(sum(transamount),0) from pay_pay_transactiondetails a
         <where>
-            transtype = '4'
+            (transtype = '1' or transtype = '4')  and canceledrecord_id is null and iscanceled = 0
             <if test="year != null">
                 and a.year =#{year}
             </if>
@@ -494,6 +547,25 @@
             </if>
         </where>
     </select>
+    <select id="getAmountSureyInfo" resultType="java.math.BigDecimal">
+        select
+            IFNULL(sum(amount_number),0)
+        from pay_amount_survey a
+        <where>
+            <if test="startDate != null">
+                and CONVERT( a.period_date, DATETIME )  &gt;=#{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>
+    </select>
 
     <select id="getAmountMonth" resultType="java.math.BigDecimal">
         select
@@ -514,6 +586,25 @@
             </if>
         </where>
     </select>
+    <select id="getAmountMonthSurvey" resultType="java.math.BigDecimal">
+        select
+            IFNULL(sum(amount_number),0)
+        from pay_amount_survey a
+        <where>
+            <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>
+    </select>
 
     <select id="getAmountGroupList" resultType="com.bz.smart_city.dto.pay.PayAmountSurveyListDto">
         select