Commit af36720b9d6e3004239e1b9b8095422d7a98e27d

Authored by 房远帅
1 parent 42f04fbf

合同打印模板修改:自动填充法定代表人、委托代理人、电话及传真、日期

... ... @@ -479,6 +479,19 @@ public class GetContractDistributorStandardBo extends BaseBo<ContractDistributor
479 479 @ApiModelProperty(value = "是否可拆分")
480 480 private Boolean canSplit;
481 481
  482 + /**
  483 + * 创建人
  484 + */
  485 + @ApiModelProperty(value = "创建人")
  486 + private String createBy;
  487 +
  488 + /**
  489 + * 创建人ID
  490 + */
  491 + @ApiModelProperty(value = "创建人ID")
  492 + private String createById;
  493 +
  494 +
482 495 public GetContractDistributorStandardBo() {
483 496
484 497 }
... ...
... ... @@ -36,6 +36,7 @@ import com.lframework.xingyun.sc.service.contract.ContractDistributorLineService
36 36 import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService;
37 37 import com.lframework.xingyun.sc.service.contract.ContractFrameworkService;
38 38 import com.lframework.xingyun.sc.service.contract.ContractStdProcessingLineService;
  39 +import com.lframework.xingyun.sc.service.customer.CorePersonnelService;
39 40 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
40 41 import com.lframework.xingyun.sc.service.customer.CustomerDevelopPlanService;
41 42 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
... ... @@ -45,6 +46,7 @@ import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractDistributorS
45 46 import com.lframework.xingyun.sc.vo.contract.queryVo.QueryContractDistributorStandardVo;
46 47 import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractDistributorStandardVo;
47 48 import com.lframework.xingyun.sc.vo.customer.credit.QueryCustomerCreditVo;
  49 +import com.lframework.xingyun.sc.vo.customer.credit.QueryCorePersonnelVo;
48 50 import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderInfoVo;
49 51 import io.swagger.annotations.Api;
50 52 import io.swagger.annotations.ApiImplicitParam;
... ... @@ -116,10 +118,13 @@ public class ContractDistributorStandardController extends DefaultBaseController
116 118 private PurchaseOrderInfoService purchaseOrderInfoService;
117 119 @Resource
118 120 private CustomerCreditService customerCreditService;
  121 + @Resource
  122 + private CorePersonnelService corePersonnelService;
119 123
120 124
121 125 public static final String SUPPLIER_DIC_CODE = "SUPPLIER"; // 所属单位/供方
122 126 public static final String UNIT_DIC_CODE = "UNIT"; // 单位
  127 + public static final String LANDLINE_DIC_CODE = "LANDLINE"; // 办事处固话
123 128 public static final String CONTRACT_PRODUCT_DIC_CODE = "CONTRACT_PRODUCT"; // 合同产品名称
124 129 public static final String CONDITIONS_REQUIRED_DIC_CODE = "CONDITIONS_REQUIRED"; // 特别条款要求
125 130 public static final String APPLICABLE_STANDARD_DIC_CODE = "APPLICABLE_STANDARD"; // 执行标准
... ... @@ -1424,9 +1429,96 @@ public class ContractDistributorStandardController extends DefaultBaseController
1424 1429 } else {
1425 1430 dataMap.put("remarks", "");
1426 1431 }
  1432 + SysUser createUser = StringUtils.isBlank(data.getCreateById()) ? null : sysUserService.findById(data.getCreateById());
  1433 + String creatorPhone = getUserContactPhone(createUser);
  1434 + String officeLandline = getOfficeLandline(data.getDeptId());
  1435 + String legalRepresentative = "";
  1436 + if (CollectionUtils.isNotEmpty(query) && query.get(0) != null) {
  1437 + QueryCorePersonnelVo corePersonnelVo = new QueryCorePersonnelVo();
  1438 + corePersonnelVo.setCreditId(query.get(0).getId());
  1439 + List<CorePersonnel> corePersonnelList = corePersonnelService.query(corePersonnelVo);
  1440 + if (CollectionUtils.isNotEmpty(corePersonnelList)) {
  1441 + legalRepresentative = corePersonnelList.stream()
  1442 + .filter(item -> StringUtils.equals("法定代表人", item.getPosition()))
  1443 + .map(CorePersonnel::getName)
  1444 + .filter(StringUtils::isNotBlank)
  1445 + .findFirst()
  1446 + .orElse("");
  1447 + }
  1448 + }
  1449 + //委托代理人
  1450 + dataMap.put("createBy", data.getCreateBy() == null ? "" : data.getCreateBy());
  1451 + //电话及传真
  1452 + dataMap.put("phone", joinContactPhones(creatorPhone, officeLandline));
  1453 + //日期
  1454 + dataMap.put("orderDate", data.getOrderDate() == null ? "" : data.getOrderDate());
  1455 + //法定代表人
  1456 + dataMap.put("legalRepresentative", legalRepresentative);
