TemplateConfigurationServiceImpl.java 27 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
package com.lhcredit.project.business.templateConfiguration.service;

import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;


import com.lhcredit.common.exception.BusinessException;
import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.common.utils.security.ShiroUtils;
import com.lhcredit.project.business.contractBusinessType.domain.ContractBusinessType;
import com.lhcredit.project.business.contractBusinessType.service.IContractBusinessTypeService;
import com.lhcredit.project.business.contractReportBusinessType.domain.ContractReportBusinessType;
import com.lhcredit.project.business.contractReportBusinessType.service.IContractReportBusinessTypeService;
import com.lhcredit.project.business.customTemplate.domain.CustomTemplate;
import com.lhcredit.project.business.customTemplate.service.ICustomTemplateService;
import com.lhcredit.project.business.frontDept.domain.FrontDept;
import com.lhcredit.project.business.frontDept.service.IFrontDeptService;
import com.lhcredit.project.business.templateConfiguration.domain.TypeIdAndName;
import com.lhcredit.project.business.templateConfigurationParameters.domain.TemplateConfigurationParameters;
import com.lhcredit.project.business.templateConfigurationParameters.mapper.TemplateConfigurationParametersMapper;
import com.lhcredit.project.system.dict.domain.DictData;
import com.lhcredit.project.system.dict.service.IDictDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.lhcredit.project.business.templateConfiguration.mapper.TemplateConfigurationMapper;
import com.lhcredit.project.business.templateConfiguration.domain.TemplateConfiguration;
import com.lhcredit.common.utils.text.Convert;

import javax.annotation.Resource;

/**
 * 模版配置 服务层实现
 *
 * @author lhcredit
 * @date 2025-04-01
 */
@Service
@Slf4j
public class TemplateConfigurationServiceImpl implements ITemplateConfigurationService {
    @Resource
    private TemplateConfigurationMapper templateConfigurationMapper;

    @Resource
    private TemplateConfigurationParametersMapper templateConfigurationParametersMapper;

    @Resource
    private IFrontDeptService frontDeptService;

    @Resource
    private ICustomTemplateService customTemplateService;

    @Resource
    private IDictDataService dictDataService;

    @Resource
    private IContractBusinessTypeService contractBusinessTypeService;

    @Resource
    private IContractReportBusinessTypeService contractReportBusinessTypeService;

    /**
     * 查询模版配置信息
     *
     * @param id 模版配置ID
     * @return 模版配置信息
     */
    @Override
    public TemplateConfiguration selectTemplateConfigurationById(Long id) {
        return templateConfigurationMapper.selectTemplateConfigurationById(id);
    }

    /**
     * 查询模版配置列表
     *
     * @param templateConfiguration 模版配置信息
     * @return 模版配置集合
     */
    @Override
    public List<TemplateConfiguration> selectTemplateConfigurationList(TemplateConfiguration templateConfiguration) {
        return templateConfigurationMapper.selectTemplateConfigurationList(templateConfiguration);
    }

    /**
     * 字段转换
     *
     * @param templateConfiguration 模版配置信息
     * @return 模版配置信息
     */
    @Override
    public TemplateConfiguration changeModel(TemplateConfiguration templateConfiguration) {
//        //这里写各字段转换逻辑
//        if(templateConfiguration!=null){
//            if(StringUtils.isNotEmpty(templateConfiguration.getXXX())){
//               templateConfiguration.setXXX(templateConfiguration.getXXX());
//            }
//        }
        return templateConfiguration;
    }

    /**
     * 列表转换
     *
     * @param templateConfigurationList 模版配置集合
     * @return 模版配置集合
     */
    @Override
    public List<TemplateConfiguration> changeModel(List<TemplateConfiguration> templateConfigurationList) {
        List<TemplateConfiguration> result = new ArrayList<TemplateConfiguration>();
        if (templateConfigurationList.size() > 0) {
            for (TemplateConfiguration templateConfiguration : templateConfigurationList) {
                result.add(changeModel(templateConfiguration));
            }
        }
        return result;
    }

