Ver código fonte

Merge branch 'tys' into hurx

hurx 2 semanas atrás
pai
commit
6bb970ae47

+ 1 - 0
ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/interceptor/PlatformDataScopeInterceptor.java

@@ -62,6 +62,7 @@ public class PlatformDataScopeInterceptor implements Interceptor {
         "customer_info",
         "customer_dept",
         "customer_contact",
+        "customer_contact_info",
         "customer_contract",
         "com_bank",
         "settlement_level",

+ 20 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/CustomerContactInfo.java

@@ -105,6 +105,26 @@ public class CustomerContactInfo extends TenantEntity {
      */
     private String homeAddressDetail;
     
+    /**
+     * 职位
+     */
+    private String position;
+
+    /**
+     * 项目角色
+     */
+    private Integer projectRole;
+
+    /**
+     * 公关情况
+     */
+    private String prStatus;
+
+    /**
+     * 是否关键人
+     */
+    private Integer isKeyPerson;
+
     /**
      * 平台标识
      */

+ 20 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/CustomerContactBo.java

@@ -209,4 +209,24 @@ public class CustomerContactBo extends BaseEntity {
      */
     private String homeAddressDetail;
 
+    /**
+     * 职位
+     */
+    private String position;
+
+    /**
+     * 项目角色
+     */
+    private Integer projectRole;
+
+    /**
+     * 公关情况
+     */
+    private String prStatus;
+
+    /**
+     * 是否关键人
+     */
+    private Integer isKeyPerson;
+
 }

+ 34 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/CustomerContactVo.java

@@ -7,6 +7,8 @@ import org.dromara.common.excel.annotation.ExcelDictFormat;
 import org.dromara.common.excel.convert.ExcelDictConvert;
 import io.github.linpeilie.annotations.AutoMapper;
 import lombok.Data;
+import org.dromara.common.translation.annotation.Translation;
+import org.dromara.common.translation.constant.TransConstant;
 
 import java.io.Serial;
 import java.io.Serializable;
@@ -156,8 +158,20 @@ public class CustomerContactVo implements Serializable {
     @ExcelProperty(value = "平台标识")
     private String platformCode;
 
+    private Long createBy;
+
     private Date createTime;
 
+    private Long updateBy;
+
+    private Date updateTime;
+
+    @Translation(type = TransConstant.USER_ID_TO_NAME, mapper = "createBy")
+    private String createByName;
+
+    @Translation(type = TransConstant.USER_ID_TO_NAME, mapper = "updateBy")
+    private String updateByName;
+
     private String delFlag;
 
     /**
@@ -229,4 +243,24 @@ public class CustomerContactVo implements Serializable {
      * 家庭详细地址
      */
     private String homeAddressDetail;
+
+    /**
+     * 职位
+     */
+    private String position;
+
+    /**
+     * 项目角色
+     */
+    private Integer projectRole;
+
+    /**
+     * 公关情况
+     */
+    private String prStatus;
+
+    /**
+     * 是否关键人
+     */
+    private Integer isKeyPerson;
 }

+ 79 - 9
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerContactServiceImpl.java

@@ -77,7 +77,7 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
             CustomerContactInfo info = contactInfoMapper.selectOne(new LambdaQueryWrapper<CustomerContactInfo>()
                 .eq(CustomerContactInfo::getContactId, id));
             if (info != null) {
-                // 将扩展信息字段合并到 VO 中
+                // 利用 MapstructUtils 自动映射所有扩展字段 (包括职位、年龄等)
                 MapstructUtils.convert(info, vo);
             }
         }
@@ -125,6 +125,8 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
                     }
                 }
             });
+            // 填充扩展信息
+            fillContactExtInfo(records);
         }
         return TableDataInfo.build(result);
     }
@@ -138,7 +140,9 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
     @Override
     public List<CustomerContactVo> queryList(CustomerContactBo bo) {
         LambdaQueryWrapper<CustomerContact> lqw = buildQueryWrapper(bo);
-        return baseMapper.selectVoList(lqw);
+        List<CustomerContactVo> list = baseMapper.selectVoList(lqw);
+        fillContactExtInfo(list);
+        return list;
     }
 
     private LambdaQueryWrapper<CustomerContact> buildQueryWrapper(CustomerContactBo bo) {
@@ -163,6 +167,18 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
         lqw.like(StringUtils.isNotBlank(bo.getDeptName()), CustomerContact::getDeptName, bo.getDeptName());
         lqw.like(StringUtils.isNotBlank(bo.getRoleName()), CustomerContact::getRoleName, bo.getRoleName());
         lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), CustomerContact::getPlatformCode, bo.getPlatformCode());
