package com.by4cloud.platformx.business.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.by4cloud.platformx.business.dto.ZBJTStatisticDTO; import com.by4cloud.platformx.business.entity.ZbStatisticCpbk; import com.by4cloud.platformx.business.entity.ZbStatisticXszb; import com.by4cloud.platformx.business.mapper.ContractOutBoundMapper; import com.by4cloud.platformx.business.mapper.ContractSubjectMatterMapper; import com.by4cloud.platformx.business.mapper.ZbStatisticCpbkMapper; import com.by4cloud.platformx.business.service.ZbStatisticCpbkService; import com.by4cloud.platformx.business.vo.GcpbkwcqkItemVo; import com.by4cloud.platformx.business.vo.GcpbkwcqkVo; import com.by4cloud.platformx.common.core.util.R; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.YearMonth; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Objects; /** * 产品板块 * * @author syt * @date 2026-11-12 10:27:07 */ @Service @RequiredArgsConstructor public class ZbStatisticCpbkServiceImpl extends ServiceImpl implements ZbStatisticCpbkService { private final ContractOutBoundMapper contractOutBoundMapper; private final ContractSubjectMatterMapper contractSubjectMatterMapper; @Override public R genCpbkwcqk(ZBJTStatisticDTO queryDTO) { if (StrUtil.isBlank(queryDTO.getYearMonth())) { queryDTO.setYearMonth(DateUtil.format(new Date(), DatePattern.NORM_MONTH_PATTERN)); } List list = new ArrayList<>(); Date monstart = DateUtil.parseDateTime(queryDTO.getYearMonth() + "-01 00:00:00"); Date monend = DateUtil.parseDateTime(queryDTO.getYearMonth() + "-31 23:59:59"); Date monstartLastYear = DateUtil.offsetYear(DateUtil.parseDateTime(queryDTO.getYearMonth() + "-01 00:00:00"), -1); Date monendLastYear = DateUtil.offsetYear(DateUtil.parseDateTime(queryDTO.getYearMonth() + "-31 23:59:59"), -1); Date yearstart = DateUtil.parseDateTime(queryDTO.getYearMonth().substring(0, 4) + "-01-01 00:00:00"); Date yearend = DateUtil.parseDateTime(queryDTO.getYearMonth() + "-31 23:59:59"); Date yearstartLastYear = DateUtil.offsetYear(DateUtil.parseDateTime(queryDTO.getYearMonth().substring(0, 4) + "-01-01 00:00:00"), -1); Date yearendLastYear = DateUtil.offsetYear(DateUtil.parseDateTime(queryDTO.getYearMonth() + "-31 23:59:59"), -1); String curYear = queryDTO.getYearMonth().substring(0, 4); String curMonth = queryDTO.getYearMonth().substring(5); YearMonth qndy = YearMonth.of(Integer.valueOf(curYear), Integer.valueOf(curMonth)).minusYears(1); YearMonth sy = YearMonth.of(Integer.valueOf(curYear), Integer.valueOf(curMonth)).minusMonths(1); //新增合同 List itemVoListMon = contractSubjectMatterMapper.gcpbkwcqk(monstart, monend); // List itemVoListMonLastYear = contractSubjectMatterMapper.gcpbkwcqk(monstartLastYear, monendLastYear); if (CollUtil.isNotEmpty(itemVoListMon)) { itemVoListMon.stream().forEach(item -> { ZbStatisticCpbk vo = new ZbStatisticCpbk(); vo.setXm("新增合同"); vo.setStatYm(queryDTO.getYearMonth()); vo.setBkmc(item.getBkmc()); vo.setDywc(item.getWc()); ZbStatisticCpbk vo1 = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, vo.getXm()) .eq(ZbStatisticCpbk::getBkmc, vo.getBkmc()).eq(ZbStatisticCpbk::getStatYm, queryDTO.getYearMonth()).last("limit 1")); ZbStatisticCpbk cpbkQndy = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, vo.getXm()) .eq(ZbStatisticCpbk::getBkmc, vo.getBkmc()).eq(ZbStatisticCpbk::getStatYm, qndy).last("limit 1")); ZbStatisticCpbk cpbkSy = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, vo.getXm()) .eq(ZbStatisticCpbk::getBkmc, vo.getBkmc()).eq(ZbStatisticCpbk::getStatYm, sy).last("limit 1")); if (ObjUtil.isNotNull(vo1)) { if (ObjUtil.isNotNull(cpbkQndy)) { BigDecimal percent = vo1.getDywc().subtract(cpbkQndy.getDywc()).divide(cpbkQndy.getDywc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo1.setYtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } if (ObjUtil.isNotNull(cpbkSy)) { vo1.setLjwc(cpbkSy.getLjwc().add(vo1.getDywc())); if (ObjUtil.isNotNull(cpbkQndy) && cpbkQndy.getLjwc().compareTo(new BigDecimal("0")) > 0) { BigDecimal percent = vo1.getLjwc().subtract(cpbkQndy.getLjwc()).divide(cpbkQndy.getLjwc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo1.setNtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } } baseMapper.updateById(vo1); list.add(vo1); } else { if (ObjUtil.isNotNull(cpbkQndy)) { BigDecimal percent = vo.getDywc().subtract(cpbkQndy.getDywc()).divide(cpbkQndy.getDywc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo.setYtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } if (ObjUtil.isNotNull(cpbkSy)) { vo.setLjwc(cpbkSy.getLjwc().add(vo.getDywc())); if (ObjUtil.isNotNull(cpbkQndy) && cpbkQndy.getLjwc().compareTo(new BigDecimal("0")) > 0) { BigDecimal percent = vo.getLjwc().subtract(cpbkQndy.getLjwc()).divide(cpbkQndy.getLjwc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo.setNtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } } baseMapper.insert(vo); list.add(vo); } }); } // List itemVoListYear = contractSubjectMatterMapper.gcpbkwcqk(yearstart,yearend); // List itemVoListYearLastYear = contractSubjectMatterMapper.gcpbkwcqk(yearstartLastYear,yearendLastYear); // if (CollUtil.isNotEmpty(itemVoListYear)){ // BigDecimal ljzh = itemVoListYear.stream().map(item->item.getWc()).filter(Objects::nonNull).reduce(BigDecimal.ZERO,BigDecimal::add); // for (GcpbkwcqkItemVo itemVo:itemVoListYear // ) { // ZbStatisticCpbk vo = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm,"新增合同") // .eq(ZbStatisticCpbk::getBkmc,itemVo.getBkmc()).eq(ZbStatisticCpbk::getStatYm,queryDTO.getYearMonth()).last("limit 1")); // if (StrUtil.equals(vo.getBkmc(),itemVo.getBkmc())&&StrUtil.equals(vo.getXm(),"新增合同")){ // vo.setLjwc(itemVo.getWc()); // if (ljzh.compareTo(new BigDecimal("0"))>0){ // BigDecimal zb = vo.getLjwc().divide(ljzh,10,RoundingMode.HALF_UP).multiply(new BigDecimal("100")); // vo.setBnzb(zb.setScale(2,RoundingMode.HALF_UP)+"%"); // } // // } // if (CollUtil.isNotEmpty(itemVoListYearLastYear)){ // BigDecimal qnljzh = itemVoListYearLastYear.stream().map(item->item.getWc()).filter(Objects::nonNull).reduce(BigDecimal.ZERO,BigDecimal::add); // // itemVoListYearLastYear.stream().forEach(item1->{ // if (StrUtil.equals(vo.getBkmc(),item1.getBkmc())&&StrUtil.equals(vo.getXm(),"新增合同")&& // item1.getWc().compareTo(new BigDecimal("0"))>0){ // BigDecimal percent = vo.getDywc().subtract(item1.getWc()).divide(item1.getWc(),10,RoundingMode.HALF_UP).multiply(new BigDecimal("100")); // vo.setNtqb(percent.setScale(2,RoundingMode.HALF_UP)+"%"); // } // if (qnljzh.compareTo(new BigDecimal("0"))>0){ // BigDecimal qnzb = item1.getWc().multiply(new BigDecimal("100")).divide(qnljzh,2,RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP); // if (StrUtil.isNotBlank(vo.getBnzb())){ // BigDecimal bnzb = new BigDecimal(vo.getBnzb().substring(0,vo.getBnzb().length()-1)); // vo.setZtqb(bnzb.subtract(qnzb)+"%"); // } // } // }); // } // baseMapper.updateById(vo); // } // // } //销售收入 List itemVoSRListMon = contractOutBoundMapper.gcpbkwcqk(monstart, monend); List itemVoListSRMonLastYear = contractOutBoundMapper.gcpbkwcqk(monstartLastYear, monendLastYear); if (CollUtil.isNotEmpty(itemVoSRListMon)) { itemVoSRListMon.stream().forEach(item -> { ZbStatisticCpbk vo = new ZbStatisticCpbk(); vo.setXm("销售收入"); vo.setStatYm(queryDTO.getYearMonth()); vo.setBkmc(item.getBkmc()); vo.setDywc(item.getWc()); ZbStatisticCpbk vo1 = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, vo.getXm()) .eq(ZbStatisticCpbk::getBkmc, vo.getBkmc()).eq(ZbStatisticCpbk::getStatYm, queryDTO.getYearMonth()).last("limit 1")); ZbStatisticCpbk cpbkQndy = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, vo.getXm()) .eq(ZbStatisticCpbk::getBkmc, vo.getBkmc()).eq(ZbStatisticCpbk::getStatYm, qndy).last("limit 1")); ZbStatisticCpbk cpbkSy = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, vo.getXm()) .eq(ZbStatisticCpbk::getBkmc, vo.getBkmc()).eq(ZbStatisticCpbk::getStatYm, sy).last("limit 1")); if (ObjUtil.isNotNull(vo1)) { if (ObjUtil.isNotNull(cpbkQndy)) { BigDecimal percent = vo1.getDywc().subtract(cpbkQndy.getDywc()).divide(cpbkQndy.getDywc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo1.setYtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } if (ObjUtil.isNotNull(cpbkSy)) { vo1.setLjwc(cpbkSy.getLjwc().add(vo1.getDywc())); if (ObjUtil.isNotNull(cpbkQndy) && cpbkQndy.getLjwc().compareTo(new BigDecimal("0")) > 0) { BigDecimal percent = vo1.getLjwc().subtract(cpbkQndy.getLjwc()).divide(cpbkQndy.getLjwc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo1.setNtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } } baseMapper.updateById(vo1); list.add(vo1); } else { if (ObjUtil.isNotNull(cpbkQndy)) { BigDecimal percent = vo.getDywc().subtract(cpbkQndy.getDywc()).divide(cpbkQndy.getDywc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo.setYtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } if (ObjUtil.isNotNull(cpbkSy)) { vo.setLjwc(cpbkSy.getLjwc().add(vo.getDywc())); if (ObjUtil.isNotNull(cpbkQndy) && cpbkQndy.getLjwc().compareTo(new BigDecimal("0")) > 0) { BigDecimal percent = vo.getLjwc().subtract(cpbkQndy.getLjwc()).divide(cpbkQndy.getLjwc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo.setNtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } } baseMapper.insert(vo); list.add(vo); } }); } // List itemVoListSRYear = contractOutBoundMapper.gcpbkwcqk(yearstart, yearend); // List itemVoListSRYearLastYear = contractOutBoundMapper.gcpbkwcqk(yearstartLastYear, yearendLastYear); // if (CollUtil.isNotEmpty(itemVoListSRYear)) { // BigDecimal ljzh = itemVoListSRYear.stream().map(item -> item.getWc()).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); // for (GcpbkwcqkItemVo itemVo : itemVoListSRYear // ) { // ZbStatisticCpbk vo = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, "销售收入") // .eq(ZbStatisticCpbk::getBkmc, itemVo.getBkmc()).eq(ZbStatisticCpbk::getStatYm, queryDTO.getYearMonth()).last("limit 1")); // if (StrUtil.equals(vo.getBkmc(), itemVo.getBkmc()) && StrUtil.equals(vo.getXm(), "销售收入")) { // vo.setLjwc(itemVo.getWc()); // if (ljzh.compareTo(new BigDecimal("0")) > 0) { // BigDecimal zb = vo.getLjwc().divide(ljzh, 10, RoundingMode.HALF_UP).multiply(new BigDecimal("100")); // vo.setBnzb(zb.setScale(2, RoundingMode.HALF_UP) + "%"); // } // } // if (CollUtil.isNotEmpty(itemVoListSRYearLastYear)) { // BigDecimal qnljzh = itemVoListSRYearLastYear.stream().map(item -> item.getWc()).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); // // itemVoListSRYearLastYear.stream().forEach(item1 -> { // if (StrUtil.equals(vo.getBkmc(), item1.getBkmc()) && StrUtil.equals(vo.getXm(), "销售收入") && // item1.getWc().compareTo(new BigDecimal("0")) > 0) { // BigDecimal percent = vo.getDywc().subtract(item1.getWc()).divide(item1.getWc(), 10, RoundingMode.HALF_UP).multiply(new BigDecimal("100")); // vo.setNtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); // } // if (qnljzh.compareTo(new BigDecimal("0")) > 0) { // BigDecimal qnzb = item1.getWc().multiply(new BigDecimal("100")).divide(qnljzh, 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP); // if (StrUtil.isNotBlank(vo.getBnzb())) { // BigDecimal bnzb = new BigDecimal(vo.getBnzb().substring(0, vo.getBnzb().length() - 1)); // vo.setZtqb(bnzb.subtract(qnzb) + "%"); // } // } // }); // } // baseMapper.updateById(vo); // } // } //货款回收 List itemVoListSKMon = contractSubjectMatterMapper.gcpbkwcqkBySK(monstart, monend); List itemVoListSKMonLastYear = contractSubjectMatterMapper.gcpbkwcqkBySK(monstartLastYear, monendLastYear); if (CollUtil.isNotEmpty(itemVoListSKMon)) { itemVoListSKMon.stream().forEach(item -> { ZbStatisticCpbk vo = new ZbStatisticCpbk(); vo.setXm("货款回收"); vo.setStatYm(queryDTO.getYearMonth()); vo.setBkmc(item.getBkmc()); vo.setDywc(item.getWc()); ZbStatisticCpbk vo1 = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, vo.getXm()) .eq(ZbStatisticCpbk::getBkmc, vo.getBkmc()).eq(ZbStatisticCpbk::getStatYm, queryDTO.getYearMonth()).last("limit 1")); ZbStatisticCpbk cpbkQndy = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, vo.getXm()) .eq(ZbStatisticCpbk::getBkmc, vo.getBkmc()).eq(ZbStatisticCpbk::getStatYm, qndy).last("limit 1")); ZbStatisticCpbk cpbkSy = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, vo.getXm()) .eq(ZbStatisticCpbk::getBkmc, vo.getBkmc()).eq(ZbStatisticCpbk::getStatYm, sy).last("limit 1")); if (ObjUtil.isNotNull(vo1)) { if (ObjUtil.isNotNull(cpbkQndy)) { BigDecimal percent = vo1.getDywc().subtract(cpbkQndy.getDywc()).divide(cpbkQndy.getDywc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo1.setYtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } if (ObjUtil.isNotNull(cpbkSy)) { vo1.setLjwc(cpbkSy.getLjwc().add(vo1.getDywc())); if (ObjUtil.isNotNull(cpbkQndy) && cpbkQndy.getLjwc().compareTo(new BigDecimal("0")) > 0) { BigDecimal percent = vo1.getLjwc().subtract(cpbkQndy.getLjwc()).divide(cpbkQndy.getLjwc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo1.setNtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } } baseMapper.updateById(vo1); list.add(vo1); } else { if (ObjUtil.isNotNull(cpbkQndy)) { BigDecimal percent = vo.getDywc().subtract(cpbkQndy.getDywc()).divide(cpbkQndy.getDywc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo.setYtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } if (ObjUtil.isNotNull(cpbkSy)) { vo.setLjwc(cpbkSy.getLjwc().add(vo.getDywc())); if (ObjUtil.isNotNull(cpbkQndy) && cpbkQndy.getLjwc().compareTo(new BigDecimal("0")) > 0) { BigDecimal percent = vo.getLjwc().subtract(cpbkQndy.getLjwc()).divide(cpbkQndy.getLjwc(), 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); vo.setNtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); } } baseMapper.insert(vo); list.add(vo); } }); } // List itemVoListSKYear = contractSubjectMatterMapper.gcpbkwcqkBySK(yearstart, yearend); // List itemVoListSKYearLastYear = contractSubjectMatterMapper.gcpbkwcqkBySK(yearstartLastYear, yearendLastYear); // if (CollUtil.isNotEmpty(itemVoListSKYear)) { // for (GcpbkwcqkItemVo itemVo : itemVoListSKYear // ) { // ZbStatisticCpbk vo = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, "货款回收") // .eq(ZbStatisticCpbk::getBkmc, itemVo.getBkmc()).eq(ZbStatisticCpbk::getStatYm, queryDTO.getYearMonth()).last("limit 1")); // if (StrUtil.equals(vo.getBkmc(), itemVo.getBkmc()) && StrUtil.equals(vo.getXm(), "货款回收")) { // vo.setLjwc(itemVo.getWc()); // } // if (CollUtil.isNotEmpty(itemVoListSKYearLastYear)) { // BigDecimal qnljzh = itemVoListSKYearLastYear.stream().map(item -> item.getWc()).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); // itemVoListSKYearLastYear.stream().forEach(item1 -> { // if (StrUtil.equals(vo.getBkmc(), item1.getBkmc()) && StrUtil.equals(vo.getXm(), "货款回收") && // item1.getWc().compareTo(new BigDecimal("0")) > 0) { // BigDecimal percent = vo.getDywc().subtract(item1.getWc()).divide(item1.getWc(), 10, RoundingMode.HALF_UP).multiply(new BigDecimal("100")); // vo.setNtqb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); // } // if (qnljzh.compareTo(new BigDecimal("0")) > 0) { // BigDecimal qnzb = item1.getWc().multiply(new BigDecimal("100")).divide(qnljzh, 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP); // if (StrUtil.isNotBlank(vo.getBnzb())) { // BigDecimal bnzb = new BigDecimal(vo.getBnzb().substring(0, vo.getBnzb().length() - 1)); // vo.setZtqb(bnzb.subtract(qnzb) + "%"); // } // } // }); // } // baseMapper.updateById(vo); // } // } BigDecimal htzh = list.stream().filter(item->StrUtil.equals(item.getXm(),"新增合同")).map(item -> item.getDywc()).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal srzh = list.stream().filter(item->StrUtil.equals(item.getXm(),"销售收入")).map(item -> item.getDywc()).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal hkzh = list.stream().filter(item->StrUtil.equals(item.getXm(),"货款回收")).map(item -> item.getDywc()).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); if (CollUtil.isNotEmpty(list)){ list.stream().forEach(item->{ if (StrUtil.equals(item.getXm(),"新增合同")&&htzh.compareTo(new BigDecimal("0"))>0){ BigDecimal percent = item.getDywc().divide(htzh, 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); item.setBnzb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); ZbStatisticCpbk cpbkQndy = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, item.getXm()) .eq(ZbStatisticCpbk::getBkmc, item.getBkmc()).eq(ZbStatisticCpbk::getStatYm, qndy).last("limit 1")); if (ObjUtil.isNotNull(cpbkQndy)&&ObjUtil.isNotNull(cpbkQndy.getBnzb())){ BigDecimal qnbnzb = new BigDecimal(cpbkQndy.getBnzb().substring(0, cpbkQndy.getBnzb().length() - 1)); item.setZtqb(percent.subtract(qnbnzb) + "%"); } baseMapper.updateById(item); } if (StrUtil.equals(item.getXm(),"销售收入")&&srzh.compareTo(new BigDecimal("0"))>0){ BigDecimal percent = item.getDywc().divide(srzh, 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); item.setBnzb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); ZbStatisticCpbk cpbkQndy = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, item.getXm()) .eq(ZbStatisticCpbk::getBkmc, item.getBkmc()).eq(ZbStatisticCpbk::getStatYm, qndy).last("limit 1")); if (ObjUtil.isNotNull(cpbkQndy)&&ObjUtil.isNotNull(cpbkQndy.getBnzb())){ BigDecimal qnbnzb = new BigDecimal(cpbkQndy.getBnzb().substring(0, cpbkQndy.getBnzb().length() - 1)); item.setZtqb(percent.subtract(qnbnzb) + "%"); } baseMapper.updateById(item); } if (StrUtil.equals(item.getXm(),"货款回收")&&hkzh.compareTo(new BigDecimal("0"))>0){ BigDecimal percent = item.getDywc().divide(hkzh, 10, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")); item.setBnzb(percent.setScale(2, RoundingMode.HALF_UP) + "%"); ZbStatisticCpbk cpbkQndy = baseMapper.selectOne(Wrappers.lambdaQuery().eq(ZbStatisticCpbk::getXm, item.getXm()) .eq(ZbStatisticCpbk::getBkmc, item.getBkmc()).eq(ZbStatisticCpbk::getStatYm, qndy).last("limit 1")); if (ObjUtil.isNotNull(cpbkQndy)&&ObjUtil.isNotNull(cpbkQndy.getBnzb())){ BigDecimal qnbnzb = new BigDecimal(cpbkQndy.getBnzb().substring(0, cpbkQndy.getBnzb().length() - 1)); item.setZtqb(percent.subtract(qnbnzb) + "%"); } baseMapper.updateById(item); } }); } return R.ok(); } }