Parcourir la source

中心文件下发,师傅端文件下发

FengChaoYu il y a 6 mois
Parent
commit
80de9b8f45

+ 15 - 1
mall-miniapp-service/pom.xml

@@ -346,7 +346,21 @@
             <artifactId>javax.mail</artifactId>
             <version>1.5.5</version>
         </dependency>
-
+        <!-- es -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>HdrHistogram</artifactId>
+                    <groupId>org.hdrhistogram</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>httpclient</artifactId>
+                    <groupId>org.apache.httpcomponents</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
     </dependencies>
 
 

+ 8 - 1
mall-miniapp-service/src/main/resources/bootstrap-dev.properties

@@ -78,4 +78,11 @@ inf.token.appid=zfire-jsm-sxb
 inf.token.appSecret=3e7iee31ub94rvvesp7266kwske7fple
 
 #分销商城appid
-share.mall.appid=wx21d155e8a449d9b1
+share.mall.appid=wx21d155e8a449d9b1
+
+spring.elasticsearch.uris=http://116.62.158.92:9200
+spring.elasticsearch.username=elastic
+spring.elasticsearch.password=zfire2022@
+spring.elasticsearch.connection-timeout=5s
+spring.elasticsearch.socket-timeout=30s
+management.health.elasticsearch.enabled=false

+ 8 - 1
mall-miniapp-service/src/main/resources/bootstrap-test.properties

@@ -76,4 +76,11 @@ inf.token.appid=zfire-jsm-sxb
 inf.token.appSecret=3e7iee31ub94rvvesp7266kwske7fple
 
 #分销商城appid
-share.mall.appid=wx21d155e8a449d9b1
+share.mall.appid=wx21d155e8a449d9b1
+
+spring.elasticsearch.uris=http://116.62.158.92:9200
+spring.elasticsearch.username=elastic
+spring.elasticsearch.password=zfire2022@
+spring.elasticsearch.connection-timeout=5s
+spring.elasticsearch.socket-timeout=30s
+management.health.elasticsearch.enabled=false

+ 150 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/es/CommonListES.java

@@ -0,0 +1,150 @@
+package com.gree.mall.manager.bean.es;
+
+/*
+ * 通用列表
+ * */
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.elasticsearch.annotations.Document;
+import org.springframework.data.elasticsearch.annotations.Field;
+import org.springframework.data.elasticsearch.annotations.FieldType;
+
+/**
+ *  FieldIndex.not_analyzed:不会分词,只能根据原词索引Field;
+ *  FieldIndex.analyzed:根据分词器分词,可以根据原词和分词后的词条索引Field;
+ *  FieldIndex.no:该字段不会被索引,查不到;
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@ApiModel
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Document(indexName = "common_list_v2", type = "_doc", replicas = 1, shards = 1, createIndex = true)
+public class CommonListES {
+
+    @Id
+    @Field(index = false, store = true, type = FieldType.Keyword)//index:设置通过这个字段是否可以进行搜索
+    private String id;
+    /**
+     * 1=标题,2=内容
+     */
+    @ApiModelProperty("1=标题,2=内容")
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String type;
+    //外键id
+    @Field(index = false, store = true, type = FieldType.Integer)
+    private String comListId;
+    @ApiModelProperty("网点编号")
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String websitNumber;
+    @ApiModelProperty("师傅编号")
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String workerNumber;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field1;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field2;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field3;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field4;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field5;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field6;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field7;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field8;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field9;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field10;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field11;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field12;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field13;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field14;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field15;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field16;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field17;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field18;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field19;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field20;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field21;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field22;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field23;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field24;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field25;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field26;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field27;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field28;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field29;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field30;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field31;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field32;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field33;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field34;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field35;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field36;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field37;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field38;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field39;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field40;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field41;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field42;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field43;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field44;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field45;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field46;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field47;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field48;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field49;
+    @Field(index = false, store = true, type = FieldType.Keyword)
+    private String field50;
+
+}

+ 5 - 0
mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/CommonMapper.java

@@ -30,6 +30,7 @@ import com.gree.mall.manager.bean.settle.SettleMonthWagesWorkerVO;
 import com.gree.mall.manager.bean.settle.repair.*;
 import com.gree.mall.manager.bean.workorder.*;
 import com.gree.mall.manager.enums.UserTypeEnum;
+import com.gree.mall.manager.plus.entity.ComList;
 import com.gree.mall.manager.zfire.bean.WorkerParamBean;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import org.apache.ibatis.annotations.Mapper;
@@ -690,4 +691,8 @@ public interface CommonMapper {
     Integer repairAllCount(@Param("companyWechatIds") List<String> companyWechatIds,
                            @Param("adminWebsitIds") List<String> adminWebsitIds,
                            @Param("status") Integer status);
+
+    IPage<ComList> queryComList(Page page,
+                                @Param("adminWebsitIds") List<String> adminWebsitIds,
+                                @Param("userName") String userName);
 }

+ 110 - 0
mall-server-api/src/main/java/com/gree/mall/manager/controller/comlist/ComListController.java

