|
@@ -1,24 +1,40 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
-import com.management.platform.entity.Clue;
|
|
|
|
-import com.management.platform.entity.ClueLog;
|
|
|
|
-import com.management.platform.entity.User;
|
|
|
|
-import com.management.platform.mapper.ClueLogMapper;
|
|
|
|
-import com.management.platform.mapper.ClueMapper;
|
|
|
|
|
|
+import com.management.platform.entity.*;
|
|
|
|
+import com.management.platform.entity.vo.TasKVo;
|
|
|
|
+import com.management.platform.mapper.*;
|
|
import com.management.platform.service.ClueService;
|
|
import com.management.platform.service.ClueService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.management.platform.service.SysFunctionService;
|
|
import com.management.platform.service.SysFunctionService;
|
|
import com.management.platform.service.UserService;
|
|
import com.management.platform.service.UserService;
|
|
|
|
+import com.management.platform.service.WxCorpInfoService;
|
|
|
|
+import com.management.platform.util.FileUtil;
|
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
|
+import com.management.platform.util.MessageUtils;
|
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
import java.beans.Transient;
|
|
import java.beans.Transient;
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -36,9 +52,26 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
@Autowired
|
|
@Autowired
|
|
private ClueMapper clueMapper;
|
|
private ClueMapper clueMapper;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private TaskMapper taskMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ClueUploadfileMapper clueUploadfileMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private WxCorpInfoService wxCorpInfoService;
|
|
|
|
+ @Autowired
|
|
private ClueLogMapper clueLogMapper;
|
|
private ClueLogMapper clueLogMapper;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private UploadFileMapper uploadFileMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysFormMapper sysFormMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserMapper userMapper;
|
|
|
|
+ @Autowired
|
|
private UserService userService;
|
|
private UserService userService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ActionLogMapper actionLogMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private ExcelExportServiceImpl excelExportService;
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -46,13 +79,20 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
setNull(clue);
|
|
setNull(clue);
|
|
clue.setCreateTime(new Date());
|
|
clue.setCreateTime(new Date());
|
|
clueMapper.insert(clue);
|
|
clueMapper.insert(clue);
|
|
- Integer id = clue.getId();
|
|
|
|
- ClueLog clueLog = new ClueLog();
|
|
|
|
- clueLog.setClueId(id);
|
|
|
|
- clueLog.setName("创建了线索");
|
|
|
|
|
|
+// Integer id = clue.getId();
|
|
|
|
+// ClueLog clueLog = new ClueLog();
|
|
|
|
+// clueLog.setClueId(id);
|
|
|
|
+// clueLog.setName("创建了线索");
|
|
// clueLog.setUserId(clue.getCreateId());
|
|
// clueLog.setUserId(clue.getCreateId());
|
|
- clueLog.setCreatTime(new Date());
|
|
|
|
- clueLogMapper.insert(clueLog);
|
|
|
|
|
|
+// clueLog.setCreatTime(new Date());
|
|
|
|
+// clueLogMapper.insert(clueLog);
|
|
|
|
+ ActionLog log = new ActionLog();
|
|
|
|
+ log.setItemId(clue.getId());
|
|
|
|
+ log.setName("创建了线索");
|
|
|
|
+ log.setCode("clue");
|
|
|
|
+ log.setUserId(clue.getCreateId());
|
|
|
|
+ log.setCreatTime(new Date());
|
|
|
|
+ actionLogMapper.insert(log);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -60,12 +100,13 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
public void update(Clue clue) {
|
|
public void update(Clue clue) {
|
|
setNull(clue);
|
|
setNull(clue);
|
|
clueMapper.updateById(clue);
|
|
clueMapper.updateById(clue);
|
|
- ClueLog clueLog = new ClueLog();
|
|
|
|
- clueLog.setClueId(clue.getId());
|
|
|
|
- clueLog.setName("编辑了线索");
|
|
|
|
-// clueLog.setUserId(clue.getCreateId());
|
|
|
|
- clueLog.setCreatTime(new Date());
|
|
|
|
- clueLogMapper.insert(clueLog);
|
|
|
|
|
|
+ ActionLog log = new ActionLog();
|
|
|
|
+ log.setItemId(clue.getId());
|
|
|
|
+ log.setName("编辑了线索");
|
|
|
|
+ log.setCode("clue");
|
|
|
|
+ log.setUserId(clue.getCreateId());
|
|
|
|
+ log.setCreatTime(new Date());
|
|
|
|
+ actionLogMapper.insert(log);
|
|
}
|
|
}
|
|
|
|
|
|
private Clue setNull(Clue clue) {
|
|
private Clue setNull(Clue clue) {
|
|
@@ -97,6 +138,9 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
clueMapper.update(clue, updateWrapper);
|
|
clueMapper.update(clue, updateWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Value(value = "${upload.file}")
|
|
|
|
+ private String path;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<Clue> getList(Clue clue) {
|
|
public List<Clue> getList(Clue clue) {
|
|
return clueMapper.list(clue);
|
|
return clueMapper.list(clue);
|
|
@@ -112,28 +156,35 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
return clueMapper.list2(clue, user.getId());
|
|
return clueMapper.list2(clue, user.getId());
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public List<Clue> getDeleterList(Clue clue) {
|
|
|
|
- return clueMapper.Deleterlist(clue);
|
|
|
|
- }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Integer getTotal(Clue clue) {
|
|
public Integer getTotal(Clue clue) {
|
|
return clueMapper.getTotal(clue);
|
|
return clueMapper.getTotal(clue);
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public Integer getDeleterTotal(Clue clue) {
|
|
|
|
- return clueMapper.getDeleterTotal(clue);
|
|
|
|
- }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Clue getInfo(Clue clue) {
|
|
public Clue getInfo(Clue clue) {
|
|
- Clue clue1 = clueMapper.selectById(clue.getId());
|
|
|
|
- QueryWrapper<ClueLog> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.eq("clue_id", clue.getId());
|
|
|
|
- List<ClueLog> logs = clueLogMapper.selectList(queryWrapper);
|
|
|
|
- clue1.setClueLogList(logs);
|
|
|
|
|
|
+ Clue clue1 = clueMapper.selectById2Info(clue.getId());
|
|
|
|
+ clue1.setClueLogList(actionLogMapper.selectByInfoList(clue1));
|
|
|
|
+ clue1.setFiles(uploadFileMapper.selectByInfoList("clue", clue1.getId()));
|
|
|
|
+ List<Task> tasks = taskMapper.selectList(new QueryWrapper<Task>().in("clue_id", clue.getId()));
|
|
|
|
+ for (Task task : tasks) {
|
|
|
|
+ String executorId = task.getExecutorId();
|
|
|
|
+ List<String> ids1 = new ArrayList<>();
|
|
|
|
+ List<String> userNames = new ArrayList<>();
|
|
|
|
+ if (!executorId.isEmpty()) {
|
|
|
|
+ for (String id : executorId.split(",")) {
|
|
|
|
+ ids1.add(id);
|
|
|
|
+ }
|
|
|
|
+ List<User> users = userMapper.selectList(new QueryWrapper<User>().in("id", ids1));
|
|
|
|
+ for (User user : users) {
|
|
|
|
+ userNames.add(user.getName());
|
|
|
|
+ }
|
|
|
|
+ task.setExecutorNames(userNames);
|
|
|
|
+ }
|
|
|
|
+ clue1.setTaskList(tasks);
|
|
|
|
+ }
|
|
return clue1;
|
|
return clue1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -154,38 +205,195 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void getAndTransfer(Clue clue,User user) {
|
|
|
|
|
|
+ public void getAndTransfer(Clue clue, User user) {
|
|
UpdateWrapper<Clue> updateWrapper = new UpdateWrapper<>();
|
|
UpdateWrapper<Clue> updateWrapper = new UpdateWrapper<>();
|
|
- updateWrapper.eq("id",clue.getId());
|
|
|
|
|
|
+ String ids1 = clue.getIds();
|
|
|
|
+ List<Integer> ids = new ArrayList<>();
|
|
|
|
+ if (!ids1.isEmpty()) {
|
|
|
|
+ for (String id : ids1.split(",")) {
|
|
|
|
+ ids.add(Integer.parseInt(id));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ updateWrapper.in("id", ids);
|
|
String inchargerId = clue.getInchargerId();
|
|
String inchargerId = clue.getInchargerId();
|
|
- ClueLog clueLog = new ClueLog();
|
|
|
|
|
|
+ ActionLog clueLog = new ActionLog();
|
|
clueLog.setUserId(user.getId());
|
|
clueLog.setUserId(user.getId());
|
|
- clueLog.setClueId(clue.getId());
|
|
|
|
clueLog.setCreatTime(new Date());
|
|
clueLog.setCreatTime(new Date());
|
|
- if (inchargerId == null ){
|
|
|
|
- //认领
|
|
|
|
- clueLog.setName("认领了线索");
|
|
|
|
- clue.setInchargerId(user.getId());
|
|
|
|
- clueLogMapper.insert(clueLog);
|
|
|
|
- }else {
|
|
|
|
- //转移
|
|
|
|
- clueLog.setName("转移了线索");
|
|
|
|
- clue.setInchargerId(clue.getInchargerId());
|
|
|
|
- clueLogMapper.insert(clueLog);
|
|
|
|
|
|
+ clueLog.setCode("clue");
|
|
|
|
+
|
|
|
|
+ List<Clue> clues = clueMapper.selectList(new QueryWrapper<Clue>().in("id", ids));
|
|
|
|
+ for (Clue clue1 : clues) {
|
|
|
|
+ clueLog.setItemId(clue1.getId());
|
|
|
|
+ if (clue1.getInchargerId() == null) {
|
|
|
|
+ //认领
|
|
|
|
+ clueLog.setName("认领了线索");
|
|
|
|
+ clueLog.setUserId(user.getId());
|
|
|
|
+ clue.setInchargerId(user.getId());
|
|
|
|
+ actionLogMapper.insert(clueLog);
|
|
|
|
+ } else {
|
|
|
|
+ //转移
|
|
|
|
+ clueLog.setName("转移了线索");
|
|
|
|
+ clue.setInchargerId(clue.getInchargerId());
|
|
|
|
+ actionLogMapper.insert(clueLog);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- clueMapper.update(clue, updateWrapper);
|
|
|
|
|
|
+
|
|
|
|
+ updateWrapper.set("incharger_id", inchargerId);
|
|
|
|
+ clueMapper.update(null, updateWrapper);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int getTotal1(Clue clue, User user) {
|
|
public int getTotal1(Clue clue, User user) {
|
|
- return clueMapper.getTotal1(clue,user.getId());
|
|
|
|
|
|
+ return clueMapper.getTotal1(clue, user.getId());
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int getTotal2(Clue clue, User user) {
|
|
public int getTotal2(Clue clue, User user) {
|
|
- return clueMapper.getTotal2(clue,user.getId());
|
|
|
|
|
|
+ return clueMapper.getTotal2(clue, user.getId());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg exportData(Clue clue, HttpServletRequest request) throws Exception {
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ SysForm sysForm = sysFormMapper.selectOne(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCompanyId, user.getCompanyId()).eq(SysForm::getCode, "Clue").eq(SysForm::getIsCurrent, 1));
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, user.getCompanyId()));
|
|
|
|
+ String config = sysForm.getConfig();
|
|
|
|
+ JSONObject configOb = JSON.parseObject(config);
|
|
|
|
+ JSONArray configObJSONArray = configOb.getJSONArray("list");
|
|
|
|
+ List<List<String>> dataList = new ArrayList<>();
|
|
|
|
+ List<String> titleList = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
|
|
+ JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
|
+ titleList.add(item.getString("label"));
|
|
|
|
+ }
|
|
|
|
+ dataList.add(titleList);//设置表头
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ clue.setCompanyId(user.getCompanyId());
|
|
|
|
+
|
|
|
|
+ String fileName = "线索表导出_" + System.currentTimeMillis();
|
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo, fileName, dataList, path);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Value(value = "${upload.file}")
|
|
|
|
+ private String filePath;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public Object uploadFile(Clue clue, HttpServletRequest request, MultipartFile file) {
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ if (!file.isEmpty()) { // 检查上传的文件是否为空
|
|
|
|
+ try {
|
|
|
|
+ // 获取上传文件的原始文件名
|
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
|
+
|
|
|
|
+ // 创建文件存储目录
|
|
|
|
+ File uploadDir = new File(filePath);
|
|
|
|
+ if (!uploadDir.exists()) {
|
|
|
|
+ uploadDir.mkdirs();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ UploadFile uf = new UploadFile();
|
|
|
|
+ uf.setName(originalFilename);
|
|
|
|
+ String realName = "";
|
|
|
|
+ int pos = originalFilename.lastIndexOf(".");
|
|
|
|
+ String suffix = originalFilename.substring(pos).toLowerCase();
|
|
|
|
+ //用uuid替换原始的文件名
|
|
|
|
+ String purFName = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
|
+ realName = purFName + suffix;
|
|
|
|
+
|
|
|
|
+ long size = file.getSize();
|
|
|
|
+ String s = "MB";
|
|
|
|
+ double l = size / 1024.00 / 1024.00;
|
|
|
|
+ System.out.println(size);
|
|
|
|
+ uf.setPath("/file/" + realName);
|
|
|
|
+ uf.setCode("clue");
|
|
|
|
+ uf.setSize(l+s);
|
|
|
|
+ uf.setItemId(clue.getId());
|
|
|
|
+ uf.setRealName(realName);
|
|
|
|
+ uf.setCreateTime(new Date());
|
|
|
|
+ uf.setCreateId(user.getId());
|
|
|
|
+ uploadFileMapper.insert(uf);
|
|
|
|
+ // 构建上传文件的目标路径
|
|
|
|
+ String filePath1 = filePath + realName;
|
|
|
|
+
|
|
|
|
+ // 在服务器上创建文件
|
|
|
|
+ File dest = new File(filePath1);
|
|
|
|
|
|
|
|
+ // 将上传的文件保存到目标路径
|
|
|
|
+ file.transferTo(dest);
|
|
|
|
+
|
|
|
|
+ // 文件上传成功的响应消息
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ msg.setMsg("上传成功");
|
|
|
|
+ return msg;
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ // 文件上传失败的响应消息
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ msg.setError("上传成功失败");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 文件为空的响应消息
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ msg.setError("请选择上传文件");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Object reFileName(UploadFile uploadFile, HttpServletRequest request) {
|
|
|
|
+ return uploadFileMapper.update(null, new UpdateWrapper<UploadFile>().eq("id", uploadFile.getId()).set("name", uploadFile.getName()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public Object deleteFile(UploadFile file, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ try {
|
|
|
|
+ UploadFile uploadFile = uploadFileMapper.selectById(file.getId());
|
|
|
|
+ uploadFileMapper.deleteById(uploadFile.getId());
|
|
|
|
+ String realName = uploadFile.getRealName();
|
|
|
|
+ File file1 = new File(path + realName);
|
|
|
|
+ file1.delete();
|
|
|
|
+ msg.setMsg("删除成功");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ msg.setError("删除失败");
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Object downFile(UploadFile file, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+// try {
|
|
|
|
+// ServletOutputStream os = response.getOutputStream();
|
|
|
|
+ UploadFile uploadFile = uploadFileMapper.selectById(file.getId());
|
|
|
|
+ String path1 = uploadFile.getPath();
|
|
|
|
+ path1 = path1.substring(2);
|
|
|
|
+ msg.setData(path1);
|
|
|
|
+// if (uploadFile == null ){
|
|
|
|
+// msg.setError("文件未找到");
|
|
|
|
+// return msg;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// File uploadFile1 = new File(uploadFile.getPath());
|
|
|
|
+// response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(uploadFile.getName(), "UTF-8"));
|
|
|
|
+// response.setContentType("application/octet-stream");
|
|
|
|
+// // 读取文件的字节流
|
|
|
|
+// os.write(FileUtil.readFileByBytes(uploadFile1));
|
|
|
|
+// os.flush();
|
|
|
|
+//
|
|
|
|
+// } catch (IOException e) {
|
|
|
|
+// msg.setError(MessageUtils.message("file.error"));
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|