Explorar o código

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

Lijy hai 11 meses
pai
achega
1bb74f065c

+ 25 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ContactsController.java

@@ -9,6 +9,7 @@ import com.management.platform.mapper.ContactsMapper;
 import com.management.platform.mapper.UserMapper;
 import com.management.platform.service.ContactsService;
 import com.management.platform.util.HttpRespMsg;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -161,5 +162,29 @@ public class ContactsController {
     }
 
 
+    //转移联系人 conctacts 里面要有要转移的负责人的 owner_id,id
+    @RequestMapping("transferContacts")
+    public HttpRespMsg transferContacts(Contacts contacts,HttpServletRequest request){
+        User user = userMapper.selectById(request.getHeader("Token"));//当前登陆的用户
+        HttpRespMsg msg = new HttpRespMsg();
+        if (contacts.getOwnerId()==null|| StringUtils.isEmpty(contacts.getOwnerId())){
+            msg.setError("请选择要转移的负责人");
+            return msg;
+        }
+        Contacts contactsGet=contactsService.getById(contacts.getId());
+        if (contacts.getOwnerId().equals(contactsGet.getOwnerId())){
+            msg.setError("该联系人已属于所选负责人");
+            return msg;
+        }
+        contactsGet.setOwnerId(contacts.getOwnerId());
+        int count= contactsService.transferContacts(contactsGet, user);
+        if (count>0){
+            msg.setMsg("操作成功");
+            return msg;
+        }else {
+            msg.setError("操作失败");
+            return msg;
+        }
+    }
 }
 

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

@@ -3,6 +3,7 @@ package com.management.platform.service;
 import com.management.platform.entity.Contacts;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.management.platform.entity.Custom;
+import com.management.platform.entity.User;
 import com.management.platform.util.HttpRespMsg;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -42,4 +43,6 @@ public interface ContactsService extends IService<Contacts> {
     HttpRespMsg exportData(String customName, String name, String email, String creatorName, String phone, String ownerName, HttpServletRequest request) throws Exception;
 
     HttpRespMsg getAllContacts(HttpServletRequest request);
+
+    int transferContacts(Contacts contactsGet, User user);
 }

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

@@ -401,7 +401,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
             //由于第一行需要指明列对应的标题
             int rowNum = sheet.getLastRowNum();
             //获取当前表单模板 校验规则
-            SysForm sysForm = sysFormMapper.selectOne(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCode, "Product").eq(SysForm::getCompanyId, companyId).eq(SysForm::getIsCurrent, 1));
+            SysForm sysForm = sysFormMapper.selectOne(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCode, "Thread").eq(SysForm::getCompanyId, companyId).eq(SysForm::getIsCurrent, 1));
             if(sysForm==null){
                 msg.setError("当前模块未配置自定义模板,需先完成配置");
                 return msg;
@@ -409,7 +409,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
             String config = sysForm.getConfig();
             JSONObject configOb = JSON.parseObject(config);
             JSONArray configObJSONArray = configOb.getJSONArray("list");
-            List<Clue> importClueList=new ArrayList<>();
+//            List<Clue> importClueList=new ArrayList<>();
             List<String> userNameList=new ArrayList<>();
             HttpRespMsg respMsg=new HttpRespMsg();
             for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
@@ -427,29 +427,32 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                     JSONObject item = configObJSONArray.getJSONObject(i);
                     String modelName = item.getString("model");
                     XSSFCell cell = row.getCell(i);
-//                    if(cell!=null){
-//                        switch (item.getString("type")){
-//                            case "time":cell.setCellType(CellType.NUMERIC);
-//                                break;
-//                            default:cell.setCellType(CellType.STRING);
-//                        }
-//                    }
-                    if(modelName.equals("inchargerId")){
-                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
-                            userNameList.add(cell.getStringCellValue());
+                    if(cell!=null){
+                        switch (item.getString("type")){
+                            case "time":cell.setCellType(CellType.NUMERIC);
+                                break;
+                            default:cell.setCellType(CellType.STRING);
                         }
                     }
+//                    if(modelName.equals("inchargerId")){
+//                        System.out.println("=====");
+//                        System.out.println(modelName);
+//                        System.out.println(cell.toString());
+//                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
+//                            userNameList.add(cell.getStringCellValue());
+//                        }
+//                    }
 
                 }
             }
-            System.out.println("参与搜索的人员列表"+userNameList + userNameList.size());
-            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
-                respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
-                if(respMsg.code.equals("0")){
-                    msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
-                    return msg;
-                }
-            }
+//            System.out.println("参与搜索的人员列表"+userNameList + userNameList.size());
+//            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
+//                respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
+//                if(respMsg.code.equals("0")){
+//                    msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
+//                    return msg;
+//                }
+//            }
             List<User> targetUserList= (List<User>) respMsg.data;
             //直接忽略空行 从row1开始
             for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
@@ -465,6 +468,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                 int cellNum = row.getLastCellNum();
                 Clue clue =new Clue();
                 clue.setCompanyId(companyId);
+                clue.setCreateTime(new Date());
                 clue.setCreateId(user.getId());
                 for (int i = 0; i < cellNum; i++) {
                     JSONObject item = configObJSONArray.getJSONObject(i);
@@ -520,7 +524,8 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
                            Optional<SysDict> first = sysDictOfClueSources.stream().filter(s -> s.getName().equals(cell.getStringCellValue())).findFirst();
                            if(first.isPresent()){
-                               clue.setClueSourceId(first.get().getId());
+                               Integer id = first.get().getId();
+                               clue.setClueSourceId(id);
                            }else {
                                throw new Exception("线索来源["+cell.getStringCellValue()+"不存在,请在系统字典中增加");
                            }
@@ -543,13 +548,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                     }
 
                 }
