瀏覽代碼

Merge remote-tracking branch 'origin/develop' into develop

FengChaoYu 7 月之前
父節點
當前提交
d06d32999b

+ 16 - 0
mall-server-api/src/main/java/com/gree/mall/manager/controller/admin/AdminDeptController.java

@@ -14,6 +14,7 @@ import com.gree.mall.manager.helper.ResponseHelper;
 import com.gree.mall.manager.logic.admin.AdminDeptLogic;
 import com.gree.mall.manager.plus.entity.AdminDept;
 import com.gree.mall.manager.plus.entity.AdminDeptWebsit;
+import com.gree.mall.manager.utils.excel.ExcelUtils;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import io.swagger.annotations.Api;
@@ -22,9 +23,11 @@ import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.text.ParseException;
 import java.util.List;
 
@@ -141,4 +144,17 @@ public class AdminDeptController {
         return ResponseHelper.success();
     }
 
+
+
+    @PostMapping("/import")
+    @ApiOperation("导入部门网点")
+    public ResponseHelper importData(
+            @RequestPart("file") MultipartFile file
+    ) throws IOException {
+        List<Object> objects = ExcelUtils.importExcel(file);
+        adminDeptLogic.importData(objects);
+        return ResponseHelper.success();
+    }
+
+
 }

+ 9 - 0
mall-server-api/src/main/java/com/gree/mall/manager/controller/websit/WebsitController.java

@@ -37,6 +37,15 @@ public class WebsitController {
         return ResponseHelper.success(list);
     }
 
+    @GetMapping("/websitSync")
+    @ApiOperation(value = "更新部门网点")
+    public ResponseHelper websitSync(
+
+    ) {
+      websitLogic.websitSync();
+        return ResponseHelper.success();
+    }
+
 
 //    @GetMapping("/position/list")
 //    @ApiOperation(value = "职位列表")

+ 46 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminDeptLogic.java

@@ -1,5 +1,6 @@
 package com.gree.mall.manager.logic.admin;
 
+import com.aliyuncs.utils.StringUtils;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.admin.AdminDeptTree;
@@ -15,6 +16,7 @@ import com.gree.mall.manager.plus.service.AdminDeptService;
 import com.gree.mall.manager.plus.service.AdminDeptWebsitService;
 import com.gree.mall.manager.plus.service.AdminUserDeptRelaService;
 import com.gree.mall.manager.plus.service.AdminWebsitService;
+import com.gree.mall.manager.utils.StringUtil;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -22,6 +24,7 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
@@ -217,4 +220,47 @@ public class AdminDeptLogic {
             adminDeptWebsit.insert();
         }
     }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void importData(List<Object> datas) {
+
+        int index = 1;
+
+        List<AdminDeptWebsit> adminDeptWebsits = new ArrayList<>();
+
+        List<AdminDept> adminDepts = adminDeptService.lambdaQuery().list();
+
+        for(Object o : datas) {
+
+            index++;
+            List<Object> row = (List<Object>) o;
+
+            if (StringUtil.isEmpty((String) row.get(2)))
+                throw new RemoteServiceException("第"+index+"行,部门名称为空");
+
+            List<AdminDept> adminDept = adminDepts.stream().filter(item -> item.getDeptName().equals(row.get(2))).collect(Collectors.toList());
+
+
+            if (CollectionUtils.isEmpty(adminDept))
+                throw new RemoteServiceException("第"+index+"行,部门名称找不到对应部门");
+
+
+            AdminDept adminDept1 = adminDept.get(0);
+
+            AdminDeptWebsit adminDeptWebsit = new AdminDeptWebsit();
+
+            adminDeptWebsit.setDeptName(adminDept1.getDeptName());
+            adminDeptWebsit.setAdminDeptId(adminDept1.getAdminDeptId());
+            adminDeptWebsit.setWebsitId((String)row.get(0));
+            adminDeptWebsit.setWebsitName((String)row.get(1));
+
+
+            adminDeptWebsits.add(adminDeptWebsit);
+
+        }
+
+        adminDeptWebsitService.saveBatch(adminDeptWebsits);
+
+
+    }
 }

+ 20 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/websit/WebsitLogic.java

@@ -1,5 +1,6 @@
 package com.gree.mall.manager.logic.websit;
 
+import com.gree.mall.manager.plus.service.AdminDeptService;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -20,6 +21,9 @@ import java.util.stream.Collectors;
 public class WebsitLogic {
     @Autowired
     private AdminWebsitService adminWebsitService;
+
+    @Autowired
+    AdminDeptService adminDeptService;
 //    @Autowired
 //    private EnterpriseWechatWorkerService enterpriseWechatWorkerService;
 
@@ -34,6 +38,22 @@ public class WebsitLogic {
                 .page(new Page<>(pageNo, pageSize));
     }
 
+    public void websitSync() {
+
+        AdminDept adminDept = adminDeptService.lambdaQuery().eq(AdminDept::getCompanyWechatId, "1831608878894858241")
+                .eq(AdminDept::getPId, "1").last("limit 1").one();
+        for (AdminWebsit adminWebsit : adminWebsitService.lambdaQuery().list()) {
+
+            AdminDeptWebsit adminDeptWebsit = new AdminDeptWebsit();
+            adminDeptWebsit.setAdminDeptId(adminDept.getAdminDeptId());
+            adminDeptWebsit.setWebsitId(adminWebsit.getWebsitId());
+            adminDeptWebsit.setWebsitName(adminWebsit.getName());
+            adminDeptWebsit.setDeptName(adminDept.getDeptName());
+            adminDeptWebsit.insert();
+        }
+
+    }
+
 //    public IPage<EnterpriseWechatWorker> positionList(Integer pageNo, Integer pageSize) {
 //        return enterpriseWechatWorkerService.lambdaQuery()
 //                .isNotNull(EnterpriseWechatWorker::getPosition)

二進制
mall-server-api/src/main/resources/template/部门网点导入.xlsx