From 822062b8083b08d38942ca7b7d40d3a1ad77a9f5 Mon Sep 17 00:00:00 2001
From: renkang <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 25 十一月 2024 15:33:41 +0800
Subject: [PATCH] 客户资料 巡检任务业务
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractBillService.java | 7 ++
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractBillCloudController.java | 3
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractRevenue.java | 3
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractRevenueCloudController.java | 3
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java | 54 +++++++++++++++--
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractBill.java | 9 +++
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractRevenueServiceImpl.java | 57 +++++++++++++++++++
7 files changed, 125 insertions(+), 11 deletions(-)
diff --git a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractBillCloudController.java b/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractBillCloudController.java
index bb4103e..57d7c63 100644
--- a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractBillCloudController.java
+++ b/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractBillCloudController.java
@@ -90,7 +90,6 @@
@GetMapping("/{id}")
@CloudRequiredPermission("business:ywcontractbill:query")
public ApiResponse findById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
-
- return ApiResponse.success(ywContractBillService.findById(id));
+ return ApiResponse.success(ywContractBillService.getDetail(id));
}
}
diff --git a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractRevenueCloudController.java b/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractRevenueCloudController.java
index 19563c3..f67ad1d 100644
--- a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractRevenueCloudController.java
+++ b/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractRevenueCloudController.java
@@ -35,7 +35,8 @@
@ApiOperation("鏂板缓")
@PostMapping("/create")
@CloudRequiredPermission("business:ywcontractrevenue:create")
- public ApiResponse create(@RequestBody YwContractRevenue ywContractRevenue) {
+ public ApiResponse create(@RequestBody YwContractRevenue ywContractRevenue,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
+ ywContractRevenue.setLoginUserInfo(getLoginUser(token));
return ApiResponse.success(ywContractRevenueService.create(ywContractRevenue));
}
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractBill.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractBill.java
index 32e2c85..4d1a770 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractBill.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractBill.java
@@ -97,6 +97,10 @@
@ApiModelProperty(value = "璐﹀崟绫诲瀷锛�0=鏀舵锛�1=浠樻", example = "1")
private Integer billType;
+ @ApiModelProperty(value = "璐圭敤绫诲瀷锛�0=鍛ㄦ湡璐圭敤锛�1=涓�娆℃�ц垂鐢�")
+ @TableField(exist = false)
+ private Integer feeType;
+
@ApiModelProperty(value = "鎵�灞炲叕鍙�", example = "1")
private Integer companyId;
@@ -143,6 +147,11 @@
@TableField(exist = false)
private String companyName;
+ @ApiModelProperty(value = "鍗曞彿鏃ユ湡", example = "1",hidden = true)
+ @TableField(exist = false)
+ private String codeDate;
+
+
@ApiModelProperty(value = "鍚堝悓缂栧彿", example = "1")
@ExcelColumn(name="鍚堝悓缂栧彿",index = 2,width = 10)
@TableField(exist = false)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractRevenue.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractRevenue.java
index 0e01ed8..c0bad0d 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractRevenue.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractRevenue.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.doumee.core.annotation.excel.ExcelColumn;
+import com.doumee.core.model.LoginUserModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
@@ -20,7 +21,7 @@
@Data
@ApiModel("杩愮淮鍚堝悓鏀舵敮娴佹按")
@TableName("`yw_contract_revenue`")
-public class YwContractRevenue {
+public class YwContractRevenue extends LoginUserModel {
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "涓婚敭", example = "1")
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractBillService.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractBillService.java
index 901b6cf..e805977 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractBillService.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractBillService.java
@@ -95,4 +95,11 @@
* @return long
*/
long count(YwContractBill ywContractBill);
+
+ YwContractBill getDetail(Integer id);
+
+ /**
+ * 澶勭悊璐﹀崟缂栧彿
+ */
+ void dealDayBillCode();
}
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 05c57c5..7d4dc16 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
@@ -27,9 +27,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;
/**
@@ -57,7 +55,6 @@
-
@Override
public Integer create(YwContractBill ywContractBill) {
if(Objects.isNull(ywContractBill)
@@ -67,9 +64,10 @@
|| 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);
}
@@ -78,7 +76,7 @@
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);
@@ -158,6 +156,7 @@
}
+ @Override
public YwContractBill getDetail(Integer id) {
YwContractBill ywContractBill = ywContractBillMapper.selectJoinOne(YwContractBill.class,
new MPJLambdaWrapper<YwContractBill>().selectAll(YwContractBill.class)
@@ -322,6 +321,47 @@
+ @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()));
+ }
+ }
+ }
+ }
+ }
+
}
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 01e6e53..7a0754c 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
@@ -1,9 +1,19 @@
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.YwAccountMapper;
+import com.doumee.dao.business.YwContractBillMapper;
import com.doumee.dao.business.YwContractRevenueMapper;
+import com.doumee.dao.business.dao.CompanyMapper;
+import com.doumee.dao.business.model.Company;
+import com.doumee.dao.business.model.YwAccount;
+import com.doumee.dao.business.model.YwContractBill;
import com.doumee.dao.business.model.YwContractRevenue;
import com.doumee.service.business.YwContractRevenueService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -14,7 +24,9 @@
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
+import java.util.Date;
import java.util.List;
+import java.util.Objects;
/**
* 杩愮淮鍚堝悓鏀舵敮娴佹按Service瀹炵幇
@@ -27,9 +39,54 @@
@Autowired
private YwContractRevenueMapper ywContractRevenueMapper;
+ @Autowired
+ private YwContractBillMapper ywContractBillMapper;
+
+ @Autowired
+ private CompanyMapper companyMapper;
+
+ @Autowired
+ private YwAccountMapper ywAccountMapper;
+
@Override
public Integer create(YwContractRevenue ywContractRevenue) {
+ if(Objects.isNull(ywContractRevenue)
+ || Objects.isNull(ywContractRevenue.getActReceivableFee())
+ || Objects.isNull(ywContractRevenue.getActPayDate())
+ || Objects.isNull(ywContractRevenue.getPayType())
+ || Objects.isNull(ywContractRevenue.getCompanyId())
+ || Objects.isNull(ywContractRevenue.getAccountId())
+ || Objects.isNull(ywContractRevenue.getBillId())
+ ){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ YwContractBill ywContractBill = ywContractBillMapper.selectById(ywContractRevenue.getBillId());
+ if(Objects.isNull(ywContractBill)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌璐﹀崟淇℃伅");
+ }
+ Company company =companyMapper.selectById(ywContractRevenue.getCompanyId());
+ if(Objects.isNull(company)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鎵�灞炲叕鍙镐俊鎭�");
+ }
+ YwAccount ywAccount =ywAccountMapper.selectById(ywContractRevenue.getAccountId());
+ if(Objects.isNull(ywAccount)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鏀舵敮璐︽埛淇℃伅");
+ }
+ LoginUserInfo loginUserInfo = ywContractRevenue.getLoginUserInfo();
+ ywContractRevenue.setCreateDate(new Date());
+ ywContractRevenue.setCreator(loginUserInfo.getId());
+ ywContractRevenue.setIsdeleted(Constants.ZERO);
+ ywContractRevenue.setStatus(Constants.ZERO);
+ ywContractRevenue.setContractId(ywContractBill.getContractId());
+ ywContractRevenue.setRevenueType(ywContractBill.getBillType());
ywContractRevenueMapper.insert(ywContractRevenue);
+ //鏍规嵁鏀舵敮鎯呭喌 鏇存柊璐﹀崟鏁版嵁
+
+
+
+
+
+
return ywContractRevenue.getId();
}
--
Gitblit v1.9.3