Browse Source

新增客户档案面谈表

anderx 9 months ago
parent
commit
a4213663d1

+ 12 - 3
src/main/java/com/goafanti/Interview/controller/UserArchivesInterviewController.java

@@ -5,7 +5,11 @@ import com.goafanti.Interview.service.UserArchivesInterviewService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.controller.BaseController;
 import com.goafanti.common.model.UserArchivesInterview;
-import org.springframework.web.bind.annotation.*;
+import com.goafanti.core.shiro.token.TokenManager;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 
@@ -16,7 +20,7 @@ import javax.annotation.Resource;
  * @since 2025-04-10 17:09:23
  */
 @RestController
-@RequestMapping("/api/admin/userArchivesInterview")
+@RequestMapping("/api/admin/interview")
 public class UserArchivesInterviewController extends BaseController {
     /**
      * 服务对象
@@ -82,8 +86,13 @@ public class UserArchivesInterviewController extends BaseController {
         return new Result<>().data(this.userArchivesInterviewService.list(in, pageNo, pageSize));
     }
 
-    @PutMapping("/updateUser")
+    /**
+     * 更新企业档案与面谈
+     * @return
+     */
+    @PostMapping("/updateUser")
     public Result updateUser(UpdateUserBo in) {
+        in.setAid(TokenManager.getAdminId());
         return new Result<>().data(this.userArchivesInterviewService.updateUser(in));
     }
 

+ 88 - 0
src/main/java/com/goafanti/Interview/controller/UserInterviewProjectController.java

@@ -0,0 +1,88 @@
+package com.goafanti.Interview.controller;
+
+import com.goafanti.Interview.service.UserInterviewProjectService;
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.controller.BaseController;
+import com.goafanti.common.model.UserInterviewProject;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * 客户面谈项目表(UserInterviewProject)表控制层
+ *
+ * @author makejava
+ * @since 2025-04-11 11:02:01
+ */
+@RestController
+@RequestMapping("/api/admin/userInterviewProject")
+public class UserInterviewProjectController extends BaseController {
+    /**
+     * 服务对象
+     */
+    @Resource
+    private UserInterviewProjectService userInterviewProjectService;
+
+
+    /**
+     * 新增数据
+     *
+     * @param userInterviewProject 实体
+     * @return 新增结果
+     */
+    @PostMapping("/add")
+    public Result add(UserInterviewProject userInterviewProject) {
+        return new Result<>().data(this.userInterviewProjectService.insert(userInterviewProject));
+    }
+
+
+    /**
+     * 通过主键查询单条数据
+     *
+     * @param id 主键
+     * @return 单条数据
+     */
+    @GetMapping("/get")
+    public Result<UserInterviewProject> queryById(Integer id) {
+        return new Result<>().data(this.userInterviewProjectService.queryById(id));
+    }
+
+
+    /**
+     * 编辑数据
+     *
+     * @param userInterviewProject 实体
+     * @return 编辑结果
+     */
+    @PostMapping("/update")
+    public Result edit(UserInterviewProject userInterviewProject) {
+        return new Result<>().data(this.userInterviewProjectService.update(userInterviewProject));
+    }
+
+    /**
+     * 删除数据
+     *
+     * @param id 主键
+     * @return 删除是否成功
+     */
+    @GetMapping("/delete")
+    public Result deleteById(Integer id) {
+        return new Result<>().data(this.userInterviewProjectService.deleteById(id));
+    }
+
+    /**
+     * 列表查询
+     *
+     * @param in 参数
+     * @return
+     */
+    @GetMapping("/list")
+    public Result<UserInterviewProject> list(UserInterviewProject in, Integer pageNo, Integer pageSize) {
+        return new Result<>().data(this.userInterviewProjectService.list(in, pageNo, pageSize));
+    }
+
+}
+

+ 54 - 0
src/main/java/com/goafanti/Interview/service/UserInterviewProjectService.java

@@ -0,0 +1,54 @@
+package com.goafanti.Interview.service;
+
+import com.goafanti.common.model.UserInterviewProject;
+
+/**
+ * 客户面谈项目表(UserInterviewProject)表服务接口
+ *
+ * @author makejava
+ * @since 2025-04-11 11:02:01
+ */
+public interface UserInterviewProjectService {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    UserInterviewProject queryById(Integer id);
+
+
+    /**
+     * 新增数据
+     *
+     * @param userInterviewProject 实例对象
+     * @return 实例对象
+     */
+    UserInterviewProject insert(UserInterviewProject userInterviewProject);
+
+    /**
+     * 修改数据
+     *
+     * @param userInterviewProject 实例对象
+     * @return 实例对象
+     */
+    UserInterviewProject update(UserInterviewProject userInterviewProject);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 是否成功
+     */
+    boolean deleteById(Integer id);
+
+    /**
+     * 列表数据
+     *
+     * @param in 参数
+     * @return 是否成功
+     */
+    Object list(UserInterviewProject in, Integer pageNo, Integer pageSize);
+
+}

+ 13 - 19
src/main/java/com/goafanti/Interview/service/impl/UserArchivesInterviewServiceImpl.java

@@ -91,41 +91,35 @@ public class UserArchivesInterviewServiceImpl extends BaseMybatisDao<UserArchive
 
     @Override
     public Object updateUser(UpdateUserBo in) {
-        //先修改用户档案表
-        UserArchives update = new UserArchives();
-        update.setId(in.getId());
-        update.setPatentCount(in.getPatentCount());
-        update.setInventionPatentCount(in.getInventionPatentCount());
-        update.setUtilityModelCount(in.getUtilityModelCount());
-        update.setAppearancePatentCount(in.getAppearancePatentCount());
-        update.setSoftwareWorksCount(in.getSoftwareWorksCount());
-        update.setOtherCount(in.getOtherCount());
-        update.setCompanyCount(in.getCompanyCount());
-        update.setSocialSecurityCount(in.getSocialSecurityCount());
-        update.setExternalInvestCount(in.getExternalInvestCount());
-        update.setExternalInvestIndustry(in.getExternalInvestIndustry());
-        update.setExternalInvestName(in.getExternalInvestName());
+
         //第一次面谈时间,暂时设定所有的
         List<MyUserDetailsBo> myUserDetailsBos =publicReleaseMapper.selectByUid(in.getUid());
         if (!myUserDetailsBos.isEmpty()){
             MyUserDetailsBo myUserDetailsBo = myUserDetailsBos.get(0);
-            update.setFirstInterviewDate(myUserDetailsBo.getReleaseStart());
+            in.setFirstInterviewDate(myUserDetailsBo.getReleaseStart());
         }
         //添加客户档案面谈记录表
         addUserArchivesInterview(in);
-        return userArchivesMapper.update(in);
+        //读取是否有档案存在
+        UserArchives userArchives = userArchivesMapper.queryByUid(in.getUid());
+        in.setId(userArchives.getId());
+        if (in.getId()!=null){
+            userArchivesMapper.update(in);
+        }else {
+            userArchivesMapper.insert(in);
+        }
+        return 1;
     }
 
     private void addUserArchivesInterview(UpdateUserBo in) {
-        UserArchivesInterview find = new UserArchivesInterview();
-        List<UserArchivesInterview> list = userArchivesInterviewMapper.findUserArchivesInterviewList(find);
+        List<UserArchivesInterview> list = userArchivesInterviewMapper.selectByUidAid(in.getUid(), in.getAid());
         UserArchivesInterview userArchivesInterview = new UserArchivesInterview();
         if (list.isEmpty()){
             userArchivesInterview.setUid(in.getUid());
             userArchivesInterview.setAid(in.getAid());
             userArchivesInterview.setCounts(1);
         }else {
-            userArchivesInterview = list.get(list.size() - 1);
+            userArchivesInterview = list.get(0);
             userArchivesInterview.setCounts(userArchivesInterview.getCounts() + 1);
             userArchivesInterview.setUid(in.getUid());
             userArchivesInterview.setAid(in.getAid());

+ 80 - 0
src/main/java/com/goafanti/Interview/service/impl/UserInterviewProjectServiceImpl.java

@@ -0,0 +1,80 @@
+package com.goafanti.Interview.service.impl;
+
+import com.goafanti.Interview.service.UserInterviewProjectService;
+import com.goafanti.common.dao.UserInterviewProjectMapper;
+import com.goafanti.common.model.UserInterviewProject;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 客户面谈项目表(UserInterviewProject)表服务实现类
+ *
+ * @author makejava
+ * @since 2025-04-11 11:02:01
+ */
+@Service("userInterviewProjectService")
+public class UserInterviewProjectServiceImpl extends BaseMybatisDao<UserInterviewProjectMapper> implements UserInterviewProjectService {
+    @Resource
+    private UserInterviewProjectMapper userInterviewProjectMapper;
+
+
+    @Override
+    public Pagination<UserInterviewProject> list(UserInterviewProject userInterviewProject, Integer pageNo, Integer pageSize) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("in", userInterviewProject);
+        return (Pagination<UserInterviewProject>) findPage("findUserInterviewProjectList",
+                "findUserInterviewProjectCount", params, pageNo, pageSize);
+    }
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    @Override
+    public UserInterviewProject queryById(Integer id) {
+        return this.userInterviewProjectMapper.selectById(id);
+    }
+
+
+    /**
+     * 新增数据
+     *
+     * @param userInterviewProject 实例对象
+     * @return 实例对象
+     */
+    @Override
+    public UserInterviewProject insert(UserInterviewProject userInterviewProject) {
+        this.userInterviewProjectMapper.insert(userInterviewProject);
+        return userInterviewProject;
+    }
+
+    /**
+     * 修改数据
+     *
+     * @param userInterviewProject 实例对象
+     * @return 实例对象
+     */
+    @Override
+    public UserInterviewProject update(UserInterviewProject userInterviewProject) {
+        this.userInterviewProjectMapper.update(userInterviewProject);
+        return this.queryById(userInterviewProject.getId());
+    }
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 是否成功
+     */
+    @Override
+    public boolean deleteById(Integer id) {
+        return this.userInterviewProjectMapper.deleteById(id) > 0;
+    }
+}

+ 1 - 0
src/main/java/com/goafanti/common/dao/UserArchivesInterviewMapper.java

@@ -78,6 +78,7 @@ public interface UserArchivesInterviewMapper {
      * @return 影响行数
      */
     int deleteById(Integer id);
+    List<UserArchivesInterview> selectByUidAid(@Param("uid") String uid, @Param("aid") String aid);
 
 }
 

+ 85 - 0
src/main/java/com/goafanti/common/dao/UserInterviewProjectMapper.java

@@ -0,0 +1,85 @@
+package com.goafanti.common.dao;
+
+import com.goafanti.common.model.UserInterviewProject;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+/**
+ * 客户面谈项目表(UserInterviewProject)表数据库访问层
+ *
+ * @author makejava
+ * @since 2025-04-11 11:01:29
+ */
+public interface UserInterviewProjectMapper {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    UserInterviewProject selectById(Integer id);
+
+
+    /**
+     * 查询指定行数据
+     *
+     * @param userInterviewProject 查询条件
+     * @param pageable             分页对象
+     * @return 对象列表
+     */
+    List<UserInterviewProject> findUserInterviewProjectList(UserInterviewProject userInterviewProject, @Param("pageable") Pageable pageable);
+
+    /**
+     * 统计总行数
+     *
+     * @param userInterviewProject 查询条件
+     * @return 总行数
+     */
+    int findUserInterviewProjectCount(UserInterviewProject userInterviewProject);
+
+    /**
+     * 新增数据
+     *
+     * @param userInterviewProject 实例对象
+     * @return 影响行数
+     */
+    int insert(UserInterviewProject userInterviewProject);
+
+    /**
+     * 批量新增数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<UserInterviewProject> 实例对象列表
+     * @return 影响行数
+     */
+    int insertBatch(@Param("entities") List<UserInterviewProject> entities);
+
+    /**
+     * 批量新增或按主键更新数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<UserInterviewProject> 实例对象列表
+     * @return 影响行数
+     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
+     */
+    int insertOrUpdateBatch(@Param("entities") List<UserInterviewProject> entities);
+
+    /**
+     * 修改数据
+     *
+     * @param userInterviewProject 实例对象
+     * @return 影响行数
+     */
+    int update(UserInterviewProject userInterviewProject);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 影响行数
+     */
+    int deleteById(Integer id);
+
+}
+

+ 14 - 0
src/main/java/com/goafanti/common/mapper/UserArchivesInterviewMapper.xml

@@ -202,5 +202,19 @@
         where id = #{id}
     </delete>
 
+    <select id="selectByUidAid" resultMap="UserArchivesInterviewMap">
+    select
+    <include refid="UserArchivesInterviewAllSql"/>
+    from user_archives_interview
+    <where>
+    <if test="uid != null and uid != ''">
+        and uid = #{uid}
+    </if>
+    <if test="aid != null and aid != ''">
+        and aid = #{aid}
+    </if>
+    </where>
+    order by counts desc
+    </select>
 </mapper>
 

+ 155 - 0
src/main/java/com/goafanti/common/mapper/UserInterviewProjectMapper.xml

@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.goafanti.common.dao.UserInterviewProjectMapper">
+
+    <resultMap type="com.goafanti.common.model.UserInterviewProject" id="UserInterviewProjectMap">
+        <result property="id" column="id" jdbcType="INTEGER"/>
+        <result property="uid" column="uid" jdbcType="VARCHAR"/>
+        <result property="pid" column="pid" jdbcType="VARCHAR"/>
+        <result property="examineStatus" column="examine_status" jdbcType="INTEGER"/>
+        <result property="examineStatusOther" column="examine_status_other" jdbcType="VARCHAR"/>
+        <result property="buyStatus" column="buy_status" jdbcType="INTEGER"/>
+        <result property="buyStatusOther" column="buy_status_other" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <sql id="UserInterviewProjectAllSql">
+        id, uid, pid, examine_status, examine_status_other, buy_status, buy_status_other
+    </sql>
+
+    <!--查询单个-->
+    <select id="selectById" resultMap="UserInterviewProjectMap">
+        select
+        <include refid="UserInterviewProjectAllSql"/>
+        from user_interview_project
+        where id = #{id}
+    </select>
+
+    <!--新增所有列-->
+    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
+        insert into user_interview_project(uid, pid, examine_status, examine_status_other, buy_status, buy_status_other)
+        values (#{uid}, #{pid}, #{examineStatus}, #{examineStatusOther}, #{buyStatus}, #{buyStatusOther})
+    </insert>
+
+    <insert id="insertBatch">
+        insert into user_interview_project(uid, pid, examine_status, examine_status_other, buy_status, buy_status_other)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.uid}, #{entity.pid}, #{entity.examineStatus}, #{entity.examineStatusOther}, #{entity.buyStatus},
+            #{entity.buyStatusOther})
+        </foreach>
+    </insert>
+
+    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
+        insert into user_interview_project(uid, pid, examine_status, examine_status_other, buy_status, buy_status_other)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.uid}, #{entity.pid}, #{entity.examineStatus}, #{entity.examineStatusOther}, #{entity.buyStatus},
+            #{entity.buyStatusOther})
+        </foreach>
+        on duplicate key update
+        uid = values(uid),
+        pid = values(pid),
+        examine_status = values(examine_status),
+        examine_status_other = values(examine_status_other),
+        buy_status = values(buy_status),
+        buy_status_other = values(buy_status_other)
+    </insert>
+
+    <!--通过主键修改数据-->
+    <update id="update">
+        update user_interview_project
+        <set>
+            <if test="uid != null and uid != ''">
+                uid = #{uid},
+            </if>
+            <if test="pid != null and pid != ''">
+                pid = #{pid},
+            </if>
+            <if test="examineStatus != null">
+                examine_status = #{examineStatus},
+            </if>
+            <if test="examineStatusOther != null and examineStatusOther != ''">
+                examine_status_other = #{examineStatusOther},
+            </if>
+            <if test="buyStatus != null">
+                buy_status = #{buyStatus},
+            </if>
+            <if test="buyStatusOther != null and buyStatusOther != ''">
+                buy_status_other = #{buyStatusOther},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+
+    <!--查询指定行数据-->
+    <select id="findUserInterviewProjectList" resultMap="UserInterviewProjectMap">
+        select
+        <include refid="UserInterviewProjectAllSql"/>
+
+        from user_interview_project
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="uid != null and uid != ''">
+                and uid = #{uid}
+            </if>
+            <if test="pid != null and pid != ''">
+                and pid = #{pid}
+            </if>
+            <if test="examineStatus != null">
+                and examine_status = #{examineStatus}
+            </if>
+            <if test="examineStatusOther != null and examineStatusOther != ''">
+                and examine_status_other = #{examineStatusOther}
+            </if>
+            <if test="buyStatus != null">
+                and buy_status = #{buyStatus}
+            </if>
+            <if test="buyStatusOther != null and buyStatusOther != ''">
+                and buy_status_other = #{buyStatusOther}
+            </if>
+        </where>
+        <if test="page_sql != null">
+            ${page_sql}
+        </if>
+    </select>
+
+    <!--统计总行数-->
+    <select id="findUserInterviewProjectCount" resultType="java.lang.Integer">
+        select count(1)
+        from user_interview_project
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="uid != null and uid != ''">
+                and uid = #{uid}
+            </if>
+            <if test="pid != null and pid != ''">
+                and pid = #{pid}
+            </if>
+            <if test="examineStatus != null">
+                and examine_status = #{examineStatus}
+            </if>
+            <if test="examineStatusOther != null and examineStatusOther != ''">
+                and examine_status_other = #{examineStatusOther}
+            </if>
+            <if test="buyStatus != null">
+                and buy_status = #{buyStatus}
+            </if>
+            <if test="buyStatusOther != null and buyStatusOther != ''">
+                and buy_status_other = #{buyStatusOther}
+            </if>
+        </where>
+    </select>
+
+    <!--通过主键删除-->
+    <delete id="deleteById">
+        delete
+        from user_interview_project
+        where id = #{id}
+    </delete>
+
+</mapper>
+

+ 99 - 0
src/main/java/com/goafanti/common/model/UserInterviewProject.java

@@ -0,0 +1,99 @@
+package com.goafanti.common.model;
+
+import java.io.Serializable;
+
+
+/**
+ * 客户面谈项目表(UserInterviewProject)实体类
+ *
+ * @author makejava
+ * @since 2025-04-11 11:01:29
+ */
+public class UserInterviewProject implements Serializable {
+    private static final long serialVersionUID = 183066365262188482L;
+
+    private Integer id;
+    /**
+     * 客户编号
+     */
+    private String uid;
+    /**
+     * 跟进人编号
+     */
+    private String pid;
+    /**
+     * 审核状态 0=否,1=初次审核,2=复审
+     */
+    private Integer examineStatus;
+    /**
+     * 复审年份
+     */
+    private String examineStatusOther;
+    /**
+     * 购买状态 0=否,1=新购,2=复购
+     */
+    private Integer buyStatus;
+    /**
+     * 复购年份
+     */
+    private String buyStatusOther;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getUid() {
+        return uid;
+    }
+
+    public void setUid(String uid) {
+        this.uid = uid;
+    }
+
+    public String getPid() {
+        return pid;
+    }
+
+    public void setPid(String pid) {
+        this.pid = pid;
+    }
+
+    public Integer getExamineStatus() {
+        return examineStatus;
+    }
+
+    public void setExamineStatus(Integer examineStatus) {
+        this.examineStatus = examineStatus;
+    }
+
+    public String getExamineStatusOther() {
+        return examineStatusOther;
+    }
+
+    public void setExamineStatusOther(String examineStatusOther) {
+        this.examineStatusOther = examineStatusOther;
+    }
+
+    public Integer getBuyStatus() {
+        return buyStatus;
+    }
+
+    public void setBuyStatus(Integer buyStatus) {
+        this.buyStatus = buyStatus;
+    }
+
+    public String getBuyStatusOther() {
+        return buyStatusOther;
+    }
+
+    public void setBuyStatusOther(String buyStatusOther) {
+        this.buyStatusOther = buyStatusOther;
+    }
+
+}
+

+ 4 - 0
src/main/java/com/goafanti/customer/service/impl/UserArchivesServiceImpl.java

@@ -30,6 +30,8 @@ public class UserArchivesServiceImpl extends BaseMybatisDao< UserArchivesMapper>
     @Resource
     private UserArchivesMapper userArchivesMapper;
     @Resource
+    private UserArchivesInterviewMapper userArchivesInterviewMapper;
+    @Resource
     private CustomerService customerService;
     @Resource
     private UserMapper userMapper;
@@ -87,6 +89,8 @@ public class UserArchivesServiceImpl extends BaseMybatisDao< UserArchivesMapper>
 
         }
         BeanUtils.copyProperties(userArchives, user);
+        List<UserArchivesInterview> userArchivesInterviews = userArchivesInterviewMapper.selectByUidAid(id, TokenManager.getAdminId());
+        user.setInterviewList(userArchivesInterviews);
         return user;
     }