fix(成本分析): 修复了几个问题

This commit is contained in:
曹鹏飞 2025-01-06 18:30:52 +08:00
parent 7f4f2b4ea5
commit 66f0f84eaf
13 changed files with 64 additions and 27 deletions

View File

@ -65,7 +65,7 @@ public class EBomDTO {
/**
* 材料分组名称
*/
private String groupName;
private String rawMaterialGroup;
/**
* 库存

View File

@ -2,10 +2,11 @@ package com.nflg.product.technology.pojo.dto;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class WorkingHourDTO {
public class WorkingHourDTO implements Serializable {
private String materialWork;

View File

@ -57,12 +57,12 @@ public class EBomChildEntity implements Serializable {
@ApiModelProperty(value = "物料编码")
private String materialNo;
// /**
// * 物料描述
// */
// @TableField(value = "material_desc")
// @ApiModelProperty(value = "物料描述")
// private String materialDesc;
/**
* 物料描述
*/
@TableField(value = "material_desc")
@ApiModelProperty(value = "物料描述")
private String materialDesc;
/**
* 单位

View File

@ -22,6 +22,10 @@ public class PaintCostConfigEntity extends EntityBase implements Serializable {
@ApiModelProperty(value = "主键行id")
private Integer id;
@TableField(value = "code")
@ApiModelProperty(value = "分类代码")
private String code;
@TableField(value = "name")
@ApiModelProperty(value = "标签名称")
private String name;

View File

@ -22,6 +22,10 @@ public class SteelsCostConfigEntity extends EntityBase implements Serializable {
@ApiModelProperty(value = "主键行id")
private Integer id;
@TableField(value = "code")
@ApiModelProperty(value = "分类代码")
private String code;
@TableField(value = "name")
@ApiModelProperty(value = "分类名称")
private String name;

View File

@ -23,6 +23,11 @@ public class PaintCostConfig implements Serializable {
@ApiModelProperty(value = "主键行id")
private Integer id;
@ApiModelProperty("分类代码")
@NotBlank(message = "分类代码不能为空")
@Length(max = 10, message = "分类代码不能超过10个字")
private String code;
@ApiModelProperty("标签名称")
@NotBlank(message = "标签名称不能为空")
@Length(max = 10, message = "标签名称不能超过10个字")

View File

@ -23,6 +23,11 @@ public class SteelsCostConfig implements Serializable {
@ApiModelProperty(value = "主键行id")
private Integer id;
@ApiModelProperty("分类代码")
@NotBlank(message = "分类代码不能为空")
@Length(max = 10, message = "分类代码不能超过10个字")
private String code;
@ApiModelProperty("分类名称")
@NotBlank(message = "分类名称不能为空")
@Length(max = 10, message = "分类名称不能超过10个字")

View File

@ -15,6 +15,7 @@ import com.nflg.product.technology.pojo.entity.PaintCostConfigEntity;
import com.nflg.product.technology.pojo.entity.SteelsCostConfigEntity;
import com.nflg.product.technology.pojo.query.VirtualWorkingManday;
import com.nflg.product.technology.pojo.vo.VirtualWorkingItemVO;
import com.nflg.product.technology.util.BigDecimalUtil;
import com.nflg.product.technology.util.JsonUtil;
import com.nflg.product.technology.util.VUtils;
import lombok.extern.slf4j.Slf4j;
@ -95,7 +96,8 @@ public class BomCostCalculateService {
.filter(d -> StrUtil.equals(d.getParentMaterialNo(), dto.getMaterialNo()))
.collect(Collectors.toList());
if (StrUtil.isBlank(cdata)) {
List<WorkingHourDTO> workingHours = processRouteTaskProcessesService.getWorkingHour(dto.getMaterialNo());
final List<WorkingHourDTO> workingHours = processRouteTaskProcessesService.getWorkingHour(dto.getMaterialNo());
log.debug(StrUtil.format("BOM成本计算 {} 物料工时: {}", dto.getMaterialNo(), JsonUtil.toJson(workingHours)));
EBomCostCacheDTO cdto = new EBomCostCacheDTO();
cdto.setMaterialNo(dto.getMaterialNo());
cdto.setCategoryCode(dto.getMaterialCategoryCode());
@ -204,7 +206,7 @@ public class BomCostCalculateService {
}
private BigDecimal calculatePaintCost(EBomDTO dto) {
PaintCostConfigEntity entity = paintCostConfigService.getCost(dto.getGroupName());
PaintCostConfigEntity entity = paintCostConfigService.getCost(dto.getRawMaterialGroup());
if (Objects.nonNull(entity)) {
return NumberUtil.mul(dto.getNum(), entity.getCost());
} else {
@ -215,7 +217,7 @@ public class BomCostCalculateService {
private BigDecimal calculateWorkshopOfficeExpenses(EBomDTO dto, BomCostCalculateConfig config, List<WorkingHourDTO> workHours) {
BigDecimal cost = BigDecimal.ZERO;
for (VirtualWorkingItemVO vw : config.getVirtualWorkings()) {
cost = cost.add(vw.getWorkshopOfficeFee().multiply(getGsForWorkingType(dto, workHours, vw)));
cost = cost.add(BigDecimalUtil.multiply(vw.getWorkshopOfficeFee(), getGsForWorkingType(dto, workHours, vw)));
}
return cost;
}
@ -223,7 +225,7 @@ public class BomCostCalculateService {
private BigDecimal calculateAuxiliaryDepartmentExpenses(EBomDTO dto, BomCostCalculateConfig config, List<WorkingHourDTO> workHours) {
BigDecimal cost = BigDecimal.ZERO;
for (VirtualWorkingItemVO vw : config.getVirtualWorkings()) {
cost = cost.add(vw.getAssistantFee().multiply(getGsForWorkingType(dto, workHours, vw)));
cost = cost.add(BigDecimalUtil.multiply(vw.getAssistantFee(), getGsForWorkingType(dto, workHours, vw)));
}
return cost;
}
@ -231,7 +233,7 @@ public class BomCostCalculateService {
private BigDecimal calculateAuxiliaryDepartmentLaborCost(EBomDTO dto, BomCostCalculateConfig config, List<WorkingHourDTO> workHours) {
BigDecimal cost = BigDecimal.ZERO;
for (VirtualWorkingItemVO vw : config.getVirtualWorkings()) {
cost = cost.add(vw.getAssistantLaborFee().multiply(getGsForWorkingType(dto, workHours, vw)));
cost = cost.add(BigDecimalUtil.multiply(vw.getAssistantLaborFee(), getGsForWorkingType(dto, workHours, vw)));
}
return cost;
}
@ -239,7 +241,7 @@ public class BomCostCalculateService {
private BigDecimal calculateWorkshopManagementLaborCost(EBomDTO dto, BomCostCalculateConfig config, List<WorkingHourDTO> workHours) {
BigDecimal cost = BigDecimal.ZERO;
for (VirtualWorkingItemVO vw : config.getVirtualWorkings()) {
cost = cost.add(vw.getWorkshopLaborFee().multiply(getGsForWorkingType(dto, workHours, vw)));
cost = cost.add(BigDecimalUtil.multiply(vw.getWorkshopLaborFee(), getGsForWorkingType(dto, workHours, vw)));
}
return cost;
}
@ -247,7 +249,7 @@ public class BomCostCalculateService {
private BigDecimal calculateDepreciationCost(EBomDTO dto, BomCostCalculateConfig config, List<WorkingHourDTO> workHours) {
BigDecimal cost = BigDecimal.ZERO;
for (VirtualWorkingItemVO vw : config.getVirtualWorkings()) {
cost = cost.add(vw.getEquipmentDepreciationFee().multiply(getGsForWorkingType(dto, workHours, vw)));
cost = cost.add(BigDecimalUtil.multiply(vw.getEquipmentDepreciationFee(), getGsForWorkingType(dto, workHours, vw)));
}
return cost;
}
@ -255,7 +257,7 @@ public class BomCostCalculateService {
private BigDecimal calculateHydropowerCost(EBomDTO dto, BomCostCalculateConfig config, List<WorkingHourDTO> workHours) {
BigDecimal cost = BigDecimal.ZERO;
for (VirtualWorkingItemVO vw : config.getVirtualWorkings()) {
cost = cost.add(vw.getConsumablesFee().multiply(getGsForWorkingType(dto, workHours, vw)));
cost = cost.add(BigDecimalUtil.multiply(vw.getConsumablesFee(), getGsForWorkingType(dto, workHours, vw)));
}
return cost;
}
@ -294,8 +296,8 @@ public class BomCostCalculateService {
BigDecimal price = Optional.ofNullable(dto.getLastPurchasePrice()).orElse(BigDecimal.ZERO);
BigDecimal unitWeight = Optional.ofNullable(dto.getNum()).orElse(BigDecimal.ZERO);
BigDecimal wastage = BigDecimal.ZERO;
if (StrUtil.isNotBlank(dto.getGroupName())) {
SteelsCostConfigEntity steelsCostConfigEntity = steelsCostConfigService.getCost(dto.getGroupName());
if (StrUtil.isNotBlank(dto.getRawMaterialGroup())) {
SteelsCostConfigEntity steelsCostConfigEntity = steelsCostConfigService.getCost(dto.getRawMaterialGroup());
if (Objects.nonNull(steelsCostConfigEntity)) {
price = Optional.ofNullable(steelsCostConfigEntity.getCost()).orElse(BigDecimal.ZERO);
wastage = Optional.ofNullable(steelsCostConfigEntity.getWastage()).orElse(BigDecimal.ZERO);

View File

@ -63,6 +63,9 @@ public class EBomService {
}
public List<EBomParentEntity> getParents(Set<String> materialNos) {
if (CollectionUtil.isEmpty(materialNos)) {
return Collections.emptyList();
}
return ebomParentService.lambdaQuery()
.in(EBomParentEntity::getMaterialNo, materialNos)
.ge(EBomParentEntity::getStatus, 4)

View File

@ -39,7 +39,7 @@ public class PaintCostConfigService extends ServiceImpl<PaintCostConfigMapper, P
configs.forEach(c -> {
PaintCostConfigEntity entity = new PaintCostConfigEntity();
if (Objects.isNull(c.getId()) || 0 == c.getId()) {
entity.setName(c.getName());
entity.setCode(c.getCode());
entity.setCreateBy(SessionUtil.getRealName());
entity.setCreateTime(LocalDateTime.now());
forAdd.add(entity);
@ -49,6 +49,7 @@ public class PaintCostConfigService extends ServiceImpl<PaintCostConfigMapper, P
entity.setUpdateTime(LocalDateTime.now());
forUpdate.add(entity);
}
entity.setName(c.getName());
entity.setCost(c.getCost());
});
if (CollectionUtil.isNotEmpty(forAdd)) {
@ -59,10 +60,10 @@ public class PaintCostConfigService extends ServiceImpl<PaintCostConfigMapper, P
}
}
public PaintCostConfigEntity getCost(String name) {
if (StrUtil.isBlank(name)) {
public PaintCostConfigEntity getCost(String code) {
if (StrUtil.isBlank(code)) {
return null;
}
return lambdaQuery().eq(PaintCostConfigEntity::getName, name).one();
return lambdaQuery().eq(PaintCostConfigEntity::getCode, code).one();
}
}

View File

@ -76,6 +76,10 @@ public class ProductCostAnalysisService {
cvo.setMaterialRowId(cpm.getMaterialRowId());
cvo.setRelCategoryCode(cpm.getRelCategoryCode());
}
if (StrUtil.equals(child.getProjectType(), BomConstant.PROJECT_TYPE_TEMPORARY)) {
//T项
cvo.setMaterialDesc(child.getMaterialDesc());
}
EBomParentEntity parent = parents.stream().filter(p -> StrUtil.equals(p.getMaterialNo(), child.getMaterialNo())).findFirst().orElse(null);
cvo.setVersion(Objects.isNull(parent) ? "A00" : parent.getCurrentVersion());
EBomCostCacheDTO ccost = datas.stream().filter(d -> StrUtil.equals(d.getMaterialNo(), child.getMaterialNo())).findFirst().orElse(null);
@ -141,6 +145,10 @@ public class ProductCostAnalysisService {
cvo.setMaterialRowId(cpm.getMaterialRowId());
cvo.setRelCategoryCode(cpm.getRelCategoryCode());
}
if (StrUtil.equals(child.getProjectType(), BomConstant.PROJECT_TYPE_TEMPORARY)) {
//T项
cvo.setMaterialDesc(child.getMaterialDesc());
}
EBomCostCacheDTO ccost = datas.stream().filter(d -> StrUtil.equals(d.getMaterialNo(), child.getMaterialNo())).findFirst().orElse(null);
if (Objects.nonNull(ccost)) {
cvo.setPrice(ccost.getTotalCost());

View File

@ -1,6 +1,7 @@
package com.nflg.product.technology.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -38,7 +39,7 @@ public class SteelsCostConfigService extends ServiceImpl<SteelsCostConfigMapper,
configs.forEach(c -> {
SteelsCostConfigEntity entity = new SteelsCostConfigEntity();
if (Objects.isNull(c.getId()) || 0 == c.getId()) {
entity.setName(c.getName());
entity.setCode(c.getCode());
entity.setCreateBy(SessionUtil.getRealName());
entity.setCreateTime(LocalDateTime.now());
forAdd.add(entity);
@ -48,6 +49,7 @@ public class SteelsCostConfigService extends ServiceImpl<SteelsCostConfigMapper,
entity.setUpdateTime(LocalDateTime.now());
forUpdate.add(entity);
}
entity.setName(c.getName());
entity.setCost(c.getCost());
entity.setWastage(c.getWastage());
});
@ -59,7 +61,10 @@ public class SteelsCostConfigService extends ServiceImpl<SteelsCostConfigMapper,
}
}
public SteelsCostConfigEntity getCost(String name) {
return lambdaQuery().eq(SteelsCostConfigEntity::getName, name).one();
public SteelsCostConfigEntity getCost(String code) {
if (StrUtil.isBlank(code)) {
return null;
}
return lambdaQuery().eq(SteelsCostConfigEntity::getCode, code).one();
}
}

View File

@ -84,10 +84,9 @@
,CONVERT(m.material_weight, DECIMAL(12,4)) AS 'unitWeight',m.material_category_code AS
'materialCategoryCode',m.last_purchase_price AS 'lastPurchasePrice'
,c.rel_category_code AS 'relCategoryCode',c.category_name AS 'categoryName'
,g.group_name AS 'groupName',m.material_stock AS 'inventory',t.plan_delivery_time AS 'leadTime'
,m.raw_material_group AS 'rawMaterialGroup',m.material_stock AS 'inventory',t.plan_delivery_time AS 'leadTime'
from t_material_main m
LEFT JOIN t_material_category c on m.material_category_code=c.category_code
LEFT JOIN t_material_raw_material_group g ON m.raw_material_group=g.group_code
LEFT JOIN t_material_main_attr t ON m.material_no=t.material_no AND t.factory='1010'
where m.material_no in
<foreach collection="materialNos" item="item" open="(" close=")" separator=",">