|
|
|
@ -0,0 +1,742 @@
|
|
|
|
|
package jnpf.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import jnpf.entity.*;
|
|
|
|
|
import jnpf.mapper.BillTableMapper;
|
|
|
|
|
import jnpf.service.*;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import jnpf.model.billtable.*;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import jnpf.permission.model.authorize.AuthorizeConditionModel;
|
|
|
|
|
import jnpf.util.GeneraterSwapUtil;
|
|
|
|
|
import jnpf.database.model.superQuery.SuperQueryJsonModel;
|
|
|
|
|
import jnpf.database.model.superQuery.ConditionJsonModel;
|
|
|
|
|
import jnpf.database.model.superQuery.SuperQueryConditionModel;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
import jnpf.model.QueryModel;
|
|
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import jnpf.base.model.ColumnDataModel;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import jnpf.database.model.superQuery.SuperJsonModel;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
|
|
import jnpf.util.*;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import jnpf.base.UserInfo;
|
|
|
|
|
import jnpf.permission.entity.UserEntity;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* BillTable
|
|
|
|
|
* 版本: V3.5
|
|
|
|
|
* 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com)
|
|
|
|
|
* 作者: JNPF开发平台组
|
|
|
|
|
* 日期: 2024-07-22
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class BillTableServiceImpl extends ServiceImpl<BillTableMapper, BillTableEntity> implements BillTableService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private GeneraterSwapUtil generaterSwapUtil;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserProvider userProvider;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private BillspacedetailService billspacedetailService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private BilldevicedeatialService billdevicedeatialService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private BillotherdeatialService billotherdeatialService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private EnterpriseMerchantsService enterpriseMerchantsService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ContractService contractService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<BillTableEntity> getList(BillTablePagination billTablePagination) {
|
|
|
|
|
return getTypeList(billTablePagination, billTablePagination.getDataType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 列表查询
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BillTableEntity> getTypeList(BillTablePagination billTablePagination, String dataType) {
|
|
|
|
|
String userId = userProvider.get().getUserId();
|
|
|
|
|
List<String> AllIdList = new ArrayList();
|
|
|
|
|
List<List<String>> intersectionList = new ArrayList<>();
|
|
|
|
|
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
|
|
|
|
|
String columnData = !isPc ? BillTableConstant.getAppColumnData() : BillTableConstant.getColumnData();
|
|
|
|
|
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
|
|
|
|
|
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
|
|
|
|
|
|
|
|
|
|
int total = 0;
|
|
|
|
|
int billTableNum = 0;
|
|
|
|
|
QueryWrapper<BillTableEntity> billTableQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
int billdevicedeatialNum = 0;
|
|
|
|
|
QueryWrapper<BilldevicedeatialEntity> billdevicedeatialQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
int billotherdeatialNum = 0;
|
|
|
|
|
QueryWrapper<BillotherdeatialEntity> billotherdeatialQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
int billspacedetailNum = 0;
|
|
|
|
|
QueryWrapper<BillspacedetailEntity> billspacedetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
long billdevicedeatialcount = billdevicedeatialService.count();
|
|
|
|
|
long billotherdeatialcount = billotherdeatialService.count();
|
|
|
|
|
long billspacedetailcount = billspacedetailService.count();
|
|
|
|
|
List<String> allSuperIDlist = new ArrayList<>();
|
|
|
|
|
String superOp = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(billTablePagination.getSuperQueryJson())) {
|
|
|
|
|
List<String> allSuperList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionSuperList = new ArrayList<>();
|
|
|
|
|
String queryJson = billTablePagination.getSuperQueryJson();
|
|
|
|
|
SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class);
|
|
|
|
|
int superNum = 0;
|
|
|
|
|
QueryWrapper<BillTableEntity> billTableSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
billTableSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(billTableSuperWrapper, BillTableEntity.class, queryJson, "0"));
|
|
|
|
|
int billTableNum1 = billTableSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (billTableNum1 > 0) {
|
|
|
|
|
List<String> billTableList = this.list(billTableSuperWrapper).stream().map(BillTableEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allSuperList.addAll(billTableList);
|
|
|
|
|
intersectionSuperList.add(billTableList);
|
|
|
|
|
superNum++;
|
|
|
|
|
}
|
|
|
|
|
String BilldevicedeatialTable = "yq_bill_device_deatial";
|
|
|
|
|
boolean BilldevicedeatialHasSql = queryJson.contains(BilldevicedeatialTable);
|
|
|
|
|
List<String> billdevicedeatialList = generaterSwapUtil.selectIdsByChildCondition(BillTableConstant.getTableList(), BilldevicedeatialTable, queryJson, null);
|
|
|
|
|
if (BilldevicedeatialHasSql) {
|
|
|
|
|
allSuperList.addAll(billdevicedeatialList);
|
|
|
|
|
intersectionSuperList.add(billdevicedeatialList);
|
|
|
|
|
superNum++;
|
|
|
|
|
}
|
|
|
|
|
String BillotherdeatialTable = "yq_bill_other_deatial";
|
|
|
|
|
boolean BillotherdeatialHasSql = queryJson.contains(BillotherdeatialTable);
|
|
|
|
|
List<String> billotherdeatialList = generaterSwapUtil.selectIdsByChildCondition(BillTableConstant.getTableList(), BillotherdeatialTable, queryJson, null);
|
|
|
|
|
if (BillotherdeatialHasSql) {
|
|
|
|
|
allSuperList.addAll(billotherdeatialList);
|
|
|
|
|
intersectionSuperList.add(billotherdeatialList);
|
|
|
|
|
superNum++;
|
|
|
|
|
}
|
|
|
|
|
String BillspacedetailTable = "yq_bill_space_detail";
|
|
|
|
|
boolean BillspacedetailHasSql = queryJson.contains(BillspacedetailTable);
|
|
|
|
|
List<String> billspacedetailList = generaterSwapUtil.selectIdsByChildCondition(BillTableConstant.getTableList(), BillspacedetailTable, queryJson, null);
|
|
|
|
|
if (BillspacedetailHasSql) {
|
|
|
|
|
allSuperList.addAll(billspacedetailList);
|
|
|
|
|
intersectionSuperList.add(billspacedetailList);
|
|
|
|
|
superNum++;
|
|
|
|
|
}
|
|
|
|
|
superOp = superNum > 0 ? superJsonModel.getMatchLogic() : "";
|
|
|
|
|
//and or
|
|
|
|
|
if (superOp.equalsIgnoreCase("and")) {
|
|
|
|
|
allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList);
|
|
|
|
|
} else {
|
|
|
|
|
allSuperIDlist = allSuperList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<String> allRuleIDlist = new ArrayList<>();
|
|
|
|
|
String ruleOp = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(ruleJson)) {
|
|
|
|
|
List<String> allRuleList = new ArrayList<>();
|
|
|
|
|
List<List<String>> intersectionRuleList = new ArrayList<>();
|
|
|
|
|
SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class);
|
|
|
|
|
int ruleNum = 0;
|
|
|
|
|
QueryWrapper<BillTableEntity> billTableSuperWrapper = new QueryWrapper<>();
|
|
|
|
|
billTableSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(billTableSuperWrapper, BillTableEntity.class, ruleJson, "0"));
|
|
|
|
|
int billTableNum1 = billTableSuperWrapper.getExpression().getNormal().size();
|
|
|
|
|
if (billTableNum1 > 0) {
|
|
|
|
|
List<String> billTableList = this.list(billTableSuperWrapper).stream().map(BillTableEntity::getId).collect(Collectors.toList());
|
|
|
|
|
allRuleList.addAll(billTableList);
|
|
|
|
|
intersectionRuleList.add(billTableList);
|
|
|
|
|
ruleNum++;
|
|
|
|
|
}
|
|
|
|
|
String BilldevicedeatialTable = "yq_bill_device_deatial";
|
|
|
|
|
boolean BilldevicedeatialHasSql = ruleJson.contains(BilldevicedeatialTable);
|
|
|
|
|
List<String> billdevicedeatialList = generaterSwapUtil.selectIdsByChildCondition(BillTableConstant.getTableList(), BilldevicedeatialTable, ruleJson, null);
|
|
|
|
|
if (BilldevicedeatialHasSql) {
|
|
|
|
|
allRuleList.addAll(billdevicedeatialList);
|
|
|
|
|
intersectionRuleList.add(billdevicedeatialList);
|
|
|
|
|
ruleNum++;
|
|
|
|
|
}
|
|
|
|
|
String BillotherdeatialTable = "yq_bill_other_deatial";
|
|
|
|
|
boolean BillotherdeatialHasSql = ruleJson.contains(BillotherdeatialTable);
|
|
|
|
|
List<String> billotherdeatialList = generaterSwapUtil.selectIdsByChildCondition(BillTableConstant.getTableList(), BillotherdeatialTable, ruleJson, null);
|
|
|
|
|
if (BillotherdeatialHasSql) {
|
|
|
|
|
allRuleList.addAll(billotherdeatialList);
|
|
|
|
|
intersectionRuleList.add(billotherdeatialList);
|
|
|
|
|
ruleNum++;
|
|
|
|
|
}
|
|
|
|
|
String BillspacedetailTable = "yq_bill_space_detail";
|
|
|
|
|
boolean BillspacedetailHasSql = ruleJson.contains(BillspacedetailTable);
|
|
|
|
|
List<String> billspacedetailList = generaterSwapUtil.selectIdsByChildCondition(BillTableConstant.getTableList(), BillspacedetailTable, ruleJson, null);
|
|
|
|
|
if (BillspacedetailHasSql) {
|
|
|
|
|
allRuleList.addAll(billspacedetailList);
|
|
|
|
|
intersectionRuleList.add(billspacedetailList);
|
|
|
|
|
ruleNum++;
|
|
|
|
|
}
|
|
|
|
|
ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : "";
|
|
|
|
|
//and or
|
|
|
|
|
if (ruleOp.equalsIgnoreCase("and")) {
|
|
|
|
|
allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList);
|
|
|
|
|
} else {
|
|
|
|
|
allRuleIDlist = allRuleList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
boolean pcPermission = false;
|
|
|
|
|
boolean appPermission = false;
|
|
|
|
|
if (isPc && pcPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object billTableObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(billTableQueryWrapper, BillTableEntity.class, billTablePagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(billTableObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
billTableQueryWrapper = (QueryWrapper<BillTableEntity>) billTableObj;
|
|
|
|
|
if (billTableQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
billTableNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Object billdevicedeatialObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(billdevicedeatialQueryWrapper, BilldevicedeatialEntity.class, billTablePagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(billdevicedeatialObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
billdevicedeatialQueryWrapper = (QueryWrapper<BilldevicedeatialEntity>) billdevicedeatialObj;
|
|
|
|
|
if (billdevicedeatialQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
billdevicedeatialNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Object billotherdeatialObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(billotherdeatialQueryWrapper, BillotherdeatialEntity.class, billTablePagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(billotherdeatialObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
billotherdeatialQueryWrapper = (QueryWrapper<BillotherdeatialEntity>) billotherdeatialObj;
|
|
|
|
|
if (billotherdeatialQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
billotherdeatialNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Object billspacedetailObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(billspacedetailQueryWrapper, BillspacedetailEntity.class, billTablePagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(billspacedetailObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
billspacedetailQueryWrapper = (QueryWrapper<BillspacedetailEntity>) billspacedetailObj;
|
|
|
|
|
if (billspacedetailQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
billspacedetailNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isPc && appPermission) {
|
|
|
|
|
if (!userProvider.get().getIsAdministrator()) {
|
|
|
|
|
Object billTableObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(billTableQueryWrapper, BillTableEntity.class, billTablePagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(billTableObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
billTableQueryWrapper = (QueryWrapper<BillTableEntity>) billTableObj;
|
|
|
|
|
if (billTableQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
billTableNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object billdevicedeatialObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(billdevicedeatialQueryWrapper, BilldevicedeatialEntity.class, billTablePagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(billdevicedeatialObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
billdevicedeatialQueryWrapper = (QueryWrapper<BilldevicedeatialEntity>) billdevicedeatialObj;
|
|
|
|
|
if (billdevicedeatialQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
billdevicedeatialNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object billotherdeatialObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(billotherdeatialQueryWrapper, BillotherdeatialEntity.class, billTablePagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(billotherdeatialObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
billotherdeatialQueryWrapper = (QueryWrapper<BillotherdeatialEntity>) billotherdeatialObj;
|
|
|
|
|
if (billotherdeatialQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
billotherdeatialNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object billspacedetailObj = generaterSwapUtil.getAuthorizeCondition(new QueryModel(billspacedetailQueryWrapper, BillspacedetailEntity.class, billTablePagination.getMenuId(), "0"));
|
|
|
|
|
if (ObjectUtil.isEmpty(billspacedetailObj)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} else {
|
|
|
|
|
billspacedetailQueryWrapper = (QueryWrapper<BillspacedetailEntity>) billspacedetailObj;
|
|
|
|
|
if (billspacedetailQueryWrapper.getExpression().getNormal().size() > 0) {
|
|
|
|
|
billspacedetailNum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isPc) {
|
|
|
|
|
if (ObjectUtil.isNotEmpty(billTablePagination.getCreationTime())) {
|
|
|
|
|
billTableNum++;
|
|
|
|
|
|
|
|
|
|
List CreationTimeList = JsonUtil.getJsonToList(billTablePagination.getCreationTime(), String.class);
|
|
|
|
|
Long fir = Long.valueOf(String.valueOf(CreationTimeList.get(0)));
|
|
|
|
|
Long sec = Long.valueOf(String.valueOf(CreationTimeList.get(1)));
|
|
|
|
|
|
|
|
|
|
billTableQueryWrapper.lambda().ge(BillTableEntity::getCreationTime, new Date(fir))
|
|
|
|
|
.le(BillTableEntity::getCreationTime, DateUtil.stringToDate(DateUtil.daFormatYmd(sec) + " 23:59:59"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(billTablePagination.getMerchantName())) {
|
|
|
|
|
billTableNum++;
|
|
|
|
|
|
|
|
|
|
String value = billTablePagination.getMerchantName() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(billTablePagination.getMerchantName()) :
|
|
|
|
|
String.valueOf(billTablePagination.getMerchantName());
|
|
|
|
|
billTableQueryWrapper.lambda().like(BillTableEntity::getMerchantName, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(billTablePagination.getContractName())) {
|
|
|
|
|
billTableNum++;
|
|
|
|
|
|
|
|
|
|
String value = billTablePagination.getContractName() instanceof List ?
|
|
|
|
|
JsonUtil.getObjectToString(billTablePagination.getContractName()) :
|
|
|
|
|
String.valueOf(billTablePagination.getContractName());
|
|
|
|
|
billTableQueryWrapper.lambda().like(BillTableEntity::getContractName, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(billTablePagination.getBillStatus())) {
|
|
|
|
|
billTableNum++;
|
|
|
|
|
|
|
|
|
|
List<String> idList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
String[][] billStatus = JsonUtil.getJsonToBean(billTablePagination.getBillStatus(), String[][].class);
|
|
|
|
|
for (int i = 0; i < billStatus.length; i++) {
|
|
|
|
|
if (billStatus[i].length > 0) {
|
|
|
|
|
idList.add(JsonUtil.getObjectToString(Arrays.asList(billStatus[i])));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
try {
|
|
|
|
|
List<String> billStatus = JsonUtil.getJsonToList(billTablePagination.getBillStatus(), String.class);
|
|
|
|
|
if (billStatus.size() > 0) {
|
|
|
|
|
idList.addAll(billStatus);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e2) {
|
|
|
|
|
idList.add(String.valueOf(billTablePagination.getBillStatus()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
billTableQueryWrapper.lambda().and(t -> {
|
|
|
|
|
idList.forEach(tt -> {
|
|
|
|
|
t.like(BillTableEntity::getBillStatus, tt).or();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (billdevicedeatialNum > 0) {
|
|
|
|
|
List<String> billdevicedeatialIdList = billdevicedeatialService.list(billdevicedeatialQueryWrapper).stream().filter(t -> StringUtil.isNotEmpty(t.getBillNumber())).map(t -> t.getBillNumber()).collect(Collectors.toList());
|
|
|
|
|
long count = billdevicedeatialService.count();
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
intersectionList.add(billdevicedeatialIdList);
|
|
|
|
|
}
|
|
|
|
|
AllIdList.addAll(billdevicedeatialIdList);
|
|
|
|
|
}
|
|
|
|
|
total += billdevicedeatialNum;
|
|
|
|
|
if (billotherdeatialNum > 0) {
|
|
|
|
|
List<String> billotherdeatialIdList = billotherdeatialService.list(billotherdeatialQueryWrapper).stream().filter(t -> StringUtil.isNotEmpty(t.getBillNumber())).map(t -> t.getBillNumber()).collect(Collectors.toList());
|
|
|
|
|
long count = billotherdeatialService.count();
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
intersectionList.add(billotherdeatialIdList);
|
|
|
|
|
}
|
|
|
|
|
AllIdList.addAll(billotherdeatialIdList);
|
|
|
|
|
}
|
|
|
|
|
total += billotherdeatialNum;
|
|
|
|
|
if (billspacedetailNum > 0) {
|
|
|
|
|
List<String> billspacedetailIdList = billspacedetailService.list(billspacedetailQueryWrapper).stream().filter(t -> StringUtil.isNotEmpty(t.getBillNumber())).map(t -> t.getBillNumber()).collect(Collectors.toList());
|
|
|
|
|
long count = billspacedetailService.count();
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
intersectionList.add(billspacedetailIdList);
|
|
|
|
|
}
|
|
|
|
|
AllIdList.addAll(billspacedetailIdList);
|
|
|
|
|
}
|
|
|
|
|
total += billspacedetailNum;
|
|
|
|
|
List<String> intersection = generaterSwapUtil.getIntersection(intersectionList);
|
|
|
|
|
if (total > 0) {
|
|
|
|
|
if (intersection.size() == 0) {
|
|
|
|
|
intersection.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
billTableQueryWrapper.lambda().in(BillTableEntity::getId, intersection);
|
|
|
|
|
}
|
|
|
|
|
//是否有高级查询
|
|
|
|
|
if (StringUtil.isNotEmpty(superOp)) {
|
|
|
|
|
if (allSuperIDlist.size() == 0) {
|
|
|
|
|
allSuperIDlist.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
List<String> finalAllSuperIDlist = allSuperIDlist;
|
|
|
|
|
billTableQueryWrapper.lambda().and(t -> t.in(BillTableEntity::getId, finalAllSuperIDlist));
|
|
|
|
|
}
|
|
|
|
|
//是否有数据过滤查询
|
|
|
|
|
if (StringUtil.isNotEmpty(ruleOp)) {
|
|
|
|
|
if (allRuleIDlist.size() == 0) {
|
|
|
|
|
allRuleIDlist.add("jnpfNullList");
|
|
|
|
|
}
|
|
|
|
|
List<String> finalAllRuleIDlist = allRuleIDlist;
|
|
|
|
|
billTableQueryWrapper.lambda().and(t -> t.in(BillTableEntity::getId, finalAllRuleIDlist));
|
|
|
|
|
}
|
|
|
|
|
//假删除标志
|
|
|
|
|
billTableQueryWrapper.lambda().isNull(BillTableEntity::getDeleteMark);
|
|
|
|
|
|
|
|
|
|
//排序
|
|
|
|
|
if (StringUtil.isEmpty(billTablePagination.getSidx())) {
|
|
|
|
|
billTableQueryWrapper.lambda().orderByDesc(BillTableEntity::getId);
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
String sidx = billTablePagination.getSidx();
|
|
|
|
|
String[] strs = sidx.split("_name");
|
|
|
|
|
BillTableEntity billTableEntity = new BillTableEntity();
|
|
|
|
|
Field declaredField = billTableEntity.getClass().getDeclaredField(strs[0]);
|
|
|
|
|
declaredField.setAccessible(true);
|
|
|
|
|
String value = declaredField.getAnnotation(TableField.class).value();
|
|
|
|
|
billTableQueryWrapper = "asc".equals(billTablePagination.getSort().toLowerCase()) ? billTableQueryWrapper.orderByAsc(value) : billTableQueryWrapper.orderByDesc(value);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("0".equals(dataType)) {
|
|
|
|
|
if ((total > 0 && AllIdList.size() > 0) || total == 0) {
|
|
|
|
|
Page<BillTableEntity> page = new Page<>(billTablePagination.getCurrentPage(), billTablePagination.getPageSize());
|
|
|
|
|
IPage<BillTableEntity> userIPage = this.page(page, billTableQueryWrapper);
|
|
|
|
|
return billTablePagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
|
|
|
|
} else {
|
|
|
|
|
List<BillTableEntity> list = new ArrayList();
|
|
|
|
|
return billTablePagination.setData(list, list.size());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return this.list(billTableQueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BillTableEntity getInfo(String id) {
|
|
|
|
|
QueryWrapper<BillTableEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(BillTableEntity::getId, id);
|
|
|
|
|
return this.getOne(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void create(BillTableEntity entity) {
|
|
|
|
|
this.save(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean update(String id, BillTableEntity entity) {
|
|
|
|
|
return this.updateById(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(BillTableEntity entity) {
|
|
|
|
|
if (entity != null) {
|
|
|
|
|
this.removeById(entity.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Billspacedetail子表方法
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BillspacedetailEntity> getBillspacedetailList(String id, BillTablePagination billTablePagination) {
|
|
|
|
|
Map<String, Object> newtabMap = BillTableConstant.TABLEFIELDKEY.entrySet()
|
|
|
|
|
.stream().collect(Collectors.toMap(e -> e.getValue(), e -> e.getKey()));
|
|
|
|
|
String tableName = "billspacedetail";
|
|
|
|
|
tableName = newtabMap.get(tableName) == null ? tableName : newtabMap.get(tableName).toString();
|
|
|
|
|
QueryWrapper<BillspacedetailEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper = billspacedetailService.getChild(billTablePagination, queryWrapper);
|
|
|
|
|
queryWrapper.lambda().eq(BillspacedetailEntity::getBillNumber, id);
|
|
|
|
|
generaterSwapUtil.wrapperHandle(BillTableConstant.getColumnData(), BillTableConstant.getAppColumnData(), queryWrapper, BillspacedetailEntity.class, "sub", tableName);
|
|
|
|
|
return billspacedetailService.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Billspacedetail子表方法
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BillspacedetailEntity> getBillspacedetailList(String id) {
|
|
|
|
|
QueryWrapper<BillspacedetailEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(BillspacedetailEntity::getBillNumber, id);
|
|
|
|
|
return billspacedetailService.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Billdevicedeatial子表方法
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BilldevicedeatialEntity> getBilldevicedeatialList(String id, BillTablePagination billTablePagination) {
|
|
|
|
|
Map<String, Object> newtabMap = BillTableConstant.TABLEFIELDKEY.entrySet()
|
|
|
|
|
.stream().collect(Collectors.toMap(e -> e.getValue(), e -> e.getKey()));
|
|
|
|
|
String tableName = "billdevicedeatial";
|
|
|
|
|
tableName = newtabMap.get(tableName) == null ? tableName : newtabMap.get(tableName).toString();
|
|
|
|
|
QueryWrapper<BilldevicedeatialEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper = billdevicedeatialService.getChild(billTablePagination, queryWrapper);
|
|
|
|
|
queryWrapper.lambda().eq(BilldevicedeatialEntity::getBillNumber, id);
|
|
|
|
|
generaterSwapUtil.wrapperHandle(BillTableConstant.getColumnData(), BillTableConstant.getAppColumnData(), queryWrapper, BilldevicedeatialEntity.class, "sub", tableName);
|
|
|
|
|
return billdevicedeatialService.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Billdevicedeatial子表方法
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BilldevicedeatialEntity> getBilldevicedeatialList(String id) {
|
|
|
|
|
QueryWrapper<BilldevicedeatialEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(BilldevicedeatialEntity::getBillNumber, id);
|
|
|
|
|
return billdevicedeatialService.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Billotherdeatial子表方法
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BillotherdeatialEntity> getBillotherdeatialList(String id, BillTablePagination billTablePagination) {
|
|
|
|
|
Map<String, Object> newtabMap = BillTableConstant.TABLEFIELDKEY.entrySet()
|
|
|
|
|
.stream().collect(Collectors.toMap(e -> e.getValue(), e -> e.getKey()));
|
|
|
|
|
String tableName = "billotherdeatial";
|
|
|
|
|
tableName = newtabMap.get(tableName) == null ? tableName : newtabMap.get(tableName).toString();
|
|
|
|
|
QueryWrapper<BillotherdeatialEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper = billotherdeatialService.getChild(billTablePagination, queryWrapper);
|
|
|
|
|
queryWrapper.lambda().eq(BillotherdeatialEntity::getBillNumber, id);
|
|
|
|
|
generaterSwapUtil.wrapperHandle(BillTableConstant.getColumnData(), BillTableConstant.getAppColumnData(), queryWrapper, BillotherdeatialEntity.class, "sub", tableName);
|
|
|
|
|
return billotherdeatialService.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Billotherdeatial子表方法
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BillotherdeatialEntity> getBillotherdeatialList(String id) {
|
|
|
|
|
QueryWrapper<BillotherdeatialEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(BillotherdeatialEntity::getBillNumber, id);
|
|
|
|
|
return billotherdeatialService.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证表单唯一字段,正则,非空 i-0新增-1修改
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String checkForm(BillTableForm form, int i) {
|
|
|
|
|
boolean isUp = StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
|
|
|
|
|
String id = "";
|
|
|
|
|
String countRecover = "";
|
|
|
|
|
if (isUp) {
|
|
|
|
|
id = form.getId();
|
|
|
|
|
}
|
|
|
|
|
//主表字段验证
|
|
|
|
|
// if (StringUtil.isEmpty(form.getMerchantId())) {
|
|
|
|
|
// return "商户名称不能为空";
|
|
|
|
|
// }
|
|
|
|
|
//子表字段验证
|
|
|
|
|
if (form.getBillspacedetailList() != null) {
|
|
|
|
|
}
|
|
|
|
|
if (form.getBilldevicedeatialList() != null) {
|
|
|
|
|
}
|
|
|
|
|
if (form.getBillotherdeatialList() != null) {
|
|
|
|
|
}
|
|
|
|
|
return countRecover;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增修改数据(事务回滚)
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param billTableForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public String saveOrUpdate(BillTableForm billTableForm, String id, boolean isSave) {
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
|
|
|
|
|
billTableForm = JsonUtil.getJsonToBean(
|
|
|
|
|
generaterSwapUtil.swapDatetime(BillTableConstant.getFormData(), billTableForm), BillTableForm.class);
|
|
|
|
|
BillTableEntity entity = JsonUtil.getJsonToBean(billTableForm, BillTableEntity.class);
|
|
|
|
|
ContractEntity contract = contractService.getInfo(billTableForm.getContractId());
|
|
|
|
|
//商户名称
|
|
|
|
|
String merchantName = enterpriseMerchantsService.findNameById(contract.getMerchantId());
|
|
|
|
|
String contractName = contractService.findNameById(billTableForm.getContractId());
|
|
|
|
|
entity.setMerchantId(contract.getMerchantId());
|
|
|
|
|
entity.setContractName(contractName);
|
|
|
|
|
entity.setMerchantName(merchantName);
|
|
|
|
|
entity.setContractNumber(contract.getContractNumber());
|
|
|
|
|
|
|
|
|
|
if (isSave) {
|
|
|
|
|
//同一个合同只能创建一条
|
|
|
|
|
LambdaQueryWrapper<BillTableEntity> wrapper = new LambdaQueryWrapper<>(BillTableEntity.class).eq(BillTableEntity::getContractId, billTableForm.getContractId());
|
|
|
|
|
if (ObjectUtil.isNotNull(this.getOne(wrapper))) {
|
|
|
|
|
return "已存在相同合同数据!";
|
|
|
|
|
}
|
|
|
|
|
//获取当前年月日
|
|
|
|
|
String currentDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
|
|
|
entity.setBillNumbe("ZD" + currentDate + RandomUtil.uuId().substring(0, 3));
|
|
|
|
|
String mainId = RandomUtil.uuId();
|
|
|
|
|
entity.setCreationTime(DateUtil.getNowDate());
|
|
|
|
|
entity.setCreateBy(userInfo.getUserId());
|
|
|
|
|
entity.setId(mainId);
|
|
|
|
|
entity.setVersion(0);
|
|
|
|
|
entity.setSubmitter(userInfo.getUserId());
|
|
|
|
|
entity.setSubmissionTime(DateUtil.getNowDate());
|
|
|
|
|
} else {
|
|
|
|
|
entity.setCreationTime(DateUtil.getNowDate());
|
|
|
|
|
}
|
|
|
|
|
boolean result = this.saveOrUpdate(entity);
|
|
|
|
|
|
|
|
|
|
//Billspacedetail子表数据新增修改
|
|
|
|
|
if (!isSave) {
|
|
|
|
|
QueryWrapper<BillspacedetailEntity> BillspacedetailqueryWrapper = new QueryWrapper<>();
|
|
|
|
|
BillspacedetailqueryWrapper.lambda().eq(BillspacedetailEntity::getBillNumber, entity.getBillNumbe());
|
|
|
|
|
billspacedetailService.remove(BillspacedetailqueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
if (billTableForm.getBillspacedetailList() != null) {
|
|
|
|
|
List<BillspacedetailEntity> tableField140 = JsonUtil.getJsonToList(billTableForm.getBillspacedetailList(), BillspacedetailEntity.class);
|
|
|
|
|
//假如选择了相同的空间 后端直接去重
|
|
|
|
|
List<BillspacedetailEntity> list1 = tableField140.stream()
|
|
|
|
|
.filter(obj -> StringUtils.isNoneBlank(obj.getSpaceId()))
|
|
|
|
|
.collect(Collectors.toMap(BillspacedetailEntity::getSpaceId, obj -> obj, (o1, o2) -> o1)).values().stream().collect(Collectors.toList());
|
|
|
|
|
for (BillspacedetailEntity entitys : list1) {
|
|
|
|
|
entitys.setId(RandomUtil.uuId());
|
|
|
|
|
entitys.setBillNumber(entity.getBillNumbe());
|
|
|
|
|
entitys.setCreateBy(userInfo.getUserId());
|
|
|
|
|
entitys.setCreationTime(DateUtil.getNowDate());
|
|
|
|
|
if (isSave) {
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
billspacedetailService.saveOrUpdate(entitys);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Billdevicedeatial子表数据新增修改
|
|
|
|
|
if (!isSave) {
|
|
|
|
|
QueryWrapper<BilldevicedeatialEntity> BilldevicedeatialqueryWrapper = new QueryWrapper<>();
|
|
|
|
|
BilldevicedeatialqueryWrapper.lambda().eq(BilldevicedeatialEntity::getBillNumber, entity.getBillNumbe());
|
|
|
|
|
billdevicedeatialService.remove(BilldevicedeatialqueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
if (billTableForm.getBilldevicedeatialList() != null) {
|
|
|
|
|
List<BilldevicedeatialEntity> tableField158 = JsonUtil.getJsonToList(billTableForm.getBilldevicedeatialList(), BilldevicedeatialEntity.class);
|
|
|
|
|
//假如选择了相同的空间 后端直接去重
|
|
|
|
|
List<BilldevicedeatialEntity> list1 = tableField158.stream()
|
|
|
|
|
.filter(obj -> StringUtils.isNoneBlank(obj.getEquipmentNumber()))
|
|
|
|
|
.collect(Collectors.toMap(BilldevicedeatialEntity::getEquipmentNumber, obj -> obj, (o1, o2) -> o1)).values().stream().collect(Collectors.toList());
|
|
|
|
|
for (BilldevicedeatialEntity entitys : list1) {
|
|
|
|
|
entitys.setId(RandomUtil.uuId());
|
|
|
|
|
entitys.setBillNumber(entity.getBillNumbe());
|
|
|
|
|
entitys.setCreateBy(userInfo.getUserId());
|
|
|
|
|
entitys.setCreationTime(DateUtil.getNowDate());
|
|
|
|
|
if (isSave) {
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
billdevicedeatialService.saveOrUpdate(entitys);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Billotherdeatial子表数据新增修改
|
|
|
|
|
if (!isSave) {
|
|
|
|
|
QueryWrapper<BillotherdeatialEntity> BillotherdeatialqueryWrapper = new QueryWrapper<>();
|
|
|
|
|
BillotherdeatialqueryWrapper.lambda().eq(BillotherdeatialEntity::getBillNumber, entity.getBillNumbe());
|
|
|
|
|
billotherdeatialService.remove(BillotherdeatialqueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
if (billTableForm.getBillotherdeatialList() != null) {
|
|
|
|
|
List<BillotherdeatialEntity> tableField166 = JsonUtil.getJsonToList(billTableForm.getBillotherdeatialList(), BillotherdeatialEntity.class);
|
|
|
|
|
for (BillotherdeatialEntity entitys : tableField166) {
|
|
|
|
|
entitys.setId(RandomUtil.uuId());
|
|
|
|
|
entitys.setBillNumber(entity.getBillNumbe());
|
|
|
|
|
entitys.setCreateBy(userInfo.getUserId());
|
|
|
|
|
entitys.setCreationTime(DateUtil.getNowDate());
|
|
|
|
|
if (isSave) {
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
billotherdeatialService.saveOrUpdate(entitys);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (result) {
|
|
|
|
|
return "success";
|
|
|
|
|
}
|
|
|
|
|
return "fail";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String billConfirm(String id) {
|
|
|
|
|
log.info("账单确认,id:{}", id);
|
|
|
|
|
BillTableEntity entity = this.getById(id);
|
|
|
|
|
entity.setBillStatus("20");
|
|
|
|
|
entity.setUpdateBy(userProvider.get().getUserId());
|
|
|
|
|
entity.setUpdateTime(DateUtil.getNowDate());
|
|
|
|
|
entity.setConfirmPersonnel(userProvider.get().getUserId());
|
|
|
|
|
entity.setConfirmTime(DateUtil.getNowDate());
|
|
|
|
|
boolean result = this.updateById(entity);
|
|
|
|
|
if (result) {
|
|
|
|
|
return "确认成功";
|
|
|
|
|
}
|
|
|
|
|
return "确认失败";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String entry(String id, BillTableForm billTableForm) {
|
|
|
|
|
log.info("结算录入,id:{},form:{}", id, billTableForm);
|
|
|
|
|
BillTableEntity entity = this.getById(id);
|
|
|
|
|
if (ObjectUtil.isNull(entity)) {
|
|
|
|
|
return "账单不存在";
|
|
|
|
|
}
|
|
|
|
|
entity.setBillAttachment(billTableForm.getBillAttachment().toString());
|
|
|
|
|
entity.setPayStatus(billTableForm.getPayStatus().toString());
|
|
|
|
|
entity.setUpdateBy(userProvider.get().getUserId());
|
|
|
|
|
entity.setUpdateTime(DateUtil.getNowDate());
|
|
|
|
|
if (entity.getBillAmount().compareTo(entity.getPayAmount()) == 0) {
|
|
|
|
|
entity.setBillStatus("50");
|
|
|
|
|
} else {
|
|
|
|
|
//每次相加的支付金额
|
|
|
|
|
BigDecimal payAmount = entity.getPayAmount().add(billTableForm.getPayAmount());
|
|
|
|
|
//判断支付金额是否大于账单金额
|
|
|
|
|
if (entity.getBillAmount().compareTo(payAmount) < 0) {
|
|
|
|
|
return "支付金额不能大于账单金额,账单金额:" + entity.getBillAmount() + "元"
|
|
|
|
|
+ ",还需支付金额为:" + entity.getBillAmount().subtract(entity.getPayAmount());
|
|
|
|
|
}
|
|
|
|
|
entity.setPayAmount(payAmount);
|
|
|
|
|
if (entity.getBillAmount().compareTo(entity.getPayAmount()) != 0) {
|
|
|
|
|
entity.setBillStatus("40");
|
|
|
|
|
} else {
|
|
|
|
|
entity.setBillStatus("50");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (this.updateById(entity)) {
|
|
|
|
|
if (entity.getPayAmount().compareTo(entity.getBillAmount()) < 0) {
|
|
|
|
|
return "结算录入成功,剩余支付额度为" + entity.getBillAmount().subtract(entity.getPayAmount());
|
|
|
|
|
}
|
|
|
|
|
return "结算录入成功";
|
|
|
|
|
}
|
|
|
|
|
return "结算录入失败";
|
|
|
|
|
}
|
|
|
|
|
}
|