1427 1457 return dataMap;
1428 1458 }
1429 1459
  1460 + private String getUserContactPhone(SysUser user) {
  1461 + if (user == null) {
  1462 + return "";
  1463 + }
  1464 +
  1465 + for (String methodName : Arrays.asList("getTelephone", "getPhone", "getMobile")) {
  1466 + String value = invokeStringMethod(user, methodName);
  1467 + if (StringUtils.isNotBlank(value)) {
  1468 + return value;
  1469 + }
  1470 + }
  1471 + return "";
  1472 + }
  1473 +
  1474 + private String getOfficeLandline(String deptId) {
  1475 + String officeCode = resolveOfficeCode(deptId);
  1476 + if (StringUtils.isBlank(officeCode)) {
  1477 + return "";
  1478 + }
  1479 +
  1480 + SysDataDicItem landlineDicItem = sysDataDicItemService.findByCode(LANDLINE_DIC_CODE, officeCode);
  1481 + return landlineDicItem == null || StringUtils.isBlank(landlineDicItem.getName()) ? "" : landlineDicItem.getName();
  1482 + }
  1483 +
  1484 + private String resolveOfficeCode(String deptId) {
  1485 + if (StringUtils.isBlank(deptId)) {
  1486 + return "";
  1487 + }
  1488 +
  1489 + Set<String> officeCodes = new HashSet<>(Arrays.asList("BF", "CZ", "DG", "FS", "NB", "SZ", "WM", "WZ", "ZT"));
  1490 + SysDept current = sysDeptService.findById(deptId);
  1491 + while (current != null) {
  1492 + if (officeCodes.contains(current.getCode())) {
  1493 + return current.getCode();
  1494 + }
  1495 + if (StringUtils.isBlank(current.getParentId())) {
  1496 + break;
  1497 + }
  1498 + current = sysDeptService.findById(current.getParentId());
  1499 + }
  1500 + return "";
  1501 + }
  1502 +
  1503 + private String joinContactPhones(String creatorPhone, String officeLandline) {
  1504 + if (StringUtils.isNotBlank(creatorPhone) && StringUtils.isNotBlank(officeLandline)) {
  1505 + return creatorPhone + " " + officeLandline;
  1506 + }
  1507 + if (StringUtils.isNotBlank(creatorPhone)) {
  1508 + return creatorPhone;
  1509 + }
  1510 + return StringUtils.defaultString(officeLandline);
  1511 + }
  1512 +
  1513 + private String invokeStringMethod(Object target, String methodName) {
  1514 + try {
  1515 + Object value = target.getClass().getMethod(methodName).invoke(target);
  1516 + return value instanceof String ? (String) value : "";
  1517 + } catch (Exception e) {
  1518 + return "";
  1519 + }
  1520 + }
  1521 +
1430 1522 private File convertExcelToPdf(File excelFile) throws IOException, InterruptedException {
1431 1523 if (!excelFile.exists()) {
1432 1524 throw new IllegalArgumentException("Excel 文件不存在: " + excelFile.getAbsolutePath());
... ...