cuijian
2025-06-16 e0529614c187a5457ca3f587a16edeec51d69d15
刀具寿命
已修改9个文件
129 ■■■■■ 文件已修改
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/OutStoreDetail.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/ToolLedgerDetail.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/dto/OutBoundAddDto.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/dto/OutBoundRequestDto.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/vo/OutStoreDetailVo.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/vo/OutboundDetailVo.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/mapper/xml/OutStoreDetailMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/InboundOrderServiceImpl.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/OutboundOrderServiceImpl.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/OutStoreDetail.java
@@ -84,4 +84,19 @@
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;
    /**额定寿命*/
    @Excel(name = "额定寿命", width = 15)
    @ApiModelProperty(value = "额定寿命")
    private BigDecimal ratedLife;
    /**使用寿命*/
    @Excel(name = "使用寿命", width = 15)
    @ApiModelProperty(value = "使用寿命")
    private BigDecimal useLife;
    /**剩余寿命*/
    @Excel(name = "剩余寿命", width = 15)
    @ApiModelProperty(value = "剩余寿命")
    private BigDecimal remainingPercentage;
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/ToolLedgerDetail.java
@@ -94,4 +94,19 @@
    @TableField(exist = false)
    @ApiModelProperty(value = "型号/图号")
    private String toolModel;
    /**额定寿命*/
    @Excel(name = "额定寿命", width = 15)
    @ApiModelProperty(value = "额定寿命")
    private BigDecimal ratedLife;
    /**使用寿命*/
    @Excel(name = "使用寿命", width = 15)
    @ApiModelProperty(value = "使用寿命")
    private BigDecimal useLife;
    /**剩余寿命*/
    @Excel(name = "剩余寿命", width = 15)
    @ApiModelProperty(value = "剩余寿命")
    private BigDecimal remainingPercentage;
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/dto/OutBoundAddDto.java
@@ -28,4 +28,12 @@
    //库位号
    @ApiModelProperty(value = "库位号")
    private String outboundLocation;
    //额定寿命
    @ApiModelProperty(value = "额定寿命")
    private BigDecimal ratedLife;
    //使用寿命
    @ApiModelProperty(value = "使用寿命")
    private BigDecimal useLife;
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/dto/OutBoundRequestDto.java
@@ -19,4 +19,17 @@
    //出库数量
    @ApiModelProperty(value = "出库数量")
    private BigDecimal outboundQuantity;
    //额定寿命
    @ApiModelProperty(value = "额定寿命")
    private BigDecimal ratedLife;
    //使用寿命
    @ApiModelProperty(value = "使用寿命")
    private BigDecimal useLife;
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/vo/OutStoreDetailVo.java
@@ -92,4 +92,19 @@
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    /**额定寿命*/
    @Excel(name = "额定寿命", width = 15)
    @ApiModelProperty(value = "额定寿命")
    private BigDecimal ratedLife;
    /**使用寿命*/
    @Excel(name = "使用寿命", width = 15)
    @ApiModelProperty(value = "使用寿命")
    private BigDecimal useLife;
    /**剩余寿命*/
    @Excel(name = "剩余寿命", width = 15)
    @ApiModelProperty(value = "剩余寿命")
    private BigDecimal remainingPercentage;
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/entity/vo/OutboundDetailVo.java
@@ -96,4 +96,7 @@
    /**工具刃磨表主键id*/
    @ApiModelProperty(value = "工具刃磨表主键id,选择刃磨工具时去重用")
    private String toolSharpeningId;
    @ApiModelProperty(value = "参数模板编号")
    private String paramaTableName;
}
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/mapper/xml/OutStoreDetailMapper.xml
@@ -18,6 +18,9 @@
            end operateType,
            t1.create_by createBy,
            t1.create_time createTime,
            t1.rated_life ratedLife,
            t1.use_life useLife,
            t1.remaining_percentage remainingPercentage,
            t2.chinese_name chineseName,
            t2.tool_model toolModel,
            t2.parama_table_name paramaTableName,
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/InboundOrderServiceImpl.java
@@ -278,6 +278,7 @@
                        toolLedgerDetail.setToolCode(inboundDetailVo.getToolCodeId());
                        toolLedgerDetail.setToolId(inboundDetailVo.getToolCode()+"-"+result);
                        toolLedgerDetail.setQuantity(BigDecimal.ONE);
                        toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE);
                        toolLedgerDetail.setStatus("1");
                        toolLedgerDetailService.save(toolLedgerDetail);
                        //更新当前编码