    /**
     * 新增模版配置
     *
     * @param templateConfiguration 模版配置信息
     * @return 结果
     */
    @Override
    public int insertTemplateConfiguration(TemplateConfiguration templateConfiguration) {
        TemplateConfiguration orgenTemplateConfiguration = templateConfigurationMapper.getTemppConfByOrg(templateConfiguration.getOrgId());
        if (orgenTemplateConfiguration != null) {
            return 1;
        }
        templateConfiguration.setCreateBy(ShiroUtils.getLoginName());
        templateConfiguration.setCreateTime(new Date());
        templateConfiguration.setUpdateBy(ShiroUtils.getLoginName());
        templateConfiguration.setUpdateTime(new Date());
        int result = templateConfigurationMapper.insertTemplateConfiguration(templateConfiguration);
        if (result > 0) {
            //新增模版配置参数
            if (templateConfiguration.getParams() != null) {
                getTemplateConfigurationParameters(templateConfiguration);
            }
        }
        return result;
    }

    private void getTemplateConfigurationParameters(TemplateConfiguration templateConfiguration) {
        List<TemplateConfigurationParameters> templateConfigurationParameters = templateConfiguration.getTemplateConfigurationParameters();
        templateConfigurationParameters.forEach(item -> {

            // 设置除了翻译的价格
            if (StringUtils.isEmpty(item.getReportTranslationType()) || item.getReportTranslationType().isEmpty() || item.getReportTranslationType().equals("NO")) {
                templateConfigurationParameters.forEach(item1 -> {

                    // 找出除了定制报告,并且为翻译的价格
                    if (item.getTypeId() == item1.getTypeId() && item.getTypeId() != -11L
                            && StringUtils.isNotEmpty(item1.getReportTranslationType())
                            && !item1.getReportTranslationType().isEmpty()
                            && !item1.getReportTranslationType().equals("NO")
                    ) {
                        if (StringUtils.isNotEmpty(item.getTypePrice())) {
                            item.setPrice(item.getTypePrice().add(item1.getReportPrice()));
                        }
                    }

                    if (item.getTypeId() == item1.getTypeId() && item.getTypeId() != -11L
                            && StringUtils.isNotEmpty(item1.getReportTranslationType())
                            && !item1.getReportTranslationType().isEmpty()
                            && item1.getReportTranslationType().equals("NO")
                    ) {
                        if (StringUtils.isNotEmpty(item.getTypePrice())) {
                            item.setPrice(item.getTypePrice());
                        }
                    }

                    // 找出定制报告,并且模版id想对应,并且为翻译的价格
                    if (item.getTypeId() == item1.getTypeId() && item.getTypeId() == -11L
                            && StringUtils.isNotEmpty(item1.getReportTranslationType())
                            && !item1.getReportTranslationType().isEmpty()
                            && !item1.getReportTranslationType().equals("NO")
                            && item.getClientId() == item1.getClientId()
                    ) {
                        if (StringUtils.isNotEmpty(item.getTypePrice())) {
                            item.setPrice(item.getTypePrice().add(item1.getReportPrice()));
                        }
                    }

                    // 找出定制报告,并且模版id想对应,并且为翻译的价格
                    if (Objects.equals(item.getTypeId(), item1.getTypeId()) && item.getTypeId() == -11L
                            && StringUtils.isNotEmpty(item1.getReportTranslationType())
                            && !item1.getReportTranslationType().isEmpty()
                            && item1.getReportTranslationType().equals("NO")
                            && Objects.equals(item.getClientId(), item1.getClientId())
                    ) {
                        if (StringUtils.isNotEmpty(item.getTypePrice())) {
                            item.setPrice(item.getTypePrice());
                        }
                    }

                });
            }

            // 更新其他字段
            item.setTemplateId(templateConfiguration.getId());
            item.setOrgId(templateConfiguration.getOrgId());
            item.setCreateBy(ShiroUtils.getLoginName());
            item.setCreateTime(new Date());
            item.setUpdateBy(ShiroUtils.getLoginName());
            item.setUpdateTime(new Date());
            if (StringUtils.isNotEmpty(item.getClientType()) && item.getTypeId() != -11) {
                item.setId(item.getOrgId() + "-" + item.getTypeId() + "-" + item.getClientType());
            } else if (item.getTypeId() == (long) -11 && StringUtils.isNotEmpty(item.getClientType())) {
                item.setId(item.getOrgId() + "-" + item.getTypeId() + "-" + item.getClientType() + "-" + item.getClientId());
            } else if (item.getTypeId() == (long) -11 && StringUtils.isEmpty(item.getClientType())) {
                item.setId(item.getOrgId() + "-" + item.getTypeId() + "-" + item.getClientId());
            } else {
                item.setId(item.getOrgId() + "-" + item.getTypeId());
            }

            item.setStatus(0);

            // 插入到数据库
            templateConfigurationParametersMapper.insertTemplateConfigurationParameters(item);
        });
    }

