Explorar o código

Merge remote-tracking branch 'origin/master'

yusm hai 1 ano
pai
achega
88fb435a6c

+ 37 - 11
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ClueController.java

@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -54,9 +55,13 @@ public class ClueController {
         return msg;
     }
 
+    @RequestMapping("exportData")
+    public Object exportData(Clue clue, HttpServletRequest request) throws Exception {
+        return clueService.exportData(clue,request);
+    }
+
     @RequestMapping("listClue")
     public Object list(Clue clue, HttpServletRequest request) {
-        //TODO token待定
         User user = userMapper.selectById(request.getHeader("Token"));
         clue.setCompanyId(user.getCompanyId());
         clue.setIsDelete(0);
@@ -86,8 +91,7 @@ public class ClueController {
     }
 
     @RequestMapping("listDeleterClue")
-    public Object listDeleterClue(@RequestBody Clue clue, HttpServletRequest request) {
-        //TODO token待定
+    public Object listDeleterClue(Clue clue, HttpServletRequest request) {
         User user = userMapper.selectById(request.getHeader("Token"));
         clue.setCompanyId(user.getCompanyId());
         boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部线索");
@@ -115,11 +119,14 @@ public class ClueController {
     }
 
     @RequestMapping("/insertAndUpdate")
-    public Object inserANdUpdate(@RequestBody Clue clue, HttpServletRequest request) {
+    public Object inserANdUpdate(Clue clue, HttpServletRequest request) {
         HttpRespMsg msg = new HttpRespMsg();
         //操作前校验
-        //TODO token待定
         User user = userMapper.selectById(request.getHeader("Token"));
+        if (user == null){
+            msg.setError("获取创建人失败");
+            return msg;
+        }
         clue.setCompanyId(user.getCompanyId());
         if (null == clue.getClueName() || "".equals(clue.getClueName())) {
             msg.setError("线索名称不能为空");
@@ -145,10 +152,20 @@ public class ClueController {
 
 
     @RequestMapping("delete")
-    public Object delete(@RequestBody List<Integer> ids) {
+    public Object delete(Clue clue) {
         HttpRespMsg msg = new HttpRespMsg();
-        msg.setMsg("操作成功");
-        clueService.isDelete(ids);
+        String ids1 = clue.getIds();
+        List<Integer> ids = new ArrayList<>();
+        if (!ids1.isEmpty()) {
+            for (String id : ids1.split(",")) {
+                ids.add(Integer.parseInt(id));
+            }
+            clueService.isDelete(ids);
+            msg.setMsg("操作成功");
+        }else {
+            msg.setError("请选择线索");
+
+        }
         return msg;
     }
 
@@ -170,10 +187,19 @@ public class ClueController {
     }
 
     @RequestMapping("deleterDelete")
-    public Object deleterDelete(@RequestBody List<Integer> ids) {
+    public Object deleterDelete( Clue clue) {
         HttpRespMsg msg = new HttpRespMsg();
-        msg.setMsg("操作成功");
-        clueService.deleterDelete(ids);
+        String ids1 = clue.getIds();
+        List<Integer> ids = new ArrayList<>();
+        if (!ids1.isEmpty()) {
+            for (String id : ids1.split(",")) {
+                ids.add(Integer.parseInt(id));
+            }
+            clueService.deleterDelete(ids);
+            msg.setMsg("操作成功");
+        }else {
+            msg.setError("请选择线索");
+        }
         return msg;
     }
 

+ 6 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Clue.java

@@ -38,6 +38,7 @@ public class Clue extends Model<Clue> {
     //创建人
     @TableField("create_id")
     private String createId;
+    private String createName;
 
     /**
      * 线索名称
@@ -53,6 +54,7 @@ public class Clue extends Model<Clue> {
      */
     @TableField("clue_source_id")
     private Integer clueSourceId;
+    private Integer clueSourceValue;
 
     /**
      * 电话
@@ -70,18 +72,21 @@ public class Clue extends Model<Clue> {
      */
     @TableField("customer_industry_id")
     private Integer customerIndustryId;
+    private Integer customerIndustryValue;
 
     /**
      * 客户级别
      */
     @TableField("customer_level_id")
     private Integer customerLevelId;
+    private Integer customerLevelValue;
 
     /**
      * 地址
      */
     @TableField("address")
     private String address;
+    private String ids;
 
 
     /**
@@ -89,6 +94,7 @@ public class Clue extends Model<Clue> {
      */
     @TableField("incharger_id")
     private String inchargerId;
+    private String inchargerName;
 
 
 //    private String tempInchargerId;

+ 3 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ClueService.java

@@ -3,6 +3,7 @@ package com.management.platform.service;
 import com.management.platform.entity.Clue;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.management.platform.entity.User;
+import com.management.platform.util.HttpRespMsg;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
@@ -40,4 +41,6 @@ public interface ClueService extends IService<Clue> {
 
     int getTotal1(Clue clue, User user);
     int getTotal2(Clue clue, User user);
+
+    HttpRespMsg exportData(Clue clue, HttpServletRequest request) throws Exception;
 }

+ 49 - 3
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ClueServiceImpl.java

@@ -1,24 +1,37 @@
 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.update.UpdateWrapper;
-import com.management.platform.entity.Clue;
-import com.management.platform.entity.ClueLog;
-import com.management.platform.entity.User;
+import com.management.platform.entity.*;
+import com.management.platform.entity.vo.TasKVo;
 import com.management.platform.mapper.ClueLogMapper;
 import com.management.platform.mapper.ClueMapper;
+import com.management.platform.mapper.SysFormMapper;
+import com.management.platform.mapper.UserMapper;
 import com.management.platform.service.ClueService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.service.SysFunctionService;
 import com.management.platform.service.UserService;
+import com.management.platform.service.WxCorpInfoService;
+import com.management.platform.util.HttpRespMsg;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.beans.Transient;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.StringJoiner;
 
 /**
  * <p>
@@ -35,10 +48,19 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
     private SysFunctionService sysFunctionService;
     @Autowired
     private ClueMapper clueMapper;
+    @Resource
+    private WxCorpInfoService wxCorpInfoService;
     @Autowired
     private ClueLogMapper clueLogMapper;
     @Autowired
+    private SysFormMapper SysFormMapper;
+    @Autowired
+    private UserMapper userMapper;
+    @Autowired
     private UserService userService;
+    @Resource
+    private ExcelExportServiceImpl excelExportService;
+
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -187,6 +209,30 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
         return clueMapper.getTotal2(clue,user.getId());
 
     }
+    @Value(value = "${upload.path}")
+    private String path;
+    @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);
+    }
 
 
 }

+ 65 - 45
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/ClueMapper.xml

@@ -33,7 +33,6 @@
     <select id="list" resultType="com.management.platform.entity.Clue">
         select c.id,
                c.company_id,
-               (select company_name from company where company_id = c.id) companyName,
                c.clue_name,
                c.clue_source_id,
                c.phone,
@@ -50,11 +49,17 @@
                c.plate4,
                c.plate5,
                c.create_time,
-               c.create_id
+               c.create_id,
+               (select company_name from company where c.company_id = id) companyName,
+               (select name from `user` where id = c.incharger_id) inchargerName,
+               (select name from `user` where id = c.create_id) createName,
+               (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
+               (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
+               (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
         from Clue c
         where
             c.company_id = #{companyId} and is_delete = #{isDelete}
-        <if test="inchargerId != null  ">
+        <if test="inchargerId != null and inchargerId != ''  ">
            and c.incharger_id =#{inchargerId}
         </if>
         <if test="startTime != null and endTime != null ">
@@ -100,14 +105,19 @@
         c.plate4,
         c.plate5,
         c.create_time,
-        c.create_id
+        c.create_id,
+        (select name from `user` where id = c.incharger_id) inchargerName,
+        (select name from `user` where id = c.create_id) createName,
+        (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
+        (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
+        (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
         from Clue c
         where
         c.company_id = #{clue.companyId} and is_delete = #{clue.isDelete}
         and c.incharger_id in
         (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
         or c.incharger_id is null
-        <if test="inchargerId != null  ">
+        <if test="clue.inchargerId != null and clue.inchargerId != ''  ">
           and  c.incharger_id =#{inchargerId}
         </if>
         <if test="clue.startTime != null and clue.endTime != null ">
@@ -119,14 +129,14 @@
         <if test="clue.clueSourceId != null">
             and  c.clue_source_id =  #{clue.clueSourceId}
         </if>
-        <if test="phone != null and phone != '' ">
-            and  c.phone =  #{phone}
+        <if test="clue.phone != null and clue.phone != '' ">
+            and  c.phone =  #{clue.phone}
         </if>
-        <if test="customerLevelId != null and customerLevelId != '' ">
-            and  c.customer_level_id =  #{customerLevelId}
+        <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
+            and  c.customer_level_id =  #{clue.customerLevelId}
         </if>
         <if test="email != null and email != '' ">
-            and  c.email =  #{email}
+            and  c.email =  #{clue.email}
         </if>
         <if test="clue.customerIndustryId != null">
             and  c.customer_industry_id =  #{clue.customerIndustryId}
@@ -153,13 +163,18 @@
         c.plate4,
         c.plate5,
         c.create_time,
-        c.create_id
+        c.create_id,
+        (select name from `user` where id = c.incharger_id) inchargerName,
+        (select name from `user` where id = c.create_id) createName,
+        (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
+        (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
+        (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
         from Clue c
         where
         c.company_id = #{clue.companyId} and is_delete = #{clue.isDelete}
         and c.incharger_id = #{userId} or c.incharger_id is null
-        <if test="inchargerId != null  ">
-          and  c.incharger_id =#{inchargerId}
+        <if test="clue.inchargerId != null and clue.inchargerId != ''  ">
+          and c.incharger_id =#{clue.inchargerId}
         </if>
         <if test="clue.startTime != null and clue.endTime != null ">
             and  c.create_time BETWEEN  #{clue.startTime} and #{clue.endTime}
@@ -167,14 +182,14 @@
         <if test="clue.clueName != null and clue.clueName != '' ">
             and  c.clue_name =  #{clue.clueName}
         </if>
-        <if test="phone != null and phone != '' ">
-            and  c.phone =  #{phone}
+        <if test="clue.phone != null and clue.phone != '' ">
+            and  c.phone =  #{clue.phone}
         </if>
-        <if test="customerLevelId != null and customerLevelId != '' ">
-            and  c.customer_level_id =  #{customerLevelId}
+        <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
+            and  c.customer_level_id =  #{clue.customerLevelId}
         </if>
-        <if test="email != null and email != '' ">
-            and  c.email =  #{email}
+        <if test="clue.email != null and clue.email != '' ">
+            and  c.email =  #{clue.email}
         </if>
         <if test="clue.clueSourceId != null">
             and  c.clue_source_id =  #{clue.clueSourceId}
@@ -204,7 +219,12 @@
                c.plate4,
                c.plate5,
                c.create_time,
-               c.create_id
+               c.create_id,
+        (select name from `user` where id = c.incharger_id) inchargerName,
+        (select name from `user` where id = c.create_id) createName,
+        (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
+        (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
+        (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
         from Clue c
         where
             c.company_id = #{companyId} and is_delete = 1
@@ -214,7 +234,7 @@
         <if test="clueName != null and clueName != '' ">
         and  c.clue_name =  #{clueName}
         </if>
-        <if test="inchargerId != null  ">
+        <if test="inchargerId != null and inchargerId != ''  ">
            and c.incharger_id =#{inchargerId}
         </if>
         <if test="clueSourceId != null">
@@ -230,20 +250,20 @@
         from Clue c
         where
         c.company_id = #{companyId} and is_delete = #{isDelete}
-        <if test="startTime != null and endTime != null ">
+        <if test="clue.startTime != null and clue.endTime != null ">
             and  c.create_time BETWEEN  #{startTime} and #{endTime}
         </if>
-        <if test="inchargerId != null  ">
+        <if test="clue.inchargerId != null and clue.inchargerId != ''  ">
            and c.incharger_id =#{inchargerId}
         </if>
-        <if test="clueName != null and clueName != '' ">
+        <if test="clue.clueName != null and clue.clueName != '' ">
             and  c.clue_name =  #{clueName}
         </if>
-        <if test="clueSourceId != null">
-            and  c.clue_source_id =  #{clueSourceId}
+        <if test="clue.clueSourceId != null">
+            and  c.clue_source_id =  #{clue.clueSourceId}
         </if>
-        <if test="customerIndustryId != null">
-            and  c.customer_industry_id =  #{customerIndustryId}
+        <if test="clue.customerIndustryId != null">
+            and  c.customer_industry_id =  #{clue.customerIndustryId}
         </if>
     </select>
     <select id="getDeleterTotal" resultType="java.lang.Integer">
@@ -251,7 +271,7 @@
         from Clue c
         where
         c.company_id = #{companyId} and is_delete = 1
-        <if test="inchargerId != null  ">
+        <if test="inchargerId != null and inchargerId != ''  ">
           and  c.incharger_id =#{inchargerId}
         </if>
         <if test="startTime != null and endTime != null ">
@@ -276,8 +296,8 @@
         and c.incharger_id in
         (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
         or c.incharger_id is null
-        <if test="inchargerId != null  ">
-           and c.incharger_id =#{inchargerId}
+        <if test="clue.inchargerId != null and clue.inchargerId != ''  ">
+           and c.incharger_id =#{clue.inchargerId}
         </if>
         <if test="clue.startTime != null and clue.endTime != null ">
             and  c.create_time BETWEEN  #{clue.startTime} and #{clue.endTime}
@@ -285,14 +305,14 @@
         <if test="clue.clueName != null and clue.clueName != '' ">
             and  c.clue_name =  #{clue.clueName}
         </if>
-        <if test="phone != null and phone != '' ">
-            and  c.phone =  #{phone}
+        <if test="clue.phone != null and clue.phone != '' ">
+            and  c.phone =  #{clue.phone}
         </if>
-        <if test="customerLevelId != null and customerLevelId != '' ">
-            and  c.customer_level_id =  #{customerLevelId}
+        <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
+            and  c.customer_level_id =  #{clue.customerLevelId}
         </if>
-        <if test="email != null and email != '' ">
-            and  c.email =  #{email}
+        <if test="clue.email != null and clue.email != '' ">
+            and  c.email =  #{clue.email}
         </if>
         <if test="clue.clueSourceId != null">
             and  c.clue_source_id =  #{clue.clueSourceId}
@@ -307,8 +327,8 @@
         from Clue c
         where
         c.company_id = #{clue.companyId} and is_delete = #{clue.isDelete}
-        <if test="inchargerId != null  ">
-          and  c.incharger_id =#{inchargerId}
+        <if test="clue.inchargerId != null and clue.inchargerId != ''  ">
+          and  c.incharger_id =#{clue.inchargerId}
         </if>
         and c.incharger_id = #{userId} or c.incharger_id is null
         <if test="clue.startTime != null and clue.endTime != null ">
@@ -317,14 +337,14 @@
         <if test="clue.clueName != null and clue.clueName != '' ">
             and c.clue_name = #{clue.clueName}
         </if>
-        <if test="phone != null and phone != '' ">
-            and  c.phone =  #{phone}
+        <if test="clue.phone != null and clue.phone != '' ">
+            and  c.phone =  #{clue.phone}
         </if>
-        <if test="customerLevelId != null and customerLevelId != '' ">
-            and  c.customer_level_id =  #{customerLevelId}
+        <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
+            and  c.customer_level_id =  #{clue.customerLevelId}
         </if>
-        <if test="email != null and email != '' ">
-            and  c.email =  #{email}
+        <if test="clue.email != null and clue.email != '' ">
+            and  c.email =  #{clue.email}
         </if>
         <if test="clue.clueSourceId != null">
             and c.clue_source_id = #{clue.clueSourceId}