@@ -328,6 +329,7 @@
                            .eq(ToolLedgerDetail::getToolCode,inboundDetailVo.getToolCodeId())
                            .eq(ToolLedgerDetail::getToolId,inboundDetailVo.getOnlyCode()).one();
                    toolLedgerDetail.setQuantity(BigDecimal.ONE);
                    toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE);
                    toolLedgerDetail.setStatus("1");
                    toolLedgerDetailService.updateById(toolLedgerDetail);
                    //保存入库流水
@@ -377,6 +379,7 @@
                            .eq(ToolLedgerDetail::getToolCode,inboundDetailVo.getToolCodeId())
                            .eq(ToolLedgerDetail::getToolId,inboundDetailVo.getOnlyCode()).one();
                    toolLedgerDetail.setQuantity(BigDecimal.ONE);
                    toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE);
                    toolLedgerDetail.setStatus("1");
                    toolLedgerDetailService.updateById(toolLedgerDetail);
                    //保存入库流水
@@ -474,6 +477,7 @@
                        toolLedgerDetail.setToolCode(inboundDetailVo.getToolCodeId());
                        toolLedgerDetail.setToolId(inboundDetailVo.getToolCode()+"-"+result);
                        toolLedgerDetail.setQuantity(BigDecimal.ONE);
                        toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE);
                        toolLedgerDetail.setStatus("1");
                        toolLedgerDetailService.save(toolLedgerDetail);
                        //更新当前编码
@@ -530,6 +534,7 @@
                            .eq(ToolLedgerDetail::getToolCode,inboundDetailVo.getToolCodeId())
                            .eq(ToolLedgerDetail::getToolId,inboundDetailVo.getOnlyCode()).one();
                    toolLedgerDetail.setQuantity(BigDecimal.ONE);
                    toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE);
                    toolLedgerDetail.setStatus("1");
                    toolLedgerDetailService.updateById(toolLedgerDetail);
                    //保存入库流水
@@ -585,6 +590,7 @@
                            .eq(ToolLedgerDetail::getToolCode,inboundDetailVo.getToolCodeId())
                            .eq(ToolLedgerDetail::getToolId,inboundDetailVo.getOnlyCode()).one();
                    toolLedgerDetail.setQuantity(BigDecimal.ONE);
                    toolLedgerDetail.setRemainingPercentage(BigDecimal.ONE);
                    toolLedgerDetail.setStatus("1");
                    toolLedgerDetailService.updateById(toolLedgerDetail);
                    //保存入库流水
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/service/impl/OutboundOrderServiceImpl.java
@@ -8,6 +8,7 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
@@ -42,6 +43,7 @@
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@@ -383,6 +385,10 @@
        Map<String, BigDecimal> outBoundRequestMap = outBoundRequestList.stream()
                .collect(Collectors.toMap(OutBoundRequestDto::getOutboundDetailId, OutBoundRequestDto::getOutboundQuantity));
        Map<String, BigDecimal> ratedLifeMap = outBoundRequestList.stream()
                .collect(Collectors.toMap(OutBoundRequestDto::getOutboundDetailId, dto->dto.getRatedLife() != null ? dto.getRatedLife() : null));
        Map<String, BigDecimal> useLifeMap = outBoundRequestList.stream()
                .collect(Collectors.toMap(OutBoundRequestDto::getOutboundDetailId, dto->dto.getUseLife() != null ? dto.getUseLife() : null));
        //处理库存台账及台账明细
        Map<String, ToolLedger> toolLedgerMap = toolLedgerService.list(new LambdaQueryWrapper<ToolLedger>().in(ToolLedger::getToolId, toolIdList)).stream()
                .collect(Collectors.toMap(ToolLedger::getToolId, item -> item, (k1, k2) -> k1));