    /*if (StringUtils.isNotEmpty(item.getReportTranslationType()) && !item.getReportTranslationType().isEmpty() && !item.getReportTranslationType().equals("NO")) {
        templateConfigurationParameters.forEach(item1 -> {
            if (item.getTypeId() == item1.getTypeId()) {
                item1.setReportPrice(item.getReportPrice());
                if (StringUtils.isNotEmpty(item1.getTypePrice())) {
                    item1.setPrice(item.getReportPrice().add(item1.getTypePrice()));
                }
            });
        BigDecimal reportPrice = Optional.ofNullable(item1.getReportPrice()).orElse(BigDecimal.ZERO);
        BigDecimal typePrice = Optional.ofNullable(item1.getTypePrice()).orElse(BigDecimal.ZERO);
        item1.setPrice(reportPrice.add(typePrice));
        item1.setTemplateId(templateConfiguration.getId());
        item1.setOrgId(templateConfiguration.getOrgId());
        item1.setCreateBy(ShiroUtils.getLoginName());
        item1.setCreateTime(new Date());
        item1.setUpdateBy(ShiroUtils.getLoginName());
        item1.setUpdateTime(new Date());
        templateConfigurationParametersMapper.insertTemplateConfigurationParameters(item1);
    });


}



/**
 * 修改模版配置
 *
 * @param templateConfiguration 模版配置信息
 * @return 结果
 */
    @Override
    public int updateTemplateConfiguration(TemplateConfiguration templateConfiguration) {
        templateConfiguration.setUpdateBy(ShiroUtils.getLoginName());
        templateConfiguration.setUpdateTime(new Date());
        Integer result = templateConfigurationMapper.updateTemplateConfiguration(templateConfiguration);
        if (result > 0) {
            templateConfigurationParametersMapper.deleteTemplateConfigurationParametersByOrgId(templateConfiguration.getOrgId());
            getTemplateConfigurationParameters(templateConfiguration);
        }
        return result;
    }

    /**
     * g根据orgId查询
     *
     * @param orgId
     * @return
     */
    @Override
    public TemplateConfiguration getTemppConfByOrg(Long orgId) {
        TemplateConfiguration templateConfiguration = templateConfigurationMapper.getTemppConfByOrg(orgId);
        return templateConfiguration;
    }