@@ -0,0 +1,110 @@
+package com.gree.mall.manager.controller.comlist;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gree.mall.manager.helper.ResponseHelper;
+import com.gree.mall.manager.logic.comlist.ComListLogic;
+import com.gree.mall.manager.plus.entity.ComDetailLog;
+import com.gree.mall.manager.plus.entity.ComList;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@Slf4j
+@RestController
+@Api(value = "通用万能列表API", tags = {"通用万能列表API"})
+@RequestMapping(value = "/com/list", produces = "application/json; charset=utf-8")
+public class ComListController {
+
+    @Autowired
+    ComListLogic comListLogic;
+
+    @GetMapping("/list")
+    @ApiOperation(value = "万能通用附件列表")
+    public ResponseHelper<ComList> list(
+            @ApiParam(required = false, value = "标题") @RequestParam(required = false) String title,
+            @ApiParam(required = false, value = "备注") @RequestParam(required = false) String remark,
+            @ApiParam(required = false, value = "是否强制提醒 true/false") @RequestParam(required = false) Boolean isNotice,
+            @ApiParam(required = true, value = "页号") @RequestParam(required = true) Integer pageNo,
+            @ApiParam(required = true, value = "页大小") @RequestParam(required = true) Integer pageSize,
+            HttpServletRequest request
+    ) {
+        IPage<ComList> list = comListLogic.list(title, remark, isNotice, pageNo, pageSize, request);
+        return ResponseHelper.success(list);
+    }
+
+
+    @PostMapping("/delete")
+    @ApiOperation(value = "删除万能通用附件")
+    public ResponseHelper list(
+            @ApiParam(required = true, value = "id") @RequestParam(required = true) Integer id,
+            HttpServletRequest request
+    ) {
+        comListLogic.delete(id, request);
+        return ResponseHelper.success();
+    }
+
+    @PostMapping("/yonge")
+    @ApiOperation(value = "上传万能通用列表附件")
+    public ResponseHelper yonge(
+            @ApiParam(required = true, value = "标题") @RequestParam(required = true) String title,
+            @ApiParam(required = false, value = "备注") @RequestParam(required = false) String remark,
+            @ApiParam(required = true, value = "file") @RequestParam(required = true) String file,
+            @ApiParam(required = false, value = "是否强制通知 true=是 false=否") @RequestParam(required = false) Boolean isNotice,
+            @ApiParam(required = false, value = "下载密码") @RequestParam(required = false) String downloadPwd,
+            HttpServletRequest request
+    ) throws Exception {
+        comListLogic.yonge(title, remark, file, isNotice, downloadPwd, request);
+        return ResponseHelper.success();
+    }
+
+    @GetMapping("/download")
+    @ApiOperation(value = "下载万能通用列表附件")
+    public void down(
+            @ApiParam(required = true, value = "id") @RequestParam(required = true) Integer id,
+            @ApiParam(required = false, value = "下载密码") @RequestParam(required = false) String downloadPwd,
+            HttpServletRequest request, HttpServletResponse response
+    ) throws Exception {
+        comListLogic.download(id, downloadPwd, request, response);
+        //return ResponseHelper.success(download);
+    }
+
+    @GetMapping("/download/get")
+    @ApiOperation("强制提醒-未下载的中心文件列表")
+    public ResponseHelper<IPage<ComList>> downGet(
+            @ApiParam(required = true, value = "页号") @RequestParam(required = true) Integer pageNo,
+            @ApiParam(required = true, value = "页大小") @RequestParam(required = true) Integer pageSize
+    ) throws Exception {
+        IPage<ComList> comListIPage = comListLogic.notDownComList(pageNo, pageSize);
+        return ResponseHelper.success(comListIPage);
+    }
+
+    @GetMapping("/download/batch")
+    @ApiOperation("强制提醒-批量下载文件")
+    public void downGet(
+            @ApiParam(required = true, value = "下载的文件数量上限") @RequestParam(required = true) Integer pageSize,
+            HttpServletRequest request, HttpServletResponse response
+    ) throws Exception {
+        comListLogic.download(pageSize, response);
+    }
+
+
+    @GetMapping("/download/log")
+    @ApiOperation(value = "下载记录")
+    public ResponseHelper<IPage<ComDetailLog>> downlog(
+            @ApiParam(required = true, value = "id") @RequestParam(required = true) Integer id,
+            @ApiParam(required = true, value = "页号") @RequestParam(required = true) Integer pageNo,
+            @ApiParam(required = true, value = "页大小") @RequestParam(required = true) Integer pageSize,
+            HttpServletRequest request
+    ) throws Exception {
+        IPage<ComDetailLog> comDetailLogIPage = comListLogic.logList(id, pageNo, pageSize, request);
+        return ResponseHelper.success(comDetailLogIPage);
+    }
+
+
+}

+ 96 - 0
mall-server-api/src/main/java/com/gree/mall/manager/controller/comlist/WorkerComListController.java

@@ -0,0 +1,96 @@
+package com.gree.mall.manager.controller.comlist;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gree.mall.manager.bean.es.CommonListES;
+import com.gree.mall.manager.helper.ResponseHelper;
+import com.gree.mall.manager.logic.comlist.WorkerComListLogic;
+import com.gree.mall.manager.plus.entity.WorkerComList;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+
+@Slf4j
+@RestController
+@Api(value = "师傅-文件下发", tags ={"师傅-文件下发"} )
+@RequestMapping(value = "/worker/comlist", produces = "application/json; charset=utf-8")
+public class WorkerComListController {
+
+    @Autowired
+    WorkerComListLogic workerComListLogic;
+
+    @GetMapping("/list")
+    @ApiOperation(value = "万能通用附件列表")
+    public ResponseHelper<IPage<WorkerComList>> list(
+            @ApiParam(required = false, value = "师傅编号") @RequestParam(required = false) String workerNumber,
+            @ApiParam(required = false, value = "标题") @RequestParam(required = false) String title,
+            @ApiParam(required = false, value = "备注") @RequestParam(required = false) String remark,
+            @ApiParam(required = false, value = "状态 true=显示 false=隐藏") @RequestParam(required = false) Boolean status,
+            @ApiParam(required = true, value = "页号") @RequestParam(required = true) Integer pageNum,
+            @ApiParam(required = true, value = "页大小") @RequestParam(required = true) Integer pageSize
+
+    ){
+        IPage<WorkerComList> list = workerComListLogic.list(workerNumber,title, status, remark, pageNum, pageSize);
+        return ResponseHelper.success(list);
+    }
+
+    @PostMapping("/delete")
+    @ApiOperation(value = "删除万能通用附件")
+    public ResponseHelper list(
+            @ApiParam(required = true, value = "id") @RequestParam(required = true) String id
+    ){
+        workerComListLogic.delete(id);
+        return ResponseHelper.success();
+    }
+
+    @PostMapping("/updateStatus")
+    @ApiOperation(value = "修改状态")
+    public ResponseHelper list(
+            @ApiParam(required = true, value = "id") @RequestParam(required = true) String id,
+            @ApiParam(required = true, value = "true=正常 false=隐藏") @RequestParam(required = true) Boolean status
+    ){
+        workerComListLogic.updateStatus(id,status);
+        return ResponseHelper.success();
+    }
+
+
+    @PostMapping("/save")
+    @ApiOperation(value = "上传万能通用列表附件")
+    public ResponseHelper save(
+            @ApiParam(required = true, value = "标题") @RequestParam(required = true) String title,
+            @ApiParam(required = false, value = "备注") @RequestParam(required = false) String remark,
+            @ApiParam(required = true, value = "fileUrl") @RequestParam(required = true) String file
+    ) throws Exception {
+        workerComListLogic.save(title,remark,file);
+        return ResponseHelper.success();
+    }
+
+    @GetMapping("/record")
+    @ApiOperation(value = "通用列表-明细")
+    public ResponseHelper<List<CommonListES>> record(
+            @ApiParam(required = true, value = "列表id") @RequestParam(required = true) String comListId,
+            @ApiParam(required = true, value = "师傅编号") @RequestParam(required = true) String workerNumber
+    ) throws Exception {
+        List<CommonListES> record = workerComListLogic.record(comListId, workerNumber);
+        return ResponseHelper.success(record);
+    }
+
+    @GetMapping("/download")
+    @ApiOperation(value = "下载万能通用列表附件")
+    public void down(
+            @ApiParam(required = true, value = "comListId") @RequestParam(required = true) Integer comListId,
+            @ApiParam(required = false, value = "websitNumber") @RequestParam(required = false) String websitNumber,
+            HttpServletRequest request, HttpServletResponse response
+    ) throws Exception {
+        workerComListLogic.download(comListId,websitNumber, request, response);
+    }
+
+
+}

+ 580 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/comlist/ComListLogic.java

