jiangping
2024-11-25 1a64b4bcc938db743396382a30f3b10136a1a27a
Merge remote-tracking branch 'origin/master'
已修改7个文件
136 ■■■■■ 文件已修改
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractBillCloudController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/YwContractRevenueCloudController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractBill.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractRevenue.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractBillService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java 54 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractRevenueServiceImpl.java 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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));
    }
}
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));
    }
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)
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")
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();
}
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()));
                    }
                }
            }
        }
    }
}
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();
    }