    @Override
    public TemplateConfiguration getTemppConfByOrg1(Long orgId) {
        TemplateConfiguration templateConfiguration = templateConfigurationMapper.getTemppConfByOrg(orgId);
        if (templateConfiguration != null) {
            //通过用户id获取部门信息
            FrontDept frontDept = frontDeptService.selectFrontDeptById(Long.valueOf(orgId));
            List<DictData> dictData = dictDataService.selectDictDataByType("background_report_type");
            String types = templateConfiguration.getTypeId();
            String[] typeIds = types.split(",");
            List<TypeIdAndName> typeIdAndNames = new ArrayList<>();
            for (String typeId : typeIds) {
                dictData.forEach(item -> {
                    if (item.getDictValue().equals(typeId)) {
                        TypeIdAndName typeIdAnd = new TypeIdAndName();
                        typeIdAnd.setTypeId(item.getDictValue());
                        typeIdAnd.setTypeName(item.getDictLabel());
                        typeIdAndNames.add(typeIdAnd);
                    }
                });
            }
            templateConfiguration.setTypeIdAndNames(typeIdAndNames);
            List<CustomTemplate> customReportType = customTemplateService.getByOrgId(Math.toIntExact(orgId));
            String clientId = templateConfiguration.getClientId();
            String[] clientIds = StringUtils.isNotEmpty(clientId) ? clientId.split(",") : new String[]{};
            List<CustomTemplate> customTemplates = new ArrayList<>();
            for (String clientId1 : clientIds) {
                customReportType.forEach(item -> {
                    if (clientId1.equals(item.getId().toString())) {
                        CustomTemplate item1 = new CustomTemplate();
                        item1.setId(item.getId());
                        item1.setTName(item.getTName());
                        customTemplates.add(item1);
                    }
                });
            }
            templateConfiguration.setCustomTemplates(customTemplates);
            templateConfiguration.setDeptName(frontDept.getDeptName());
            TemplateConfigurationParameters templateConfigurationParameters = new TemplateConfigurationParameters();
            templateConfigurationParameters.setTemplateId(templateConfiguration.getId());
            List<TemplateConfigurationParameters> templateConfigurationParametersList = templateConfigurationParametersMapper.selectTemplateConfigurationParametersList(templateConfigurationParameters);

            templateConfiguration.setTemplateConfigurationParameters(templateConfigurationParametersList);
        }
        return templateConfiguration;
    }

//    @Override
//    @Async
//    public int task() {
//        try {
//            // 并行获取数据
//            CompletableFuture<List<ContractBusinessType>> contractBusinessTypesFuture = CompletableFuture.supplyAsync(() -> contractBusinessTypeService.selectContractBusinessTypeList(new ContractBusinessType()));
//            CompletableFuture<List<ContractReportBusinessType>> contractReportBusinessTypeListFuture = CompletableFuture.supplyAsync(() -> contractReportBusinessTypeService.selectContractReportBusinessTypeList(new ContractReportBusinessType()));
//            CompletableFuture<List<FrontDept>> frontDeptFuture = CompletableFuture.supplyAsync(() -> frontDeptService.selectFrontDeptList(new FrontDept()));
//            CompletableFuture<Map<String, String>> backgroundReportTypeFuture = CompletableFuture.supplyAsync(() -> dictDataService.selectDictDataByType("background_report_type").stream().collect(Collectors.toMap(DictData::getDictValue, DictData::getDictLabel, (key1, key2) -> key1)));
//
//            // 等待所有异步任务完成
//            CompletableFuture.allOf(contractBusinessTypesFuture, contractReportBusinessTypeListFuture, frontDeptFuture, backgroundReportTypeFuture).join();
//
//            List<ContractBusinessType> contractBusinessTypes = contractBusinessTypesFuture.get();
//            List<ContractReportBusinessType> contractReportBusinessTypeList = contractReportBusinessTypeListFuture.get();
//            List<FrontDept> frontDept = frontDeptFuture.get();
//            Map<String, String> backgroundReportType = backgroundReportTypeFuture.get();
//
//            // 并行处理每个 frontDept
//            frontDept.parallelStream().forEach(item -> {
//                processFrontDept(item, contractBusinessTypes, contractReportBusinessTypeList, backgroundReportType);
//            });
//
//        } catch (Exception e) {
//            log.error("Error occurred during task execution", e);
//            return 0;
//        }
//        return 1;
//    }