@@ -0,0 +1,580 @@
+package com.gree.mall.manager.logic.comlist;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.excel.write.metadata.style.WriteCellStyle;
+import com.alibaba.excel.write.metadata.style.WriteFont;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.commonmapper.CommonMapper;
+import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.logic.common.CommonLogic;
+import com.gree.mall.manager.plus.entity.AdminWebsit;
+import com.gree.mall.manager.plus.entity.ComDetail;
+import com.gree.mall.manager.plus.entity.ComDetailLog;
+import com.gree.mall.manager.plus.entity.ComList;
+import com.gree.mall.manager.plus.service.AdminWebsitService;
+import com.gree.mall.manager.plus.service.ComDetailLogService;
+import com.gree.mall.manager.plus.service.ComDetailService;
+import com.gree.mall.manager.plus.service.ComListService;
+import com.gree.mall.manager.utils.CommonUtils;
+import com.gree.mall.manager.utils.DateUtils;
+import com.gree.mall.manager.utils.excel.ExcelUtils;
+import com.gree.mall.manager.utils.oss.OSSUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFFont;
+import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.xssf.streaming.SXSSFCell;
+import org.apache.poi.xssf.streaming.SXSSFRow;
+import org.apache.poi.xssf.streaming.SXSSFSheet;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class ComListLogic {
+
+    @Autowired
+    CommonLogic commonLogic;
+    @Autowired
+    OSSUtil ossUtil;
+
+    @Autowired
+    ComDetailService comDetailService;
+    @Autowired
+    ComListService comListService;
+    @Autowired
+    ComDetailLogService comDetailLogService;
+    @Autowired
+    CommonMapper commonMapper;
+    @Autowired
+    AdminWebsitService adminWebsitService;
+
+
+    public IPage<ComList> list(String title, String remark, Boolean isNotice, Integer pageNo, Integer pageSize, HttpServletRequest request) {
+        AdminUserCom adminUser = commonLogic.getAdminUser(request);
+
+        List<ComDetail> comDetails = comDetailService.lambdaQuery()
+                .select(ComDetail::getComListId)
+                .in(CollectionUtil.isNotEmpty(adminUser.getAdminWebsitIds()), ComDetail::getWebsitId, adminUser.getAdminWebsitIds())
+                .list();
+        List<String> comListIds = comDetails.stream().map(ComDetail::getComListId).collect(Collectors.toList());
+        if (comListIds.size() == 0) {
+            return new Page<>(pageNo, pageSize);
+        }
+
+        IPage<ComList> page = comListService.lambdaQuery()
+                //.eq(StringUtils.isNotEmpty(admin.getBelongCompany()),ComList::getBelongCompany,admin.getBelongCompany())
+                .in(ComList::getId, comListIds)
+                .eq(isNotice != null, ComList::getIsNotice, isNotice)
+                .like(StringUtils.isNotEmpty(title), ComList::getTitle, title)
+                .like(StringUtils.isNotEmpty(remark), ComList::getRemark, remark)
+                .orderByDesc(ComList::getCreateTime)
+                .page(new Page<>(pageNo, pageSize));
+        //不返回密码
+        page.getRecords().forEach(v -> v.setDownloadPwd(""));
+        return page;
+    }
+
+
+    public void delete(Integer id, HttpServletRequest request) {
+        AdminUserCom adminUser = commonLogic.getAdminUser(request);
+        if (adminUser.getType() == 0) {
+            throw new RemoteServiceException("暂无权限");
+        }
+        comListService.removeById(id);
+        comDetailService.lambdaUpdate().eq(ComDetail::getComListId, id).remove();
+    }
+
+
+    public void yonge(String title, String remark, String file, Boolean isNotice, String downloadPwd, HttpServletRequest request) throws RemoteServiceException, IOException {
+        AdminUserCom adminUser = commonLogic.getAdminUser(request);
+
+        Map<String, String> map = new HashMap<>();
+        ComList comList = new ComList();
+        comList.setCompanyWechatId(adminUser.getCompanyWechatId());
+        comList.setCompanyName(adminUser.getCompanyName());
+        comList.setTitle(title);
+        comList.setRemark(remark);
+        comList.setFileName(title);
+        comList.setIsNotice(isNotice);
+        comList.setDownloadPwd(downloadPwd);
+        comList.setIsPwd(StringUtils.isNotBlank(downloadPwd));
+        comList.setOperatorUserName(adminUser.getUserName());
+        comList.setOperatorNickName(adminUser.getNickName());
+        comList.setCreateTime(new Date());
+        comList.insert();
+
+        //新增拆分的附件明细表
+        ComDetail bean = new ComDetail();
+        bean.setCompanyWechatId(adminUser.getCompanyWechatId());
+        bean.setCompanyName(adminUser.getCompanyName());
+        bean.setTitle(title);
+        bean.setComListId(comList.getId());
+        bean.setFileName(title);
+        bean.setWebsitId(adminUser.getAdminWebsitIds().get(0));
+        bean.setFileUrl(file);
+        bean.setIsDownload(false);
+        bean.setCreateTime(new Date());
+        bean.insert();
+
+        map.put(comList.getCompanyName(), comList.getId());
+
+        //上传主文件到oss,并记录
+        //CommonFile commonFile = commonLogic.uploadFile(file);
+
+        String url = ossUtil.getUrl(file);
+        InputStream inputStream = commonLogic.getFileInputStreamByUrl(url);
+        List<Object> objects = ExcelUtils.importExcel(inputStream);
+        //拆分excel并上传oss
+        List<Map<String, Object>> fileUrls = this.createExcel(objects);
+        if (fileUrls == null) {
+            throw new RemoteServiceException("拆分失败");
+        }
+        List<ComDetail> comDetails = new ArrayList<>();
+        for (Map<String, Object> fileUrl : fileUrls) {
+            String websitNumber = (String) fileUrl.get("websitNumber");
+            String filePath = (String) fileUrl.get("filePath");
+            //新增拆分的附件明细表
+            //for(Belongcompany belongcompany : list) {
+            ComDetail comDetail = new ComDetail();
+            comDetail.setCompanyWechatId(adminUser.getCompanyWechatId());
+            comDetail.setCompanyName(adminUser.getCompanyName());
+            comDetail.setTitle(title);
+            comDetail.setComListId(map.get(comDetail.getCompanyName()));
+            comDetail.setFileName(title);
+            comDetail.setWebsitId(websitNumber);
+            comDetail.setFileUrl(filePath);
+            comDetail.setIsDownload(false);
+            comDetail.setCreateTime(new Date());
+            //comDetail.insert();
+            comDetails.add(comDetail);
+            //}
+        }
+        comDetailService.saveBatch(comDetails);
+    }
+
+    public void download(Integer id, String downloadPwd, HttpServletRequest request, HttpServletResponse response) throws IOException {
+        AdminUserCom adminUser = commonLogic.getAdminUser(request);
+        ComList comList = comListService.getById(id);
+        if (comList.getIsPwd() && !StringUtils.equals(comList.getDownloadPwd(), downloadPwd)) {
+            throw new RemoteServiceException("下载密码校验失败,请联系相关人员");
+        }
+        log.info("【中心文件下发下载】:{}", JSONObject.toJSONString(adminUser));
+        List<ComDetail> comDetails = comDetailService.lambdaQuery()
+                .eq(ComDetail::getComListId, id)
+                .eq(ComDetail::getWebsitId, adminUser.getAdminWebsitIds())
+                .list();
+
+        if (CollectionUtils.isEmpty(comDetails)) {
+            throw new RemoteServiceException("暂无您可下载的内容");
+        }
+        this.download(comDetails, adminUser, response);
+    }
+
+    private void download(List<ComDetail> comDetails, AdminUserCom admin, HttpServletResponse response) throws IOException {
+        String title = comDetails.get(0).getTitle();
+
+        final List<AdminWebsit> websitList = adminWebsitService.lambdaQuery()
+                .eq(AdminWebsit::getCompanyWechatId, admin.getCompanyWechatId())
+                .eq(AdminWebsit::getType, AdminWebsitTypeEnum.C.getKey())
+                .in(AdminWebsit::getWebsitId, admin.getAdminWebsitIds())
+                .list();
+
+        final Map<String, String> websitMap = websitList.stream().collect(Collectors.toMap(AdminWebsit::getWebsitId, AdminWebsit::getName));
+
+        for (ComDetail comDetail : comDetails) {
+            ComDetailLog comDetailLog = new ComDetailLog();
+            comDetailLog.setCompanyWechatId(admin.getCompanyWechatId());
+            comDetailLog.setCompanyName(admin.getCompanyName());
+            comDetailLog.setCreateTime(new Date());
+            comDetailLog.setComListId(comDetail.getComListId());
+            comDetailLog.setTitle(comDetail.getTitle());
+            comDetailLog.setUserName(admin.getUserName());
+            comDetailLog.setWebsitId(comDetail.getWebsitId());
+            comDetailLog.setWebsitName(websitMap.get(comDetail.getWebsitId()));
+            comDetailLog.insert();
+        }
+        List<Map<String, Object>> files = new ArrayList<>();
+        //String fileUrl = comDetail.getFileUrl();
+        for (ComDetail comDetail : comDetails) {
+            if (StringUtils.isEmpty(comDetail.getWebsitId())) {
+                continue;
+            }
+            String fileUrl = ossUtil.getUrlWw(comDetail.getFileUrl());
+            Map<String, Object> map = new HashMap<>();
+            map.put("fileUrl", fileUrl);
+            map.put("fileName", comDetail.getWebsitId() + "-(" + comDetail.getTitle() + ").xlsx");
+            files.add(map);
+        }
+        if (files.size() > 1) {
+            CommonUtils.writeZip(response, files);
+        } else {
+            CommonUtils.downloadFile(files.get(0).get("fileUrl").toString(), websitMap.get(admin.getAdminWebsitIds().get(0)) + "-" + title + ".xlsx", response);
+        }
+        //CommonUtils.downloadFile(imgFile,admin.getWebsitNumber()+"-"+comDetail.getTitle()+".csv",response);
+        //return imgFile;
+    }
+
+
+    public IPage<ComDetailLog> logList(Integer id, Integer pageNo, Integer pageSize, HttpServletRequest request) {
+        AdminUserCom adminUser = commonLogic.getAdminUser(request);
+
+        IPage<ComDetailLog> page = comDetailLogService.lambdaQuery()
+                .in(CollectionUtil.isNotEmpty(adminUser.getAdminWebsitIds()), ComDetailLog::getWebsitId, adminUser.getAdminWebsitIds())
+                .eq(Objects.nonNull(adminUser.getAdminCompanyWechat()), ComDetailLog::getCompanyWechatId, adminUser.getCompanyWechatId())
+                .eq(ComDetailLog::getComListId, id)
+                .orderByDesc(ComDetailLog::getCreateTime)
+                .page(new Page<>(pageNo, pageSize));
+        return page;
+    }
+
+    /**
+     * 未下载的中心文件
+     *
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    public IPage<ComList> notDownComList(Integer pageNum, Integer pageSize) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        if (adminUser.getType() != 0) {
+            return new Page<>();
+        }
+        IPage<ComList> comListIPage = commonMapper.queryComList(new Page(pageNum, pageSize), adminUser.getAdminWebsitIds(), adminUser.getUserName());
+        return comListIPage;
+    }
+
+    /**
+     * 公告提示的批量下载文件
+     */
+    public void download(Integer pageSize, HttpServletResponse response) throws IOException {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        //最多下载10个
+        IPage<ComList> comListIPage = commonMapper.queryComList(new Page(1, 10), adminUser.getAdminWebsitIds(), adminUser.getUserName());
+        if (CollectionUtils.isEmpty(comListIPage.getRecords())) {
+            return;
+        }
+        List<String> comListIds = comListIPage.getRecords().stream().map(ComList::getId).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(comListIds))
+            return;
+        List<ComDetail> comDetails = comDetailService.lambdaQuery()
+                .in(ComDetail::getComListId, comListIds)
+                .in(ComDetail::getWebsitId, adminUser.getAdminWebsitIds()).list();
+        if (CollectionUtils.isEmpty(comDetails)) {
+            return;
+        }
+        List<String> comDetailIds = comDetails.stream().map(ComDetail::getId).collect(Collectors.toList());
+        comDetailService.lambdaUpdate().set(ComDetail::getIsDownload, true).in(ComDetail::getId, comDetailIds).update();
+        this.download(comDetails, adminUser, response);
+    }
+
+
+    /**
+     * 创建Excel
+     */
+    public List<Map<String, Object>> createExcel(List<Object> datas) {
+        try {
+            // List<Object> datas = ExcelUtils.importExcel(file);
+            List<Object> tableHeaders = (List<Object>) datas.get(0);
+
+            Map<String, List<List<Object>>> map = new HashMap<>();
+            log.info("【中心下发文件1】" + DateUtils.formatDate(new Date()));
+            for (int i = 1; i < datas.size(); i++) {
+                List<Object> row = (List<Object>) datas.get(i);
+                CommonUtils.initList2(row, row.size() + 1);
+                //网点编号
+                String websitNumber = (String) row.get(1);
+
+                List<List<Object>> objects = map.get(websitNumber);
+                if (objects == null) {
+                    objects = new ArrayList<>();
+                }
+                //row.remove(0);
+                objects.add(row);
+
+                if (!map.containsKey(websitNumber)) {
+                    map.put(websitNumber, objects);
+                }
+            }
+            log.info("【中心下发文件2】" + DateUtils.formatDate(new Date()));
+            List<Map<String, Object>> fileUrls = new ArrayList<>();
+            for (String websitNumber : map.keySet()) {
+                //String filePath = "B:/"+email+"-"+file.getName()+".xlsx";
+                long currentTime = System.currentTimeMillis();
+                String filePath = OSSUtil.OSS_TYPE_PIC + websitNumber + currentTime + ".csv";
+                //executorService.submit( ()->{
+//                    try {
+//                ExcelData excelData = new ExcelData();
+//                excelData.setTitles(tableHeaders);
+//                excelData.setRows(map.get(websitNumber));
+
+                this.write(filePath, tableHeaders, map.get(websitNumber));
+//                    } catch (IOException e) {
+//                        log.error("上传文件失败",e);
+//                    }
+                //});
+                Map<String, Object> mp = new HashMap<>();
+                mp.put("websitNumber", websitNumber);
+                mp.put("filePath", filePath);
+                fileUrls.add(mp);
+            }
+            log.info("【中心下发文件3】" + DateUtils.formatDate(new Date()));
+            return fileUrls;
+        } catch (Exception e) {
+            log.error("【创建excel失败】", e);
+        }
+        return null;
+    }
+
+
+    //    public void export(ExcelData excelData,String fileName) throws IOException {
+//        OutputStream outputStream = null;
+//        try {
+//            //标题
+//            List<List<String>> titles = new ArrayList<>();
+//            for(String title : excelData.getTitles()){
+//                titles.add(Arrays.asList(title));
+//            }
+//
+//            //记录总数:实际中需要根据查询条件进行统计即可
+//            Integer totalCount = excelData.getRows().size();
+//            //每一个Sheet存放100w条数据
+//            Integer sheetDataRows = 1000000;
+//            //每次写入的数据量20w,每页查询20W
+//            Integer writeDataRows = 200000;
+//            //计算需要的Sheet数量
+//            Integer sheetNum = totalCount % sheetDataRows == 0 ? (totalCount / sheetDataRows) : (totalCount / sheetDataRows + 1);
+//            //计算一般情况下每一个Sheet需要写入的次数(一般情况不包含最后一个sheet,因为最后一个sheet不确定会写入多少条数据)
+//            Integer oneSheetWriteCount = sheetDataRows / writeDataRows;
+//            //计算最后一个sheet需要写入的次数
+//            Integer lastSheetWriteCount = totalCount % sheetDataRows == 0 ? oneSheetWriteCount : (totalCount % sheetDataRows % writeDataRows == 0 ? (totalCount / sheetDataRows / writeDataRows) : (totalCount / sheetDataRows / writeDataRows + 1));
+//            ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+//            HttpServletResponse response = requestAttributes.getResponse();
+//            outputStream = response.getOutputStream();
+//
+//            //样式
+//            WriteCellStyle cellStyle = writeCellStyle();
+//
+//            //必须放到循环外,否则会刷新流
+//            ExcelWriter excelWriter = EasyExcel.write(outputStream).registerWriteHandler(new CellWriteHandler(){
+//                public void afterCellDispose(CellWriteHandlerContext context) {
+//                    CellWriteHandler.super.afterCellDispose(context);
+//                    if (BooleanUtils.isNotTrue(context.getHead())) {
+//                        context.getFirstCellData().setWriteCellStyle(cellStyle);
+//                    }
+//                }
+//            }).build();
+//            //开始分批查询分次写入
+//            for (int i = 0; i < sheetNum; i++) {
+//                //创建Sheet
+////                WriteSheet sheet = new WriteSheet();
+////                sheet.setSheetName("Sheet"+i);
+////                sheet.setSheetNo(i);
+//                //循环写入次数: j的自增条件是当不是最后一个Sheet的时候写入次数为正常的每个Sheet写入的次数,如果是最后一个就需要使用计算的次数lastSheetWriteCount
+//                for (int j = 0; j < (i != sheetNum - 1 ? oneSheetWriteCount : lastSheetWriteCount); j++) {
+//                    //分页查询一次20w
+//                    WriteSheet writeSheet = EasyExcel.writerSheet(i, "Sheet" + (i + 1)).head(titles)
+//                            .registerWriteHandler(new SimpleColumnWidthStyleStrategy(30))
+//                            .build();
+//                    //写数据
+//                    excelWriter.write(excelData.getRows(), writeSheet);
+//                }
+//            }
+//            // 下载EXCEL
+////            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+////            response.setCharacterEncoding("utf-8");
+////            // 这里URLEncoder.encode可以防止浏览器端导出excel文件名中文乱码 当然和easyexcel没有关系
+////            //String fileName = URLEncoder.encode("员工信息", "UTF-8").replaceAll("\\+", "%20");
+////            response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName);
+//            Workbook workbook = excelWriter.writeContext().writeWorkbookHolder().getWorkbook();
+//            ByteArrayOutputStream ba = new ByteArrayOutputStream();
+//            try {
+//                workbook.write(ba);
+//                ByteArrayInputStream bio = new ByteArrayInputStream(ba.toByteArray());
+//                ossUtil.uploadFile(fileName,bio);
+//                bio.close();
+//            }finally {
+//                ba.flush();
+//                ba.close();
+//            }
+//            excelWriter.finish();
+//            outputStream.flush();
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        } catch (BeansException e) {
+//            e.printStackTrace();
+//        }finally {
+//            if (outputStream != null) {
+//                outputStream.close();
+//            }
+//        }
+//    }
+//
+//
+//    /**
+//     * excel样式
+//     * @return
+//     */
+    public static WriteCellStyle writeCellStyle() {
+        //样式
+        WriteFont font = new WriteFont();
+        font.setFontName("simsun");
+        font.setFontHeightInPoints((short) 10);
+        font.setColor(IndexedColors.BLACK.index);
+        WriteCellStyle cellStyle = new WriteCellStyle();
+        cellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
+        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyle.setWriteFont(font);
+        cellStyle.setWrapped(false);
+        cellStyle.setBorderTop(BorderStyle.THIN);
+        cellStyle.setBorderLeft(BorderStyle.THIN);
+        cellStyle.setBorderBottom(BorderStyle.THIN);
+        cellStyle.setBorderRight(BorderStyle.THIN);
+        return cellStyle;
+    }
+
+
+    /**
+     * 生成Excel文件的方法write
+     */
+    public void write(String fileName, List<Object> tableHeaders, List<List<Object>> rows) throws IOException {
+        // 初始一个workbook
+        SXSSFWorkbook workbook = new SXSSFWorkbook();
+        // 创建单个sheet
+        SXSSFSheet sheet = workbook.createSheet("sheet1");
+        // 创建第一行,设置列名
+        SXSSFRow row0 = sheet.createRow(0);
+        row0.setHeight((short) 400);             // 设置行高         // Excel的列
+
+        short cellNumber = (short) tableHeaders.size();  // 表的列数
+        //限制最多1000列
+        cellNumber = cellNumber > 1000 ? 1000 : cellNumber;
+        for (int k = 0; k < cellNumber; k++) {
+            short b = 5000;
+            SXSSFCell cell = row0.createCell(k);          // 创建第0行第k列
+            cell.setCellValue((String) tableHeaders.get(k));  // 设置第0行第k列的值
+            sheet.setColumnWidth(k, b);         // 设置列的宽度
+        }
+        if (rows.size() > 0) {
+            // 创建剩余行
+            for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) {
+                SXSSFRow row = sheet.createRow(rowIndex + 1);
+                List<Object> values = rows.get(rowIndex);
+                // 创建多列
+                for (int cellIndex = 0; cellIndex < values.size(); cellIndex++) {
+                    if (cellIndex > 1000) {
+                        continue;
+                    }
+                    SXSSFCell cell = row.createCell(cellIndex);
+                    cell.setCellValue((String) values.get(cellIndex));
+                }
+            }
+        }
+        ByteArrayOutputStream ba = new ByteArrayOutputStream();
+        try {
+
+            workbook.write(ba);
+            ByteArrayInputStream bio = new ByteArrayInputStream(ba.toByteArray());
+            ossUtil.uploadFile(fileName, bio);
+            bio.close();
+        } finally {
+            workbook.close();
+            ba.flush();
+            ba.close();
+        }
+    }
+
+    //
+//
+//    /**
+//     * 设备条码生成Excel文件的方法write
+//     */
+    public void writeExcel(String fileName, List<Object> tableHeaders, List<List<Object>> rows) throws IOException {
+        // 初始一个workbook
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        // 创建单个sheet
+        XSSFSheet sheet = workbook.createSheet("sheet1");
+        // 创建第一行,设置列名
+        XSSFRow row0 = sheet.createRow(0);
+        row0.setHeight((short) 400);             // 设置行高         // Excel的列
+        XSSFFont font = workbook.createFont();// 设置字体
+        font.setColor(HSSFFont.COLOR_NORMAL);           // 设置单元格字体的颜色
+        XSSFCellStyle style = workbook.createCellStyle();// 样式
+        // 设置边框颜色
+        style.setTopBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
+        style.setBottomBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
+        style.setLeftBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
+        style.setRightBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
+        // 设置文本格式
+        XSSFDataFormat format = workbook.createDataFormat();
+        style.setDataFormat(format.getFormat("@"));
+
+        short cellNumber = (short) tableHeaders.size();  // 表的列数
+        for (int k = 0; k < cellNumber; k++) {
+            short b = 5000;
+            XSSFCell cell = row0.createCell(k);          // 创建第0行第k列
+            cell.setCellValue((String) tableHeaders.get(k));  // 设置第0行第k列的值
+            sheet.setColumnWidth(k, b);         // 设置列的宽度
+            style.setFont(font);                // 设置字体风格
+            cell.setCellStyle(style);
+        }
+
+        XSSFCellStyle styleContext = workbook.createCellStyle();
+        styleContext.setWrapText(true);
+        // 设置边框颜色
+        styleContext.setTopBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
+        styleContext.setBottomBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
+        styleContext.setLeftBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
+        styleContext.setRightBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
+        // 设置文本格式
+        styleContext.setDataFormat(format.getFormat("@"));
+
+        if (rows.size() > 0) {
+            // 创建剩余行
+            for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) {
+                XSSFRow row = sheet.createRow(rowIndex + 1);
+                List<Object> values = rows.get(rowIndex);
+                // 创建多列
+                for (int cellIndex = 0; cellIndex < values.size(); cellIndex++) {
+                    XSSFCell cell = row.createCell(cellIndex);
+                    cell.setCellStyle(styleContext);               // 设置风格
+                    cell.setCellValue(values.get(cellIndex).toString());
+                }
+            }
+        }
+        ByteArrayOutputStream ba = new ByteArrayOutputStream();
+        try {
+
+            workbook.write(ba);
+            ByteArrayInputStream bio = new ByteArrayInputStream(ba.toByteArray());
+            ossUtil.uploadFile(fileName, bio);
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            ba.flush();
+            ba.close();
+        }
+    }
+
+}

