leon пре 5 година
родитељ
комит
67376879c8

+ 5 - 6
src/main/java/com/mokamrp/privates/controller/WorkContactEmployeeController.java

@@ -161,13 +161,12 @@ public class WorkContactEmployeeController extends BaseController<WorkContactEmp
         Map<Integer, String> feild = new HashMap<>(2);
         Map<Integer, String> feild = new HashMap<>(2);
         feild.put(0,"fanId");
         feild.put(0,"fanId");
         feild.put(1,"tagNames");
         feild.put(1,"tagNames");
-        List<Map<String,String>> row = new ArrayList<>();
-        //调用工具类解析excel文件
-        try {
-            row = Analysis.analysis(file,feild);
-        }catch (Exception e){
-            return AjaxResult.error(e.getMessage());
+        List<Map<String, String>> row;
+        VoltaHandle<ArrayList<Map<String,String>>> voltaRes = Analysis.analysis(file, feild);
+        if (voltaRes.getErr() != null){
+            return AjaxResult.error(voltaRes.getErr());
         }
         }
+        row = voltaRes.getData();
 
 
         Map<String, Object> resMap = WorkContactEmployeeService.batchSetNovelFanTags(row,authUser);
         Map<String, Object> resMap = WorkContactEmployeeService.batchSetNovelFanTags(row,authUser);
 
 

+ 7 - 6
src/main/java/com/mokamrp/privates/controller/WorkEmployeeFriendcircleController.java

@@ -3,6 +3,7 @@ package com.mokamrp.privates.controller;
 import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.help.Analysis;
 import com.mokamrp.privates.help.Analysis;
 import com.mokamrp.privates.interceptor.AuthUser;
 import com.mokamrp.privates.interceptor.AuthUser;
@@ -65,19 +66,19 @@ public class WorkEmployeeFriendcircleController extends BaseController<WorkEmplo
         Map<String, Object> map = new HashMap<>(16);
         Map<String, Object> map = new HashMap<>(16);
         Map<Integer, String> feild = new HashMap<>(8);
         Map<Integer, String> feild = new HashMap<>(8);
         feild.put(0, "deviceCode");
         feild.put(0, "deviceCode");
-        feild.put(1, "corpId");
+        feild.put(1, "corpName");
         feild.put(2, "type");
         feild.put(2, "type");
         feild.put(3, "boxName");
         feild.put(3, "boxName");
         feild.put(4, "tagName");
         feild.put(4, "tagName");
         feild.put(5, "shareUrl");
         feild.put(5, "shareUrl");
         feild.put(6, "title");
         feild.put(6, "title");
         feild.put(7, "sendAt"); //.2021-01-01 22:22:22
         feild.put(7, "sendAt"); //.2021-01-01 22:22:22
-        List<Map<String, String>> row = new ArrayList<>();
-        try {
-            row = Analysis.analysis(file, feild);
-        } catch (Exception e) {
-            return AjaxResult.error(e.getMessage());
+        List<Map<String, String>> row;
+        VoltaHandle<ArrayList<Map<String,String>>> voltaRes = Analysis.analysis(file, feild);
+        if (voltaRes.getErr() != null){
+            return AjaxResult.error(voltaRes.getErr());
         }
         }
+        row = voltaRes.getData();
         Boolean res = workEmployeeFriendcircleService.importData(row);
         Boolean res = workEmployeeFriendcircleService.importData(row);
         return AjaxResult.success(HttpMsg.importSuccess);
         return AjaxResult.success(HttpMsg.importSuccess);
     }
     }

+ 16 - 15
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileController.java

@@ -6,10 +6,7 @@ import com.mokamrp.privates.constant.Constants;
 import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.controller.BaseController;
 import com.mokamrp.privates.controller.BaseController;
-import com.mokamrp.privates.entity.AddHandle;
-import com.mokamrp.privates.entity.DelHandle;
-import com.mokamrp.privates.entity.EditHandle;
-import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.entity.*;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
 import com.mokamrp.privates.entity.pangu.SetWorkWxInfoHandle;
 import com.mokamrp.privates.entity.pangu.SetWorkWxInfoHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.help.AjaxResult;
