From 7880875b4d9ee5cd249bbf577838dcbdb28c5166 Mon Sep 17 00:00:00 2001
From: renkang <8417338+k94314517@user.noreply.gitee.com>
Date: 星期二, 10 十二月 2024 13:53:27 +0800
Subject: [PATCH] 客户资料 巡检任务业务
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractRevenueServiceImpl.java | 104 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 82 insertions(+), 22 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractRevenueServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractRevenueServiceImpl.java
index 8843a63..a462929 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractRevenueServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractRevenueServiceImpl.java
@@ -24,16 +24,14 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
+import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -87,7 +85,12 @@
){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
- YwContractBill ywContractBill = ywContractBillMapper.selectById(ywContractRevenue.getBillId());
+ YwContractBill ywContractBill = ywContractBillMapper.selectJoinOne(YwContractBill.class,
+ new MPJLambdaWrapper<YwContractBill>()
+ .selectAll(YwContractBill.class)
+ .selectAs(YwContract::getStatus, YwContractBill::getContractStatus)
+ .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
+ .eq(YwContractBill::getId,ywContractRevenue.getBillId()));
if(Objects.isNull(ywContractBill)){
throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌璐﹀崟淇℃伅");
}
@@ -128,7 +131,7 @@
BigDecimal waitPayTotal = BigDecimal.ZERO;
//鏃犱粯娆捐褰� 鍒欎负鍒濇鏀粯 鏍规嵁璐﹀崟绫诲瀷 鍒ゆ柇鏄敮鍑� / 鏀跺叆
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ywContractRevenueList)){
- ywContractRevenue.setRevenueType(ywContractBill.getType());
+ ywContractRevenue.setRevenueType(ywContractBill.getBillType());
if(ywContractRevenue.getActReceivableFee().compareTo(ywContractBill.getReceivableFee())>Constants.ZERO){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璇疯緭鍏ユ纭殑閲戦锛�");
}else if(ywContractRevenue.getActReceivableFee().compareTo(ywContractBill.getReceivableFee())==Constants.ZERO){
@@ -138,19 +141,39 @@
}
}else{
//鑾峰彇宸叉敮浠樼殑鎬婚噾棰� 锛堝彲鑳芥湁鏀跺叆 鏈夋敮鍑猴級
- payTotal = ywContractRevenueList.stream().map(i->i.getActReceivableFee().multiply(
- BigDecimal.valueOf(Constants.equalsInteger(ywContractRevenue.getRevenueType(),Constants.ZERO)?Constants.ONE:-Constants.ONE))
- ).reduce(BigDecimal.ZERO,BigDecimal::add);
- //鑾峰彇寰呮敮浠樻閲戦 濡傛灉璐﹀崟绫诲瀷涓烘敮鍑� 鎴� 锛堣处鍗曠被鍨嬩负鏀跺叆 涓� 寰呮敮浠橀噾棰� 灏忎簬 0锛� 鍒欎负鏀粯
- waitPayTotal = ywContractBill.getReceivableFee().subtract(payTotal);
- //濡傛灉寰呮敮浠橀噾棰� 澶т簬 0 鍒欐槸 鏀跺叆 鍚﹀垯鏄敮鍑� 鍏朵粬鐘舵�� 涓哄紓甯革紒
- if(waitPayTotal.compareTo(BigDecimal.ZERO)>Constants.ZERO){
- ywContractRevenue.setRevenueType(Constants.ZERO);
- }else if(waitPayTotal.compareTo(BigDecimal.ZERO)<Constants.ZERO){
- ywContractRevenue.setRevenueType(Constants.ONE);
+ if(Constants.equalsInteger(ywContractBill.getBillType(),Constants.ZERO)){
+ payTotal = ywContractRevenueList.stream().map(i->
+ i.getActReceivableFee().multiply(
+ BigDecimal.valueOf(Constants.equalsInteger(i.getRevenueType(),Constants.ZERO)?Constants.ONE:-Constants.ONE))
+ ).reduce(BigDecimal.ZERO,BigDecimal::add);
+ //鑾峰彇寰呮敮浠樻閲戦 濡傛灉璐﹀崟绫诲瀷涓烘敮鍑� 鎴� 锛堣处鍗曠被鍨嬩负鏀跺叆 涓� 寰呮敮浠橀噾棰� 灏忎簬 0锛� 鍒欎负鏀粯
+ waitPayTotal = ywContractBill.getReceivableFee().subtract(payTotal);
+ //濡傛灉寰呮敮浠橀噾棰� 澶т簬 0 鍒欐槸 鏀跺叆 鍚﹀垯鏄敮鍑� 鍏朵粬鐘舵�� 涓哄紓甯革紒
+ if(waitPayTotal.compareTo(BigDecimal.ZERO)>Constants.ZERO){
+ ywContractRevenue.setRevenueType(Constants.ZERO);
+ }else if(waitPayTotal.compareTo(BigDecimal.ZERO)<Constants.ZERO){
+ ywContractRevenue.setRevenueType(Constants.ONE);
+ }else{
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏀舵敮閲戦寮傚父!璇疯仈绯荤鐞嗗憳");
+ }
}else{
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏀舵敮閲戦寮傚父!璇疯仈绯荤鐞嗗憳");
+ payTotal = ywContractRevenueList.stream().map(i->
+ i.getActReceivableFee().multiply(
+ BigDecimal.valueOf(Constants.equalsInteger(i.getRevenueType(),Constants.ZERO)?-Constants.ONE:Constants.ONE))
+ ).reduce(BigDecimal.ZERO,BigDecimal::add);
+ //鑾峰彇寰呮敮浠樻閲戦 濡傛灉璐﹀崟绫诲瀷涓烘敮鍑� 鎴� 锛堣处鍗曠被鍨嬩负鏀跺叆 涓� 寰呮敮浠橀噾棰� 灏忎簬 0锛� 鍒欎负鏀粯
+ waitPayTotal = ywContractBill.getReceivableFee().subtract(payTotal);
+ //濡傛灉寰呮敮浠橀噾棰� 澶т簬 0 鍒欐槸 鏀跺叆 鍚﹀垯鏄敮鍑� 鍏朵粬鐘舵�� 涓哄紓甯革紒
+ if(waitPayTotal.compareTo(BigDecimal.ZERO)>Constants.ZERO){
+ ywContractRevenue.setRevenueType(Constants.ONE);
+ }else if(waitPayTotal.compareTo(BigDecimal.ZERO)<Constants.ZERO){
+ ywContractRevenue.setRevenueType(Constants.ZERO);
+ }else{
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏀舵敮閲戦寮傚父!璇疯仈绯荤鐞嗗憳");
+ }
}
+
+
//寰呮敮浠樼殑娴佹按 濡傛灉涓烘敹鍏� 鍒欐瘮瀵� 閲戦鍊� 濡傛灉鏄敮鍑� 鍒欒幏鍙栫粷瀵瑰�� 杩涜瀵规瘮
if(Constants.equalsInteger(ywContractRevenue.getRevenueType(),Constants.ZERO)){
//濡傛灉鏀粯閲戦 澶т簬 寰呮敮浠橀噾棰� 鍒欐彁绀哄紓甯� 濡傛灉鏀粯閲戦灏忎簬 寰呮敮浠橀噾棰� 鍒欑姸鎬佷笉鍙樺寲 鍏朵粬鐘舵�� 寮傚父
@@ -170,6 +193,22 @@
}
ywContractRevenueMapper.insert(ywContractRevenue);
ywContractBillMapper.updateById(ywContractBill);
+ //濡傛灉璐﹀崟瀹岀粨锛屽垯鏌ヨ鍚堝悓涓嬪紑鍚腑鐨勮处鍗曟槸鍚﹀瓨鍦ㄩ��娆句腑 濡傛灉涓嶅瓨鍦ㄥ垯鏍囪鍚堝悓宸查��娆�
+ if(Constants.equalsInteger(ywContractBill.getContractStatus(),Constants.THREE)
+ && Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.ONE)){
+ if( ywContractBillMapper
+ .selectCount(new QueryWrapper<YwContractBill>().lambda().eq(YwContractBill::getContractId,ywContractBill.getContractId())
+ .ne(YwContractBill::getId,ywContractBill.getId())
+ .eq(YwContractBill::getStatus,Constants.ZERO)
+ .in(YwContractBill::getPayStatus,Constants.ZERO,Constants.FOUR, Constants.TWO,Constants.THREE)
+ ) == Constants.ZERO){
+ ywContractMapper.update(new UpdateWrapper<YwContract>().lambda()
+ .set(YwContract::getStatus,Constants.FOUR)
+ .set(YwContract::getEditDate,DateUtil.getCurrDateTime())
+ .eq(YwContract::getId,ywContractBill.getContractId())
+ );
+ }
+ }
//瀛樺偍闄勪欢淇℃伅
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractRevenue.getMultifileList())){
for (Multifile multifile:ywContractRevenue.getMultifileList()) {
@@ -235,6 +274,7 @@
new MPJLambdaWrapper<YwContractRevenue>().selectAll(YwContractRevenue.class)
.selectAs(YwContractBill::getCode,YwContractRevenue::getBillCode)
.selectAs(YwContract::getCode,YwContractRevenue::getContractCode)
+ .selectAs(YwContract::getStatus,YwContractRevenue::getContractStatus)
.selectAs(YwCustomer::getName,YwContractRevenue::getCustomerName)
.selectAs(SystemUser::getRealname,YwContractRevenue::getRealname)
.selectAs(YwAccount::getTitle,YwContractRevenue::getAccountTitle)
@@ -392,7 +432,9 @@
IPage<YwContractRevenue> iPage = ywContractRevenueMapper.selectJoinPage(page,YwContractRevenue.class,
queryWrapper.selectAll(YwContractRevenue.class)
.selectAs(YwContractBill::getCode,YwContractRevenue::getBillCode)
+ .selectAs(YwContractBill::getType,YwContractRevenue::getBillType)
.selectAs(YwContract::getCode,YwContractRevenue::getContractCode)
+ .selectAs(YwContract::getStatus,YwContractRevenue::getContractStatus)
.selectAs(YwCustomer::getName,YwContractRevenue::getCustomerName)
.selectAs(SystemUser::getRealname,YwContractRevenue::getRealname)
.leftJoin(YwContractBill.class,YwContractBill::getId,YwContractRevenue::getBillId)
@@ -407,7 +449,8 @@
.eq(Objects.nonNull(model)&&Objects.nonNull(model.getRevenueType()),
YwContractRevenue::getRevenueType,model.getRevenueType())
.ge(Objects.nonNull(model)&&Objects.nonNull(model.getPayDateStart()),YwContractRevenue::getActPayDate, Utils.Date.getStart(model.getPayDateStart()))
- .le(Objects.nonNull(model)&&Objects.nonNull(model.getPayDateEnd()),YwContractRevenue::getActPayDate, Utils.Date.getEnd(model.getPayDateEnd())) )
+ .le(Objects.nonNull(model)&&Objects.nonNull(model.getPayDateEnd()),YwContractRevenue::getActPayDate, Utils.Date.getEnd(model.getPayDateEnd()))
+ .orderByDesc(YwContractRevenue::getId))
;
this.dealRoomDetail(iPage.getRecords());
@@ -418,6 +461,17 @@
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractRoomList)){
StringBuilder roomPathName = new StringBuilder();
for (YwContractRoom ywContractRoom:ywContractRoomList) {
+ if(Constants.equalsInteger(ywContractRevenue.getBillType(),Constants.ZERO)){
+ if(!(Constants.equalsInteger(ywContractRevenue.getContractId(),ywContractRoom.getContractId())
+ && Constants.equalsInteger(ywContractRoom.getType(),Constants.ZERO))){
+ continue;
+ }
+ }else{
+ if(!(Constants.equalsInteger(ywContractRevenue.getBillId(),ywContractRoom.getContractId())
+ && Constants.equalsInteger(ywContractRoom.getType(),Constants.ONE))){
+ continue;
+ }
+ }
if(StringUtils.isNotBlank(ywContractRoom.getProjectName())){
roomPathName.append(ywContractRoom.getProjectName()+"/");
}
@@ -447,24 +501,30 @@
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractRevenueList)){
//鑾峰彇鎵�鏈夋暟鎹�
List<Integer> billIdList = ywContractRevenueList.stream().map(i->i.getBillId()).collect(Collectors.toList());
+ List<Integer> contractIdList = ywContractRevenueList.stream().map(i->i.getContractId()).collect(Collectors.toList());
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(billIdList)){
List<YwContractRoom> ywContractRoomList = 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::getName,YwContractRoom::getRoomName)
+ .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)
+ .and(i->i.in(YwContractRoom::getContractId,billIdList).eq(YwContractRoom::getType,Constants.ONE)
+ .or().in(YwContractRoom::getContractId,contractIdList).eq(YwContractRoom::getType,Constants.ZERO)
+ )
+// .in(YwContractRoom::getContractId,billIdList)
+// .eq(YwContractRoom::getType,Constants.ONE)
);
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractRoomList)){
for (YwContractRevenue ywContractRevenue:ywContractRevenueList) {
ywContractRevenue.setYwContractRoomList(
- ywContractRoomList.stream().filter(i->Constants.equalsInteger(i.getContractId(),ywContractRevenue.getBillId())).collect(Collectors.toList())
+ ywContractRoomList.stream().filter(i->
+ Constants.equalsInteger(i.getContractId(),ywContractRevenue.getBillId())||Constants.equalsInteger(i.getContractId(),ywContractRevenue.getContractId()))
+ .collect(Collectors.toList())
);
}
}
--
Gitblit v1.9.3