+ 238 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/comlist/WorkerComListLogic.java

@@ -0,0 +1,238 @@
+package com.gree.mall.manager.logic.comlist;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.collect.Lists;
+import com.gree.mall.manager.bean.ExcelData;
+import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.bean.es.CommonListES;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.logic.common.CommonLogic;
+import com.gree.mall.manager.logic.es.EsLogic;
+import com.gree.mall.manager.plus.entity.AdminWebsit;
+import com.gree.mall.manager.plus.entity.WorkerComList;
+import com.gree.mall.manager.plus.entity.WorkerComListWebsit;
+import com.gree.mall.manager.plus.entity.WorkerComListWorker;
+import com.gree.mall.manager.plus.service.AdminWebsitService;
+import com.gree.mall.manager.plus.service.WorkerComListService;
+import com.gree.mall.manager.plus.service.WorkerComListWebsitService;
+import com.gree.mall.manager.plus.service.WorkerComListWorkerService;
+import com.gree.mall.manager.utils.CommonUtils;
+import com.gree.mall.manager.utils.excel.ExcelUtils;
+import com.gree.mall.manager.utils.oss.OSSUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class WorkerComListLogic {
+
+    @Autowired
+    CommonLogic commonLogic;
+    @Autowired
+    OSSUtil ossUtil;
+    @Autowired
+    EsLogic esLogic;
+    @Autowired
+    WorkerComListService workerComListService;
+    @Autowired
+    WorkerComListWorkerService workerComListWorkerService;
+    @Autowired
+    WorkerComListWebsitService workerComListWebsitService;
+    @Autowired
+    AdminWebsitService adminWebsitService;
+
+
+    /**
+     * 列表
+     */
+    public IPage<WorkerComList> list(String workerNumber, String title, Boolean status, String remark, Integer pageNum, Integer pageSize) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        List<String> comListIds = new ArrayList<>();
+        if (StringUtils.isNotEmpty(workerNumber)) {
+            //师傅编号不为空以师傅为准
+            List<WorkerComListWorker> worker = workerComListWorkerService.lambdaQuery()
+                    .eq(WorkerComListWorker::getWorkerComListWorkerNumber, workerNumber).list();
+            if (CollectionUtils.isEmpty(worker)) {
+                return new Page<>(pageNum, pageSize);
+            }
+            comListIds = worker.stream().map(WorkerComListWorker::getWorkerComListId).distinct().collect(Collectors.toList());
+        } else {
+            //以登录人为准
+            List<WorkerComListWebsit> websit = workerComListWebsitService.lambdaQuery()
+                    .in(WorkerComListWebsit::getWebsitId, adminUser.getAdminWebsitIds())
+                    .list();
+            if (CollectionUtils.isEmpty(websit)) {
+                return new Page<>(pageNum, pageSize);
+            }
+            comListIds = websit.stream().map(WorkerComListWebsit::getWorkerComListId).distinct().collect(Collectors.toList());
+        }
+        IPage<WorkerComList> page = workerComListService.lambdaQuery()
+                .like(StringUtils.isNotEmpty(title), WorkerComList::getTitle, title)
+                .eq(status != null, WorkerComList::getStatus, status)
+                .like(StringUtils.isNotEmpty(remark), WorkerComList::getRemark, remark)
+                .in(!CollectionUtils.isEmpty(comListIds), WorkerComList::getId, comListIds)
+                .orderByDesc(WorkerComList::getCreateTime)
+                .page(new Page<>(pageNum, pageSize));
+        return page;
+    }
+
+    /**
+     * 删除
+     */
+    public void delete(String id) {
+        workerComListService.removeById(id);
+    }
+
+    /**
+     * 修改状态
+     */
+    public void updateStatus(String id, Boolean status) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        WorkerComList workerComList = new WorkerComList();
+        workerComList.setId(id);
+        workerComList.setStatus(status);
+        workerComList.setUpdateBy(adminUser.getNickName());
+        workerComList.setUpdateTime(new Date());
+        workerComList.updateById();
+    }
+
+    /**
+     * 保存师傅通用列表
+     */
+    @Transactional
+    public void save(String title, String remark, String fileUrl) throws NoSuchFieldException, IllegalAccessException {
+
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        WorkerComList workerComList = new WorkerComList();
+        workerComList.setTitle(title);
+        workerComList.setRemark(remark);
+        workerComList.setFileUrl(fileUrl);
+        workerComList.setCreateTime(new Date());
+        workerComList.setUpdateTime(new Date());
+        workerComList.insert();
+
+        String url = ossUtil.getUrl(fileUrl);
+        InputStream inputStream = commonLogic.getFileInputStreamByUrl(url);
+        List<Object> objects = ExcelUtils.importExcel(inputStream);
+        //添加师傅
+        List<WorkerComListWorker> workerComListWorkers = new ArrayList<>();
+        for (Object o : objects) {
+            List<Object> row = (List<Object>) o;
+            String workerNumber = (String) row.get(0);
+            if (StringUtils.isEmpty(workerNumber)) {
+                continue;
+            }
+            WorkerComListWorker workerComListWorker = new WorkerComListWorker();
+            workerComListWorker.setCreateBy(workerComList.getCreateBy());
+            workerComListWorker.setCreateTime(new Date());
+            workerComListWorker.setWebsitId(workerNumber);
+            workerComListWorker.setWorkerComListId(workerComList.getId());
+            workerComListWorker.setWorkerComListWorkerNumber(workerNumber);
+            workerComListWorkers.add(workerComListWorker);
+        }
+        workerComListWorkerService.saveBatch(workerComListWorkers);
+        //添加网点
+        List<WorkerComListWebsit> workerComListWebsits = new ArrayList<>();
+        List<String> websitNumbers = workerComListWorkers.stream()
+                .map(WorkerComListWorker::getWebsitId).distinct().collect(Collectors.toList());
+        for (String websitNumber : websitNumbers) {
+            WorkerComListWebsit workerComListWebsit = new WorkerComListWebsit();
+            workerComListWebsit.setWorkerComListId(workerComList.getId());
+            workerComListWebsit.setWebsitId(websitNumber);
+            workerComListWebsit.setCreateBy(workerComList.getCreateBy());
+            workerComListWebsit.setCreateTime(workerComList.getCreateTime());
+            workerComListWebsits.add(workerComListWebsit);
+        }
+        workerComListWebsitService.saveBatch(workerComListWebsits);
+
+        //按2w/次添加到es
+        List<List<Object>> partition = Lists.partition(objects, 20000);
+        for (List<Object> datas : partition) {
+            //添加到es
+            esLogic.add(workerComList.getId(), remark, datas);
+        }
+    }
+
+
+    /**
+     * 通用列表明细
+     *
+     * @param comListId
+     * @param workerNumber
+     */
+    public List<CommonListES> record(String comListId, String workerNumber) {
+        List<CommonListES> list = esLogic.list(Arrays.asList(workerNumber), workerNumber, comListId);
+        return list;
+    }
+
+
+    public void download(Integer id, String websitNumber, HttpServletRequest request, HttpServletResponse response) throws Exception {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        if (StringUtils.isNotEmpty(websitNumber)) {
+            adminUser.setAdminWebsitIds(new ArrayList<String>() {{ this.add(websitNumber); }});
+        }
+        WorkerComList workerComList = workerComListService.getById(id);
+
+        if (adminUser.getType() == 1 || adminUser.getNickName().equals(workerComList.getCreateBy())) {
+            log.info("【中心文件下发下载】:{}", JSONObject.toJSONString(adminUser));
+            CommonUtils.downloadFile(ossUtil.getUrl(workerComList.getFileUrl()), workerComList.getTitle() + ".xlsx", response);
+        } else {
+            List<AdminWebsit> websitList = adminWebsitService.lambdaQuery().in(AdminWebsit::getWebsitId, adminUser.getCompanyWechatIds()).list();
+            List<String> websitNumbers = websitList.stream().map(AdminWebsit::getWebsitId).collect(Collectors.toList());
+            List<CommonListES> list = esLogic.list(websitNumbers, null, id.toString());
+            if (CollectionUtils.isEmpty(list)) {
+                throw new RemoteServiceException("暂无可下载的内容");
+            }
+            List<String> titles = new ArrayList<>();
+            List<List<Object>> datas = new ArrayList<>();
+            for (int i = 0; i < list.size(); i++) {
+
+                CommonListES bean = list.get(i);
+                List<Object> data = new ArrayList<>();
+
+                for (int x = 1; x <= 50; x++) {
+                    String field = "field" + x;
+                    Field declaredField = bean.getClass().getDeclaredField(field);
+                    declaredField.setAccessible(true);
+                    String value = (String) declaredField.get(bean);
+                    if (i == 0) {
+                        if (StringUtils.isNotEmpty(value)) {
+                            titles.add(value);
+                        }
+                    } else {
+                        if (StringUtils.isNotEmpty(value)) {
+                            data.add(value);
+                        }
+                    }
+                }
+
+                if (i > 0) {
+                    datas.add(data);
+                }
+            }
+            ExcelData excelData = new ExcelData();
+            excelData.setTitles(titles);
+            excelData.setRows(datas);
+            ExcelUtils.exportExcel(request, response, "info.xlsx", excelData);
+        }
+    }
+
+
+}

