zss
6 天以前 2bbd50fb56275986e2a8658c373686d56804b99b
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java
@@ -18,8 +18,9 @@
import com.ruoyi.basic.dto.*;
import com.ruoyi.basic.pojo.IfsInventoryQuantity;
import com.ruoyi.common.constant.InsOrderTypeConstants;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.core.domain.entity.User;
import com.ruoyi.common.properties.WechatProperty;
import com.ruoyi.common.config.WechatProperty;
import com.ruoyi.common.utils.LimsDateUtil;
import com.ruoyi.common.utils.QueryWrappers;
import com.ruoyi.common.utils.SecurityUtils;
@@ -57,7 +58,6 @@
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
 * @Author zhuo
@@ -75,48 +75,30 @@
    private InsSampleMapper insSampleMapper;
    private final NumberGenerator<InsOrder> numberGenerator;
    private InsReportService insReportService;
    private WechatProperty wechatProperty;
//    private WechatProperty wechatProperty;
    private ThreadPoolTaskExecutor threadPoolTaskExecutor;
    private InsProductMapper insProductMapper;
    private AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper;
    @Override
    public RawMaterialStandardTreeDto selectStandardTreeListByPartNo(String partNo) {
        if (StringUtils.isBlank(partNo)) {
            throw new ErrorException("零件号丢失");
        }
    public Result selectStandardTreeListByPartNo(String partNo) {
        List<FactoryDto> factoryDtos = standardTreeMapper.selectStandardTreeListByPartNo(partNo);
        if (CollectionUtil.isEmpty(factoryDtos)) {
            throw new ErrorException("零件号为" + partNo + "的原材料没有对应的标准库配置");
            return Result.success(null, "零件号为" + partNo + "的原材料没有对应的标准库配置");
        }
        RawMaterialStandardTreeDto rawMaterialStandardTreeDto = new RawMaterialStandardTreeDto();
        Set<String> sampleTypeValues = new HashSet<>();
        for (FactoryDto factoryDto : factoryDtos) {
            for (LaboratoryDto laboratoryDto : factoryDto.getChildren()) {
                for (SampleTypeDto sampleTypeDto : laboratoryDto.getChildren()) {
                    if (sampleTypeDto.getChildren().size() == 0) {
                        sampleTypeValues.add(sampleTypeDto.getValue());
                    }
                }
            }
        }
        // 批量查询所有 sampleTypeDto 的数据
        List<SampleDto> standardList = standardTreeMapper.getStandardTree3Batch(sampleTypeValues);
        Map<String, List<SampleDto>> standardTreeMap = standardList.stream().collect(Collectors.groupingBy(SampleDto::getValue));
        for (FactoryDto factoryDto : factoryDtos) {
            for (LaboratoryDto laboratoryDto : factoryDto.getChildren()) {
                for (SampleTypeDto sampleTypeDto : laboratoryDto.getChildren()) {
                    List<SampleDto> standardTreeList = standardTreeMap.get(sampleTypeDto.getValue());
                    if (sampleTypeDto.getChildren().size() == 0) {
                        sampleTypeDto.getChildren().addAll(standardTreeList);
                        sampleTypeDto.setChildren(standardTreeMapper.getStandardTree3(sampleTypeDto.getValue()));
                    }
                    // 判断绑定的是否是当前零件号
                    if (sampleTypeDto.getPartNo() != null && sampleTypeDto.getPartNo().equals(partNo)) {
                        // 添加对象
                        rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + "-"
                                + laboratoryDto.getValue() + "-"
                        rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + " - "
                                + laboratoryDto.getValue() + " - "
                                + sampleTypeDto.getValue());
                        rawMaterialStandardTreeDto.setCode(sampleTypeDto.getCode());
                        rawMaterialStandardTreeDto.setLabel(sampleTypeDto.getLabel());
@@ -126,9 +108,9 @@
                        for (SampleDto sampleDto : sampleTypeDto.getChildren()) {
                            if (sampleDto.getPartNo() != null && sampleDto.getPartNo().equals(partNo)) {
                                // 添加对象
                                rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + "-"
                                        + laboratoryDto.getValue() + "-"
                                        + sampleTypeDto.getValue() + "-"
                                rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + " - "
                                        + laboratoryDto.getValue() + " - "
                                        + sampleTypeDto.getValue() + " - "
                                        + sampleDto.getValue());
                                rawMaterialStandardTreeDto.setCode(sampleDto.getCode());
                                rawMaterialStandardTreeDto.setLabel(sampleDto.getLabel());
@@ -140,7 +122,7 @@
                }
            }
        }
        return rawMaterialStandardTreeDto;
        return Result.success(rawMaterialStandardTreeDto);
    }
    @Override
@@ -169,31 +151,31 @@
                .set(IfsInventoryQuantity::getIsInspect, 1)
                .set(IfsInventoryQuantity::getDeclareDate, LocalDateTime.now())
        );
        threadPoolTaskExecutor.execute(() -> {
            List<IfsInventoryQuantity> quantityList = ifsInventoryQuantityMapper.selectList(Wrappers.<IfsInventoryQuantity>lambdaQuery()
                    .in(IfsInventoryQuantity::getId, ids));
            // 企业微信通知
            String message = "";
            message += "新增报检通知";
            for (IfsInventoryQuantity inventoryQuantity : quantityList) {
                message += "\n批次号: " + inventoryQuantity.getUpdateBatchNo();
                message += "\n零件描述: " + inventoryQuantity.getPartDesc();
                message += "\n抵达数量: " + inventoryQuantity.getQtyArrived().stripTrailingZeros().toPlainString() + inventoryQuantity.getBuyUnitMeas();
                // 判断有没有到20吨. 或者能否免检
                int result = notificationRawOrder(inventoryQuantity.getId());
                switch (result) {
                    case 1:
                        message += "\n当前样品已检验过, 可以免检";
                        break;
                    case 2:
                        message += "\n当前样品已超过20吨";
                        break;
                }
                message += "\n";
            }
            WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message);
        });
