From b142b67b25531fa9df35bb42500596bd7616f319 Mon Sep 17 00:00:00 2001
From: renkang <8417338+k94314517@user.noreply.gitee.com>
Date: 星期六, 23 十一月 2024 17:18:10 +0800
Subject: [PATCH] 客户资料 巡检任务业务

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java |  123 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 122 insertions(+), 1 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 730db94..b3cdf03 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,21 +1,32 @@
 package com.doumee.service.business.impl;
 
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
 import com.doumee.core.model.LoginUserInfo;
 import com.doumee.core.model.PageData;
 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.system.MultifileMapper;
+import com.doumee.dao.system.model.Multifile;
 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 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;
 
 /**
  * 杩愮淮鍚堝悓璐﹀崟淇℃伅琛⊿ervice瀹炵幇
@@ -28,9 +39,65 @@
     @Autowired
     private YwContractBillMapper ywContractBillMapper;
 
+    @Autowired
+    private YwContractRoomMapper ywContractRoomMapper;
+
+    @Autowired
+    private MultifileMapper multifileMapper;
+
     @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.getCostType())
+                || Objects.isNull(ywContractBill.getBillType())
+                || Objects.isNull(ywContractBill.getCompanyId())
+                || Objects.isNull(ywContractBill.getStartDate())
+                || Objects.isNull(ywContractBill.getEndDate())
+        ){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        LoginUserInfo loginUserInfo = ywContractBill.getLoginUserInfo();
+        ywContractBill.setCreateDate(new Date());
+        ywContractBill.setCreator(loginUserInfo.getId());
+        ywContractBill.setIsdeleted(Constants.ZERO);
+        ywContractBill.setStatus(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)
+                || 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());
+        }
+
         return ywContractBill.getId();
     }
 
@@ -55,7 +122,61 @@
 
     @Override
     public void updateById(YwContractBill ywContractBill) {
-        ywContractBillMapper.updateById(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());
+        }
     }
 
     @Override

--
Gitblit v1.9.3