+ 111 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/es/EsLogic.java

@@ -0,0 +1,111 @@
+package com.gree.mall.manager.logic.es;
+
+import com.aliyuncs.utils.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.gree.mall.manager.bean.es.CommonListES;
+import com.gree.mall.manager.utils.CommonUtils;
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
+import org.springframework.data.elasticsearch.core.SearchHit;
+import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
+import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
+import org.springframework.stereotype.Service;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 操作es
+ */
+
+@Service
+public class EsLogic {
+
+    @Autowired
+    private ElasticsearchRestTemplate elasticsearchRestTemplate;
+
+    public boolean createIndexAndMapping(Class<?> classType) {
+        if(elasticsearchRestTemplate.indexOps(classType).exists()){
+            return true;
+        }
+        boolean b = elasticsearchRestTemplate.indexOps(classType).create();
+        return b;
+    }
+
+    //@Test
+    public void add(String comListId,String remark,List<Object> rows) throws NoSuchFieldException, IllegalAccessException {
+        //0=workerNumber,从1开始
+        Integer start = 1;
+        Integer fieldSize = 50;
+        //1.创建索引
+        this.createIndexAndMapping(CommonListES.class);
+        //2.新增内容
+        List<CommonListES> list = new ArrayList<>();
+        for(int i = 0;i< rows.size() ; i++) {
+            CommonUtils.initList2(rows,rows.size());
+            List<Object> row = (List<Object>) rows.get(i);
+            String workerNumber = (String)row.get(0);
+            if(StringUtils.isEmpty(workerNumber) || (i > 0 && workerNumber.length() < 8)){
+                break;
+            }
+            CommonListES commonListES = new CommonListES();
+            commonListES.setType(i==0?"1":"2");
+            commonListES.setWorkerNumber(workerNumber);
+            if(workerNumber.length() >= 8) {
+                commonListES.setWebsitNumber(workerNumber.substring(0, 8));
+            }
+            commonListES.setComListId(comListId);
+            
+            for(int x = start;x <= row.size();x++) {
+                if(x > fieldSize){
+                    continue;
+                }
+                String field = "field"+x;
+                Field declaredField = commonListES.getClass().getDeclaredField(field);
+                declaredField.setAccessible(true);
+                declaredField.set(commonListES,row.get(x-1)==null?"-":row.get(x-1));
+            }
+
+            list.add(commonListES);
+        }
+
+        elasticsearchRestTemplate.save(list);
+    }
+
+
+    public  List<CommonListES>  list(List<String> websitNumbers,String workerNumber,String comId){
+        //标题
+        BoolQueryBuilder titleQueryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("type", "1"));
+        if(StringUtils.isNotEmpty(comId)){
+            titleQueryBuilder.must(QueryBuilders.termQuery("comListId", comId));
+        }
+        //内容
+        BoolQueryBuilder must = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("type", "2"));
+        if(StringUtils.isNotEmpty(comId)){
+            must.must(QueryBuilders.termQuery("comListId", comId));
+        }
+        if(StringUtils.isNotEmpty(workerNumber)){
+            must.must(QueryBuilders.termQuery("workerNumber", workerNumber));
+        }
+        if(CollectionUtils.isNotEmpty(websitNumbers)){
+            must.must(QueryBuilders.termsQuery("websitNumber",websitNumbers));
+        }
+        NativeSearchQuery titleBuild = new NativeSearchQueryBuilder().withQuery(titleQueryBuilder).build();
+        NativeSearchQuery dataBuild = new NativeSearchQueryBuilder().withQuery(must).build();
+
+        List<SearchHit<CommonListES>> searchHits1 = elasticsearchRestTemplate.search(titleBuild, CommonListES.class).getSearchHits();
+        List<SearchHit<CommonListES>> searchHits2 = elasticsearchRestTemplate.search(dataBuild, CommonListES.class).getSearchHits();
+        List<CommonListES> titles = searchHits1.stream().map(SearchHit<CommonListES>::getContent).collect(Collectors.toList());
+        List<CommonListES> datas = searchHits2.stream().map(SearchHit<CommonListES>::getContent).collect(Collectors.toList());
+        titles.addAll(datas);
+
+        return titles;
+    }
+
+
+
+}