-                importClueList.add(clue);
-            }
-            if(importClueList.size()>0){
-                if(!saveOrUpdateBatch(importClueList)){
-                    msg.setError("验证失败");
-                    return msg;
-                }
+                clueMapper.insert(clue);
             }
         } catch (IOException | NoSuchMethodException e) {
             e.printStackTrace();

+ 26 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContactsServiceImpl.java

@@ -80,7 +80,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
 
 
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public HttpRespMsg addContacts(Contacts contacts, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         String token = String.valueOf(request.getHeader("Token"));
@@ -167,6 +167,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public HttpRespMsg updateContacts(Contacts contacts, HttpServletRequest request) {
         HttpRespMsg msg = new HttpRespMsg();
         String token = String.valueOf(request.getHeader("Token"));
@@ -189,6 +190,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public HttpRespMsg deleteContacts(List<Integer> ids, HttpServletRequest request) {
         HttpRespMsg msg = new HttpRespMsg();
         UpdateWrapper<Contacts> contactsUpdateWrapper = new UpdateWrapper<>();
@@ -245,6 +247,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public HttpRespMsg returnContacts(List<Integer> ids) {
         HttpRespMsg msg = new HttpRespMsg();
         UpdateWrapper<Contacts> contactsUpdateWrapper = new UpdateWrapper<>();
@@ -583,5 +586,27 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
         return mgs;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int transferContacts(Contacts contactsGet, User user) {
+        UpdateWrapper<Contacts> contactsUpdateWrapper = new UpdateWrapper<>();
+        contactsUpdateWrapper.eq("id", contactsGet.getId());
+        contactsUpdateWrapper.set("owner_id", contactsGet.getOwnerId());
+        int count1 = contactsMapper.update(null, contactsUpdateWrapper);
+
+        ContactsLog contactsLog = new ContactsLog();
+        contactsLog.setCompanyId(user.getCompanyId());
+        contactsLog.setContactsId(contactsGet.getId());
+        contactsLog.setOperateId(user.getId());
+        contactsLog.setOperateDate(LocalDateTime.now());
+        contactsLog.setMsg("转移联系人");
+        int count2 = contactsLogMapper.insert(contactsLog);
+        if (count1>0&&count2>0){
+            return 1;
+        }else {
+            return 0;
+        }
+    }
+
 
 }

+ 12 - 8
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -17,6 +17,10 @@ import com.management.platform.util.HttpRespMsg;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -302,9 +306,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             outputStream.close();
 
             //解析表格
-            HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(file));
+            XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(file));
             //我们只需要第一个sheet
-            HSSFSheet sheet = workbook.getSheetAt(0);
+            XSSFSheet sheet = workbook.getSheetAt(0);
             //由于第一行需要指明列对应的标题
             int rowNum = sheet.getLastRowNum();
             //获取当前表单模板 校验规则
@@ -329,7 +333,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             List<SalesOrder> orderList = salesOrderMapper.getList(user);
              List<Clue> clueList = clueMapper.selectList(new LambdaQueryWrapper<Clue>().eq(Clue::getCompanyId, user.getCompanyId()).eq(Clue::getIsDelete, 0).orderByDesc(Clue::getCreateTime));
             for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
-                HSSFRow row = sheet.getRow(rowIndex);
+                XSSFRow row = sheet.getRow(rowIndex);
                 if (row == null) {
                     continue;
                 }
@@ -343,8 +347,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 for (int i = 0; i < cellNum; i++) {
                     JSONObject item = configObJSONArray.getJSONObject(i);
                     String modelName = item.getString("model");
-                    HSSFCell cell = row.getCell(i);
-                    if(cell!=null&&StringUtils.isNotEmpty(cell.getStringCellValue())){
+                    XSSFCell cell = row.getCell(i);
+/*                    if(cell!=null&&StringUtils.isNotEmpty(cell.getStringCellValue())){
                         switch (item.getString("type")){
                             case "time":cell.setCellType(CellType.NUMERIC);
                                 System.out.println(cell.getNumericCellValue());
@@ -353,7 +357,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                                 break;
                             default:cell.setCellType(CellType.STRING);
                         }
-                    }
+                    }*/
                     if(modelName.equals("executorId")){
                         if(!StringUtils.isEmpty(cell.getStringCellValue())){
                             List<String> executorNames = new ArrayList<>();
@@ -382,7 +386,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             List<User> targetUserList= (List<User>) respMsg.data;
 
             for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
-                HSSFRow row = sheet.getRow(rowIndex);
+                XSSFRow row = sheet.getRow(rowIndex);
                 if (row == null) {
                     continue;
                 }
@@ -403,7 +407,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                     String className = modelName.substring(0, 1).toUpperCase() + modelName.substring(1);
                     String getter="get"+className;
                     String setter="set"+className;
-                    HSSFCell cell = row.getCell(i);
+                    XSSFCell cell = row.getCell(i);
                     if(cell!=null&&StringUtils.isNotEmpty(cell.getStringCellValue())){
                         switch (item.getString("type")){
                             case "time":cell.setCellType(CellType.NUMERIC);