yangys
2024-03-28 23a939ed820ee32f9a4309f9c81b7bab5a566f30
smart-man-boot/src/main/java/com/qianwen/smartman/modules/cps/service/impl/ProcessServiceImpl.java
@@ -1,25 +1,19 @@
package com.qianwen.smartman.modules.cps.service.impl;
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import java.lang.invoke.SerializedLambda;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.qianwen.smartman.common.cache.RegionCache;
import com.qianwen.smartman.common.constant.CommonConstant;
import com.qianwen.smartman.common.constant.ExcelConstant;
import com.qianwen.smartman.common.enums.StatusType;
import com.qianwen.smartman.common.utils.MessageUtils;
import com.qianwen.smartman.common.utils.ValidatorUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qianwen.core.excel.util.ExcelUtil;
import com.qianwen.core.log.exception.ServiceException;
import com.qianwen.core.mp.service.impl.BladeServiceImpl;
@@ -27,8 +21,14 @@
import com.qianwen.core.mp.support.Query;
import com.qianwen.core.oss.model.BladeFile;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.common.constant.CommonConstant;
import com.qianwen.smartman.common.constant.ExcelConstant;
import com.qianwen.smartman.common.enums.StatusType;
import com.qianwen.smartman.common.utils.MessageUtils;
import com.qianwen.smartman.common.utils.ValidatorUtils;
import com.qianwen.smartman.modules.cps.convert.ProcessConvert;
import com.qianwen.smartman.modules.cps.entity.Process;
import com.qianwen.smartman.modules.cps.entity.ProcessAssociation;
import com.qianwen.smartman.modules.cps.enums.WorkTypeEnum;
import com.qianwen.smartman.modules.cps.excel.ProcessExcel;
import com.qianwen.smartman.modules.cps.excel.ProcessImport;
@@ -44,12 +44,8 @@
import com.qianwen.smartman.modules.system.service.ICodeGeneratorService;
import com.qianwen.smartman.modules.system.service.IDictService;
import com.qianwen.smartman.modules.tpm.enums.MetaTypeEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@Service
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/cps/service/impl/ProcessServiceImpl.class */
public class ProcessServiceImpl extends BladeServiceImpl<ProcessMapper, Process> implements IProcessService {
    private static final Logger log = LoggerFactory.getLogger(ProcessServiceImpl.class);
    private final IProcessAssociationService processAssociationService;
@@ -58,136 +54,6 @@
    private final IDictService dictService;
    private final ICodeGeneratorService codeGeneratorService;
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case -1601031533:
                if (implMethodName.equals("getDictKey")) {
                    z = false;
                    break;
                }
                break;
            case -1104365260:
                if (implMethodName.equals("getProcessId")) {
                    z = true;
                    break;
                }
                break;
            case -982980443:
                if (implMethodName.equals("getDictValue")) {
                    z = true;
                    break;
                }
                break;
            case -75622813:
                if (implMethodName.equals("getCode")) {
                    z = true;
                    break;
                }
                break;
            case 98245393:
                if (implMethodName.equals("getId")) {
                    z = true;
                    break;
                }
                break;
            case 803533544:
                if (implMethodName.equals("getStatus")) {
                    z = true;
                    break;
                }
                break;
            case 1567138533:
                if (implMethodName.equals("getIsImport")) {
                    z = true;
                    break;
                }
                break;
        }
        switch (z) {
            case false:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dict") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getDictKey();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProcessAssociation") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getProcessId();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getStatus();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getStatus();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dict") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getDictValue();
                    };
                }
                break;
            case RegionCache.VILLAGE_LEVEL /* 5 */:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dict") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getCode();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/Process") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getCode();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/Process") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getCode();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/Process") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getIsImport();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
    public ProcessServiceImpl(final IProcessAssociationService processAssociationService, final OssBuilder ossBuilder, final ProcessMapper processMapper, final IDictService dictService, final ICodeGeneratorService codeGeneratorService) {
        this.processAssociationService = processAssociationService;
@@ -240,12 +106,14 @@
        if (StatusType.REMOVE.getType().equals(type)) {
            int count = this.baseMapper.existCraftProcess(processIds);
            ThrowFun.isTrue(count > 0).throwMessage(MessageUtils.message("cps.process.binding.craft", new Object[0]));
            this.processAssociationService.remove(Wrappers.<ProcessAssociation>query().lambda().in(Func.isNotEmpty(processIds), ProcessAssociation::getProcessId, processIds));
            /*
            this.processAssociationService.remove(Wrappers.query().lambda().in(Func.isNotEmpty(processIds), (v0) -> {
                return v0.getProcessId();
            }, processIds));
            remove(Wrappers.query().lambda().in(Func.isNotEmpty(processIds), (v0) -> {
                return v0.getId();
            }, processIds));
            */
            remove(Wrappers.<Process>query().lambda().in(Func.isNotEmpty(processIds), Process::getId, processIds));
            return true;
        }
        return Boolean.valueOf(changeStatus(processIds, CommonConstant.DEACTIVATE));
@@ -269,21 +137,24 @@
                }
            });
        }
        Set<String> codeDisableSet = (Set) processList.stream().filter(c -> {
        Set<String> codeDisableSet =  processList.stream().filter(c -> {
            return CommonConstant.DEACTIVATE.equals(c.getStatus());
        }).map((v0) -> {
            return v0.getCode();
        }).collect(Collectors.toSet());
        Map<String, String> dictMap = new HashMap<>(16);
        List<Dict> dictList = this.dictService.list(Wrappers.<Dict>lambdaQuery().select(Dict::getDictKey, Dict::getDictValue).eq(Dict::getCode, "work_type"));
        /*
        List<Dict> dictList = this.dictService.list((Wrapper) Wrappers.lambdaQuery().select(new SFunction[]{(v0) -> {
            return v0.getDictKey();
        }, (v0) -> {
            return v0.getDictValue();
        }}).eq((v0) -> {
            return v0.getCode();
        }, "work_type"));
        }, "work_type"));*/
        if (Func.isNotEmpty(dictList)) {
            dictMap = (Map) dictList.stream().collect(Collectors.toMap((v0) -> {
            dictMap = dictList.stream().collect(Collectors.toMap((v0) -> {
                return v0.getDictValue();
            }, (v0) -> {
                return v0.getDictKey();
@@ -297,9 +168,9 @@
            }
        }
        if (!flag) {
            MultipartFile multipartFile = ExcelUtil.exportFillTemplateToMultipartFile(ExcelConstant.DIRECTORY + "processFailTemplate" + ExcelConstant.SUFFIX, MessageUtils.message("excel.import.failed.report.name", new Object[0]) + ExcelConstant.SUFFIX, "工序信息表", (List) data.stream().filter(x2 -> {
            MultipartFile multipartFile = ExcelUtil.exportFillTemplateToMultipartFile(ExcelConstant.DIRECTORY + "processFailTemplate" + ExcelConstant.SUFFIX, MessageUtils.message("excel.import.failed.report.name", new Object[0]) + ExcelConstant.SUFFIX, "工序信息表", data.stream().filter(x2 -> {
                return Func.isNotEmpty(x2.getFailReason());
            }).collect(Collectors.toList()), (Object) null, (AbstractMergeStrategy) null);
            }).collect(Collectors.toList()),  null,  null);
            return this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile);
        }
        data.forEach(x3 -> {
@@ -316,6 +187,12 @@
    }
    private void checkProcess(ProcessSaveVO processSaveVO) {
       long count = count(Wrappers.<Process>lambdaQuery()
               .ne(Func.isNotEmpty(processSaveVO.getId()), Process::getId, processSaveVO.getId())
               .eq(Process::getCode, processSaveVO.getCode())
               .eq(Process::getStatus, CommonConstant.ENABLE));
       /*
        long count = count((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().ne(Func.isNotEmpty(processSaveVO.getId()), (v0) -> {
            return v0.getId();
        }, processSaveVO.getId()).eq((v0) -> {
@@ -323,16 +200,22 @@
        }, processSaveVO.getCode())).eq((v0) -> {
            return v0.getStatus();
        }, CommonConstant.ENABLE));
        */
        if (count > 0) {
            throw new ServiceException(MessageUtils.message("cps.process.code.already.exists", new Object[0]));
        }
        long countDisable = count(Wrappers.<Process>lambdaQuery()
                .ne(Func.isNotEmpty(processSaveVO.getId()), Process::getId, processSaveVO.getId())
                .eq(Process::getCode, processSaveVO.getCode())
                .eq(Process::getStatus, CommonConstant.ENABLE));
        /*
        long countDisable = count((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().ne(Func.isNotEmpty(processSaveVO.getId()), (v0) -> {
            return v0.getId();
        }, processSaveVO.getId()).eq((v0) -> {
            return v0.getCode();
        }, processSaveVO.getCode())).eq((v0) -> {
            return v0.getStatus();
        }, CommonConstant.ENABLE));
        }, CommonConstant.ENABLE));*/
        if (countDisable > 0) {
            throw new ServiceException(MessageUtils.message("cps.process.code.disable.already.exists", new Object[0]));
        }
@@ -342,11 +225,8 @@
    }
    private void checkImport(List<Long> ids) {
        Long count = Long.valueOf(count((Wrapper) Wrappers.query().lambda().in(Func.isNotEmpty(ids), (v0) -> {
            return v0.getId();
        }, ids).eq((v0) -> {
            return v0.getIsImport();
        }, 1)));
       Long count = Long.valueOf(count(Wrappers.<Process>query().lambda().in(Func.isNotEmpty(ids), Process::getId, ids).eq(Process::getIsImport, 1)));
        if (count.longValue() > 0) {
            throw new ServiceException(MessageUtils.message("cps.process.delete.failed", new Object[0]));
        }