zhangjinli 3 years ago
parent 3e377f220a
commit fbf1e21fc5

@ -720,7 +720,7 @@ public class TaskController {
qw.like(param.getTel() != null, "t1.tel", param.getTel()); qw.like(param.getTel() != null, "t1.tel", param.getTel());
qw.like(param.getBrand() != null, "t1.brandList", param.getBrand()); qw.like(param.getBrand() != null, "t1.brandList", param.getBrand());
qw.like(param.getProviderName() != null, "t2.name", param.getProviderName()); qw.like(param.getProviderName() != null, "t2.name", param.getProviderName());
qw.eq(param.getDepartmentId() != null, "t4.departmentId", param.getDepartmentId()); qw.inSql(param.getDepartmentId() != null,"t2.openid","SELECT openid from qywxDepartmentUserLink WHERE qywxDepartmentUserLink.departmentId = "+param.getDepartmentId());
IPage<Map> iPage = customerActionNoteService.pageList(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()), null, qw); IPage<Map> iPage = customerActionNoteService.pageList(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()), null, qw);
List<Map> records = iPage.getRecords(); List<Map> records = iPage.getRecords();
for (Map m : records) { for (Map m : records) {

@ -18,6 +18,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -33,6 +34,7 @@ import java.io.OutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -96,9 +98,9 @@ public class UserController {
public void excel(HttpServletResponse response, @Validated @RequestBody UParam param) throws IOException { public void excel(HttpServletResponse response, @Validated @RequestBody UParam param) throws IOException {
//这是表头及格式 //这是表头及格式
String[][] array = { String[][] array = {
{"员工", "部门", "上级部门", "手机号", "积分", "历史积分", "创建时间", "上次登录"}, {"员工", "部门", "上级部门","部门列表", "手机号", "积分", "历史积分", "创建时间", "上次登录"},
{"name", "main_departmentName", "sub_departmentName", "tel", "points", "historyPoints", "creatAt", "lastLoginAt"}, {"name", "main_departmentName", "sub_departmentName", "departmentList","tel", "points", "historyPoints", "creatAt", "lastLoginAt"},
{"String", "String", "String", "String", "int", "int", "LocalDateTime", "LocalDateTime"} {"String", "String", "String", "String","String", "int", "int", "LocalDateTime", "LocalDateTime"}
}; };
QueryWrapper<User> qw = new QueryWrapper<>(); QueryWrapper<User> qw = new QueryWrapper<>();
qw qw
@ -106,8 +108,15 @@ public class UserController {
.or(o -> o.like("t3.name", param.getDepartment()))) .or(o -> o.like("t3.name", param.getDepartment())))
.like(param.getName() != null, "t1.name", param.getName()); .like(param.getName() != null, "t1.name", param.getName());
IPage<Map> iPage = userService.userDpList(MybatisPlusUtil.SetNumPage(1, 10000), qw); IPage<Map> iPage = userService.userDpList(MybatisPlusUtil.SetNumPage(1, 10000), qw);
List<Map> records = iPage.getRecords();
Workbook wb = ExcelUtil.writeToExcelByList(array, iPage.getRecords()); for (Map map:records){
List<HashMap> departmentList = (List) map.get("departmentList");
StringBuffer s = new StringBuffer();
departmentList.forEach(v->s.append(v.get("departmentName")+""));
String s1 = s.toString();
map.replace("departmentList", StringUtils.isBlank(s)?"":(s1.substring(0, s1.length()-1)));
}
Workbook wb = ExcelUtil.writeToExcelByList(array,records );
OutputStream output = response.getOutputStream(); OutputStream output = response.getOutputStream();
String fileName = "成员导出.xlsx"; String fileName = "成员导出.xlsx";
try { try {

@ -25,23 +25,24 @@ public interface CustomerActionNoteMapper extends BaseMapper<CustomerActionNote>
"select ( #{provideId}, #{area}, #{creatAt}, #{brandList}, #{tel}, #{taskId}, #{remarks}, #{customerName} ) " + "select ( #{provideId}, #{area}, #{creatAt}, #{brandList}, #{tel}, #{taskId}, #{remarks}, #{customerName} ) " +
"WHERE not EXISTS (SELECT 1 FROM user WHERE tel =#{tel}) ") "WHERE not EXISTS (SELECT 1 FROM user WHERE tel =#{tel}) ")
void add(CustomerActionNote customerActionNote); void add(CustomerActionNote customerActionNote);
@Select("<script> " + // @Select("<script> " +
"select t1.*,t2.name as provideName,t3.title as taskTitle, t4.departmentId,t4.name as departmentName\n" + // "select t1.*,t2.name as provideName,t3.title as taskTitle, t4.departmentId,t4.department as departmentName\n" +
"from customerActionNote as t1\n" + // "from customerActionNote as t1\n" +
"LEFT JOIN user as t2 on t1.provideId = t2.id\n" + // "LEFT JOIN user as t2 on t1.provideId = t2.id\n" +
"LEFT JOIN qywxDepartment as t4 on t4.departmentId = t2.main_department\n" + //// "LEFT JOIN qywxDepartment as t4 on t4.departmentId = t2.main_department\n" +
"LEFT JOIN task as t3 on t1.taskId = t3.id\n" + // "LEFT JOIN (SELECT t.*,d.name as department from qywxDepartmentUserLink t left join qywxDepartment d on t.departmentId = d.departmentId) as t4 on t4.openid = t2.openid\n"+
"where 1=1 "+ // "LEFT JOIN task as t3 on t1.taskId = t3.id\n" +
"<if test='openid!=null'>and t2.openid =#{openid} </if>" + // "where 1=1 "+
// "<if test='openid!=null'>and t2.openid =#{openid} </if>" +
"<if test='ew != null'>" + //
"<if test='ew.nonEmptyOfWhere'>" + // "<if test='ew != null'>" +
"AND " + // "<if test='ew.nonEmptyOfWhere'>" +
"</if> " + // "AND " +
"${ew.SqlSegment}" + // "</if> " +
"</if> " + // "${ew.SqlSegment}" +
// "</if> " +
"order by t1.creatAt desc"+ //
"</script>") // "order by t1.creatAt desc"+
// "</script>")
IPage<Map> pageList(IPage page,String openid, @Param("ew") Wrapper<CustomerActionNote> queryWrapper); IPage<Map> pageList(IPage page,String openid, @Param("ew") Wrapper<CustomerActionNote> queryWrapper);
} }

@ -32,7 +32,7 @@ public interface UserMapper extends BaseMapper<User> {
void updByOpenid(String openid, String token, LocalDateTime time); void updByOpenid(String openid, String token, LocalDateTime time);
// @Select("SELECT t1.id,t1.name,t1.tel,t1.avatar,t1.main_department,t1.sub_department,t1.points,t1.historyPoints,t1.creatAt,t1.updateAt,t1.lastLoginAt" + // @Select("SELECT t1.id,t1.name,t1.tel,t1.avatar,t1.main_department,t1.sub_department,t1.points,t1.historyPoints,t1.creatAt,t1.updateAt,t1.lastLoginAt" +
// ",t2.name as main_departmentName,t3.name as sub_departmentName,t4.department " + // ",t2.name as main_departmentName,t3.name as sub_departmentName,t4.departmentId as dpId,t4.department " +
// "from user as t1 " + // "from user as t1 " +
// "left join qywxDepartment as t2 on t1.main_department = t2.departmentId " + // "left join qywxDepartment as t2 on t1.main_department = t2.departmentId " +
// "left join qywxDepartment as t3 on t1.sub_department = t3.departmentId " + // "left join qywxDepartment as t3 on t1.sub_department = t3.departmentId " +

@ -0,0 +1,42 @@
<?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.zh.project0512.mapper.CustomerActionNoteMapper">
<resultMap id="pageList" type="java.util.Map" autoMapping="false">
<id property="id" column="id"/>
<result column="customerName" property="customerName"/>
<result column="tel" property="tel"/>
<result column="area" property="area"/>
<result column="brandList" property="brandList"/>
<result column="remarks" property="remarks"/>
<result column="provideId" property="provideId"/>
<result column="taskId" property="taskId"/>
<result column="creatAt" property="creatAt"/>
<result column="provideName" property="provideName"/>
<result column="taskTitle" property="taskTitle"/>
<result column="departmentId" property="departmentId"/>
<result column="departmentName" property="departmentName"/>
<collection property="departmentList" ofType="java.util.Map" javaType="java.util.List" autoMapping="false">
<id column="dpId" property="id"/>
<result column="department" property="departmentName"/>
</collection>
</resultMap>
<select id="pageList" resultMap="pageList">
select t1.*,t2.name as provideName,t3.title as taskTitle,t4.departmentId,t4.name as departmentName,t5.departmentId as dpId,t5.department
from customerActionNote as t1
LEFT JOIN user as t2 on t1.provideId = t2.id
LEFT JOIN qywxDepartment as t4 on t4.departmentId = t2.main_department
LEFT JOIN (SELECT t.*,d.name as department from qywxDepartmentUserLink t left join qywxDepartment d on t.departmentId = d.departmentId) as t5 on t5.openid = t2.openid
LEFT JOIN task as t3 on t1.taskId = t3.id
where 1=1
<if test='openid!=null'>and t2.openid =#{openid} </if>
<if test='ew != null'>
<if test='ew.nonEmptyOfWhere'>
AND
</if>
${ew.SqlSegment}
</if>
order by t1.creatAt desc
</select>
</mapper>
Loading…
Cancel
Save