更新细节
This commit is contained in:
parent
bafc61051b
commit
55cb5e1ae8
|
@ -3,7 +3,10 @@ package com.ruoyi.yh.report.service.impl;
|
|||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.MathUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import com.ruoyi.yh.price.domain.PriceVO;
|
||||
import com.ruoyi.yh.price.service.PriceService;
|
||||
import com.ruoyi.yh.report.domain.ReportVO;
|
||||
import com.ruoyi.yh.report.domain.bo.ReportBO;
|
||||
import com.ruoyi.yh.report.domain.enums.ReportStatus;
|
||||
|
@ -12,13 +15,13 @@ import com.ruoyi.yh.report.service.ReportService;
|
|||
import com.ruoyi.yh.reportProd.domain.ReportProdVO;
|
||||
import com.ruoyi.yh.reportProd.domain.bo.ReportProdBO;
|
||||
import com.ruoyi.yh.reportProd.service.ReportProdConverter;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
|
@ -36,6 +39,9 @@ public class ReportConverterImpl implements ReportConverter {
|
|||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
@Autowired
|
||||
private PriceService priceService;
|
||||
|
||||
@Override
|
||||
public ReportBO toBoByCreate(ReportVO vo, boolean submit) {
|
||||
if (vo == null) {
|
||||
|
@ -56,11 +62,15 @@ public class ReportConverterImpl implements ReportConverter {
|
|||
bo.setReportDate(vo.getReportDate());
|
||||
bo.setCreateBy(user.getNickName());
|
||||
|
||||
// 查询单价数据
|
||||
List<PriceVO> prices = priceService.selectPriceListByIds(CollectionUtils.map(vo.getProductList(), ReportProdVO::getPriceId));
|
||||
|
||||
// 报表产量数据
|
||||
List<ReportProdBO> productList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(vo.getProductList())) {
|
||||
for (ReportProdVO item : vo.getProductList()) {
|
||||
ReportProdBO prodBo = reportProdConverter.toBoByCreate(item);
|
||||
PriceVO price = prices.stream().filter(p -> Objects.equals(p.getPriceId(), item.getPriceId())).findFirst().orElse(null);
|
||||
ReportProdBO prodBo = reportProdConverter.toBoByCreate(item, price);
|
||||
productList.add(prodBo);
|
||||
}
|
||||
}
|
||||
|
@ -91,11 +101,15 @@ public class ReportConverterImpl implements ReportConverter {
|
|||
bo.setUpdateId(user.getUserId());
|
||||
bo.setUpdateBy(user.getNickName());
|
||||
|
||||
// 查询单价数据
|
||||
List<PriceVO> prices = priceService.selectPriceListByIds(CollectionUtils.map(vo.getProductList(), ReportProdVO::getPriceId));
|
||||
|
||||
// 报表产量数据
|
||||
List<ReportProdBO> productList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(vo.getProductList())) {
|
||||
for (ReportProdVO item : vo.getProductList()) {
|
||||
ReportProdBO prodBo = reportProdConverter.toBoByUpdate(item);
|
||||
PriceVO price = prices.stream().filter(p -> Objects.equals(p.getPriceId(), item.getPriceId())).findFirst().orElse(null);
|
||||
ReportProdBO prodBo = reportProdConverter.toBoByUpdate(item, price);
|
||||
productList.add(prodBo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.ruoyi.yh.reportProd.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.yh.price.domain.PriceVO;
|
||||
import com.ruoyi.yh.reportProd.domain.ReportProd;
|
||||
import com.ruoyi.yh.reportProd.domain.ReportProdVO;
|
||||
import com.ruoyi.yh.reportProd.domain.bo.ReportProdBO;
|
||||
import com.ruoyi.yh.reportProd.domain.dto.ReportProdNewPriceDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/11/2
|
||||
|
@ -19,14 +19,14 @@ public interface ReportProdConverter {
|
|||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
ReportProdBO toBoByCreate(ReportProdVO vo);
|
||||
ReportProdBO toBoByCreate(ReportProdVO vo, PriceVO price);
|
||||
|
||||
/**
|
||||
* 更新时,VO 转 BO
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
ReportProdBO toBoByUpdate(ReportProdVO vo);
|
||||
ReportProdBO toBoByUpdate(ReportProdVO vo, PriceVO price);
|
||||
|
||||
/**
|
||||
* 将通过的单价转为报表单价
|
||||
|
@ -35,4 +35,11 @@ public interface ReportProdConverter {
|
|||
*/
|
||||
List<ReportProdNewPriceDTO> toNewPriceDTO(List<PriceVO> passList);
|
||||
|
||||
/**
|
||||
* 设置单价信息
|
||||
* @param prod
|
||||
* @param price
|
||||
*/
|
||||
void setPriceInfo(ReportProd prod, PriceVO price);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.ruoyi.yh.price.domain.PriceVO;
|
|||
import com.ruoyi.yh.reportOrderProd.domain.ReportOrderProdVO;
|
||||
import com.ruoyi.yh.reportOrderProd.domain.bo.ReportOrderProdBO;
|
||||
import com.ruoyi.yh.reportOrderProd.service.ReportOrderProdConverter;
|
||||
import com.ruoyi.yh.reportProd.domain.ReportProd;
|
||||
import com.ruoyi.yh.reportProd.domain.ReportProdVO;
|
||||
import com.ruoyi.yh.reportProd.domain.bo.ReportProdBO;
|
||||
import com.ruoyi.yh.reportProd.domain.dto.ReportProdNewPriceDTO;
|
||||
|
@ -35,13 +36,12 @@ public class ReportProdConverterImpl implements ReportProdConverter {
|
|||
private ReportOrderProdConverter reportOrderProdConverter;
|
||||
|
||||
@Override
|
||||
public ReportProdBO toBoByCreate(ReportProdVO vo) {
|
||||
public ReportProdBO toBoByCreate(ReportProdVO vo, PriceVO price) {
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ReportProdBO bo = new ReportProdBO();
|
||||
bo.setPriceId(vo.getPriceId());
|
||||
bo.setNum(vo.getNum());
|
||||
bo.setPriceCategory(vo.getPriceCategory());
|
||||
bo.setPriceSize(vo.getPriceSize());
|
||||
|
@ -62,6 +62,7 @@ public class ReportProdConverterImpl implements ReportProdConverter {
|
|||
bo.setColor(vo.getColor());
|
||||
bo.setIsEnd(vo.getIsEnd());
|
||||
bo.setSort(vo.getSort());
|
||||
this.setPriceInfo(bo, price); // 设置单价信息(如果有)
|
||||
bo.setTotalAmount(this.calculateTotalAmount(bo));
|
||||
|
||||
// 用户产量明细
|
||||
|
@ -89,7 +90,7 @@ public class ReportProdConverterImpl implements ReportProdConverter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ReportProdBO toBoByUpdate(ReportProdVO vo) {
|
||||
public ReportProdBO toBoByUpdate(ReportProdVO vo, PriceVO price) {
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -97,7 +98,6 @@ public class ReportProdConverterImpl implements ReportProdConverter {
|
|||
ReportProdBO bo = new ReportProdBO();
|
||||
bo.setId(vo.getId());
|
||||
bo.setReportId(vo.getReportId());
|
||||
bo.setPriceId(vo.getPriceId());
|
||||
bo.setNum(vo.getNum());
|
||||
bo.setPriceCategory(vo.getPriceCategory());
|
||||
bo.setPriceSize(vo.getPriceSize());
|
||||
|
@ -118,6 +118,7 @@ public class ReportProdConverterImpl implements ReportProdConverter {
|
|||
bo.setColor(vo.getColor());
|
||||
bo.setIsEnd(vo.getIsEnd());
|
||||
bo.setSort(vo.getSort());
|
||||
this.setPriceInfo(bo, price); // 设置单价信息(如果有)
|
||||
bo.setTotalAmount(this.calculateTotalAmount(bo));
|
||||
|
||||
// 用户产量明细
|
||||
|
@ -144,6 +145,24 @@ public class ReportProdConverterImpl implements ReportProdConverter {
|
|||
return bo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriceInfo(ReportProd prod, PriceVO price) {
|
||||
if (price != null) {
|
||||
prod.setPriceId(price.getPriceId());
|
||||
prod.setPriceCategory(price.getCategory());
|
||||
prod.setPriceSize(price.getSize());
|
||||
prod.setPriceName(price.getName());
|
||||
prod.setPriceSubName(price.getSubName());
|
||||
prod.setPricePattern(price.getPattern());
|
||||
prod.setPriceSpec(price.getSpec());
|
||||
prod.setPricePrice(price.getPrice());
|
||||
prod.setPriceUnit(price.getUnit());
|
||||
prod.setPriceClassify(price.getClassify());
|
||||
prod.setPriceQuantityDenominator(price.getQuantityDenominator());
|
||||
prod.setPriceQuantityNumerator(price.getQuantityNumerator());
|
||||
}
|
||||
}
|
||||
|
||||
private BigDecimal calculateTotalAmount(ReportProdBO bo) {
|
||||
BigDecimal count = MathUtils.addDecimal(bo.getNum(), bo.getDefectNum());
|
||||
return MathUtils.multiply(bo.getPricePrice(), count);
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
package com.ruoyi.yh.reportProd.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.yh.price.domain.PriceQuery;
|
||||
|
@ -24,6 +14,15 @@ import com.ruoyi.yh.reportProd.mapper.ReportProdMapper;
|
|||
import com.ruoyi.yh.reportProd.service.ReportProdConverter;
|
||||
import com.ruoyi.yh.reportProd.service.ReportProdService;
|
||||
import com.ruoyi.yh.reportUserProd.service.ReportUserProdService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 报表产量Service业务层处理
|
||||
|
@ -219,19 +218,7 @@ public class ReportProdServiceImpl implements ReportProdService
|
|||
}
|
||||
ReportProd prod = new ReportProd();
|
||||
prod.setId(old.getId());
|
||||
prod.setPriceId(price.getPriceId());
|
||||
prod.setPriceSubName(price.getSubName());
|
||||
prod.setPriceSpec(price.getSpec());
|
||||
prod.setPricePrice(price.getPrice());
|
||||
prod.setPriceUnit(price.getUnit());
|
||||
prod.setPriceClassify(price.getClassify());
|
||||
prod.setPriceQuantityNumerator(price.getQuantityNumerator());
|
||||
prod.setPriceQuantityDenominator(price.getQuantityDenominator());
|
||||
prod.setPriceCode(price.getCode());
|
||||
prod.setPriceCategory(price.getCategory());
|
||||
prod.setPriceSize(price.getSize());
|
||||
prod.setPriceName(price.getName());
|
||||
prod.setPricePattern(price.getPattern());
|
||||
reportProdConverter.setPriceInfo(prod, price);
|
||||
list.add(prod);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user