+        // 增加联系人类型查询
+        if (StringUtils.isNotBlank(bo.getType())) {
+            List<CustomerContactInfo> infoList = contactInfoMapper.selectList(new LambdaQueryWrapper<CustomerContactInfo>()
+                .select(CustomerContactInfo::getContactId)
+                .eq(CustomerContactInfo::getType, bo.getType()));
+            if (ObjectUtil.isNotEmpty(infoList)) {
+                List<Long> contactIds = infoList.stream().map(CustomerContactInfo::getContactId).collect(Collectors.toList());
+                lqw.in(CustomerContact::getId, contactIds);
+            } else {
+                lqw.eq(CustomerContact::getId, 0L);
+            }
+        }
 
         if (ObjectUtil.isNotEmpty(bo.getCustomerName())) {
             CustomerInfoVo customerInfoVo = customerInfoMapper.selectVoOne(new LambdaQueryWrapper<CustomerInfo>().eq(CustomerInfo::getCustomerName, bo.getCustomerName()));
@@ -279,6 +295,8 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
                 // 保存扩展信息
                 CustomerContactInfo info = MapstructUtils.convert(bo, CustomerContactInfo.class);
                 info.setContactId(add.getId());
+                // 按照要求,不插入扩展表的 platform_code
+                info.setPlatformCode(null);
                 contactInfoMapper.insert(info);
             } catch (Exception e) {
                 log.warn("保存联系人扩展信息失败,可能表 customer_contact_info 尚未创建: {}", e.getMessage());
@@ -319,6 +337,8 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
                 // 更新或插入扩展信息
                 CustomerContactInfo info = MapstructUtils.convert(bo, CustomerContactInfo.class);
                 info.setContactId(bo.getId());
+                // 按照要求,不插入扩展表的 platform_code
+                info.setPlatformCode(null);
                 CustomerContactInfo exist = contactInfoMapper.selectOne(new LambdaQueryWrapper<CustomerContactInfo>()
                     .eq(CustomerContactInfo::getContactId, bo.getId()));
                 if (exist != null) {
@@ -393,13 +413,6 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
      * @param isValid 是否进行有效性校验
      * @return 是否删除成功
      */
-    /**
-     * 批量删除联系人
-     *
-     * @param ids     ID 集合
-     * @param isValid 是否需要业务校验
-     * @return 是否删除成功
-     */
     @Transactional(rollbackFor = Exception.class) // 1. 开启事务
     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
         if (ids == null || ids.isEmpty()) {
@@ -445,4 +458,61 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
 
         return rows > 0;
     }
+
+    /**
+     * 新增或编辑扩展联系人信息 (独立方法)
+     *
+     * @param bo 业务对象
+     * @return 是否成功
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean saveOrUpdateContactExtInfo(CustomerContactBo bo) {
+        if (bo == null || bo.getId() == null) {
+            return false;
+        }
+        // 1. 将 BO 转换为扩展信息实体
+        CustomerContactInfo info = MapstructUtils.convert(bo, CustomerContactInfo.class);
+        info.setContactId(bo.getId());
+
+        // 2. 按照要求,不插入 platform_code 字段
+        info.setPlatformCode(null);
+
+        // 3. 根据联系人 ID 查询是否已存在扩展记录
+        CustomerContactInfo exist = contactInfoMapper.selectOne(new LambdaQueryWrapper<CustomerContactInfo>()
+            .eq(CustomerContactInfo::getContactId, bo.getId()));
+
+        if (exist != null) {
+            // 已存在则更新
+            info.setId(exist.getId());
+            return contactInfoMapper.updateById(info) > 0;
+        } else {
+            // 不存在则新增
+            return contactInfoMapper.insert(info) > 0;
+        }
+    }
+
+    /**
+     * 批量填充联系人扩展信息
+     *
+     * @param voList 联系人视图对象列表
+     */
+    public void fillContactExtInfo(List<CustomerContactVo> voList) {
+        if (ObjectUtil.isEmpty(voList)) {
+            return;
+        }
+        List<Long> contactIds = voList.stream().map(CustomerContactVo::getId).collect(Collectors.toList());
+        List<CustomerContactInfo> infos = contactInfoMapper.selectList(new LambdaQueryWrapper<CustomerContactInfo>()
+            .in(CustomerContactInfo::getContactId, contactIds));
+        if (ObjectUtil.isEmpty(infos)) {
+            return;
+        }
+        Map<Long, CustomerContactInfo> infoMap = infos.stream().collect(Collectors.toMap(CustomerContactInfo::getContactId, i -> i, (k1, k2) -> k1));
+        voList.forEach(item -> {
+            CustomerContactInfo info = infoMap.get(item.getId());
+            if (info != null) {
+                // 使用 MapstructUtils 自动映射,避免手动赋值遗漏字段
+                MapstructUtils.convert(info, item);
+            }
+        });
+    }
 }