CRM项目后端根据已有业务逻辑用户转为Excel优化实现可根据前端提交转换------CRM项目

CRM项目后端根据已有业务逻辑用户转为Excel优化实现可根据前端提交转换------CRM项目

java">package ***.alatus.web;

import ***.alatus.constant.Constants;
import ***.alatus.model.TCustomer;
import ***.alatus.query.CustomerQuery;
import ***.alatus.result.CustomerExcel;
import ***.alatus.result.Result;
import ***.alatus.service.CustomerService;
import ***.alibaba.excel.EasyExcel;
import ***.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.***.URLEncoder;
import java.util.Arrays;
import java.util.List;

@RestController
public class CustomerController {
    @Resource
    private CustomerService customerService;

    @PostMapping(value = "/api/clue/customer")
    public Result transferCustomer(@RequestBody CustomerQuery customerQuery, @RequestHeader(value = Constants.TOKEN_NAME)String token){
        customerQuery.setToken(token);
        Boolean convert = customerService.convertCustomer(customerQuery);
        return convert ? Result.OK() : Result.FAIL();
    }
    @GetMapping(value = "/api/customers")
    public Result CustomersByPages(@RequestParam(value = Constants.CURRENT,required = false)Integer current){
        if(current == null){
            current = 1;
        }
        PageInfo<TCustomer> pageInfo = customerService.getCustomerByPage(current);
        return Result.OK(pageInfo);
    }
    @GetMapping(value = "/api/exportExcel")
    public void exportExcel(@RequestParam(value = Constants.IDS,required = false)String ids, HttpServletResponse response) throws IOException {
        List<String> idList = null;
        if(!ObjectUtils.isEmpty(ids)){
            idList = Arrays.asList(ids.split(","));
        }
        //要想让浏览器弹出下载框,后端要设置一下响应头信息
        response.setContentType("application/octet-stream");
        response.setCharacterEncoding(Constants.UTF_8);
        response.setHeader("X-Frame-Options", "allow-from uri");// 解决IFrame拒绝的问题
        response.setHeader("Content-disposition", "attachment;filename="+ URLEncoder.encode(Constants.CUSTOMER_FILE_NAME,Constants.UTF_8)+System.currentTimeMillis() +".xlsx");
        List<CustomerExcel> dataList = customerService.getCustomerByExcel(idList);
        EasyExcel.write(response.getOutputStream(), CustomerExcel.class)
                .sheet()
                .doWrite(dataList);
    }
}
package ***.alatus.web;

import ***.alatus.constant.Constants;
import ***.alatus.model.TCustomer;
import ***.alatus.query.CustomerQuery;
import ***.alatus.result.CustomerExcel;
import ***.alatus.result.Result;
import ***.alatus.service.CustomerService;
import ***.alibaba.excel.EasyExcel;
import ***.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.***.URLEncoder;
import java.util.Arrays;
import java.util.List;

@RestController
public class CustomerController {
    @Resource
    private CustomerService customerService;