@@ -297,7 +294,7 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
     public Object uploadFile(@RequestBody MultipartFile file, @AuthUser User authUser) {
     public Object uploadFile(@RequestBody MultipartFile file, @AuthUser User authUser) {
         Map<String, Object> map = new HashMap<>(16);
         Map<String, Object> map = new HashMap<>(16);
         Map<Integer, String> feild = new HashMap<>(5);
         Map<Integer, String> feild = new HashMap<>(5);
-        feild.put(0, "stationId");
+        feild.put(0, "stationName");
         feild.put(1, "mobileCode");
         feild.put(1, "mobileCode");
         feild.put(2, "mobileNo");
         feild.put(2, "mobileNo");
         feild.put(3, "mobileOperator");
         feild.put(3, "mobileOperator");
@@ -319,15 +316,19 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
         feild.put(19, "wxFriendUserName2");
         feild.put(19, "wxFriendUserName2");
         feild.put(20, "wxFriendName3");
         feild.put(20, "wxFriendName3");
         feild.put(21, "wxFriendUserName3");
         feild.put(21, "wxFriendUserName3");
-        feild.put(22, "workWxCorp");
-        feild.put(23, "workWxRegisterAt");
+        feild.put(22, "workWxCorp|default");
+        feild.put(23, "workWxRegisterAt|default");
         List<Map<String, String>> row = new ArrayList<>();
         List<Map<String, String>> row = new ArrayList<>();
-        try {
-            row = Analysis.analysis(file, feild);
-        } catch (Exception e) {
+        VoltaHandle<ArrayList<Map<String,String>>> voltaRes = Analysis.analysis(file, feild);
+        if (voltaRes.getErr() != null){
+            return AjaxResult.error(voltaRes.getErr());
+        }
+        row = voltaRes.getData();
+        try{
+            VoltaHandle<Boolean> res = fosterwxMobileService.importData(row, authUser);
+        }catch (Exception e){
             return AjaxResult.error(e.getMessage());
             return AjaxResult.error(e.getMessage());
         }
         }
-        Boolean res = fosterwxMobileService.importData(row, authUser);
         return AjaxResult.success(HttpMsg.importSuccess);
         return AjaxResult.success(HttpMsg.importSuccess);
     }
     }
 
 
@@ -437,11 +438,11 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
         field.put(1, "codeUrl");
         field.put(1, "codeUrl");
         field.put(2, "wxAppid");
         field.put(2, "wxAppid");
         List<Map<String, String>> row;
         List<Map<String, String>> row;
-        try {
-            row = Analysis.analysis(file, field);
-        } catch (Exception e) {
-            return AjaxResult.error(e.getMessage());
+        VoltaHandle<ArrayList<Map<String,String>>> voltaRes = Analysis.analysis(file, field);
+        if (voltaRes.getErr() != null){
+            return AjaxResult.error(voltaRes.getErr());
         }
         }