    private void processFrontDept(FrontDept item, List<ContractBusinessType> contractBusinessTypes, List<ContractReportBusinessType> contractReportBusinessTypeList, Map<String, String> backgroundReportType) {
        // 筛选出相同合同编号数据
        List<ContractBusinessType> contractList = contractBusinessTypes.stream()
                .filter(contract -> contract.getContractId().equals(item.getContractNum()))
                .collect(Collectors.toList());

        List<ContractReportBusinessType> contractList1 = contractReportBusinessTypeList.stream()
                .filter(contract -> contract.getContractId().equals(item.getContractNum()))
                .collect(Collectors.toList());

        // 获取typeId去重
        List<Long> typeIds = contractList.stream()
                .map(ContractBusinessType::getTypeId).distinct()
                .collect(Collectors.toList());

        // 将 typeIds 转换为以逗号分隔的字符串
        String typeIdsString = String.join(",", typeIds.stream().map(String::valueOf).collect(Collectors.toList()));

        TemplateConfiguration templateConfiguration = TemplateConfiguration.builder()
                .orgId(item.getId())
                .contractId(item.getContractNum().toString())
                .typeId(typeIdsString)
                .reportForm("1")
                .build();
        templateConfigurationMapper.insertTemplateConfiguration(templateConfiguration);

        contractList1.forEach(item1 -> {
            contractList.forEach(contract -> {
                if (item1.getTypeId().equals(contract.getTypeId())
                        && item1.getContractId().equals(contract.getContractId())
                        && !Objects.equals(item1.getCreateImmediate(), "Y")) {
                    insertTemplateConfigurationParameters(templateConfiguration.getId(), item.getId(), contract, backgroundReportType, item1.getCreateImmediate());
                }
                if (item1.getTypeId().equals(contract.getTypeId())
                        && item1.getContractId().equals(contract.getContractId())
                        && Objects.equals(item1.getCreateImmediate(), "Y")
                        && contract.getClientType().equals("0")) {
                    insertTemplateConfigurationParametersForImmediate(templateConfiguration.getId(), item.getId(), contract, backgroundReportType);
                }
            });
            if (!Objects.equals(item1.getCreateImmediate(), "Y")) {
                insertTemplateConfigurationParametersForClientType3(templateConfiguration.getId(), item.getId(), item1.getTypeId(), backgroundReportType);
            }
            if (item1.getTypeId() != -10) {
                insertTemplateConfigurationParametersForReportPrice(templateConfiguration.getId(), item.getId(), item1.getTypeId(), BigDecimal.valueOf(0), null);
            } else {
                insertTemplateConfigurationParametersForReportPrice(templateConfiguration.getId(), item.getId(), item1.getTypeId(), BigDecimal.valueOf(250), "NO");
            }
        });
    }

    private void insertTemplateConfigurationParameters(Long templateId, Long orgId, ContractBusinessType contract, Map<String, String> backgroundReportType, String createImmediate) {
        TemplateConfigurationParameters templateConfigurationParameters = TemplateConfigurationParameters.builder()
                .templateId(templateId)
                .orgId(orgId)
                .typeId(contract.getTypeId())
                .typeName(backgroundReportType.get(contract.getTypeId().toString()))
                .clientType(contract.getClientType())
                .checked(Objects.equals(contract.getIsCheck(), "N") ? " " : "Y")
                .typePrice(contract.getTypePrice())
                .deliveryDays(StringUtils.isEmpty(contract.getDeliveryDays()) ? 0 : Integer.parseInt(contract.getDeliveryDays()))
                .build();
        if (Objects.isNull(templateConfigurationParameters.getTypePrice())) {
            switch (contract.getClientType()) {
                case "0":
                    templateConfigurationParameters.setTypePrice(BigDecimal.valueOf(400));
                    break;
                case "2":
                    templateConfigurationParameters.setTypePrice(BigDecimal.valueOf(600));
                    break;
                case "1":
                case "3":
                case "4":
                    templateConfigurationParameters.setTypePrice(BigDecimal.valueOf(500));
                    break;
            }
        }
        if (templateConfigurationParameters.getClientType() != null) {
            templateConfigurationParameters.setId(templateConfigurationParameters.getOrgId() + "-" + templateConfigurationParameters.getTypeId() + "-" + templateConfigurationParameters.getClientType());
        } else {
            templateConfigurationParameters.setId(templateConfigurationParameters.getOrgId() + "-" + templateConfigurationParameters.getTypeId());
        }
        templateConfigurationParameters.setPrice(templateConfigurationParameters.getTypePrice());
        templateConfigurationParametersMapper.insertTemplateConfigurationParameters(templateConfigurationParameters);
    }

