From 35ed9cd31d7b675082425361a9f08bec40aa1292 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 03 十二月 2024 18:23:01 +0800
Subject: [PATCH] ll
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java | 447 ++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 325 insertions(+), 122 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java
index b3cdf03..03953ce 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java
@@ -1,5 +1,6 @@
package com.doumee.service.business.impl;
+import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
@@ -7,26 +8,25 @@
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
-import com.doumee.dao.business.YwContractBillMapper;
-import com.doumee.dao.business.YwContractRoomMapper;
-import com.doumee.dao.business.model.YwContractBill;
-import com.doumee.dao.business.model.YwContractRoom;
+import com.doumee.dao.business.*;
+import com.doumee.dao.business.model.*;
import com.doumee.dao.system.MultifileMapper;
import com.doumee.dao.system.model.Multifile;
+import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.YwContractBillService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* 杩愮淮鍚堝悓璐﹀崟淇℃伅琛⊿ervice瀹炵幇
@@ -45,27 +45,68 @@
@Autowired
private MultifileMapper multifileMapper;
+ @Autowired
+ private YwContractRevenueMapper ywContractRevenueMapper;
+
+ @Autowired
+ private SystemDictDataBiz systemDictDataBiz;
+
+ @Autowired
+ private YwContractMapper ywContractMapper;
+
+
+
@Override
public Integer create(YwContractBill ywContractBill) {
if(Objects.isNull(ywContractBill)
- || Objects.isNull(ywContractBill.getContractId())
- || Objects.isNull(ywContractBill.getTotleFee())
- || Objects.isNull(ywContractBill.getPlanPayData())
+ || Objects.isNull(ywContractBill.getContractId())
+ || Objects.isNull(ywContractBill.getTotleFee())
+ || Objects.isNull(ywContractBill.getPlanPayDate())
|| Objects.isNull(ywContractBill.getCostType())
|| Objects.isNull(ywContractBill.getBillType())
|| Objects.isNull(ywContractBill.getCompanyId())
- || Objects.isNull(ywContractBill.getStartDate())
- || Objects.isNull(ywContractBill.getEndDate())
+ || com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ywContractBill.getYwContractRoomList())
+ || Objects.isNull(ywContractBill.getFeeType())
+ || (Constants.equalsInteger(ywContractBill.getFeeType(),Constants.ZERO)&& (Objects.isNull(ywContractBill.getStartDate())
+ || Objects.isNull(ywContractBill.getEndDate())))
){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
+ YwContract ywContract = ywContractMapper.selectById(ywContractBill.getContractId());
+ if(Objects.isNull(ywContract)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+ if(Constants.equalsInteger(ywContract.getStatus(),Constants.THREE)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍚堝悓鐘舵�佸凡娴佽浆,鏃犳硶杩涜璇ユ搷浣�");
+ }
+
LoginUserInfo loginUserInfo = ywContractBill.getLoginUserInfo();
+ ywContractBill.setReceivableFee(ywContractBill.getTotleFee());
ywContractBill.setCreateDate(new Date());
ywContractBill.setCreator(loginUserInfo.getId());
ywContractBill.setIsdeleted(Constants.ZERO);
+ ywContractBill.setType(Constants.ONE);
ywContractBill.setStatus(Constants.ZERO);
+ if(Constants.equalsInteger(ywContractBill.getBillType(),Constants.ZERO)){
+ ywContractBill.setPayStatus(Constants.ZERO);
+ }else{
+ ywContractBill.setPayStatus(Constants.THREE);
+ }
+
+ if(Constants.equalsInteger(ywContractBill.getFeeType(),Constants.ONE)){
+ ywContractBill.setStartDate(ywContractBill.getPlanPayDate());
+ ywContractBill.setEndDate(ywContractBill.getPlanPayDate());
+ }
+ //鏌ヨ鍚堝悓涓嬬殑鏈�澶х殑搴忓彿
+ List<YwContractBill> ywContractBillList = ywContractBillMapper.selectList(new QueryWrapper<YwContractBill>().lambda().eq(YwContractBill::getContractId,ywContract.getId()).orderByDesc(YwContractBill::getId));
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBillList)){
+ ywContractBill.setSortnum(ywContractBillList.size() + 1 );
+ }else{
+ ywContractBill.setSortnum(Constants.ZERO);
+ }
ywContractBillMapper.insert(ywContractBill);
+ //鎴挎簮鏁版嵁
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBill.getYwContractRoomList())){
for (YwContractRoom ywContractRoom:ywContractBill.getYwContractRoomList()) {
if(Objects.isNull(ywContractRoom)
@@ -77,11 +118,11 @@
ywContractRoom.setIsdeleted(Constants.ZERO);
ywContractRoom.setContractId(ywContractBill.getId());
ywContractRoom.setType(Constants.ONE);
-
}
ywContractRoomMapper.insert(ywContractBill.getYwContractRoomList());
}
+ //闄勪欢鏁版嵁
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBill.getMultifileList())){
for (Multifile multifile:ywContractBill.getMultifileList()) {
if(Objects.isNull(multifile)
@@ -92,7 +133,7 @@
multifile.setCreator(loginUserInfo.getId());
multifile.setCreateDate(new Date());
multifile.setIsdeleted(Constants.ZERO);
- multifile.setObjType(Constants.MultiFile.FN_PATROL_POINT_FILE.getKey());
+ multifile.setObjType(Constants.MultiFile.FN_CONTRACT_BILL_FILE.getKey());
multifile.setObjId(ywContractBill.getId());
}
multifileMapper.insert(ywContractBill.getMultifileList());
@@ -122,61 +163,7 @@
@Override
public void updateById(YwContractBill ywContractBill) {
- if(Objects.isNull(ywContractBill)
- || Objects.isNull(ywContractBill.getId())
- || Objects.isNull(ywContractBill.getContractId())
- || Objects.isNull(ywContractBill.getTotleFee())
- || Objects.isNull(ywContractBill.getPlanPayData())
- || Objects.isNull(ywContractBill.getCostType())
- || Objects.isNull(ywContractBill.getBillType())
- || Objects.isNull(ywContractBill.getCompanyId())
- || Objects.isNull(ywContractBill.getStartDate())
- || Objects.isNull(ywContractBill.getEndDate())
- || ywContractBill.getTotleFee().compareTo(BigDecimal.ZERO)<=Constants.ZERO
- ){
- throw new BusinessException(ResponseStatus.BAD_REQUEST);
- }
- LoginUserInfo loginUserInfo = ywContractBill.getLoginUserInfo();
- ywContractBill.setEditDate(new Date());
- ywContractBill.setEditor(loginUserInfo.getId());
- if(Constants.equalsInteger(ywContractBill.getBillType(),Constants.ZERO)){
- ywContractBill.setPayStatus(Constants.ZERO);
- }else{
- ywContractBill.setPayStatus(Constants.THREE);
- }
- ywContractBillMapper.insert(ywContractBill);
-
- if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBill.getYwContractRoomList())){
- for (YwContractRoom ywContractRoom:ywContractBill.getYwContractRoomList()) {
- if(Objects.isNull(ywContractRoom)
- || Objects.isNull(ywContractRoom.getRoomId())){
- throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"璇烽�夋嫨鎴挎簮鏁版嵁");
- }
- ywContractRoom.setCreateDate(new Date());
- ywContractRoom.setCreator(loginUserInfo.getId());
- ywContractRoom.setIsdeleted(Constants.ZERO);
- ywContractRoom.setContractId(ywContractBill.getId());
- ywContractRoom.setType(Constants.ONE);
-
- }
- ywContractRoomMapper.insert(ywContractBill.getYwContractRoomList());
- }
-
- if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBill.getMultifileList())){
- for (Multifile multifile:ywContractBill.getMultifileList()) {
- if(Objects.isNull(multifile)
- || StringUtils.isBlank(multifile.getFileurl())
- || StringUtils.isBlank(multifile.getName())){
- throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"闄勪欢淇℃伅閿欒");
- }
- multifile.setCreator(loginUserInfo.getId());
- multifile.setCreateDate(new Date());
- multifile.setIsdeleted(Constants.ZERO);
- multifile.setObjType(Constants.MultiFile.FN_PATROL_POINT_FILE.getKey());
- multifile.setObjId(ywContractBill.getId());
- }
- multifileMapper.insert(ywContractBill.getMultifileList());
- }
+ ywContractBillMapper.updateById(ywContractBill);
}
@Override
@@ -194,6 +181,81 @@
return ywContractBillMapper.selectById(id);
}
+
+ @Override
+ public YwContractBill getDetail(Integer id) {
+ YwContractBill ywContractBill = ywContractBillMapper.selectJoinOne(YwContractBill.class,
+ new MPJLambdaWrapper<YwContractBill>().selectAll(YwContractBill.class)
+ .select(" ( select ifnull(sum(case when yw.REVENUE_TYPE = 0 then yw.ACT_RECEIVABLE_FEE else -yw.ACT_RECEIVABLE_FEE end),0) from yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as actReceivableFee ")
+ .selectAs(YwContract::getCode,YwContractBill::getContractCode)
+ .selectAs(YwCustomer::getName,YwContractBill::getCustomerName)
+ .selectAs(Company::getName,YwContractBill::getCompanyName)
+ .selectAs(SystemUser::getRealname,YwContractBill::getRealname)
+ .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
+ .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
+ .leftJoin(Company.class,Company::getId,YwContract::getCompanyId)
+ .leftJoin(SystemUser.class,SystemUser::getId,YwContractBill::getCreator)
+ .eq(YwContractBill::getIsdeleted,Constants.ZERO)
+ .eq(YwContractBill::getId,id));
+ if(Objects.isNull(ywContractBill)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+ ywContractBill.setNeedReceivableFee(
+ ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee())
+ );
+
+ //鎴挎簮鏁版嵁
+ ywContractBill.setYwContractRoomList(ywContractRoomMapper.selectJoinList(YwContractRoom.class,new MPJLambdaWrapper<YwContractRoom>()
+ .selectAll(YwContractRoom.class)
+ .selectAs(YwProject::getName,YwRoom::getProjectName)
+ .selectAs(YwFloor::getName,YwRoom::getFloorName)
+ .selectAs(YwBuilding::getName,YwRoom::getBuildingName)
+ .selectAs(YwRoom::getCode,YwContractRoom::getRoomName)
+ .selectAs(YwRoom::getArea,YwContractRoom::getArea)
+ .leftJoin(YwRoom.class,YwRoom::getId,YwContractRoom::getRoomId)
+ .leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor)
+ .leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId)
+ .leftJoin(YwBuilding.class,YwBuilding::getId,YwRoom::getBuildingId)
+ .eq(Constants.equalsInteger(ywContractBill.getType(),Constants.ONE),YwContractRoom::getContractId,id)
+ .eq(Constants.equalsInteger(ywContractBill.getType(),Constants.ONE),YwContractRoom::getType,Constants.ONE)
+ .eq(Constants.equalsInteger(ywContractBill.getType(),Constants.ZERO),YwContractRoom::getContractId,ywContractBill.getContractId())
+ .eq(Constants.equalsInteger(ywContractBill.getType(),Constants.ZERO),YwContractRoom::getType,Constants.ZERO)
+ ));
+
+ //鏀舵敮璁板綍
+ ywContractBill.setYwContractRevenueList(
+ ywContractRevenueMapper.selectJoinList(YwContractRevenue.class,new MPJLambdaWrapper<YwContractRevenue>()
+ .selectAll(YwContractRevenue.class)
+ .selectAs(YwCustomer::getName,YwContractRevenue::getCustomerName)
+ .leftJoin(YwContract.class,YwContract::getId,YwContractRevenue::getContractId)
+ .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
+ .eq(YwContractRevenue::getStatus,Constants.ZERO)
+ .eq(YwContractRevenue::getBillId,ywContractBill.getId())
+ .orderByDesc(YwContractRevenue::getId)
+ )
+ );
+
+ //闄勪欢鏁版嵁
+ List<Multifile> multifileList = multifileMapper.selectJoinList(Multifile.class,new MPJLambdaWrapper<Multifile>()
+ .selectAll(Multifile.class)
+ .selectAs(SystemUser::getRealname,Multifile::getUserName)
+ .leftJoin(SystemUser.class,SystemUser::getId,Multifile::getCreator)
+ .eq(Multifile::getObjId,id)
+ .eq(Multifile::getIsdeleted,Constants.ZERO)
+ .eq(Multifile::getObjType,Constants.MultiFile.FN_CONTRACT_BILL_FILE.getKey()));
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){
+ String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode()
+ +systemDictDataBiz.queryByCode(Constants.FTP,Constants.YW_CONTRACT_BILL).getCode();
+ for (Multifile multifile:multifileList) {
+ if(StringUtils.isNotBlank(multifile.getFileurl())){
+ multifile.setFileurlFull(path + multifile.getFileurl());
+ }
+ }
+ ywContractBill.setMultifileList(multifileList);
+ }
+ return ywContractBill;
+ }
+
@Override
public YwContractBill findOne(YwContractBill ywContractBill) {
QueryWrapper<YwContractBill> wrapper = new QueryWrapper<>(ywContractBill);
@@ -209,67 +271,208 @@
@Override
public PageData<YwContractBill> findPage(PageWrap<YwContractBill> pageWrap) {
IPage<YwContractBill> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
- QueryWrapper<YwContractBill> queryWrapper = new QueryWrapper<>();
+ MPJLambdaWrapper<YwContractBill> queryWrapper = new MPJLambdaWrapper<>();
Utils.MP.blankToNull(pageWrap.getModel());
- if (pageWrap.getModel().getId() != null) {
- queryWrapper.lambda().eq(YwContractBill::getId, pageWrap.getModel().getId());
- }
- if (pageWrap.getModel().getCreator() != null) {
- queryWrapper.lambda().eq(YwContractBill::getCreator, pageWrap.getModel().getCreator());
- }
- if (pageWrap.getModel().getCreateDate() != null) {
- queryWrapper.lambda().ge(YwContractBill::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate()));
- queryWrapper.lambda().le(YwContractBill::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate()));
- }
- if (pageWrap.getModel().getEditor() != null) {
- queryWrapper.lambda().eq(YwContractBill::getEditor, pageWrap.getModel().getEditor());
- }
- if (pageWrap.getModel().getEditDate() != null) {
- queryWrapper.lambda().ge(YwContractBill::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate()));
- queryWrapper.lambda().le(YwContractBill::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate()));
- }
- if (pageWrap.getModel().getIsdeleted() != null) {
- queryWrapper.lambda().eq(YwContractBill::getIsdeleted, pageWrap.getModel().getIsdeleted());
- }
- if (pageWrap.getModel().getRemark() != null) {
- queryWrapper.lambda().eq(YwContractBill::getRemark, pageWrap.getModel().getRemark());
- }
- if (pageWrap.getModel().getStatus() != null) {
- queryWrapper.lambda().eq(YwContractBill::getStatus, pageWrap.getModel().getStatus());
- }
- if (pageWrap.getModel().getStartDate() != null) {
- queryWrapper.lambda().ge(YwContractBill::getStartDate, Utils.Date.getStart(pageWrap.getModel().getStartDate()));
- queryWrapper.lambda().le(YwContractBill::getStartDate, Utils.Date.getEnd(pageWrap.getModel().getStartDate()));
- }
- if (pageWrap.getModel().getEndDate() != null) {
- queryWrapper.lambda().ge(YwContractBill::getEndDate, Utils.Date.getStart(pageWrap.getModel().getEndDate()));
- queryWrapper.lambda().le(YwContractBill::getEndDate, Utils.Date.getEnd(pageWrap.getModel().getEndDate()));
- }
- if (pageWrap.getModel().getDetailId() != null) {
- queryWrapper.lambda().eq(YwContractBill::getDetailId, pageWrap.getModel().getDetailId());
- }
- if (pageWrap.getModel().getContractId() != null) {
- queryWrapper.lambda().eq(YwContractBill::getContractId, pageWrap.getModel().getContractId());
- }
- if (pageWrap.getModel().getSortnum() != null) {
- queryWrapper.lambda().eq(YwContractBill::getSortnum, pageWrap.getModel().getSortnum());
- }
- if (pageWrap.getModel().getTotleFee() != null) {
- queryWrapper.lambda().eq(YwContractBill::getTotleFee, pageWrap.getModel().getTotleFee());
- }
- for(PageWrap.SortData sortData: pageWrap.getSorts()) {
- if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
- queryWrapper.orderByDesc(sortData.getProperty());
- } else {
- queryWrapper.orderByAsc(sortData.getProperty());
+ YwContractBill model = pageWrap.getModel();
+ IPage<YwContractBill> iPage = ywContractBillMapper.selectJoinPage(page,YwContractBill.class,
+ queryWrapper.selectAll(YwContractBill.class)
+ .select(" ( select ifnull(sum(case when yw.REVENUE_TYPE = 0 then yw.ACT_RECEIVABLE_FEE else -yw.ACT_RECEIVABLE_FEE end),0) from yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as actReceivableFee ")
+ .selectAs(YwContract::getCode,YwContractBill::getContractCode)
+ .selectAs(YwCustomer::getName,YwContractBill::getCustomerName)
+ .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
+ .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
+ .eq(YwContractBill::getIsdeleted,Constants.ZERO)
+ .like(Objects.nonNull(model)&&StringUtils.isNotBlank(model.getCustomerName()),
+ YwCustomer::getName,model.getCustomerName())
+ .eq(Objects.nonNull(model)&&Objects.nonNull(model.getStatus()),
+ YwContractBill::getStatus,model.getStatus())
+ .eq(Objects.nonNull(model)&&Objects.nonNull(model.getBillType()),
+ YwContractBill::getBillType,model.getBillType())
+ .eq(Objects.nonNull(model)&&Objects.nonNull(model.getPayStatus()),
+ YwContractBill::getPayStatus,model.getPayStatus())
+ .eq(Objects.nonNull(model)&&Objects.nonNull(model.getType()),
+ YwContractBill::getType,model.getType())
+ .eq(Objects.nonNull(model)&&Objects.nonNull(model.getContractId()),
+ YwContractBill::getContractId,model.getContractId())
+ .like(Objects.nonNull(model)&&StringUtils.isNotBlank(model.getContractCode()),
+ YwContract::getCode,model.getContractCode())
+ .ge(Objects.nonNull(model)&&Objects.nonNull(model.getPlanPayDateStart()),YwContractBill::getPlanPayDate, Utils.Date.getStart(model.getPlanPayDateStart()))
+ .le(Objects.nonNull(model)&&Objects.nonNull(model.getPlanPayDateEnd()),YwContractBill::getPlanPayDate, Utils.Date.getEnd(model.getPlanPayDateEnd())) )
+ ;
+ this.dealRoomDetail(iPage.getRecords());
+ for (YwContractBill ywContractBill:iPage.getRecords()) {
+ //闇�鏀堕噾棰�
+ ywContractBill.setNeedReceivableFee(
+ ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee())
+ );
+ //鏄惁閫炬湡
+ if(Constants.equalsInteger(ywContractBill.getStatus(),Constants.ZERO)
+ && (Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.ZERO)
+ || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.TWO)
+ || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.THREE)
+ || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.FOUR))
+ && ywContractBill.getPlanPayDate().getTime() < System.currentTimeMillis()){
+ ywContractBill.setIsOverdue(Constants.ONE);
+ }else{
+ ywContractBill.setIsOverdue(Constants.ZERO);
+ }
+ //妤煎畤鍚嶇О
+ List<YwContractRoom> ywContractRoomList = ywContractBill.getYwContractRoomList();
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractRoomList)){
+ StringBuilder roomPathName = new StringBuilder();
+ for (YwContractRoom ywContractRoom:ywContractRoomList) {
+ if(StringUtils.isNotBlank(ywContractRoom.getProjectName())){
+ roomPathName.append(ywContractRoom.getProjectName()+"/");
+ }
+ if(StringUtils.isNotBlank(ywContractRoom.getBuildingName())){
+ roomPathName.append(ywContractRoom.getBuildingName()+"/");
+ }
+ if(StringUtils.isNotBlank(ywContractRoom.getFloorName())){
+ roomPathName.append(ywContractRoom.getFloorName()+"/");
+ }
+ if(StringUtils.isNotBlank(ywContractRoom.getRoomName())){
+ roomPathName.append(ywContractRoom.getRoomName());
+ }
+ if(StringUtils.isNotBlank(roomPathName)){
+ roomPathName.append(";");
+ }
+ }
+ ywContractBill.setRoomPathName(roomPathName.toString());
}
}
- return PageData.from(ywContractBillMapper.selectPage(page, queryWrapper));
+
+ return PageData.from(iPage);
}
+
+ public void dealRoomDetail(List<YwContractBill> ywContractBillList){
+ //鏌ヨ璐﹀崟涓嬬殑妤煎畤鏁版嵁
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBillList)){
+ //鑾峰彇鎵�鏈夋暟鎹�
+ List<Integer> billIdList = ywContractBillList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ONE)).map(i->i.getId()).collect(Collectors.toList());
+ List<Integer> contractIdList = ywContractBillList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ZERO)).map(i->i.getContractId()).collect(Collectors.toList());
+ List<YwContractRoom> ywContractRoomList = new ArrayList<>();
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(billIdList)){
+ ywContractRoomList.addAll( ywContractRoomMapper.selectJoinList(YwContractRoom.class,new MPJLambdaWrapper<YwContractRoom>()
+ .selectAll(YwContractRoom.class)
+ .selectAs(YwProject::getName,YwRoom::getProjectName)
+ .selectAs(YwFloor::getName,YwRoom::getFloorName)
+ .selectAs(YwBuilding::getName,YwRoom::getBuildingName)
+ .selectAs(YwRoom::getCode,YwContractRoom::getRoomName)
+ .leftJoin(YwRoom.class,YwRoom::getId,YwContractRoom::getRoomId)
+ .leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor)
+ .leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId)
+ .leftJoin(YwBuilding.class,YwBuilding::getId,YwRoom::getBuildingId)
+ .in(YwContractRoom::getContractId,billIdList)
+ .eq(YwContractRoom::getType,Constants.ONE)
+ ));
+
+ }
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(contractIdList)){
+ ywContractRoomList.addAll( ywContractRoomMapper.selectJoinList(YwContractRoom.class,new MPJLambdaWrapper<YwContractRoom>()
+ .selectAll(YwContractRoom.class)
+ .selectAs(YwProject::getName,YwRoom::getProjectName)
+ .selectAs(YwFloor::getName,YwRoom::getFloorName)
+ .selectAs(YwBuilding::getName,YwRoom::getBuildingName)
+ .selectAs(YwRoom::getCode,YwContractRoom::getRoomName)
+ .leftJoin(YwRoom.class,YwRoom::getId,YwContractRoom::getRoomId)
+ .leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor)
+ .leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId)
+ .leftJoin(YwBuilding.class,YwBuilding::getId,YwRoom::getBuildingId)
+ .in(YwContractRoom::getContractId,contractIdList)
+ .eq(YwContractRoom::getType,Constants.ZERO)
+ ));
+ }
+
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractRoomList)){
+ for (YwContractBill ywContractBill:ywContractBillList) {
+ if(Constants.equalsInteger(ywContractBill.getType(),Constants.ZERO)){
+ ywContractBill.setYwContractRoomList(
+ ywContractRoomList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ZERO)&&Constants.equalsInteger(i.getContractId(),ywContractBill.getContractId())).collect(Collectors.toList())
+ );
+ }else{
+ ywContractBill.setYwContractRoomList(
+ ywContractRoomList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ONE)&&Constants.equalsInteger(i.getContractId(),ywContractBill.getId())).collect(Collectors.toList())
+ );
+ }
+
+ }
+ }
+
+ }
+ }
+
@Override
public long count(YwContractBill ywContractBill) {
QueryWrapper<YwContractBill> wrapper = new QueryWrapper<>(ywContractBill);
return ywContractBillMapper.selectCount(wrapper);
}
+
+
+
+ @Override
+ public void dealDayBillCode(){
+ List<YwContractBill> ywContractBillList = ywContractBillMapper.selectJoinList(YwContractBill.class,
+ new MPJLambdaWrapper<YwContractBill>()
+ .selectAll(YwContractBill.class)
+ .select(" DATE(CREATE_DATE) as codeDate")
+ .isNull(YwContractBill::getCode)
+ .orderByAsc(YwContractBill::getId)
+ );
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBillList)){
+ List<String> codeDateList = ywContractBillList.stream().map(i->i.getCodeDate()).collect(Collectors.toList());
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(codeDateList)){
+ Set<String> codeDateSet = new HashSet<String>(codeDateList);
+ for (String codeDate:codeDateSet) {
+ //鑾峰彇褰撳墠鏃ユ湡鐨勬暟鎹�
+ List<YwContractBill> codeDateBillList =
+ ywContractBillList.stream().filter(i->i.getCodeDate().equals(codeDate)).collect(Collectors.toList());
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(codeDateBillList)){
+ continue;
+ }
+ //鏌ヨ鏈�澶х殑鍗曞彿
+ YwContractBill ywContractBill = ywContractBillMapper.selectOne(new QueryWrapper<YwContractBill>().lambda()
+ .isNotNull(YwContractBill::getCode)
+ .apply(" CREATE_DATE like '"+codeDate+"%' ")
+ .orderByDesc(YwContractBill::getId)
+ .last(" limit 1 ")
+ );
+ Integer maxCode = Constants.ZERO;
+ if(Objects.nonNull(ywContractBill)){
+ maxCode = Integer.valueOf(ywContractBill.getCode().replace(("ZD"+codeDate+"-"),""));
+ }
+ for (YwContractBill contractBill:codeDateBillList) {
+ maxCode = maxCode + 1;
+ contractBill.setCode("ZD" + codeDate + "-" + StringUtils.leftPad(maxCode.toString() , 4,"0"));
+ ywContractBillMapper.update(null, new UpdateWrapper<YwContractBill>().lambda().set(YwContractBill::getCode,contractBill.getCode())
+ .eq(YwContractBill::getId,contractBill.getId()));
+ }
+ }
+ }
+ }
+ }
+
+
+ @Override
+ public List<YwContractBill> getCanBackBill(YwContractBill model) {
+ List<YwContractBill> list = ywContractBillMapper.selectJoinList(YwContractBill.class,
+ new MPJLambdaWrapper<YwContractBill>().selectAll(YwContractBill.class)
+ .select(" ( select ifnull(sum(case when yw.REVENUE_TYPE = 0 then yw.ACT_RECEIVABLE_FEE else -yw.ACT_RECEIVABLE_FEE end),0) from yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as actReceivableFee ")
+ .selectAs(YwContract::getCode,YwContractBill::getContractCode)
+ .selectAs(YwCustomer::getName,YwContractBill::getCustomerName)
+ .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
+ .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
+ .eq(YwContractBill::getIsdeleted,Constants.ZERO)
+ .in(YwContractBill::getCostType,Constants.ZERO,Constants.ONE,Constants.FOUR,Constants.FIVE,7)
+ .eq(Objects.nonNull(model)&&Objects.nonNull(model.getContractId()),
+ YwContractBill::getContractId,model.getContractId())
+ .le(Objects.nonNull(model)&&Objects.nonNull(model.getPlanPayDateEnd()),YwContractBill::getStartDate, Utils.Date.getEnd(model.getPlanPayDateEnd())) )
+ ;
+
+ for (YwContractBill ywContractBill:list) {
+ ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee()));
+ }
+ return list;
+ }
+
}
--
Gitblit v1.9.3