Ver código fonte

Merge branch 'test' of http://git.mokasz.com/marketing/moka-private into test

leon 4 anos atrás
pai
commit
7cd4fe0a2e

+ 103 - 0
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileController.java

@@ -1,5 +1,6 @@
 package com.mokamrp.privates.controller.pangu;
 
+import com.aliyun.oss.OSSClient;
 import com.aliyun.oss.model.PutObjectRequest;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -20,6 +21,7 @@ import com.mokamrp.privates.mapper.pojo.User;
 import com.mokamrp.privates.service.CorpService;
 import com.mokamrp.privates.service.pangu.*;
 import com.mokamrp.privates.utils.OssFile;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -75,6 +77,12 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
     @Autowired
     private FosterwxTaskListService fosterwxTaskListService;
 
+    @Autowired
+    private OSSConfiguration ossConfiguration;
+
+    @Autowired
+    private OSSClient ossClient;
+
     /*
      * @fast
      * 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
@@ -1063,5 +1071,100 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
 //                new ByteArrayInputStream(content.toString().getBytes()));
 //        ossClient.putObject(putObjectRequest);
 //    }
+
+    @PostMapping("/export")
+    @ApiOperation("导出账号列表")
+    public Object export(@Valid @RequestBody GetForsterwxMobileHandle getForsterwxMobileHandle, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        ResHandle<List<FosterwxMobileVo>> res = fosterwxMobileService.getList(getForsterwxMobileHandle);
+        List<Object> tempObj;
+        List<List<Object>> resList = new ArrayList<List<Object>>();
+        Object[] head = {
+                "站点ID",
+                "手机编号",
+                "是否划入个微池 0:未划入,1:已划入",
+                "手机号码",
+                "手机运营商(1.中国移动2.中国联通3.中国电信4.物联卡5.铁通6.其他)",
+                "手机开卡时间",
+                "手机预支付金额",
+                "手机套餐",
+                "手机套餐包含流量",
+                "微信实名姓名",
+                "微信状态(1.正常2.封禁)",
+                "微信注册时间",
+                "银行卡手机号码",
+                "企业微信主体",
+                "企微appid",
+                "企业微信注册时间",
+                "企业微信状态(1.正常2.封禁)",
+                "客服名称",
+                "个微二维码"
+        };
+        List<Object> headList = Arrays.asList(head);
+        Date currentTime = new Date();
+        String fileName = "账号列表数据.csv";
+        resList.add(headList);
+        for (FosterwxMobileVo fosterwxMobileVo : res.getList()) {
+            tempObj = new ArrayList<Object>() {
+                {
+                    // "站点ID",
+                    this.add(fosterwxMobileVo.getStationId());
+                    // "手机编号",
+                    this.add(fosterwxMobileVo.getMobileCode());
+                    // "是否划入个微池 0:未划入,1:已划入",
+                    this.add(fosterwxMobileVo.getInPool());
+                    // "手机号码",
+                    this.add(fosterwxMobileVo.getMobileNo());
+                    // "手机运营商(1.中国移动2.中国联通3.中国电信4.物联卡5.铁通6.其他)",
+                    this.add(fosterwxMobileVo.getMobileOperator());
+                    // "手机开卡时间",
+                    this.add(fosterwxMobileVo.getMobileCreateAt());
+                    // "手机预支付金额",
+                    this.add(fosterwxMobileVo.getMobileAdvancePayAmt());
+                    // "手机套餐",
+                    this.add(fosterwxMobileVo.getMobileCombo());
+                    // "手机套餐包含流量",
+                    this.add(fosterwxMobileVo.getMobileComboFlow());
+                    // "微信实名姓名",
+                    this.add(fosterwxMobileVo.getWxRealName());
+                    // "微信状态(1.正常2.封禁)",
+                    this.add(fosterwxMobileVo.getWxStatus());
+                    // "微信注册时间",
+                    this.add(fosterwxMobileVo.getWxRegisterAt());
+                    // "银行卡手机号码",
+                    this.add(fosterwxMobileVo.getBankCardMobileNo());
+
+                    // 获取企微主体信息
+                    Corp corp = corpService.getById(fosterwxMobileVo.getWorkWxCorpId());
+                    if (null != corp) {
+                        // "企业微信主体",
+                        this.add(corp.getName());
+                        // "企微appid",
+                        this.add(corp.getWxCorpid());
+                    }
+                    // "企业微信注册时间",
+                    this.add(fosterwxMobileVo.getWorkWxRegisterAt());
+                    // "企业微信状态(1.正常2.封禁)",
+                    this.add(fosterwxMobileVo.getWorkWxStatus());
+                    // "客服名称",
+                    this.add(fosterwxMobileVo.getCustserviceName());
+                    // "个微二维码"
+                    this.add(fosterwxMobileVo.getCodeUrl());
+                }
+            };
+            resList.add(tempObj);
+        }
+        StringBuffer content = OssFile.createCSV(resList);
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        String dateString = formatter.format(currentTime);
+        String randNum = UUID.randomUUID().toString().replaceAll("-", "");
+        String filePath = OSSConfiguration.PAN_DIR + dateString + "/" + randNum + "_" + fileName;
+        PutObjectRequest putObjectRequest = new PutObjectRequest(ossConfiguration.getBucketName(), filePath,
+                new ByteArrayInputStream(content.toString().getBytes()));
+        ossClient.putObject(putObjectRequest);
+        return AjaxResult.success(ossConfiguration.getHost() + filePath);
+    }
 }