    private void insertTemplateConfigurationParametersForImmediate(Long templateId, Long orgId, ContractBusinessType contract, Map<String, String> backgroundReportType) {
        TemplateConfigurationParameters templateConfigurationParameters = TemplateConfigurationParameters.builder()
                .templateId(templateId)
                .orgId(orgId)
                .typeId(contract.getTypeId())
                .typeName(backgroundReportType.get(contract.getTypeId().toString()))
                .clientType(String.valueOf(3))
                .checked("Y")
                .typePrice(contract.getTypePrice())
                .deliveryDays(StringUtils.isEmpty(contract.getDeliveryDays()) ? 0 : Integer.parseInt(contract.getDeliveryDays()))
                .reportPrice(BigDecimal.valueOf(500))
                .build();

        templateConfigurationParameters.setId(templateConfigurationParameters.getOrgId() + "-" + templateConfigurationParameters.getTypeId() + "-" + 3);

        templateConfigurationParameters.setPrice(BigDecimal.valueOf(500));
        templateConfigurationParametersMapper.insertTemplateConfigurationParameters(templateConfigurationParameters);

        List<Integer> arr = Arrays.asList(0, 1, 2, 4);
        arr.forEach(i -> {
            TemplateConfigurationParameters templateConfigurationParameters1 = new TemplateConfigurationParameters();
            templateConfigurationParameters1.setTemplateId(templateId);
            templateConfigurationParameters1.setOrgId(orgId);
            templateConfigurationParameters1.setTypeId(contract.getTypeId());
            templateConfigurationParameters1.setTypeName(backgroundReportType.get(contract.getTypeId().toString()));
            templateConfigurationParameters1.setChecked(null);
            templateConfigurationParameters1.setTypePrice(contract.getTypePrice());
            templateConfigurationParameters1.setDeliveryDays(0);
            switch (i) {
                case 0:
                    templateConfigurationParameters1.setTypePrice(BigDecimal.valueOf(400));
                    break;
                case 2:
                    templateConfigurationParameters1.setTypePrice(BigDecimal.valueOf(600));
                    break;
                case 1:
                case 4:
                    templateConfigurationParameters1.setTypePrice(BigDecimal.valueOf(500));
                    break;
            }
            templateConfigurationParameters1.setClientType(String.valueOf(i));
            if (templateConfigurationParameters1.getClientType() != null) {
                templateConfigurationParameters1.setId(templateConfigurationParameters1.getOrgId() + "-" + templateConfigurationParameters1.getTypeId() + "-" + templateConfigurationParameters1.getClientType());
            } else {
                templateConfigurationParameters1.setId(templateConfigurationParameters1.getOrgId() + "-" + templateConfigurationParameters1.getTypeId());
            }
            templateConfigurationParametersMapper.insertTemplateConfigurationParameters(templateConfigurationParameters1);
        });
    }

    private void insertTemplateConfigurationParametersForClientType3(Long templateId, Long orgId, Long typeId, Map<String, String> backgroundReportType) {
        TemplateConfigurationParameters templateConfigurationParameters = TemplateConfigurationParameters.builder()
                .templateId(templateId)
                .orgId(orgId)
                .typeId(typeId)
                .clientType(String.valueOf(3))
                .typeName(backgroundReportType.get(typeId.toString()))
                .build();
        if (templateConfigurationParameters.getClientType() != null) {
            templateConfigurationParameters.setId(templateConfigurationParameters.getOrgId() + "-" + templateConfigurationParameters.getTypeId() + "-" + templateConfigurationParameters.getClientType());
        } else {
            templateConfigurationParameters.setId(templateConfigurationParameters.getOrgId() + "-" + templateConfigurationParameters.getTypeId());
        }
        templateConfigurationParametersMapper.insertTemplateConfigurationParameters(templateConfigurationParameters);
    }

    private void insertTemplateConfigurationParametersForReportPrice(Long templateId, Long orgId, Long typeId, BigDecimal reportPrice, String reportTranslationType) {
        TemplateConfigurationParameters templateConfigurationParameters = TemplateConfigurationParameters.builder()
                .templateId(templateId)
                .orgId(orgId)
                .typeId(typeId)
                .reportPrice(reportPrice)
                .typeName(null)
                .clientType(null)
                .checked(null)
                .clientId(null)
                .reportTranslationType(reportTranslationType)
                .build();

        templateConfigurationParameters.setId(templateConfigurationParameters.getOrgId() + "-" + templateConfigurationParameters.getTypeId());

        templateConfigurationParametersMapper.insertTemplateConfigurationParameters(templateConfigurationParameters);
    }


    /**
     * 删除模版配置对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTemplateConfigurationByIds(String ids) {
        return templateConfigurationMapper.deleteTemplateConfigurationByIds(Convert.toStrArray(ids));


    }

}