@@ -418,6 +424,14 @@
            //更新库存台账
            ToolLedger toolLedger = toolLedgerMap.get(detail.getToolCode());
            BigDecimal outboundQuantity = outBoundRequestMap.get(detail.getId());
            BigDecimal ratedLife = ratedLifeMap.get(detail.getId());
            BigDecimal useLife = useLifeMap.get(detail.getId());
            //唯一编码不为空时(管到把),计算剩余寿命
            BigDecimal remandLife = null;
            if(StringUtils.isNotBlank(detail.getToolId())){
                ToolLedgerDetail toolLedgerDetail = toolLedgerDetailService.lambdaQuery().eq(ToolLedgerDetail::getToolId,detail.getToolId()).one();
                remandLife = (ratedLife.multiply(toolLedgerDetail.getRemainingPercentage()).subtract(useLife).max(BigDecimal.ZERO)).divide(ratedLife, 4, RoundingMode.HALF_UP);
            }
            OutStorehouseType outStorehouseType = OutStorehouseType.getByValue(outboundOrder.getOutStorehouseType());
            switch (outStorehouseType) {
                case TOOL_BORROW:
@@ -438,20 +452,33 @@
            toolLedgerUpdateList.add(toolLedger);
            //更新台账明细
            BigDecimal finalRemandLife = remandLife;
            toolLedgerDetailList.stream().filter(item -> item.getToolCode().equals(detail.getToolCode()) && item.getToolId().equals(detail.getToolId()))
                    .findFirst().ifPresent(item -> {
                        switch (outStorehouseType) {
                            case TOOL_BORROW:
                                item.setStatus(ToolCirculationStatus.BORROWED.getValue());
                                item.setRatedLife(ratedLife);
                                item.setUseLife(useLife);
                                item.setRemainingPercentage(finalRemandLife);
                                break;
                            case MAINTENANCE_OUTBOUND:
                                item.setStatus(ToolCirculationStatus.REPAIRING.getValue());
                                item.setRatedLife(ratedLife);
                                item.setUseLife(useLife);
                                item.setRemainingPercentage(finalRemandLife);
                                break;
                            case CALIBRATION_OUTBOUND:
                                item.setStatus(ToolCirculationStatus.INSPECTING.getValue());
                                item.setRatedLife(ratedLife);
                                item.setUseLife(useLife);
                                item.setRemainingPercentage(finalRemandLife);
                                break;
                            case GRINDING_OUTBOUND:
                                item.setStatus(ToolCirculationStatus.GRINDING.getValue());
                                item.setRatedLife(ratedLife);
                                item.setUseLife(useLife);
                                item.setRemainingPercentage(finalRemandLife);
                                break;
                            default:
                                throw new JeecgBootException("未知的出库类型!");
@@ -476,6 +503,9 @@
                    .setGoodsShelvesCode(detail.getOutboundLocation())
                    .setOutNumber(outboundQuantity)
                    .setOutStorehouseId(outboundOrder.getId())
                    .setRatedLife(ratedLife)
                    .setUseLife(useLife)
                    .setRemainingPercentage(remandLife)
                    .setOperateType("1");//1:按申请单
            outStoreAddList.add(outStoreDetail);
@@ -562,6 +592,8 @@
        for (String toolLedgerDetailId : boundAddDtoMap.keySet()) {
            OutBoundAddDto outBoundAddDto = boundAddDtoMap.get(toolLedgerDetailId);
            BigDecimal outboundQuantity = outBoundAddDto.getOutboundQuantity();
            BigDecimal ratedLife = outBoundAddDto.getRatedLife();
            BigDecimal useLife = outBoundAddDto.getUseLife();
            ToolLedgerDetail toolLedgerDetail = toolLedgerDetailMap.get(toolLedgerDetailId);
            if (Objects.isNull(toolLedgerDetail) || toolLedgerDetail.getQuantity().compareTo(outboundQuantity) < 0) {
                BaseTools tools = baseToolsService.getById(outBoundAddDto.getToolCode());
@@ -573,20 +605,34 @@
                    toolLedgerDetail.setQuantity(toolLedgerDetail.getQuantity().subtract(outboundQuantity));
                } else {
                    //有唯一编码,管道把的
                    //计算剩余寿命
                    BigDecimal remandLife = (ratedLife.multiply(toolLedgerDetail.getRemainingPercentage()).subtract(useLife).max(BigDecimal.ZERO)).divide(ratedLife, 4, RoundingMode.HALF_UP);
                    toolLedgerDetail.setQuantity(BigDecimal.ZERO);//数量只会是0和1
                    OutStorehouseType outStorehouseType = OutStorehouseType.getByValue(boundAddList.get(0).getOutStorehouseType());
                    switch (outStorehouseType) {
                        case TOOL_BORROW:
                            toolLedgerDetail.setStatus(ToolCirculationStatus.BORROWED.getValue());
                            toolLedgerDetail.setRatedLife(ratedLife);
                            toolLedgerDetail.setUseLife(useLife);
                            toolLedgerDetail.setRemainingPercentage(remandLife);
                            break;
                        case MAINTENANCE_OUTBOUND:
                            toolLedgerDetail.setStatus(ToolCirculationStatus.REPAIRING.getValue());
                            toolLedgerDetail.setRatedLife(ratedLife);
                            toolLedgerDetail.setUseLife(useLife);
                            toolLedgerDetail.setRemainingPercentage(remandLife);
                            break;
                        case CALIBRATION_OUTBOUND:
                            toolLedgerDetail.setStatus(ToolCirculationStatus.INSPECTING.getValue());
                            toolLedgerDetail.setRatedLife(ratedLife);
                            toolLedgerDetail.setUseLife(useLife);
                            toolLedgerDetail.setRemainingPercentage(remandLife);
                            break;
                        case GRINDING_OUTBOUND:
                            toolLedgerDetail.setStatus(ToolCirculationStatus.GRINDING.getValue());
                            toolLedgerDetail.setRatedLife(ratedLife);
                            toolLedgerDetail.setUseLife(useLife);
                            toolLedgerDetail.setRemainingPercentage(remandLife);
                            //同时更新刃磨单状态
                            toolSharpeningList.stream().filter(item -> item.getToolCode().equals(outBoundAddDto.getToolCode())
                                    && item.getToolId().equals(outBoundAddDto.getToolId())).findFirst().ifPresent(item -> {
@@ -607,12 +653,17 @@
        //记录出库流水
        List<OutStoreDetail> outStoreAddList = CollectionUtil.newArrayList();
        for (OutBoundAddDto outBoundAddDto : boundAddList) {
            //获取剩余寿命
            ToolLedgerDetail toolLedgerDetail = toolLedgerDetailService.getById(outBoundAddDto.getToolLedgerDetailId());
            OutStoreDetail outStoreDetail = new OutStoreDetail()
                    .setToolCode(outBoundAddDto.getToolCode())
                    .setToolId(outBoundAddDto.getToolId())
                    .setOutStorehouseType(outBoundAddDto.getOutStorehouseType())
                    .setGoodsShelvesCode(outBoundAddDto.getOutboundLocation())
                    .setOutNumber(outBoundAddDto.getOutboundQuantity())
                    .setRatedLife(outBoundAddDto.getRatedLife())
                    .setUseLife(outBoundAddDto.getUseLife())
                    .setRemainingPercentage(toolLedgerDetail.getRemainingPercentage())
                    .setOperateType("2");//2:手工操作
            outStoreAddList.add(outStoreDetail);
        }