+ 49 - 0
mall-server-api/src/main/java/com/gree/mall/manager/utils/CommonUtils.java

@@ -387,6 +387,55 @@ public class CommonUtils {
         }
     }
 
+    /**
+     * 打包下载
+     */
+    public static void writeZip(HttpServletResponse response,List<Map<String,Object>> files){
+        String fileName = "info.zip";
+        response.setContentType("application/zip");
+        response.setHeader("content-disposition", "attachment;filename=" + fileName);
+
+        ZipOutputStream zos = null;
+        BufferedInputStream bis = null;
+        try{
+            zos = new ZipOutputStream(response.getOutputStream());
+            byte[] buf = new byte[8192];
+            int len;
+            for (int i = 0; i < files.size(); i++) {
+                String fileUrl = files.get(i).get("fileUrl").toString();
+                String name = files.get(i).get("fileName").toString();
+                URL url = new URL(fileUrl);
+                URLConnection conn = url.openConnection();
+                InputStream inputStream = conn.getInputStream();
+                ZipEntry ze = new ZipEntry(name);
+                zos.putNextEntry(ze);
+                bis = new BufferedInputStream(inputStream);
+                while ((len = bis.read(buf)) > 0) {
+                    zos.write(buf, 0, len);
+                }
+                zos.closeEntry();
+            }
+            zos.closeEntry();
+        }catch(Exception ex){
+            ex.printStackTrace();
+        }finally {
+            if(bis != null){
+                try{
+                    bis.close();
+                }catch(Exception e){
+                    e.printStackTrace();
+                }
+            }
+            if(zos != null){
+                try{
+                    zos.close();
+                }catch(Exception e){
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
     public static Map<String, Object> objectToMap(Object obj) throws IllegalAccessException {
         Map<String, Object> map = new HashMap<String, Object>();
         Class<?> clazz = obj.getClass();

+ 19 - 13
mall-server-api/src/main/java/com/gree/mall/manager/utils/excel/ExcelUtils.java

@@ -4,11 +4,6 @@ package com.gree.mall.manager.utils.excel;
 
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.excel.EasyExcelFactory;
-import com.alibaba.excel.ExcelReader;
-
-import com.alibaba.excel.context.AnalysisContext;
-import com.alibaba.excel.event.AnalysisEventListener;
-
 import com.alibaba.excel.read.listener.PageReadListener;
 import com.gree.mall.manager.bean.ExcelData;
 import com.gree.mall.manager.exception.RemoteServiceException;
@@ -22,24 +17,19 @@ import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.streaming.SXSSFSheet;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
-import org.apache.poi.xssf.usermodel.XSSFCellStyle;
 import org.apache.poi.xssf.usermodel.XSSFColor;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder.BorderSide;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.awt.Color;
-import java.io.*;
-
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
-
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ConcurrentLinkedQueue;
 
 @Slf4j
 public class ExcelUtils {
@@ -224,6 +214,22 @@ public class ExcelUtils {
         return datas;
     }
 
+    public static List<Object> importExcel(InputStream inputStream) throws RemoteServiceException {
+        log.info("【本次导入数据】开始:" + DateUtils.formatDate(new Date()));
+        List<Object> datas = new ArrayList<>();
+        EasyExcelFactory.read(inputStream, new PageReadListener<Map<Integer, Object>>(v -> {
+            for (Map<Integer, Object> map : v) {
+                List<Object> list = new ArrayList<>();
+                for (Integer key : map.keySet()) {
+                    list.add(map.get(key));
+                }
+                datas.add(list);
+            }
+        })).sheet().doRead();
+        log.info("【本次导入数据】结束:" + DateUtils.formatDate(new Date()) + ",一共" + datas.size());
+        return datas;
+    }
+
 
     public static List<Map<String,Object>> importExcelByTitle(InputStream inputStream,Integer headRowNumber) throws RemoteServiceException {
         if(headRowNumber == null){

+ 1 - 0
mall-server-api/src/main/java/com/gree/mall/manager/utils/oss/OSSUtil.java

@@ -42,6 +42,7 @@ public class OSSUtil {
     @Value("${spring.profiles.active}")
     private String active;
 
+    public static final String OSS_TYPE_PIC = "upload/";
     public String getAccessUrl(){
         return "https://" + OSS_BUCKET_NAME +"."+ OSS_ENDPOINT_WW;
     }

+ 17 - 0
mall-server-api/src/main/resources/mapper/CommonMapper.xml

@@ -1317,4 +1317,21 @@
             c.status = #{status}
     </select>
 
+    <select id="queryComList" resultType="com.gree.mall.manager.plus.entity.ComList">
+        select
+            a.*
+        from
+            com_list a join com_detail b on a.id=b.com_list_id
+        where
+            <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
+                b.websit_id IN
+                <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+                AND
+            </if>
+            is_notice=1 and is_pwd = 0
+            and not exists (select 1 from com_detail_log where user_name=#{userName} and com_list_id=a.id)
+    </select>
+
 </mapper>