zhangjinli 3 years ago
parent c663bd76ea
commit 5a0bbed254

@ -44,6 +44,7 @@ import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* <p>
@ -168,63 +169,63 @@ public class UtilsController {
@PostMapping("/test")
@ResponseBody
public Result test() {
String url ="http://www.baidu.com/#wd=%E6%88%91%E6%98%AF%E6%AD%8C%E6%89%8B&rsv_bp=0&tn=baidu&rsv_spt=3&ie=utf-8&rsv_sug3=11&rsv_sug4=643&rsv_sug1=11&inputT=5484&rsv_sug2=0";
Pattern p = Pattern.compile("(http://|https://)?([^/]*)",Pattern.CASE_INSENSITIVE);
String url = "http://www.baidu.com/#wd=%E6%88%91%E6%98%AF%E6%AD%8C%E6%89%8B&rsv_bp=0&tn=baidu&rsv_spt=3&ie=utf-8&rsv_sug3=11&rsv_sug4=643&rsv_sug1=11&inputT=5484&rsv_sug2=0";
Pattern p = Pattern.compile("(http://|https://)?([^/]*)", Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(url);
String a= m.find()?m.group(2):url;
String a = m.find() ? m.group(2) : url;
// (https://)+\S*\s
return Result.success(a);
}
public static void main(String[] args) {
// String url ="9.20 tRK:/ 男人第一天上班就被当成修电脑的,谁知他竟然是总经理%好剧推荐 %全集解说%幸福一家人%关于爱情%宅家dou剧 %持续关注持续精彩 https://v.kuaishou.com/Yh4DwM9/ 复制此链接打开Dou音搜索直接观看视频";
// Pattern p = Pattern.compile("((https://)+\\S*\\s)",Pattern.CASE_INSENSITIVE);
// String url = "9.20 tRK:/ 男人第一天上班就被当成修电脑的,谁知他竟然是总经理%好剧推荐 %全集解说%幸福一家人%关于爱情%宅家dou剧 %持续关注持续精彩 https://v.kuaishou.com/Yh4DwM9/ 复制此链接打开Dou音搜索直接观看视频";
// Pattern p = Pattern.compile("((https://)+\\S*\\s)", Pattern.CASE_INSENSITIVE);
//
// Matcher m = p.matcher(url);
//System.out.println(m);
// String a= m.find()?m.group(1):url;
// System.out.println(m);
// String a = m.find() ? m.group(1) : url;
// System.out.println(a);
// int b = StringUtils.countOccurrencesOf(a,"https://v.douyin");
// int b = StringUtils.countOccurrencesOf(a, "https://v.douyin");
// System.out.println(b);
//
// List<String> list1 = new ArrayList<String>();
// list1.add("1");
// list1.add("2");
// list1.add("3");
// list1.add("5");
// list1.add("6");
// List<String> list2 = new ArrayList<String>();
// list2.add("2");
// list2.add("3");
// list2.add("7");
// list2.add("8");
//// 交集
// List<String> intersection = list1.stream().filter(item -> list2.contains(item)).collect(toList());
// System.out.println("---交集 intersection---");
// intersection.parallelStream().forEach(System.out :: println);
//// 差集 (list1 - list2)
// List<String> reduce1 = list1.stream().filter(item -> !list2.contains(item)).collect(toList());
// System.out.println("---差集 reduce1 (list1 - list2)---");
// reduce1.parallelStream().forEach(System.out :: println);
//// 差集 (list2 - list1)
// List<String> reduce2 = list2.stream().filter(item -> !list1.contains(item)).collect(toList());
// System.out.println("---差集 reduce2 (list2 - list1)---");
// reduce2.parallelStream().forEach(System.out :: println);
//// 并集
// List<String> listAll = list1.parallelStream().collect(toList());
// List<String> listAll2 = list2.parallelStream().collect(toList());
// listAll.addAll(listAll2);
// System.out.println("---并集 listAll---");
// listAll.parallelStream().forEachOrdered(System.out :: println);
//// 去重并集
// List<String> listAllDistinct = listAll.stream().distinct().collect(toList());
// System.out.println("---得到去重并集 listAllDistinct---");
// listAllDistinct.parallelStream().forEachOrdered(System.out :: println);
// System.out.println("---原来的List1---");
// list1.parallelStream().forEachOrdered(System.out :: println);
// System.out.println("---原来的List2---");
// list2.parallelStream().forEachOrdered(System.out :: println);
List<String> list1 = new ArrayList<String>();
list1.add("1");
list1.add("2");
list1.add("3");
list1.add("5");
list1.add("6");
List<String> list2 = new ArrayList<String>();
list2.add("2");
list2.add("3");
list2.add("7");
list2.add("8");
// 交集
List<String> intersection = list1.stream().filter(item -> list2.contains(item)).collect(Collectors.toList());
System.out.println("---交集 intersection---");
intersection.parallelStream().forEach(System.out::println);
// 差集 (list1 - list2)
List<String> reduce1 = list1.stream().filter(item -> !list2.contains(item)).collect(Collectors.toList());
System.out.println("---差集 reduce1 (list1 - list2)---");
reduce1.parallelStream().forEach(System.out::println);
// 差集 (list2 - list1)
List<String> reduce2 = list2.stream().filter(item -> !list1.contains(item)).collect(Collectors.toList());
System.out.println("---差集 reduce2 (list2 - list1)---");
reduce2.parallelStream().forEach(System.out::println);
// 并集
List<String> listAll = list1.parallelStream().collect(Collectors.toList());
List<String> listAll2 = list2.parallelStream().collect(Collectors.toList());
listAll.addAll(listAll2);
System.out.println("---并集 listAll---");
listAll.parallelStream().forEachOrdered(System.out::println);
// 去重并集
List<String> listAllDistinct = listAll.stream().distinct().collect(Collectors.toList());
System.out.println("---得到去重并集 listAllDistinct---");
listAllDistinct.parallelStream().forEachOrdered(System.out::println);
System.out.println("---原来的List1---");
list1.parallelStream().forEachOrdered(System.out::println);
System.out.println("---原来的List2---");
list2.parallelStream().forEachOrdered(System.out::println);
}
}

@ -23,7 +23,6 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@ -39,6 +38,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
@ -116,7 +116,7 @@ public class TaskController {
}
List departmentGroupList = task.getDepartmentGroupList();
if (departmentGroupList != null && departmentGroupList.size() > 0) {
List departmentIdList = qywxDepartmentGroupLinkService.departmentIdList(null,departmentGroupList);
List departmentIdList = qywxDepartmentGroupLinkService.departmentIdList(null, departmentGroupList);
taskDepartmentService.addGroup(departmentIdList, id);
}
// 上传任务时同时上传素材
@ -317,17 +317,87 @@ public class TaskController {
@PostMapping("/upd")
@AdminTokenValid
public Result upd(@Validated(TaskValidGroup2.class) @RequestBody Task task) {
if (LocalDateTime.now().isAfter(task.getStart())) {
if (task.getStart() != null && LocalDateTime.now().isAfter(task.getStart())) {
task.setStatus(1);
}
int id = task.getId();
List tagList = task.getTagList();
// List<Map> tagList = taskTagService.selByTaskId(id);
// 添加任务标签
List tagIdList = task.getTagList();
if(tagIdList !=null){
if(tagIdList.size()== 0){
taskTagService.remove(new QueryWrapper<TaskTag>().eq("taskId", id));
}else{
List<Map> tagListOri = taskTagService.selByTaskId(id);
taskTagService.remove(new QueryWrapper<TaskTag>().eq("taskId", id).notIn((tagIdList!=null&&tagIdList.size()!=0),"tagId", tagIdList));
List tagIdListOri = new ArrayList();
for (Map map : tagListOri) {
tagIdListOri.add(map.get("id"));
}
List collect = (List) tagIdList.stream().filter(item -> !tagIdListOri.contains(item)).collect(Collectors.toList());
if (collect != null && collect.size() != 0) {
taskTagService.addGroup(collect, id);
}
}
}
// 添加任务品牌
List brandIdList = task.getBrandList();
if(brandIdList !=null){
if(brandIdList.size()== 0){
taskBrandService.remove(new QueryWrapper<TaskBrand>().eq("taskId", id));
}else{
List<Map> brandListOri = taskBrandService.selByTaskId(id);
taskBrandService.remove(new QueryWrapper<TaskBrand>().eq("taskId", id).notIn((brandIdList!=null&&brandIdList.size()!=0),"brandId", brandIdList));
List brandIdListOri = new ArrayList();
for (Map map : brandListOri) {
brandIdListOri.add(map.get("id"));
}
List collect = (List) brandIdList.stream().filter(item -> !brandIdListOri.contains(item)).collect(Collectors.toList());
if (collect != null && collect.size() != 0) {
taskBrandService.addGroup(collect, id);
}
}
}
List dpIdList = new ArrayList();
List<Integer> departmentIdList = task.getDepartmentList();
if (departmentIdList != null && departmentIdList.size() > 0) {
for (Integer e : departmentIdList) {
dpIdList.add(e);
}
}
List departmentGroupList = task.getDepartmentGroupList();
if (departmentGroupList != null && departmentGroupList.size() > 0) {
List<Integer> departmentIdList1 = qywxDepartmentGroupLinkService.departmentIdList(null, departmentGroupList);
if (departmentIdList != null && departmentIdList.size() > 0) {
for (Integer e : departmentIdList1) {
dpIdList.add(e);
}
}
}
if(dpIdList !=null){
if(dpIdList.size()== 0){
taskDepartmentService.remove(new QueryWrapper<TaskDepartment>().eq("taskId", id));
}else{
List<TaskDepartment> departmentListOri = taskDepartmentService.list(new QueryWrapper<TaskDepartment>().eq("taskId",task.getId()));
taskDepartmentService.remove(new QueryWrapper<TaskDepartment>().eq("taskId", id).notIn((dpIdList!=null&&dpIdList.size()!=0),"brandId", departmentIdList));
List departmentIdListOri = new ArrayList();
for (TaskDepartment taskDepartment : departmentListOri) {
departmentIdListOri.add(taskDepartment.getDepartmentId());
}
List collect = (List) dpIdList.stream().filter(item -> !departmentIdListOri.contains(item)).collect(Collectors.toList());
if (collect != null && collect.size() != 0) {
taskDepartmentService.addGroup(collect, id);
}
}
}
return Result.success();
// if (tagList != null && tagList.size() > 0) {
// taskTagService.addGroup(tagList, id);
// }
task.setUpdateAt(LocalDateTime.now());
return MybatisPlusUtil.sqlResult(taskService.updateById(task), "修改");
// task.setUpdateAt(LocalDateTime.now());
// return MybatisPlusUtil.sqlResult(taskService.updateById(task), "修改");
}
// @Operation(summary = "删除")
@ -467,10 +537,10 @@ public class TaskController {
@AdminTokenValid
public void excel(HttpServletResponse response, @Validated @RequestBody DetTaskParam param) throws IOException {
//这是表头及格式
String[][] array ={
{"任务名称", "员工姓名","部门","播放数","点赞数","收藏数","评论数","转发数","推荐数","传播值"},
{"taskTitle", "userName","departmentName","playNumSum","commendNumSum","collectionNumSum","commentNumSum","reSendNumSum","recommendNumSum","effectResultSum"},
{"String", "String","String","int","int","int","int","int","int","int"}
String[][] array = {
{"任务名称", "员工姓名", "部门", "播放数", "点赞数", "收藏数", "评论数", "转发数", "推荐数", "传播值"},
{"taskTitle", "userName", "departmentName", "playNumSum", "commendNumSum", "collectionNumSum", "commentNumSum", "reSendNumSum", "recommendNumSum", "effectResultSum"},
{"String", "String", "String", "int", "int", "int", "int", "int", "int", "int"}
};
QueryWrapper<Task> qw = new QueryWrapper<>();
qw.eq("t2.id", param.getId()).groupBy("t1.userId");
@ -528,12 +598,12 @@ public class TaskController {
@Operation(summary = "导出用户线索excel", description = "用户线索")
@PostMapping("/cnExcel")
// @AdminTokenValid
public void cnExcel(HttpServletResponse response,@RequestBody CNListParam param) throws IOException {
public void cnExcel(HttpServletResponse response, @RequestBody CNListParam param) throws IOException {
//这是表头及格式
String[][] array ={
{"姓名", "手机号","地区","关注车型","备注","关联任务","提交人","部门"},
{"customerName", "tel","area","brandList","remarks","taskTitle","provideName","departmentName"},
{"String", "String","String","String","String","String","String","String","String","String"}
String[][] array = {
{"姓名", "手机号", "地区", "关注车型", "备注", "关联任务", "提交人", "部门"},
{"customerName", "tel", "area", "brandList", "remarks", "taskTitle", "provideName", "departmentName"},
{"String", "String", "String", "String", "String", "String", "String", "String", "String", "String"}
};
QueryWrapper<CustomerActionNote> qw = new QueryWrapper<>();
qw.like(param.getName() != null, "t1.customerName", param.getName());
@ -541,7 +611,7 @@ public class TaskController {
qw.like(param.getBrand() != null, "t1.brandList", param.getBrand());
qw.like(param.getProviderName() != null, "t2.name", param.getProviderName());
qw.eq(param.getDepartmentId() != null, "t4.departmentId", param.getDepartmentId());
IPage<Map> iPage = customerActionNoteService.pageList(MybatisPlusUtil.SetNumPage(1,10000), null, qw);
IPage<Map> iPage = customerActionNoteService.pageList(MybatisPlusUtil.SetNumPage(1, 10000), null, qw);
List<Map> records = iPage.getRecords();
Workbook wb = ExcelUtil.writeToExcelByList(array, records);
OutputStream output = response.getOutputStream();

@ -94,6 +94,7 @@ public class Task extends Model {
/**
* id
*/
@NotNull(message = "请输入奖励模版id",groups = {TaskValidGroup1.class})
@Schema(title="奖励模版id")
@TableField("rewardRuleTemplateId")
private Integer rewardRuleTemplateId;

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zh.project0512.model.Reference;
import com.zh.project0512.model.Task;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zh.project0512.model.vo.FileUploadParamVo;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.formula.functions.T;
@ -28,4 +29,9 @@ public interface ITaskService extends IService<Task> {
JSONObject taskEffect(@Param("ew") Wrapper<Task> queryWrapper);
List<Map> taskEffectData(@Param("ew") Wrapper<Task> queryWrapper);
List<Map> taskDepartment(int taskId);
// 上传任务时同时上传素材
Boolean upReferenceInTask(Task task, List<Integer> referenceList, List<FileUploadParamVo> referenceUrlList) ;
// 上传任务的通用教程
Boolean upTeachRefeInTask(Task task,List<Integer> teachRefeList, List<FileUploadParamVo> teachRefeUrlList);
}

@ -3,16 +3,23 @@ package com.zh.project0512.serviceImpl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zh.project0512.mapper.ReferenceMapper;
import com.zh.project0512.model.Reference;
import com.zh.project0512.model.Task;
import com.zh.project0512.mapper.TaskMapper;
import com.zh.project0512.service.ITaskService;
import com.zh.project0512.model.TaskTeachRefe;
import com.zh.project0512.model.TeachingRefe;
import com.zh.project0512.model.vo.FileUploadParamVo;
import com.zh.project0512.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zh.project0512.utils.FileTypeUtil;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -28,26 +35,99 @@ import java.util.Map;
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements ITaskService {
@Autowired
private TaskMapper taskMapper;
@Autowired
private IReferenceService referenceService;
@Autowired
private ITaskReferenceService taskReferenceService;
@Autowired
private ITeachingRefeService teachingRefeService;
@Autowired
private ITaskTeachRefeService taskTeachRefeService;
public void add(Task task) {
taskMapper.add(task);
}
public IPage<Integer> idList(IPage iPage,String openid, List<Integer> tagIdList, List<Integer> brandIdList, @Param("ew") Wrapper<Reference> queryWrapper){
return taskMapper.idList(iPage,openid,tagIdList,brandIdList,queryWrapper);
public IPage<Integer> idList(IPage iPage, String openid, List<Integer> tagIdList, List<Integer> brandIdList, @Param("ew") Wrapper<Reference> queryWrapper) {
return taskMapper.idList(iPage, openid, tagIdList, brandIdList, queryWrapper);
}
public List<Map> list(String openid,List<Integer> list, List<Integer> tagIdList, List<Integer> brandIdList, @Param("ew") Wrapper<Reference> queryWrapper){
return taskMapper.list(openid,list,tagIdList,brandIdList,queryWrapper);
public List<Map> list(String openid, List<Integer> list, List<Integer> tagIdList, List<Integer> brandIdList, @Param("ew") Wrapper<Reference> queryWrapper) {
return taskMapper.list(openid, list, tagIdList, brandIdList, queryWrapper);
}
public Task detailById(String openid,int id){
return taskMapper.detailById(openid,id);
public Task detailById(String openid, int id) {
return taskMapper.detailById(openid, id);
}
public JSONObject taskEffect(@Param("ew") Wrapper<Task> queryWrapper){
public JSONObject taskEffect(@Param("ew") Wrapper<Task> queryWrapper) {
return taskMapper.taskEffect(queryWrapper);
}
public List<Map> taskEffectData(@Param("ew") Wrapper<Task> queryWrapper){
public List<Map> taskEffectData(@Param("ew") Wrapper<Task> queryWrapper) {
return taskMapper.taskEffectData(queryWrapper);
}
public List<Map> taskDepartment(int taskId){
public List<Map> taskDepartment(int taskId) {
return taskMapper.taskDepartment(taskId);
}
// 上传任务时同时上传素材
public Boolean upReferenceInTask(Task task, List<Integer> referenceList, List<FileUploadParamVo> referenceUrlList) {
List<Integer> reference = new ArrayList<>();
if (referenceList != null && referenceList.size() > 0) {
for (Integer e : referenceList) {
reference.add(e);
}
}
// 上传任务时同时上传素材
if (referenceUrlList != null && referenceUrlList.size() > 0) {
List<Reference> l = new ArrayList<>();
// List<TopicActivity> ta = new ArrayList<>();
for (FileUploadParamVo e : referenceUrlList) {
String url = e.getUrl();
if (url != null && e.getUrl().lastIndexOf(".") != -1) {
l.add(new Reference().setTitle(task.getTitle()).setCoverUrl(task.getCoverUrl()).setDuration(e.getDuration()).setCreatAt(LocalDateTime.now()).setUpdateAt(LocalDateTime.now())
.setFileUrl(url).setType(FileTypeUtil.getcontentTypeNum(url.substring(url.lastIndexOf(".")))));
// ta.add(new TopicActivity().setTitle(task.getTitle()).setCover(task.getCoverUrl()).setCreatAt(LocalDateTime.now())
// .setContent(e).setType(FileTypeUtil.getcontentTypeNum(e.substring(e.lastIndexOf(".")))));
}
}
if (l.size() > 0) {
referenceService.saveBatch(l);
// topicActivityService.saveBatch(ta);
for (Reference r : l) {
referenceList.add(r.getId());
}
}
}
if (reference.size() > 0) {
taskReferenceService.addGroup(reference, task.getId());
}
return true;
}
// 上传任务的通用教程
public Boolean upTeachRefeInTask(Task task,List<Integer> teachRefeList, List<FileUploadParamVo> teachRefeUrlList) {
List<TaskTeachRefe> l2 = new ArrayList<>();
if (teachRefeList != null && teachRefeList.size() > 0) {
List<TeachingRefe> teachingRefes = (List<TeachingRefe>) teachingRefeService.listByIds(teachRefeList);
for (TeachingRefe e : teachingRefes) {
l2.add((new TaskTeachRefe().setTaskId(task.getId()).setCreatAt(LocalDateTime.now())
.setFileUrl(e.getFileUrl()).setType(FileTypeUtil.getcontentTypeNum(e.getFileUrl().substring(e.getFileUrl().lastIndexOf("."))))));
}
}
for (
FileUploadParamVo e : teachRefeUrlList) {
String url = e.getUrl();
if (url != null && url.lastIndexOf(".") != -1) {
l2.add(new TaskTeachRefe().setTaskId(task.getId()).setCreatAt(LocalDateTime.now()).setDuration(e.getDuration())
.setFileUrl(url).setType(FileTypeUtil.getcontentTypeNum(url.substring(url.lastIndexOf(".")))));
}
}
if (l2.size() > 0) {
taskTeachRefeService.saveBatch(l2);
}
return true;
}
}

Loading…
Cancel
Save