//        threadPoolTaskExecutor.execute(() -> {
//            List<IfsInventoryQuantity> quantityList = ifsInventoryQuantityMapper.selectList(Wrappers.<IfsInventoryQuantity>lambdaQuery()
//                    .in(IfsInventoryQuantity::getId, ids));
//            // 企业微信通知
//            String message = "";
//            message += "新增报检通知";
//            for (IfsInventoryQuantity inventoryQuantity : quantityList) {
//                message += "\n批次号: " + inventoryQuantity.getUpdateBatchNo();
//                message += "\n零件描述: " + inventoryQuantity.getPartDesc();
//                message += "\n抵达数量: " + inventoryQuantity.getQtyArrived().stripTrailingZeros().toPlainString() + inventoryQuantity.getBuyUnitMeas();
//
//                // 判断有没有到20吨. 或者能否免检
//                int result = notificationRawOrder(inventoryQuantity.getId());
//                switch (result) {
//                    case 1:
//                        message += "\n当前样品已检验过, 可以免检";
//                        break;
//                    case 2:
//                        message += "\n当前样品已超过20吨";
//                        break;
//                }
//                message += "\n";
//            }
//            WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message);
//        });
        return 1;
    }
@@ -237,16 +219,16 @@
                .set(IfsInventoryQuantity::getUpdateBatchNo, ifsInventoryQuantity.getUpdateBatchNo())
        );
        threadPoolTaskExecutor.execute(() -> {
            IfsInventoryQuantity inventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryQuantity.getId());
            // 企业微信通知
            String message = "";
            message += "新增报检通知";
            message += "\n批次号: " + inventoryQuantity.getUpdateBatchNo();
            message += "\n零件描述: " + inventoryQuantity.getPartDesc();
            message += "\n抵达数量: " + inventoryQuantity.getQtyArrived().stripTrailingZeros().toPlainString() + inventoryQuantity.getBuyUnitMeas();
            WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message);
        });
//        threadPoolTaskExecutor.execute(() -> {
//            IfsInventoryQuantity inventoryQuantity = ifsInventoryQuantityMapper.selectById(ifsInventoryQuantity.getId());
//            // 企业微信通知
//            String message = "";
//            message += "新增报检通知";
//            message += "\n批次号: " + inventoryQuantity.getUpdateBatchNo();
//            message += "\n零件描述: " + inventoryQuantity.getPartDesc();
//            message += "\n抵达数量: " + inventoryQuantity.getQtyArrived().stripTrailingZeros().toPlainString() + inventoryQuantity.getBuyUnitMeas();
//            WxCpUtils.informWebHook(wechatProperty.getExaminingUrl(), message);
//        });
        return 1;
    }
@@ -691,12 +673,19 @@
     */
    @Override
    public void rawAllExport(IfsInventoryQuantitySupplierDto ifsInventoryQuantityDto, HttpServletResponse response) throws UnsupportedEncodingException {
        //查询导出的费用统计数据
        String beginDeclareDate = ifsInventoryQuantityDto.getBeginDeclareDate();
        String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate();
        ifsInventoryQuantityDto.setBeginDeclareDate(null);
        ifsInventoryQuantityDto.setEndDeclareDate(null);
        List<IfsInventoryQuantitySupplierDto> ifsByOverList = standardTreeMapper.getIfsByOverList(QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate);
        // 判断是否是根据选择的导出
        List<IfsInventoryQuantitySupplierDto> ifsByOverList = new ArrayList<>();
        if (StringUtils.isNotBlank(ifsInventoryQuantityDto.getIds())) {
            List<String> ifsIds = StrUtil.split(ifsInventoryQuantityDto.getIds(), ",");
            ifsByOverList = standardTreeMapper.getIfsByIds(ifsIds);
        } else {
            String beginDeclareDate = ifsInventoryQuantityDto.getBeginDeclareDate();
            String endDeclareDate = ifsInventoryQuantityDto.getEndDeclareDate();
            ifsInventoryQuantityDto.setBeginDeclareDate(null);
            ifsInventoryQuantityDto.setEndDeclareDate(null);
            ifsInventoryQuantityDto.setIds(null);
            ifsByOverList = standardTreeMapper.getIfsByOverList(QueryWrappers.queryWrappers(ifsInventoryQuantityDto), beginDeclareDate, endDeclareDate);
        }
        for (IfsInventoryQuantitySupplierDto dto : ifsByOverList) {
            dto.setSendTimeString(dto.getSendTime() == null ? "" : dto.getSendTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));