    @PostMapping(value = "/api/clue/customer")
    public Result transferCustomer(@RequestBody CustomerQuery customerQuery, @RequestHeader(value = Constants.TOKEN_NAME)String token){
        customerQuery.setToken(token);
        Boolean convert = customerService.convertCustomer(customerQuery);
        return convert ? Result.OK() : Result.FAIL();
    }
    @GetMapping(value = "/api/customers")
    public Result CustomersByPages(@RequestParam(value = Constants.CURRENT,required = false)Integer current){
        if(current == null){
            current = 1;
        }
        PageInfo<TCustomer> pageInfo = customerService.getCustomerByPage(current);
        return Result.OK(pageInfo);
    }
    @GetMapping(value = "/api/exportExcel")
    public void exportExcel(@RequestParam(value = Constants.IDS,required = false)String ids, HttpServletResponse response) throws IOException {
        List<String> idList = null;
        if(!ObjectUtils.isEmpty(ids)){
            idList = Arrays.asList(ids.split(","));
        }
        //要想让浏览器弹出下载框,后端要设置一下响应头信息
        response.setContentType("application/octet-stream");
        response.setCharacterEncoding(Constants.UTF_8);
        response.setHeader("X-Frame-Options", "allow-from uri");// 解决IFrame拒绝的问题
        response.setHeader("Content-disposition", "attachment;filename="+ URLEncoder.encode(Constants.CUSTOMER_FILE_NAME,Constants.UTF_8)+System.currentTimeMillis() +".xlsx");
        List<CustomerExcel> dataList = customerService.getCustomerByExcel(idList);
        EasyExcel.write(response.getOutputStream(), CustomerExcel.class)
                .sheet()
                .doWrite(dataList);
    }
}
<?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="***.alatus.mapper.TCustomerMapper">
  <resultMap id="BaseResultMap" type="***.alatus.model.TCustomer">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="clue_id" jdbcType="INTEGER" property="clueId" />
    <result column="product" jdbcType="INTEGER" property="product" />
    <result column="description" jdbcType="VARCHAR" property="description" />
    <result column="next_contact_time" jdbcType="TIMESTAMP" property="nextContactTime" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
    <result column="edit_time" jdbcType="TIMESTAMP" property="editTime" />
    <result column="edit_by" jdbcType="INTEGER" property="editBy" />
  </resultMap>

  <resultMap id="CustomerResultMap" type="***.alatus.model.TCustomer">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="clue_id" jdbcType="INTEGER" property="clueId" />
    <result column="product" jdbcType="INTEGER" property="product" />
    <result column="description" jdbcType="VARCHAR" property="description" />
    <result column="next_contact_time" jdbcType="TIMESTAMP" property="nextContactTime" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
    <result column="edit_time" jdbcType="TIMESTAMP" property="editTime" />
    <result column="edit_by" jdbcType="INTEGER" property="editBy" />
    <!--一对一关联线索-->
    <association property="clueDO" javaType="***.alatus.model.TClue">
      <id column="clueId" jdbcType="INTEGER" property="id" />
      <result column="full_name" jdbcType="VARCHAR" property="fullName" />
      <result column="phone" jdbcType="VARCHAR" property="phone" />
      <result column="weixin" jdbcType="VARCHAR" property="weixin" />
      <result column="qq" jdbcType="VARCHAR" property="qq" />
      <result column="email" jdbcType="VARCHAR" property="email" />
      <result column="age" jdbcType="INTEGER" property="age" />
      <result column="job" jdbcType="VARCHAR" property="job" />
      <result column="year_in***e" jdbcType="DECIMAL" property="yearIn***e" />
      <result column="address" jdbcType="VARCHAR" property="address" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="ownerDO" javaType="***.alatus.model.TUser">
      <id column="ownerId" jdbcType="INTEGER" property="id" />
      <result column="ownerName" jdbcType="VARCHAR" property="name" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="activityDO" javaType="***.alatus.model.TActivity">
      <id column="activityId" jdbcType="INTEGER" property="id" />
      <result column="activityName" jdbcType="VARCHAR" property="name" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="appellationDO" javaType="***.alatus.model.TDicValue">
      <id column="appellationId" jdbcType="INTEGER" property="id" />
      <result column="appellationName" jdbcType="VARCHAR" property="typeValue" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="needLoanDO" javaType="***.alatus.model.TDicValue">
      <id column="needLoanId" jdbcType="INTEGER" property="id" />
      <result column="needLoanName" jdbcType="VARCHAR" property="typeValue" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="intentionStateDO" javaType="***.alatus.model.TDicValue">
      <id column="intentionStateId" jdbcType="INTEGER" property="id" />
      <result column="intentionStateName" jdbcType="VARCHAR" property="typeValue" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="stateDO" javaType="***.alatus.model.TDicValue">
      <id column="stateId" jdbcType="INTEGER" property="id" />
      <result column="stateName" jdbcType="VARCHAR" property="typeValue" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="sourceDO" javaType="***.alatus.model.TDicValue">
      <id column="sourceId" jdbcType="INTEGER" property="id" />
      <result column="sourceName" jdbcType="VARCHAR" property="typeValue" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="intentionProductDO" javaType="***.alatus.model.TProduct">
      <id column="intentionProductId" jdbcType="INTEGER" property="id" />
      <result column="intentionProductName" jdbcType="VARCHAR" property="name" />
    </association>
  </resultMap>

  <sql id="Base_Column_List">
    id, clue_id, product, description, next_contact_time, create_time, create_by, edit_time, 
    edit_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_customer
    where id = #{id,jdbcType=INTEGER}
  </select>

  <select id="selectCustomerByPage" parameterType="java.lang.Integer" resultMap="CustomerResultMap">
    select
      tct.*,
      tc.id clueId, tc.full_name, tc.phone, tc.weixin,
      tu1.id ownerId, tu1.name ownerName,
      ta.id activityId, ta.name activityName,
      tdv.id appellationId, tdv.type_value appellationName,
      tdv2.id needLoanId, tdv2.type_value needLoanName,
      tdv3.id intentionStateId, tdv3.type_value intentionStateName,
      tdv4.id stateId, tdv4.type_value stateName,
      tdv5.id sourceId, tdv5.type_value sourceName,
      tp.id intentionProductId, tp.name intentionProductName
    from t_customer tct left join t_clue tc on tct.clue_id = tc.id
                        left join t_user tu1 on tc.owner_id = tu1.id
                        left join t_activity ta on tc.activity_id = ta.id
                        left join t_dic_value tdv on tc.appellation = tdv.id
                        left join t_dic_value tdv2 on tc.need_loan = tdv2.id
                        left join t_dic_value tdv3 on tc.intention_state = tdv3.id
                        left join t_dic_value tdv4 on tc.state = tdv4.id
                        left join t_dic_value tdv5 on tc.source = tdv5.id
                        left join t_product tp on tct.product = tp.id
  </select>

    <select id="selectCustomerByExcel" parameterType="java.util.List" resultMap="CustomerResultMap">
      select
        tct.*,
        tc.id clueId, tc.full_name, tc.phone, tc.weixin,tc.qq,tc.email,tc.age,tc.job,tc.address,tc.year_in***e,
        tu1.id ownerId, tu1.name ownerName,
        ta.id activityId, ta.name activityName,
        tdv.id appellationId, tdv.type_value appellationName,
        tdv2.id needLoanId, tdv2.type_value needLoanName,
        tdv3.id intentionStateId, tdv3.type_value intentionStateName,
        tdv4.id stateId, tdv4.type_value stateName,
        tdv5.id sourceId, tdv5.type_value sourceName,
        tp.id intentionProductId, tp.name intentionProductName
      from t_customer tct left join t_clue tc on tct.clue_id = tc.id
                          left join t_user tu1 on tc.owner_id = tu1.id
                          left join t_activity ta on tc.activity_id = ta.id
                          left join t_dic_value tdv on tc.appellation = tdv.id
                          left join t_dic_value tdv2 on tc.need_loan = tdv2.id
                          left join t_dic_value tdv3 on tc.intention_state = tdv3.id
                          left join t_dic_value tdv4 on tc.state = tdv4.id
                          left join t_dic_value tdv5 on tc.source = tdv5.id
                          left join t_product tp on tct.product = tp.id
      <where>
        <if test="idList != null and idList.size() > 0">
          and tct.id in
            <foreach collection="idList" item="id" open="(" close=")" separator=",">
              #{id}
            </foreach>
        </if>
      </where>
    </select>


    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_customer
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="***.alatus.model.TCustomer" useGeneratedKeys="true">
    insert into t_customer (clue_id, product, description, 
      next_contact_time, create_time, create_by, 
      edit_time, edit_by)
    values (#{clueId,jdbcType=INTEGER}, #{product,jdbcType=INTEGER}, #{description,jdbcType=VARCHAR}, 
      #{nextContactTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=INTEGER}, 
      #{editTime,jdbcType=TIMESTAMP}, #{editBy,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="***.alatus.model.TCustomer" useGeneratedKeys="true">
    insert into t_customer
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="clueId != null">
        clue_id,
      </if>
      <if test="product != null">
        product,
      </if>
      <if test="description != null">
        description,
      </if>
      <if test="nextContactTime != null">
        next_contact_time,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="editTime != null">
        edit_time,
      </if>
      <if test="editBy != null">
        edit_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="clueId != null">
        #{clueId,jdbcType=INTEGER},
      </if>
      <if test="product != null">
        #{product,jdbcType=INTEGER},
      </if>
      <if test="description != null">
        #{description,jdbcType=VARCHAR},
      </if>
      <if test="nextContactTime != null">
        #{nextContactTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=INTEGER},
      </if>
      <if test="editTime != null">
        #{editTime,jdbcType=TIMESTAMP},
      </if>
      <if test="editBy != null">
        #{editBy,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="***.alatus.model.TCustomer">
    update t_customer
    <set>
      <if test="clueId != null">
        clue_id = #{clueId,jdbcType=INTEGER},
      </if>
      <if test="product != null">
        product = #{product,jdbcType=INTEGER},
      </if>
      <if test="description != null">
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="nextContactTime != null">
        next_contact_time = #{nextContactTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=INTEGER},
      </if>
      <if test="editTime != null">
        edit_time = #{editTime,jdbcType=TIMESTAMP},
      </if>
      <if test="editBy != null">
        edit_by = #{editBy,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="***.alatus.model.TCustomer">
    update t_customer
    set clue_id = #{clueId,jdbcType=INTEGER},
      product = #{product,jdbcType=INTEGER},
      description = #{description,jdbcType=VARCHAR},
      next_contact_time = #{nextContactTime,jdbcType=TIMESTAMP},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_by = #{createBy,jdbcType=INTEGER},
      edit_time = #{editTime,jdbcType=TIMESTAMP},
      edit_by = #{editBy,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>
<?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="***.alatus.mapper.TCustomerMapper">
  <resultMap id="BaseResultMap" type="***.alatus.model.TCustomer">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="clue_id" jdbcType="INTEGER" property="clueId" />
    <result column="product" jdbcType="INTEGER" property="product" />
    <result column="description" jdbcType="VARCHAR" property="description" />
    <result column="next_contact_time" jdbcType="TIMESTAMP" property="nextContactTime" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
    <result column="edit_time" jdbcType="TIMESTAMP" property="editTime" />
    <result column="edit_by" jdbcType="INTEGER" property="editBy" />
  </resultMap>

  <resultMap id="CustomerResultMap" type="***.alatus.model.TCustomer">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="clue_id" jdbcType="INTEGER" property="clueId" />
    <result column="product" jdbcType="INTEGER" property="product" />
    <result column="description" jdbcType="VARCHAR" property="description" />
    <result column="next_contact_time" jdbcType="TIMESTAMP" property="nextContactTime" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
    <result column="edit_time" jdbcType="TIMESTAMP" property="editTime" />
    <result column="edit_by" jdbcType="INTEGER" property="editBy" />
    <!--一对一关联线索-->
    <association property="clueDO" javaType="***.alatus.model.TClue">
      <id column="clueId" jdbcType="INTEGER" property="id" />
      <result column="full_name" jdbcType="VARCHAR" property="fullName" />
      <result column="phone" jdbcType="VARCHAR" property="phone" />
      <result column="weixin" jdbcType="VARCHAR" property="weixin" />
      <result column="qq" jdbcType="VARCHAR" property="qq" />
      <result column="email" jdbcType="VARCHAR" property="email" />
      <result column="age" jdbcType="INTEGER" property="age" />
      <result column="job" jdbcType="VARCHAR" property="job" />
      <result column="year_in***e" jdbcType="DECIMAL" property="yearIn***e" />
      <result column="address" jdbcType="VARCHAR" property="address" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="ownerDO" javaType="***.alatus.model.TUser">
      <id column="ownerId" jdbcType="INTEGER" property="id" />
      <result column="ownerName" jdbcType="VARCHAR" property="name" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="activityDO" javaType="***.alatus.model.TActivity">
      <id column="activityId" jdbcType="INTEGER" property="id" />
      <result column="activityName" jdbcType="VARCHAR" property="name" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="appellationDO" javaType="***.alatus.model.TDicValue">
      <id column="appellationId" jdbcType="INTEGER" property="id" />
      <result column="appellationName" jdbcType="VARCHAR" property="typeValue" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="needLoanDO" javaType="***.alatus.model.TDicValue">
      <id column="needLoanId" jdbcType="INTEGER" property="id" />
      <result column="needLoanName" jdbcType="VARCHAR" property="typeValue" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="intentionStateDO" javaType="***.alatus.model.TDicValue">
      <id column="intentionStateId" jdbcType="INTEGER" property="id" />
      <result column="intentionStateName" jdbcType="VARCHAR" property="typeValue" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="stateDO" javaType="***.alatus.model.TDicValue">
      <id column="stateId" jdbcType="INTEGER" property="id" />
      <result column="stateName" jdbcType="VARCHAR" property="typeValue" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="sourceDO" javaType="***.alatus.model.TDicValue">
      <id column="sourceId" jdbcType="INTEGER" property="id" />
      <result column="sourceName" jdbcType="VARCHAR" property="typeValue" />
    </association>
    <!--一对一关联查询的映射-->
    <association property="intentionProductDO" javaType="***.alatus.model.TProduct">
      <id column="intentionProductId" jdbcType="INTEGER" property="id" />
      <result column="intentionProductName" jdbcType="VARCHAR" property="name" />
    </association>
  </resultMap>

  <sql id="Base_Column_List">
    id, clue_id, product, description, next_contact_time, create_time, create_by, edit_time, 
    edit_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_customer
    where id = #{id,jdbcType=INTEGER}
  </select>

  <select id="selectCustomerByPage" parameterType="java.lang.Integer" resultMap="CustomerResultMap">
    select
      tct.*,
      tc.id clueId, tc.full_name, tc.phone, tc.weixin,
      tu1.id ownerId, tu1.name ownerName,
      ta.id activityId, ta.name activityName,
      tdv.id appellationId, tdv.type_value appellationName,
      tdv2.id needLoanId, tdv2.type_value needLoanName,
      tdv3.id intentionStateId, tdv3.type_value intentionStateName,
      tdv4.id stateId, tdv4.type_value stateName,
      tdv5.id sourceId, tdv5.type_value sourceName,
      tp.id intentionProductId, tp.name intentionProductName
    from t_customer tct left join t_clue tc on tct.clue_id = tc.id
                        left join t_user tu1 on tc.owner_id = tu1.id
                        left join t_activity ta on tc.activity_id = ta.id
                        left join t_dic_value tdv on tc.appellation = tdv.id
                        left join t_dic_value tdv2 on tc.need_loan = tdv2.id
                        left join t_dic_value tdv3 on tc.intention_state = tdv3.id
                        left join t_dic_value tdv4 on tc.state = tdv4.id
                        left join t_dic_value tdv5 on tc.source = tdv5.id
                        left join t_product tp on tct.product = tp.id
  </select>

    <select id="selectCustomerByExcel" parameterType="java.util.List" resultMap="CustomerResultMap">
      select
        tct.*,
        tc.id clueId, tc.full_name, tc.phone, tc.weixin,tc.qq,tc.email,tc.age,tc.job,tc.address,tc.year_in***e,
        tu1.id ownerId, tu1.name ownerName,
        ta.id activityId, ta.name activityName,
        tdv.id appellationId, tdv.type_value appellationName,
        tdv2.id needLoanId, tdv2.type_value needLoanName,
        tdv3.id intentionStateId, tdv3.type_value intentionStateName,
        tdv4.id stateId, tdv4.type_value stateName,
        tdv5.id sourceId, tdv5.type_value sourceName,
        tp.id intentionProductId, tp.name intentionProductName
      from t_customer tct left join t_clue tc on tct.clue_id = tc.id
                          left join t_user tu1 on tc.owner_id = tu1.id
                          left join t_activity ta on tc.activity_id = ta.id
                          left join t_dic_value tdv on tc.appellation = tdv.id
                          left join t_dic_value tdv2 on tc.need_loan = tdv2.id
                          left join t_dic_value tdv3 on tc.intention_state = tdv3.id
                          left join t_dic_value tdv4 on tc.state = tdv4.id
                          left join t_dic_value tdv5 on tc.source = tdv5.id
                          left join t_product tp on tct.product = tp.id
      <where>
        <if test="idList != null and idList.size() > 0">
          and tct.id in
            <foreach collection="idList" item="id" open="(" close=")" separator=",">
              #{id}
            </foreach>
        </if>
      </where>
    </select>


    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_customer
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="***.alatus.model.TCustomer" useGeneratedKeys="true">
    insert into t_customer (clue_id, product, description, 
      next_contact_time, create_time, create_by, 
      edit_time, edit_by)
    values (#{clueId,jdbcType=INTEGER}, #{product,jdbcType=INTEGER}, #{description,jdbcType=VARCHAR}, 
      #{nextContactTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=INTEGER}, 
      #{editTime,jdbcType=TIMESTAMP}, #{editBy,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="***.alatus.model.TCustomer" useGeneratedKeys="true">
    insert into t_customer
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="clueId != null">
        clue_id,
      </if>
      <if test="product != null">
        product,
      </if>
      <if test="description != null">
        description,
      </if>
      <if test="nextContactTime != null">
        next_contact_time,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="editTime != null">
        edit_time,
      </if>
      <if test="editBy != null">
        edit_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="clueId != null">
        #{clueId,jdbcType=INTEGER},
      </if>
      <if test="product != null">
        #{product,jdbcType=INTEGER},
      </if>
      <if test="description != null">
        #{description,jdbcType=VARCHAR},
      </if>
      <if test="nextContactTime != null">
        #{nextContactTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=INTEGER},
      </if>
      <if test="editTime != null">
        #{editTime,jdbcType=TIMESTAMP},
      </if>
      <if test="editBy != null">
        #{editBy,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="***.alatus.model.TCustomer">
    update t_customer
    <set>
      <if test="clueId != null">
        clue_id = #{clueId,jdbcType=INTEGER},
      </if>
      <if test="product != null">
        product = #{product,jdbcType=INTEGER},
      </if>
      <if test="description != null">
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="nextContactTime != null">
        next_contact_time = #{nextContactTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=INTEGER},
      </if>
      <if test="editTime != null">
        edit_time = #{editTime,jdbcType=TIMESTAMP},
      </if>
      <if test="editBy != null">
        edit_by = #{editBy,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="***.alatus.model.TCustomer">
    update t_customer
    set clue_id = #{clueId,jdbcType=INTEGER},
      product = #{product,jdbcType=INTEGER},
      description = #{description,jdbcType=VARCHAR},
      next_contact_time = #{nextContactTime,jdbcType=TIMESTAMP},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_by = #{createBy,jdbcType=INTEGER},
      edit_time = #{editTime,jdbcType=TIMESTAMP},
      edit_by = #{editBy,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>
package ***.alatus.service;

import ***.alatus.model.TCustomer;
import ***.alatus.query.CustomerQuery;
import ***.alatus.result.CustomerExcel;
import ***.github.pagehelper.PageInfo;

import java.util.List;

public interface CustomerService {
    Boolean convertCustomer(CustomerQuery customerQuery);

    PageInfo<TCustomer> getCustomerByPage(Integer current);

    List<CustomerExcel> getCustomerByExcel(List<String> idList);
}
package ***.alatus.service;

import ***.alatus.model.TCustomer;
import ***.alatus.query.CustomerQuery;
import ***.alatus.result.CustomerExcel;
import ***.github.pagehelper.PageInfo;

import java.util.List;

public interface CustomerService {
    Boolean convertCustomer(CustomerQuery customerQuery);

    PageInfo<TCustomer> getCustomerByPage(Integer current);

    List<CustomerExcel> getCustomerByExcel(List<String> idList);
}
package ***.alatus.service.impl;

import ***.alatus.constant.Constants;
import ***.alatus.manager.CustomerManager;
import ***.alatus.mapper.TCustomerMapper;
import ***.alatus.model.TCustomer;
import ***.alatus.query.CustomerQuery;
import ***.alatus.result.CustomerExcel;
import ***.alatus.service.CustomerService;
import ***.github.pagehelper.PageHelper;
import ***.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {
    @Resource
    private TCustomerMapper tCustomerMapper;
    @Resource
    private CustomerManager customerManager;

    @Override
    public Boolean convertCustomer(CustomerQuery customerQuery) {
        return customerManager.transferCustomer(customerQuery);
    }

    @Override
    public PageInfo<TCustomer> getCustomerByPage(Integer current) {
//        设置PageHelper和分页情况
        PageHelper.startPage(current, Constants.PAGE_SIZE);
//        查询
        ArrayList<TCustomer> list = tCustomerMapper.selectCustomerByPage();
//        封装分页到PageInfo中
        PageInfo<TCustomer> info = new PageInfo<>(list);
        return info;
    }

    @Override
    public List<CustomerExcel> getCustomerByExcel(List<String> idList) {
        List<TCustomer> customers = tCustomerMapper.selectCustomerByExcel(idList);
//        把数据转为CustomerExcel
        List<CustomerExcel> customerExcelList = new ArrayList<>();
        customers.forEach(tCustomer -> {
            CustomerExcel customerExcel = new CustomerExcel();
            //需要一个一个设置,没有办法,因为没法使用BeanUtils复制
            customerExcel.setOwnerName(ObjectUtils.isEmpty(tCustomer.getOwnerDO()) ? Constants.EMPTY : tCustomer.getOwnerDO().getName());
            customerExcel.setActivityName(ObjectUtils.isEmpty(tCustomer.getActivityDO()) ? Constants.EMPTY : tCustomer.getActivityDO().getName());
            customerExcel.setFullName(tCustomer.getClueDO().getFullName());
            customerExcel.setAppellationName(ObjectUtils.isEmpty(tCustomer.getAppellationDO()) ? Constants.EMPTY : tCustomer.getAppellationDO().getTypeValue());
            customerExcel.setPhone(ObjectUtils.isEmpty(tCustomer.getClueDO().getPhone()) ? Constants.EMPTY :tCustomer.getClueDO().getPhone());
            customerExcel.setWeixin(ObjectUtils.isEmpty(tCustomer.getClueDO().getWeixin()) ? Constants.EMPTY :tCustomer.getClueDO().getWeixin());
            customerExcel.setQq(ObjectUtils.isEmpty(tCustomer.getClueDO().getQq()) ? Constants.EMPTY :tCustomer.getClueDO().getQq());
            customerExcel.setEmail(ObjectUtils.isEmpty(tCustomer.getClueDO().getEmail()) ? Constants.EMPTY :tCustomer.getClueDO().getEmail());
            customerExcel.setAge(ObjectUtils.isEmpty(tCustomer.getClueDO().getAge()) ? 0 :tCustomer.getClueDO().getAge());
            customerExcel.setJob(ObjectUtils.isEmpty(tCustomer.getClueDO().getJob()) ? Constants.EMPTY :tCustomer.getClueDO().getJob());
            customerExcel.setYearIn***e(ObjectUtils.isEmpty(tCustomer.getClueDO().getYearIn***e()) ? new BigDecimal(0) : tCustomer.getClueDO().getYearIn***e());
            customerExcel.setAddress(ObjectUtils.isEmpty(tCustomer.getClueDO().getAddress()) ? Constants.EMPTY : tCustomer.getClueDO().getAddress());
            customerExcel.setNeedLoadName(ObjectUtils.isEmpty(tCustomer.getNeedLoanDO().getTypeValue()) ? Constants.EMPTY : tCustomer.getNeedLoanDO().getTypeValue());
            customerExcel.setProductName(ObjectUtils.isEmpty(tCustomer.getIntentionProductDO().getName()) ? Constants.EMPTY : tCustomer.getIntentionProductDO().getName());
            customerExcel.setSourceName(ObjectUtils.isEmpty(tCustomer.getSourceDO().getTypeValue()) ? Constants.EMPTY : tCustomer.getSourceDO().getTypeValue());
            customerExcel.setDescription(tCustomer.getDescription());
            customerExcel.setNextContactTime(tCustomer.getNextContactTime());
            customerExcelList.add(customerExcel);
        });
        return customerExcelList;
    }
}

package ***.alatus.service.impl;

import ***.alatus.constant.Constants;
import ***.alatus.manager.CustomerManager;
import ***.alatus.mapper.TCustomerMapper;
import ***.alatus.model.TCustomer;
import ***.alatus.query.CustomerQuery;
import ***.alatus.result.CustomerExcel;
import ***.alatus.service.CustomerService;
import ***.github.pagehelper.PageHelper;
import ***.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {
    @Resource
    private TCustomerMapper tCustomerMapper;
    @Resource
    private CustomerManager customerManager;

    @Override
    public Boolean convertCustomer(CustomerQuery customerQuery) {
        return customerManager.transferCustomer(customerQuery);
    }

    @Override
    public PageInfo<TCustomer> getCustomerByPage(Integer current) {
//        设置PageHelper和分页情况
        PageHelper.startPage(current, Constants.PAGE_SIZE);
//        查询
        ArrayList<TCustomer> list = tCustomerMapper.selectCustomerByPage();
//        封装分页到PageInfo中
        PageInfo<TCustomer> info = new PageInfo<>(list);
        return info;
    }

    @Override
    public List<CustomerExcel> getCustomerByExcel(List<String> idList) {
        List<TCustomer> customers = tCustomerMapper.selectCustomerByExcel(idList);
//        把数据转为CustomerExcel
        List<CustomerExcel> customerExcelList = new ArrayList<>();
        customers.forEach(tCustomer -> {
            CustomerExcel customerExcel = new CustomerExcel();
            //需要一个一个设置,没有办法,因为没法使用BeanUtils复制
            customerExcel.setOwnerName(ObjectUtils.isEmpty(tCustomer.getOwnerDO()) ? Constants.EMPTY : tCustomer.getOwnerDO().getName());
            customerExcel.setActivityName(ObjectUtils.isEmpty(tCustomer.getActivityDO()) ? Constants.EMPTY : tCustomer.getActivityDO().getName());
            customerExcel.setFullName(tCustomer.getClueDO().getFullName());
            customerExcel.setAppellationName(ObjectUtils.isEmpty(tCustomer.getAppellationDO()) ? Constants.EMPTY : tCustomer.getAppellationDO().getTypeValue());
            customerExcel.setPhone(ObjectUtils.isEmpty(tCustomer.getClueDO().getPhone()) ? Constants.EMPTY :tCustomer.getClueDO().getPhone());
            customerExcel.setWeixin(ObjectUtils.isEmpty(tCustomer.getClueDO().getWeixin()) ? Constants.EMPTY :tCustomer.getClueDO().getWeixin());
            customerExcel.setQq(ObjectUtils.isEmpty(tCustomer.getClueDO().getQq()) ? Constants.EMPTY :tCustomer.getClueDO().getQq());
            customerExcel.setEmail(ObjectUtils.isEmpty(tCustomer.getClueDO().getEmail()) ? Constants.EMPTY :tCustomer.getClueDO().getEmail());
            customerExcel.setAge(ObjectUtils.isEmpty(tCustomer.getClueDO().getAge()) ? 0 :tCustomer.getClueDO().getAge());
            customerExcel.setJob(ObjectUtils.isEmpty(tCustomer.getClueDO().getJob()) ? Constants.EMPTY :tCustomer.getClueDO().getJob());
            customerExcel.setYearIn***e(ObjectUtils.isEmpty(tCustomer.getClueDO().getYearIn***e()) ? new BigDecimal(0) : tCustomer.getClueDO().getYearIn***e());
            customerExcel.setAddress(ObjectUtils.isEmpty(tCustomer.getClueDO().getAddress()) ? Constants.EMPTY : tCustomer.getClueDO().getAddress());
            customerExcel.setNeedLoadName(ObjectUtils.isEmpty(tCustomer.getNeedLoanDO().getTypeValue()) ? Constants.EMPTY : tCustomer.getNeedLoanDO().getTypeValue());
            customerExcel.setProductName(ObjectUtils.isEmpty(tCustomer.getIntentionProductDO().getName()) ? Constants.EMPTY : tCustomer.getIntentionProductDO().getName());
            customerExcel.setSourceName(ObjectUtils.isEmpty(tCustomer.getSourceDO().getTypeValue()) ? Constants.EMPTY : tCustomer.getSourceDO().getTypeValue());
            customerExcel.setDescription(tCustomer.getDescription());
            customerExcel.setNextContactTime(tCustomer.getNextContactTime());
            customerExcelList.add(customerExcel);
        });
        return customerExcelList;
    }
}

package ***.alatus.mapper;

import ***.alatus.model.TCustomer;

import java.util.ArrayList;
import java.util.List;

public interface TCustomerMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(TCustomer record);

    int insertSelective(TCustomer record);

    TCustomer selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(TCustomer record);

    int updateByPrimaryKey(TCustomer record);

    ArrayList<TCustomer> selectCustomerByPage();

    List<TCustomer> selectCustomerByExcel(List<String> idList);
}
package ***.alatus.mapper;

import ***.alatus.model.TCustomer;

import java.util.ArrayList;
import java.util.List;

public interface TCustomerMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(TCustomer record);

    int insertSelective(TCustomer record);

    TCustomer selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(TCustomer record);

    int updateByPrimaryKey(TCustomer record);

    ArrayList<TCustomer> selectCustomerByPage();

    List<TCustomer> selectCustomerByExcel(List<String> idList);
}
转载请说明出处内容投诉
CSS教程_站长资源网 » CRM项目后端根据已有业务逻辑用户转为Excel优化实现可根据前端提交转换------CRM项目

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买