Browse Source

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

Lijy 11 months ago
parent
commit
4108004a7e

+ 2 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ClueService.java

@@ -9,6 +9,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 
 /**
@@ -54,5 +55,5 @@ public interface ClueService extends IService<Clue> {
 
     HttpRespMsg importData(MultipartFile multipartFile);
 
-    HttpRespMsg exportData(Clue clue);
+    HttpRespMsg exportData(Clue clue) throws Exception;
 }

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

@@ -42,6 +42,7 @@ import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 
@@ -370,6 +371,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public HttpRespMsg importData(MultipartFile multipartFile) {
         HttpRespMsg msg=new HttpRespMsg();
         String fileName = multipartFile.getOriginalFilename();
@@ -429,30 +431,30 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                     XSSFCell cell = row.getCell(i);
                     if(cell!=null){
                         switch (item.getString("type")){
-                            case "time":cell.setCellType(CellType.NUMERIC);
-                                break;
+//                            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());
-//                        }
-//                    }
+                    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++) {
@@ -479,8 +481,8 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                     XSSFCell cell = row.getCell(i);
                     if(cell!=null){
                         switch (item.getString("type")){
-                            case "time":cell.setCellType(CellType.NUMERIC);
-                                break;
+//                            case "time":cell.setCellType(CellType.NUMERIC);
+//                                break;
                             default:cell.setCellType(CellType.STRING);
                         }
                     }
@@ -511,7 +513,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                                 return msg;
                             }
                         }
-                    }else if(modelName.equals("customLevel")){
+                    }else if(modelName.equals("customLevelId")){
                         if(!StringUtils.isEmpty(cell.getStringCellValue())){
                             Optional<SysDict> first = sysDictOfCustomLevel.stream().filter(s -> s.getName().equals(cell.getStringCellValue())).findFirst();
                             if(first.isPresent()){
@@ -520,7 +522,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                                 throw new Exception("客户级别["+cell.getStringCellValue()+"不存在,请在系统字典中增加");
                             }
                         }
-                    }else if(modelName.equals("clueSources")){
+                    }else if(modelName.equals("clueSourcesId")){
                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
                            Optional<SysDict> first = sysDictOfClueSources.stream().filter(s -> s.getName().equals(cell.getStringCellValue())).findFirst();
                            if(first.isPresent()){
@@ -530,7 +532,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                                throw new Exception("线索来源["+cell.getStringCellValue()+"不存在,请在系统字典中增加");
                            }
                        }
-                   }else if(modelName.equals("customIndustry")){
+                   }else if(modelName.equals("customIndustryId")){
                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
                            Optional<SysDict> first = sysDictOfCustomIndustry.stream().filter(s -> s.getName().equals(cell.getStringCellValue())).findFirst();
                            if(first.isPresent()){
@@ -565,8 +567,65 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
     }
 
     @Override
-    public HttpRespMsg exportData(Clue clue) {
-        return null;
+    public HttpRespMsg exportData(Clue clue) throws Exception {
+        User user = userMapper.selectById(request.getHeader("token"));
+        SysForm sysForm = sysFormMapper.selectOne(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCompanyId, user.getCompanyId()).eq(SysForm::getCode, "Thread").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);
+        List<Clue> list1 = getList(clue);
+        for (Clue clue1 : list1) {
+            List<String> item=new ArrayList<>();
+            for (int i = 0; i < configObJSONArray.size(); i++) {
+                JSONObject target = configObJSONArray.getJSONObject(i);
+                if(target.getString("type").equals("grid")){
+                    JSONArray columns = target.getJSONArray("columns");
+                    for (int i1 = 0; i1 < columns.size(); i1++) {
+                        JSONObject columnsJSONObject = columns.getJSONObject(i1);
+                        JSONArray list = columnsJSONObject.getJSONArray("list");
+                        for (int i2 = 0; i2 < list.size(); i2++) {
+                            JSONObject object = list.getJSONObject(i2);
+                            String model = object.getString("model");
+                            String targetName = model.substring(0, 1).toUpperCase() + model.substring(1);
+                            Class<? extends Clue> aClass = clue1.getClass();
+                            String value = String.valueOf(aClass.getMethod("get" + targetName).invoke(clue1)==null?"":aClass.getMethod("get" + targetName).invoke(clue1));
+                            if(model.equals("inchargerId")){
+                                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                                    value = "$userName"+String.valueOf(aClass.getMethod("getInchargerName").invoke(clue1))+"$";
+                                }else {
+                                    value = String.valueOf(aClass.getMethod("getInchargerName").invoke(clue1));
+                                }
+                            }
+                            item.add(value);
+                        }
+                    }
+                }else {
+                    String model = target.getString("model");
+                    String targetName = model.substring(0, 1).toUpperCase() + model.substring(1);
+                    Class<? extends Clue> aClass = clue1.getClass();
+                    String value = String.valueOf(aClass.getMethod("get" + targetName).invoke(clue1)==null?"":aClass.getMethod("get" + targetName).invoke(clue1));
+                    if(model.equals("inchargerId")){
+                        if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                            value = "$userName"+String.valueOf(aClass.getMethod("getInchargerName").invoke(clue1))+"$";
+                        }else {
+                            value = String.valueOf(aClass.getMethod("getInchargerName").invoke(clue1));
+                        }
+                    }
+                    item.add(value);
+                }
+            }
+            dataList.add(item);
+        }
+        String fileName="线索表导出_"+ System.currentTimeMillis();
+        return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName,dataList,path);
     }
 
 

+ 5 - 10
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/CustomServiceImpl.java

@@ -184,21 +184,16 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
         for (CustomItemContacts contact : contacts) {
             ids.add(contact.getCustomId());
         }
-//        List<Contacts> cs = contactsMapper.selectList(new QueryWrapper<Contacts>().in("id", ids));
-        List<Contacts> cs = contactsMapper.selectListByIds(ids);
-        custom1.setContactsList(cs);
+        if (ids.size() > 0){
+            List<Contacts> cs = contactsMapper.selectListByIds(ids);
+            custom1.setContactsList(cs);
+        }
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         httpRespMsg.setData(custom1);
         return httpRespMsg;
     }
 
-//    @Override
-//    public HttpRespMsg getLog(Custom custom, HttpServletRequest request) {
-//        List<ActionLog> actionLogs = actionLogMapper.selectList(new QueryWrapper<ActionLog>().eq("code", "custom").eq("item_id", custom.getId()));
-//        HttpRespMsg httpRespMsg = new HttpRespMsg();
-//        httpRespMsg.setData(actionLogs);
-//        return httpRespMsg;
-//    }
+
 
     @Override
     public HttpRespMsg getList(Custom custom, HttpServletRequest request) {