From bc87b51e20a0adf0badf2033ede93cafeb5fc147 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 27 十一月 2024 17:29:59 +0800
Subject: [PATCH] 开发更新

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java |  178 ++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 138 insertions(+), 40 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 9ac3f78..641c496 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
@@ -8,13 +8,11 @@
 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.YwContractRevenueMapper;
-import com.doumee.dao.business.YwContractRoomMapper;
-import com.doumee.dao.business.YwRoomMapper;
+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;
@@ -27,9 +25,7 @@
 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;
 
 /**
@@ -55,6 +51,8 @@
     @Autowired
     private SystemDictDataBiz systemDictDataBiz;
 
+    @Autowired
+    private YwContractMapper ywContractMapper;
 
 
 
@@ -67,18 +65,27 @@
                 || 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.nonNull(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.contractBillType.create);
+        ywContractBill.setType(Constants.ONE);
         ywContractBill.setStatus(Constants.ZERO);
         ywContractBillMapper.insert(ywContractBill);
 
@@ -94,7 +101,6 @@
                 ywContractRoom.setIsdeleted(Constants.ZERO);
                 ywContractRoom.setContractId(ywContractBill.getId());
                 ywContractRoom.setType(Constants.ONE);
-
             }
             ywContractRoomMapper.insert(ywContractBill.getYwContractRoomList());
         }
@@ -159,6 +165,7 @@
     }
 
 
+    @Override
     public YwContractBill getDetail(Integer id) {
         YwContractBill ywContractBill = ywContractBillMapper.selectJoinOne(YwContractBill.class,
                 new MPJLambdaWrapper<YwContractBill>().selectAll(YwContractBill.class)
@@ -172,6 +179,7 @@
         if(Objects.isNull(ywContractBill)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
+
         //鎴挎簮鏁版嵁
         ywContractBill.setYwContractRoomList(ywContractRoomMapper.selectJoinList(YwContractRoom.class,new MPJLambdaWrapper<YwContractRoom>()
                 .selectAll(YwContractRoom.class)
@@ -185,19 +193,14 @@
                 .eq(YwContractRoom::getContractId,id)
                 .eq(YwContractRoom::getType,Constants.ONE)
         ));
-        //鏀舵敮鏄庣粏
-        ywContractBill.setYwContractRevenueList(
-            ywContractRevenueMapper.selectJoinList(YwContractRevenue.class,new MPJLambdaWrapper<YwContractRevenue>()
-                            .selectAll(YwContractRevenue.class)
-                            .selectAs(YwCustomer::getName,YwContractRevenue::getCustomerNme)
-                            .leftJoin(YwContract.class,YwContract::getId,YwContractRevenue::getContractId)
-                            .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
-                    .eq(YwContractRevenue::getBillId,id)
-            )
-        );
+
         //闄勪欢鏁版嵁
-        List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda()
+        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()
@@ -248,8 +251,8 @@
                             YwContractBill::getType,model.getType())
                     .eq(Objects.nonNull(model)&&Objects.nonNull(model.getContractId()),
                             YwContractBill::getContractId,model.getContractId())
-                .ge(YwContractBill::getPlanPayDate, Utils.Date.getStart(model.getPlanPayDateStart()))
-                .le(YwContractBill::getPlanPayDate, Utils.Date.getEnd(model.getPlanPayDateEnd())) )
+                .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()) {
@@ -257,49 +260,98 @@
             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.getEndDate().getTime() < System.currentTimeMillis()){
+                ywContractBill.setIsOverdue(Constants.ONE);
+            }else{
+                ywContractBill.setIsOverdue(Constants.ZERO);
+            }
             //妤煎畤鍚嶇О
             List<YwContractRoom> ywContractRoomList = ywContractBill.getYwContractRoomList();
-//            String roomPathName = new StringBuffer();
-//            for (:
-//                 ) {
-//
-//            }
-
-
-
+            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(iPage);
     }
 
-
-
     public void dealRoomDetail(List<YwContractBill> ywContractBillList){
         //鏌ヨ璐﹀崟涓嬬殑妤煎畤鏁版嵁
         if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBillList)){
             //鑾峰彇鎵�鏈夋暟鎹�
-            List<Integer> billIdList = ywContractBillList.stream().map(i->i.getId()).collect(Collectors.toList());
+            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)){
-                List<YwContractRoom> ywContractRoomList  = ywContractRoomMapper.selectJoinList(YwContractRoom.class,new MPJLambdaWrapper<YwContractRoom>()
+                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(ywContractRoomList)){
-                    for (YwContractBill ywContractBill:ywContractBillList) {
+                ));
+
+            }
+            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.getContractId(),ywContractBill.getId())).collect(Collectors.toList())
+                                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())
                         );
                     }
+
                 }
             }
+
         }
     }
 
@@ -309,4 +361,50 @@
         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)
+                    );
+                    Integer maxCode = Constants.ONE;
+                    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,ywContractBill.getId()));
+                    }
+                }
+            }
+        }
+    }
+
+
+
 }

--
Gitblit v1.9.3