+        row = voltaRes.getData();
 
 
         StringBuffer sb = new StringBuffer();
         StringBuffer sb = new StringBuffer();
         row.forEach(map -> {
         row.forEach(map -> {

+ 6 - 5
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxStationBindBoxController.java

@@ -3,6 +3,7 @@ package com.mokamrp.privates.controller.pangu;
 import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxStationBindBoxHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxStationBindBoxHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.help.Analysis;
 import com.mokamrp.privates.help.Analysis;
@@ -72,12 +73,12 @@ public class FosterwxStationBindBoxController extends BaseController<FosterwxSta
         feild.put(2, "ghId");
         feild.put(2, "ghId");
         feild.put(3, "boxName");
         feild.put(3, "boxName");
         feild.put(4, "scope");
         feild.put(4, "scope");
-        List<Map<String, String>> row = new ArrayList<>();
-        try {
-            row = Analysis.analysis(file, feild);
-        } catch (Exception e) {
-            return AjaxResult.error(e.getMessage());
+        List<Map<String, String>> row;
+        VoltaHandle<ArrayList<Map<String,String>>> voltaRes = Analysis.analysis(file, feild);
+        if (voltaRes.getErr() != null){
+            return AjaxResult.error(voltaRes.getErr());
         }
         }
+        row = voltaRes.getData();
         Boolean res = fosterwxStationBindBoxService.importData(row,authUser);
         Boolean res = fosterwxStationBindBoxService.importData(row,authUser);
         return AjaxResult.success(HttpMsg.importSuccess);
         return AjaxResult.success(HttpMsg.importSuccess);
     }
     }

+ 6 - 6
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxTaskListController.java

@@ -7,6 +7,7 @@ import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.controller.BaseController;
 import com.mokamrp.privates.controller.BaseController;
 import com.mokamrp.privates.entity.AddHandle;
 import com.mokamrp.privates.entity.AddHandle;
+import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.pangu.FosterwxTaskListHandle;
 import com.mokamrp.privates.entity.pangu.FosterwxTaskListHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.help.Analysis;
 import com.mokamrp.privates.help.Analysis;
@@ -142,13 +143,12 @@ public class FosterwxTaskListController extends BaseController<FosterwxTaskList>
     public Object uploadFile(@RequestParam Integer templateId, @RequestBody MultipartFile file, @AuthUser User authUser) {
     public Object uploadFile(@RequestParam Integer templateId, @RequestBody MultipartFile file, @AuthUser User authUser) {
         Map<Integer, String> field = new HashMap<>(1);
         Map<Integer, String> field = new HashMap<>(1);
         field.put(0, "taskContent");
         field.put(0, "taskContent");
-        List<Map<String, String>> row = new ArrayList<>();
-        try {
-            row = Analysis.analysis(file, field);
-        } catch (Exception e) {
-            return AjaxResult.error(e.getMessage());
+        List<Map<String, String>> row;
+        VoltaHandle<ArrayList<Map<String,String>>> voltaRes = Analysis.analysis(file, field);
+        if (voltaRes.getErr() != null){
+            return AjaxResult.error(voltaRes.getErr());
         }
         }
-
+        row = voltaRes.getData();
         LambdaQueryWrapper<FosterwxTaskList> taskListLambdaQueryWrapper = new LambdaQueryWrapper<>();
         LambdaQueryWrapper<FosterwxTaskList> taskListLambdaQueryWrapper = new LambdaQueryWrapper<>();
         taskListLambdaQueryWrapper.eq(FosterwxTaskList::getTemplateId, templateId);
         taskListLambdaQueryWrapper.eq(FosterwxTaskList::getTemplateId, templateId);
         taskListLambdaQueryWrapper.orderByDesc(FosterwxTaskList::getId);
         taskListLambdaQueryWrapper.orderByDesc(FosterwxTaskList::getId);

+ 12 - 0
src/main/java/com/mokamrp/privates/entity/VoltaHandle.java

@@ -0,0 +1,12 @@
+package com.mokamrp.privates.entity;
+
+import lombok.Data;
+
+@Data
+public class VoltaHandle <T> {
+
+    private String err;
+
+    private T data;
+
+}

+ 33 - 22
src/main/java/com/mokamrp/privates/help/Analysis.java

@@ -1,5 +1,7 @@
 package com.mokamrp.privates.help;
 package com.mokamrp.privates.help;
 
 
+import com.mokamrp.privates.entity.VoltaHandle;
+import com.mokamrp.privates.utils.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Row;
@@ -29,11 +31,12 @@ public class Analysis {
      * @param file 上传的文件
      * @param file 上传的文件
      * @return 二维集合(第一重集合为行,第二重集合为列,每一行包含该行的列集合,列集合包含该行的全部单元格的值)
      * @return 二维集合(第一重集合为行,第二重集合为列,每一行包含该行的列集合,列集合包含该行的全部单元格的值)
      */
      */
-    public static ArrayList<Map<String,String>> analysis(MultipartFile file, Map<Integer, String> field) throws IOException {
-
+    public static VoltaHandle<ArrayList<Map<String,String>>> analysis(MultipartFile file, Map<Integer, String> field) {
+        VoltaHandle<ArrayList<Map<String,String>>> res = new VoltaHandle<>();
         ArrayList<Map<String,String>> row = new ArrayList<>();
         ArrayList<Map<String,String>> row = new ArrayList<>();
         if(field.size()<=0){
         if(field.size()<=0){
-            return row;
+            res.setErr("表格每列绑定参数为空,请先绑定");
+            return res;
         }
         }
 
 
         //获取文件名称
         //获取文件名称
@@ -60,21 +63,35 @@ public class Analysis {
                 //循环获取每一列
                 //循环获取每一列
                 Map<String,String> cell = new HashMap<>();
                 Map<String,String> cell = new HashMap<>();
                 for (int j = 0; j < sheetRow.getPhysicalNumberOfCells(); j++) {
                 for (int j = 0; j < sheetRow.getPhysicalNumberOfCells(); j++) {
-                    //将每一个单元格的值装入列集合
+                    String[] param = field.get(j).split("\\|");
+                    String paramKey = param[0];
+                    String paramValue = null;
+                    String paramRule = null;
+                    if (param.length > 1){
+                        paramRule = param[1];
+                    }
                     if (sheetRow.getCell(j) == null){
                     if (sheetRow.getCell(j) == null){
                         continue;
                         continue;
                     }
                     }
                     sheetRow.getCell(j).setCellType(CellType.STRING);
                     sheetRow.getCell(j).setCellType(CellType.STRING);
-                    if (sheetRow.getCell(j).getStringCellValue() == null || sheetRow.getCell(j).getStringCellValue().isEmpty()){
-                        continue;
+                    //如果列数据为空,检查是否允许此列数据为空
+                    if (sheetRow.getCell(j).getStringCellValue() == null || sheetRow.getCell(j).getStringCellValue().isEmpty()) {
+                        if (paramRule == null){
+                            String collName = sheet.getRow(0).getCell(j).getStringCellValue();
+                            res.setErr("第"+i+"行,("+collName+")列数据不可为空,请检查表格");
+                            return res;
+                        }else if (paramRule.equals("default")) {
+                            continue;
+                        }else {
+                            paramValue = paramRule;
+                        }
+                    }else{
+                        paramValue = sheetRow.getCell(j).getStringCellValue();
                     }
                     }
-                    System.out.println(sheetRow.getCell(j).getStringCellValue());
                     if(j>=field.size()){
                     if(j>=field.size()){
                         break;
                         break;
                     }
                     }
-
-                    String tempKey = field.get(j);
-                    cell.put(tempKey,sheetRow.getCell(j).getStringCellValue());
+                    cell.put(paramKey,paramValue);
                 }
                 }
                 if (!cell.isEmpty()){
                 if (!cell.isEmpty()){
                     //将装有每一列的集合装入大集合
                     //将装有每一列的集合装入大集合
@@ -84,20 +101,14 @@ public class Analysis {
                 workbook.close();
                 workbook.close();
             }
             }
         } catch (FileNotFoundException e) {
         } catch (FileNotFoundException e) {
-            e.printStackTrace();
-            System.out.println("===================未找到文件======================");
-            throw e;
+            res.setErr("未找到文件");
+            return res;
         } catch (IOException e) {
         } catch (IOException e) {
-            e.printStackTrace();
-            System.out.println("===================上传失败======================");
-            throw e;
-        } catch(Throwable e){
-            e.printStackTrace();
-            System.out.println(e.getMessage());
-            throw e;
+            res.setErr("上传时报");
+            return res;
         }
         }
-
-        return row;
+        res.setData(row);
+        return res;
     }
     }
 
 
     /**
     /**

+ 15 - 3
src/main/java/com/mokamrp/privates/service/impl/WorkEmployeeFriendcircleServiceImpl.java

@@ -1,11 +1,14 @@
 package com.mokamrp.privates.service.impl;
 package com.mokamrp.privates.service.impl;
 
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.mapper.pojo.Corp;
 import com.mokamrp.privates.mapper.pojo.SetUserTag;
 import com.mokamrp.privates.mapper.pojo.SetUserTag;
 import com.mokamrp.privates.mapper.pojo.SetUserTagMain;
 import com.mokamrp.privates.mapper.pojo.SetUserTagMain;
 import com.mokamrp.privates.mapper.pojo.WorkEmployeeFriendcircle;
 import com.mokamrp.privates.mapper.pojo.WorkEmployeeFriendcircle;
 import com.mokamrp.privates.mapper.WorkEmployeeFriendcircleMapper;
 import com.mokamrp.privates.mapper.WorkEmployeeFriendcircleMapper;
 import com.mokamrp.privates.mapper.vo.WorkEmployeeFriendcircleVo;
 import com.mokamrp.privates.mapper.vo.WorkEmployeeFriendcircleVo;
+import com.mokamrp.privates.service.CorpService;
 import com.mokamrp.privates.service.WorkEmployeeFriendcircleService;
 import com.mokamrp.privates.service.WorkEmployeeFriendcircleService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.tomcat.jni.Local;
 import org.apache.tomcat.jni.Local;
@@ -14,6 +17,7 @@ import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.transaction.annotation.Transactional;
 
 
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
@@ -32,6 +36,9 @@ public class WorkEmployeeFriendcircleServiceImpl extends ServiceImpl<WorkEmploye
 
 
     @Autowired
     @Autowired
     public WorkEmployeeFriendcircleMapper workEmployeeFriendcircleMapper;
     public WorkEmployeeFriendcircleMapper workEmployeeFriendcircleMapper;
+
+    @Autowired
+    public CorpService corpService;
     /**
     /**
      * 获取数据列表 支持分页
      * 获取数据列表 支持分页
      * @param handle
      * @param handle
@@ -58,18 +65,23 @@ public class WorkEmployeeFriendcircleServiceImpl extends ServiceImpl<WorkEmploye
      * @param row
      * @param row
      * @return
      * @return
      */
      */
-    public Boolean importData(List<Map<String,String>> row){
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean importData(List<Map<String,String>> row)  throws Exception{
         if(row.size() <= 0){
         if(row.size() <= 0){
-            return false;
+            throw new Exception("表格读取完成后,没有获取到任何数据");
         }
         }
         List<WorkEmployeeFriendcircle> add = new ArrayList<>();
         List<WorkEmployeeFriendcircle> add = new ArrayList<>();
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         for (int i = 0;i<row.size();i++) {
         for (int i = 0;i<row.size();i++) {
             System.out.println(row.get(i));
             System.out.println(row.get(i));
+            Corp corp = corpService.getOne(new QueryWrapper<Corp>().eq("name",row.get(i).get("corpName")));
+            if (corp == null){
+                throw new Exception(row.get(i).get("corpName") + "不存在");
+            }
             Map<String, String> cell = row.get(i);
             Map<String, String> cell = row.get(i);
             WorkEmployeeFriendcircle workEmployeeFriendcircle = new WorkEmployeeFriendcircle();
             WorkEmployeeFriendcircle workEmployeeFriendcircle = new WorkEmployeeFriendcircle();
             workEmployeeFriendcircle.setDeviceCode(row.get(i).get("deviceCode"));
             workEmployeeFriendcircle.setDeviceCode(row.get(i).get("deviceCode"));
-            workEmployeeFriendcircle.setCorpId(Integer.parseInt(row.get(i).get("corpId")));
+            workEmployeeFriendcircle.setCorpId(corp.getId());
             workEmployeeFriendcircle.setType(Integer.parseInt(row.get(i).get("type")));
             workEmployeeFriendcircle.setType(Integer.parseInt(row.get(i).get("type")));
             workEmployeeFriendcircle.setBoxName(row.get(i).get("boxName"));
             workEmployeeFriendcircle.setBoxName(row.get(i).get("boxName"));
             workEmployeeFriendcircle.setTagName(row.get(i).get("tagName"));
             workEmployeeFriendcircle.setTagName(row.get(i).get("tagName"));

+ 2 - 1
src/main/java/com/mokamrp/privates/service/pangu/FosterwxMobileService.java

@@ -1,6 +1,7 @@
 package com.mokamrp.privates.service.pangu;
 package com.mokamrp.privates.service.pangu;
 
 
 import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -23,5 +24,5 @@ public interface FosterwxMobileService extends IService<FosterwxMobile> {
     //.@leon 获取指定站点下账号列表
     //.@leon 获取指定站点下账号列表
     public Map<String, Object> getListByStationId(GetForsterwxMobileHandle getForsterwxMobileHandle, Integer stationId);
     public Map<String, Object> getListByStationId(GetForsterwxMobileHandle getForsterwxMobileHandle, Integer stationId);
 
 
-    Boolean importData(List<Map<String,String>> row, User authUser);
+    public VoltaHandle<Boolean> importData(List<Map<String,String>> row, User authUser) throws Exception;
 }
 }

+ 29 - 10
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
 import com.mokamrp.privates.mapper.pangu.FosterwxMobileMapper;
 import com.mokamrp.privates.mapper.pangu.FosterwxMobileMapper;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
@@ -17,6 +18,7 @@ import com.mokamrp.privates.service.pangu.FosterwxMobileWxfriendService;
 import com.mokamrp.privates.service.pangu.FosterwxStationService;
 import com.mokamrp.privates.service.pangu.FosterwxStationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
@@ -46,6 +48,9 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
     public FosterwxStationService fosterwxStationService;
     public FosterwxStationService fosterwxStationService;
 
 
     @Autowired
     @Autowired
+    public FosterwxMobileService fosterwxMobileService;
+
+    @Autowired
     public CorpService corpService;
     public CorpService corpService;
 
 
     /**
     /**
@@ -91,27 +96,42 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
      * @param row
      * @param row
      * @return
      * @return
      */
      */
-    public Boolean importData(List<Map<String, String>> row, User authUser) {
+    @Transactional(rollbackFor = Exception.class)
+    public VoltaHandle<Boolean> importData(List<Map<String, String>> row, User authUser) throws Exception{
+        VoltaHandle<Boolean> res = new VoltaHandle<>();
         if (row.size() <= 0) {
         if (row.size() <= 0) {
-            return false;
+            throw new Exception("表格读取完成后,没有获取到任何数据");
         }
         }
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         for (int i = 0; i < row.size(); i++) {
         for (int i = 0; i < row.size(); i++) {
             LocalDateTime nowDate = LocalDateTime.now();
             LocalDateTime nowDate = LocalDateTime.now();
             Map<String, String> cell = row.get(i);
             Map<String, String> cell = row.get(i);
             FosterwxMobile fosterwxMobile = new FosterwxMobile();
             FosterwxMobile fosterwxMobile = new FosterwxMobile();
-            fosterwxMobile.setStationId(Integer.parseInt(row.get(i).get("stationId")));
-            fosterwxMobile.setMobileCode(String.format("%03d", Integer.parseInt(row.get(i).get("mobileCode"))));
+            FosterwxStation stationInfo = fosterwxStationService.getOne(new QueryWrapper<FosterwxStation>()
+                    .eq("station_name", row.get(i).get("stationName")));
+            if (stationInfo == null){
+                throw new Exception("站点编号不存在");
+            }
+            String mobileCode = String.format("%03d", Integer.parseInt(row.get(i).get("mobileCode")));
+            FosterwxMobile mobileInfo = fosterwxMobileService.getOne(new QueryWrapper<FosterwxMobile>()
+                    .eq("station_id",stationInfo.getId())
+                    .eq("mobile_code",mobileCode)
+            );
+            if (mobileInfo != null){
+                throw new Exception("第"+(i+1)+"行,手机编号:"+mobileCode+",已存在相同记录");
+            }
+            fosterwxMobile.setStationId(stationInfo.getId());
+            fosterwxMobile.setMobileCode(mobileCode);
             fosterwxMobile.setMobileNo(row.get(i).get("mobileNo"));
             fosterwxMobile.setMobileNo(row.get(i).get("mobileNo"));
             fosterwxMobile.setMobileOperator(Integer.parseInt(row.get(i).get("mobileOperator")));
             fosterwxMobile.setMobileOperator(Integer.parseInt(row.get(i).get("mobileOperator")));
-            fosterwxMobile.setMobileCreateAt(LocalDateTime.parse(row.get(i).get("mobileCreateAt"), df));
+            fosterwxMobile.setMobileCreateAt(LocalDateTime.parse(row.get(i).get("mobileCreateAt")+" 08:00:00", df));
             fosterwxMobile.setMobileAdvancePayAmt(Integer.parseInt(row.get(i).get("mobileAdvancePayAmt")));
             fosterwxMobile.setMobileAdvancePayAmt(Integer.parseInt(row.get(i).get("mobileAdvancePayAmt")));
             fosterwxMobile.setMobileCombo(row.get(i).get("mobileCombo"));
             fosterwxMobile.setMobileCombo(row.get(i).get("mobileCombo"));
             fosterwxMobile.setMobileComboFlow(row.get(i).get("mobileComboFlow"));
             fosterwxMobile.setMobileComboFlow(row.get(i).get("mobileComboFlow"));
             fosterwxMobile.setMobileRealName(row.get(i).get("mobileRealName"));
             fosterwxMobile.setMobileRealName(row.get(i).get("mobileRealName"));
             fosterwxMobile.setMobileIdentityCardNo(row.get(i).get("mobileIdentityCardNo"));
             fosterwxMobile.setMobileIdentityCardNo(row.get(i).get("mobileIdentityCardNo"));
             fosterwxMobile.setWxPassword(row.get(i).get("wxPassword"));
             fosterwxMobile.setWxPassword(row.get(i).get("wxPassword"));
-            fosterwxMobile.setWxRegisterAt(LocalDateTime.parse(row.get(i).get("wxRegisterAt"), df));
+            fosterwxMobile.setWxRegisterAt(LocalDateTime.parse(row.get(i).get("wxRegisterAt")+" 08:00:00", df));
             fosterwxMobile.setWxRealName(row.get(i).get("wxRealName"));
             fosterwxMobile.setWxRealName(row.get(i).get("wxRealName"));
             fosterwxMobile.setWxIdentityCardNo(row.get(i).get("wxIdentityCardNo"));
             fosterwxMobile.setWxIdentityCardNo(row.get(i).get("wxIdentityCardNo"));
             fosterwxMobile.setBankCardNo(row.get(i).get("bankCardNo"));
             fosterwxMobile.setBankCardNo(row.get(i).get("bankCardNo"));
@@ -120,12 +140,11 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
                 fosterwxMobile.setWorkWxCorp(row.get(i).get("workWxCorp"));
                 fosterwxMobile.setWorkWxCorp(row.get(i).get("workWxCorp"));
             }
             }
             if (row.get(i).get("workWxRegisterAt") != null && !row.get(i).get("workWxRegisterAt").isEmpty()) {
             if (row.get(i).get("workWxRegisterAt") != null && !row.get(i).get("workWxRegisterAt").isEmpty()) {
-                fosterwxMobile.setWorkWxRegisterAt(LocalDateTime.parse(row.get(i).get("workWxRegisterAt"), df));
+                fosterwxMobile.setWorkWxRegisterAt(LocalDateTime.parse(row.get(i).get("workWxRegisterAt")+" 08:00:00", df));
             }
             }
             fosterwxMobile.setCreateAt(nowDate);
             fosterwxMobile.setCreateAt(nowDate);
             fosterwxMobile.setUpdateAt(nowDate);
             fosterwxMobile.setUpdateAt(nowDate);
-            FosterwxStation stationInfo = fosterwxStationService.getOne(new QueryWrapper<FosterwxStation>()
-                    .eq("id", fosterwxMobile.getStationId()));
+
             fosterwxMobile.setMobileUnioCode(stationInfo.getStationName() + fosterwxMobile.getMobileCode());
             fosterwxMobile.setMobileUnioCode(stationInfo.getStationName() + fosterwxMobile.getMobileCode());
             this.save(fosterwxMobile);
             this.save(fosterwxMobile);
             //.批量录入微信好友
             //.批量录入微信好友
@@ -154,7 +173,7 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
             }
             }
         }
         }
 //        this.saveBatch(add);
 //        this.saveBatch(add);
-        return true;
+        return res;
     }
     }
 
 
 }
 }

+ 2 - 0
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxStationBindBoxServiceImpl.java

@@ -12,6 +12,7 @@ import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.transaction.annotation.Transactional;
 
 
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
@@ -51,6 +52,7 @@ public class FosterwxStationBindBoxServiceImpl extends ServiceImpl<FosterwxStati
      * @param row
      * @param row
      * @return
      * @return
      */
      */
+    @Transactional
     public Boolean importData(List<Map<String,String>> row, User authUser){
     public Boolean importData(List<Map<String,String>> row, User authUser){
         if(row.size() <= 0){
         if(row.size() <= 0){
             return false;
             return false;

+ 13 - 5
src/main/java/com/mokamrp/privates/task/pangu/StationMobileNotice.java

@@ -1,5 +1,6 @@
 package com.mokamrp.privates.task.pangu;
 package com.mokamrp.privates.task.pangu;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
@@ -16,6 +17,7 @@ import org.springframework.stereotype.Component;
 
 
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -44,24 +46,30 @@ public class StationMobileNotice {
         String lastDay = LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
         String lastDay = LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
         getForsterwxMobileHandle.setCreateDate(lastDay);
         getForsterwxMobileHandle.setCreateDate(lastDay);
         getForsterwxMobileHandle.setPage(1);
         getForsterwxMobileHandle.setPage(1);
-        getForsterwxMobileHandle.setPagesize(9999);
+        getForsterwxMobileHandle.setPagesize(99999);
         ResHandle<List<FosterwxMobile>> res = fosterwxMobileService.getList(getForsterwxMobileHandle);
         ResHandle<List<FosterwxMobile>> res = fosterwxMobileService.getList(getForsterwxMobileHandle);
         List<FosterwxMobile> list = res.getList();
         List<FosterwxMobile> list = res.getList();
-        Map<String,String> sendMap = new HashMap<>();
+        Map<String,List<String>> sendMap = new HashMap<>();
         List<FosterwxStation> fosterwxStationList = fosterwxStationService.list();
         List<FosterwxStation> fosterwxStationList = fosterwxStationService.list();
         for (FosterwxMobile fosterwxMobile : list){
         for (FosterwxMobile fosterwxMobile : list){
             FosterwxStation fosterwxStationInfo = this.getStationInfo(fosterwxMobile.getStationId(),fosterwxStationList);
             FosterwxStation fosterwxStationInfo = this.getStationInfo(fosterwxMobile.getStationId(),fosterwxStationList);
             String stationNm = fosterwxStationInfo.getStationName();
             String stationNm = fosterwxStationInfo.getStationName();
             if (sendMap.get(stationNm) == null || sendMap.get(stationNm).isEmpty()){
             if (sendMap.get(stationNm) == null || sendMap.get(stationNm).isEmpty()){
-                sendMap.put(stationNm,fosterwxMobile.getMobileCode().toString());
+                List<String> mobileList = new ArrayList<>();
+                mobileList.add(fosterwxMobile.getMobileCode().toString());
+                sendMap.put(stationNm,mobileList);
             }else{
             }else{
-                sendMap.put(stationNm,sendMap.get(stationNm)+"、"+fosterwxMobile.getMobileCode().toString());
+                List<String> mobileList = sendMap.get(stationNm);
+                mobileList.add(fosterwxMobile.getMobileCode().toString());
+                sendMap.put(stationNm,mobileList);
             }
             }
         }
         }
         String sendMsg = "[站点账号新增 "+lastDay+"]\r\n";
         String sendMsg = "[站点账号新增 "+lastDay+"]\r\n";
         for (String key : sendMap.keySet()){
         for (String key : sendMap.keySet()){
+            FosterwxStation station = fosterwxStationService.getOne(new QueryWrapper<FosterwxStation>().eq("station_name",key));
+            int stationMobileCnt = fosterwxMobileService.count(new QueryWrapper<FosterwxMobile>().eq("station_id",station.getId()));
             sendMsg += "站点编号:"+key+"   ";
             sendMsg += "站点编号:"+key+"   ";
-            sendMsg += "手机编号:"+sendMap.get(key)+"\r\n";
+            sendMsg += "新增手机:"+sendMap.get(key).size()+",累计手机:"+stationMobileCnt;
         }
         }
         Cmd.sendFeishuMsg(feishu, sendMsg);
         Cmd.sendFeishuMsg(feishu, sendMsg);
     }
     }