|
@@ -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.Pagination;
|
|
import com.bz.smart_city.commom.model.ResultStatus;
|
|
import com.bz.smart_city.commom.model.ResultStatus;
|
|
import com.bz.smart_city.commom.util.UserUtil;
|
|
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.BaseClosingAccountInfoMapper;
|
|
import com.bz.smart_city.dao.pay.PayBaseConfigMapper;
|
|
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.LoginUser;
|
|
import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
|
|
import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
|
|
import com.bz.smart_city.dto.pay.PayBaseConfigDto;
|
|
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.bz.smart_city.service.pay.BaseClosingAccountInfoService;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.apache.ibatis.annotations.Param;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.math.BigInteger;
|
|
import java.math.BigInteger;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -34,6 +35,8 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
|
|
private BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
|
|
private BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
|
|
@Resource
|
|
@Resource
|
|
private PayBaseConfigMapper baseConfigMapper;
|
|
private PayBaseConfigMapper baseConfigMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private PayChargeSurveyMapper payChargeSurveyMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Pagination<BaseClosingAccountInfoDto> getList(Integer year, Integer month, Integer pageNum, Integer pageSize) {
|
|
public Pagination<BaseClosingAccountInfoDto> getList(Integer year, Integer month, Integer pageNum, Integer pageSize) {
|
|
@@ -110,12 +113,28 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (isOk) {
|
|
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) + "月已经结账";
|
|
String msg2 = year + "年" + String.format("%02d", month) + "月已经结账";
|
|
-
|
|
|
|
baseClosingAccountInfoDto.setEndTime(new Date());
|
|
baseClosingAccountInfoDto.setEndTime(new Date());
|
|
baseClosingAccountInfoDto.setRemarks(msg2);
|
|
baseClosingAccountInfoDto.setRemarks(msg2);
|
|
baseClosingAccountInfoDto.setState(1);
|
|
baseClosingAccountInfoDto.setState(1);
|
|
@@ -149,6 +168,68 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
|
|
return message;
|
|
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
|
|
@Override
|
|
public List<BaseClosingAccountInfoDto> getList(Integer year, Integer month) {
|
|
public List<BaseClosingAccountInfoDto> getList(Integer year, Integer month) {
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|