Forráskód Böngészése

Merge branch 'test'

songyh 3 éve
szülő
commit
9f100ad788

+ 1 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -224,6 +224,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ctop/projectMember/**", "anon");
         filterChainDefinitionMap.put("/agent/**", "anon");
         filterChainDefinitionMap.put("/materialUse/**", "anon");
+        filterChainDefinitionMap.put("/document/library/**", "anon");
 
 
         // 添加自己的过滤器并且取名为jwt

+ 2 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/SettlementReportBytedanceVo.java

@@ -50,6 +50,8 @@ public class SettlementReportBytedanceVo implements Serializable {
 
 
     private String accountName;
+    private String agentId;
+    private String agentName;
 
 
 

+ 2 - 2
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java

@@ -79,9 +79,9 @@ public interface ReportSettlementMapper {
      * @param
      * @return
      */
-    List<Map<String,Object>> getProfitBytedance(@Param("productName") String productName,@Param("mediaType") String mediaType,@Param("startTime")String startTime,@Param("endTime")String endTime);
+    List<Map<String,Object>> getProfitBytedance(@Param("advertiserName") String advertiserName,@Param("productName") String productName,@Param("saleId") String saleId,@Param("mediaType") String mediaType,@Param("startTime")String startTime,@Param("endTime")String endTime);
 
-    Map<String,Object> getProfitRebate(@Param("productName") String productName,@Param("startTime")String startTime,@Param("endTime")String endTime);
+    Map<String,Object> getProfitRebate(@Param("advertiserName") String advertiserName,@Param("productName") String productName,@Param("saleId") String saleId,@Param("mediaType") String mediaType,@Param("startTime")String startTime,@Param("endTime")String endTime);
 
     Map<String,Object> getProfitReportSale(String accountId);
 

+ 29 - 12
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml

@@ -7,7 +7,27 @@
         select t.*,c.auth_name as accountName from (select id,
         advertiser_id,
         date,DATE_FORMAT(date,'%Y-%m') as uploadYears,
-        balance,cash_cost,cost,frozen,income,reward_cost,shared_wallet_cost,transfer_in,transfer_out,create_time
+        balance,cash_cost,cost,frozen,income,reward_cost,shared_wallet_cost,transfer_in,transfer_out,create_time,
+        (
+        SELECT
+        ag.agent_id
+        from
+        ctop_cwjs_agent_info ag
+        LEFT JOIN ctop_agent_account ac on ag.agent_id = ac.agent_id
+        where ac.state = 0
+        and ag.`status` = 0
+        and ag.enabled = 0
+        and ac.account_id = #{accountId}) as agentId,
+        (
+        SELECT
+        ag.name
+        from
+        ctop_cwjs_agent_info ag
+        LEFT JOIN ctop_agent_account ac on ag.agent_id = ac.agent_id
+        where ac.state = 0
+        and ag.`status` = 0
+        and ag.enabled = 0
+        and ac.account_id = #{accountId}) as agentName
          from
         ctop_account_transaction_day
         where cost >0
@@ -316,7 +336,9 @@
         <if test="mediaType !=null and mediaType != ''">
             AND cp.media_type = #{mediaType}
         </if>
+            AND r.advertiser_name = #{advertiserName}
             AND r.product_name = #{productName}
+            AND r.create_user_id = #{saleId}
         <if test="startTime !=null and startTime != ''">
             AND  r.policy_date &gt;= #{startTime}
         </if>
@@ -339,9 +361,12 @@
         LEFT JOIN ctop_cwjs_policy_info p ON r.policy_id = p.id
         WHERE
         p.del_flag = 0
-        <if test="productName !=null and productName != ''">
-            AND r.product_name = #{productName}
+        <if test="mediaType !=null and mediaType != ''">
+            AND p.media_type = #{mediaType}
         </if>
+        AND r.advertiser_name = #{advertiserName}
+        AND r.product_name = #{productName}
+        AND r.create_user_id = #{saleId}
         <if test="startTime !=null and startTime != ''">
             AND  r.policy_date &gt;= #{startTime}
         </if>
@@ -355,16 +380,8 @@
 
     <!-- 查询 利润表  销售人员姓名 -->
     <select id="getProfitReportSale" resultType="java.util.LinkedHashMap">
-       <!-- SELECT f.create_user_id,u.realname as saleName
-        from ctop_cwjs_settlement_info f
-        LEFT  JOIN sys_user u on u.id = f.create_user_id
-        where f.del_flag = 0
-        <if test="accountId !=null and accountId != ''">
-            AND f.account_id = #{accountId}
-        </if>
-        limit 1-->
         ( SELECT
-        p.sale_id,
+        p.sale_id AS saleId,
         y.realname AS saleName
         FROM
         ctop_user_allocation u

+ 7 - 33
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java

@@ -204,8 +204,8 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                     row.createCell(0).setCellValue(vo.getDate());
                     row.createCell(1).setCellValue(vo.getAccountName());
                     row.createCell(2).setCellValue(vo.getAdvertiserId());
-                    row.createCell(3).setCellValue("北京汇创思拓数字科技有限公司-ka");
-                    row.createCell(4).setCellValue("73970348172");
+                    row.createCell(3).setCellValue(vo.getAgentName());
+                    row.createCell(4).setCellValue(vo.getAgentId());
                     row.createCell(5).setCellValue(vo.getCost());
                     row.createCell(6).setCellValue(vo.getCashCost());
                     row.createCell(7).setCellValue(vo.getRewardCost());
@@ -567,7 +567,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 List<String> policyDaysList = new ArrayList<>();
                 if (!Check.isNull(map.get("productName"))){
                     //查询 头条利润表  返点类型和比列
-                    List<Map<String,Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("productName")+"","1",paramsVo.getStartTime(),paramsVo.getEndTime());
+                    List<Map<String,Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName")+"",slaeMap.get("saleId")+"","1",paramsVo.getStartTime(),paramsVo.getEndTime());
                     List listPolicyTIme = new ArrayList();
                     for (Map<String, Object> rate : rateMap) {
                         listPolicyTIme.add(rate.get("policyStartDate"));
@@ -589,7 +589,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                     for (Map<String, String> stringMap : arrayList) {
                         ProfitReportBytedanceVo vo = new ProfitReportBytedanceVo();
                         //使用政策 返点类型和比例
-                        Map<String,Object>  policyRateMap = reportSettlementMapper.getProfitRebate(map.get("productName")+"",stringMap.get("startDate"),stringMap.get("endDate"));
+                        Map<String,Object>  policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName")+"",map.get("productName")+"",slaeMap.get("saleId")+"","1",stringMap.get("startDate"),stringMap.get("endDate"));
                         if (!Check.isNull(policyRateMap)){
                             if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 0){
                                 vo.setRebateType("返现");//返点类型
@@ -725,7 +725,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 List<String> policyDaysList = new ArrayList<>();
                 if (!Check.isNull(map.get("productName"))) {
                     //查询 快手利润表  返点类型和比列
-                    List<Map<String, Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("productName") + "", "2", paramsVo.getStartTime(), paramsVo.getEndTime());
+                    List<Map<String, Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName") + "", slaeMap.get("saleId")+"","2", paramsVo.getStartTime(), paramsVo.getEndTime());
                     List listPolicyTIme = new ArrayList();
                     for (Map<String, Object> rate : rateMap) {
                         listPolicyTIme.add(rate.get("policyStartDate"));
@@ -749,7 +749,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                     for (Map<String, String> stringMap : arrayList) {
                         ProfitReportKuaiShouVo vo = new ProfitReportKuaiShouVo();
                         //使用政策 返点类型和比例
-                        Map<String, Object> policyRateMap = reportSettlementMapper.getProfitRebate(map.get("productName") + "", stringMap.get("startDate"), stringMap.get("endDate"));
+                        Map<String, Object> policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName")+"",map.get("productName") + "", slaeMap.get("saleId")+"","2",stringMap.get("startDate"), stringMap.get("endDate"));
                         if (!Check.isNull(policyRateMap)) {
                             if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 0) {
                                 vo.setRebateType("返现");//返点类型
@@ -800,11 +800,9 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                     vo.setTime(!Check.isNull(vo.getRebateType()) ? stringMap.get("startDate") + "----" + stringMap.get("endDate") : "");
                     resultList.add(vo);
                 }
-
             }
 
             Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("快手利润单", "快手利润单"), ProfitReportKuaiShouVo.class, resultList);
-
             try {
                 response.setCharacterEncoding("UTF-8");
                 response.setHeader("content-Type", "application/vnd.ms-excel");
@@ -813,7 +811,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             } catch (IOException e) {
                 throw new RuntimeException(e);
             }
-
         } catch (Exception e) {
             e.printStackTrace();
             return Result.errorMsg(e.getMessage());
@@ -838,7 +835,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
         int accountNum = 0;
         String productInfo = null;
         String message =  "{0},您好!您{1}月份有{2}个产品的账户需要进行媒体后台消耗截图上传,共计{3}个账户。产品分别为:{4}。请及时上传,多谢配合!";
-
         //查询所有 运营绑定的账户
         List<Map<String,Object>> userList = reportSettlementMapper.getAccountOperateUserId();
         for (Map<String, Object> userMap : userList) {
@@ -853,7 +849,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             productNum = product.size();
             accountNum = productList.size();
             productInfo = StringUtils.join(product.toArray(),"、");
-
             //发送微信通知
             JSONObject jsonObject =  mailLogMapper.getWChatIdByUserId(userId);
             String msg = MessageFormat.format(message,userMap.get("userName").toString(),month,productNum,accountNum,productInfo);
@@ -885,7 +880,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             productNum = product.size();
             accountNum = productList.size();
             productInfo = StringUtils.join(product.toArray(),"、");
-
             //发送微信通知
             JSONObject jsonObject =  mailLogMapper.getWChatIdByUserId(Check.isNull(userId) ? "f990f815ecef43fab9cbe1bb22bb6d63" : userId);
             String msg = MessageFormat.format(message,userMap.get("userName").toString(),month,productNum,accountNum,productInfo);
@@ -897,17 +891,14 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     @Resource
     private CwjsPolicyProductMapper cwjsPolicyProductMapper;
 
-
     @Override
     public void cwjsPRofit(CwjsPolicyInfo cwjsPolicyInfo) {
-
         // 获取两个日期之间 所有的 时间 年-月-日
         List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(cwjsPolicyInfo.getPolicyStartDate(),cwjsPolicyInfo.getPolicyEndDate());
         //查看 政策下的产品
         List<CwjsPolicyProduct> productList = cwjsPolicyProductMapper.queryProductsByPolicyId(cwjsPolicyInfo.getId());
         if (!Check.isNull(productList)){
             if (!Check.isNull(betweenDaysList)){
-
                 List<CtopCwjsSlettementReport> reportList = new ArrayList<>();
                 for (CwjsPolicyProduct product : productList) {
                     for (String day : betweenDaysList) {
@@ -927,9 +918,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
         }
     }
 
-
-
-
     @Resource
     private CwjsPolicyInfoMapper cwjsPolicyInfoMapper;
     @Resource
@@ -937,8 +925,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     @Resource
     private CwjsCompanySubjectMapper cwjsCompanySubjectMapper;
 
-
-
     @Override
     public Result importPolicyInit(MultipartFile file) {
         try {
@@ -946,7 +932,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             //settlementInfo.setCreateUserId(user.getId());
             //settlementInfo.setCreateUserId("b161b7d9793942f980dbfe8c931cd1b0");
             ImportParams importParams = new ImportParams();
-
             //表头行数
             importParams.setHeadRows(1);
 
@@ -955,17 +940,13 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 return Result.error("读取Excel失败,数据不能为空,请重新检查数据并导入");
             }
 
-
             for (PolicyImportVo importVo : importResult.getList()) {
                 if (cn.com.ctop.common.module.utils.Check.isNull(importVo.getCompanyName())){
                     continue;
                 }
-
                 if (cn.com.ctop.common.module.utils.Check.isNull(importVo.getPolicyProductName())){
                     continue;
                 }
-
-
                 List<String> productNameList = Arrays.asList(importVo.getPolicyProductName().split("-"));
 
                 CwjsPolicyInfo cwjsPolicyInfo = new CwjsPolicyInfo();
@@ -986,10 +967,8 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 CwjsCompanySubject companySubject = cwjsCompanySubjectMapper.selectOne(companySubQw);
                 cwjsPolicyInfo.setCompanySubjectId(companySubject.getId());
 
-
                 cwjsPolicyInfo.setApprovedStatus(3);
 
-
                 CwjsPolicyInfo policy = cwjsPolicyInfoMapper.getPolicyInfo(cwjsPolicyInfo);
 
                 if (cn.com.ctop.common.module.utils.Check.isNull(policy)){
@@ -1000,9 +979,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 //查看 政策下的产品
                 List<CwjsPolicyProduct> productList = cwjsPolicyProductMapper.queryProductsByPolicyId(policy.getId());
                 List proList = productList.stream().map(CwjsPolicyProduct:: getPolicyProductName).collect(Collectors.toList());
-
                 for (String str : productNameList) {
-
                     if (!proList.contains(str)){
                         //新增产品
                         CwjsPolicyProduct policyProduct = new CwjsPolicyProduct();
@@ -1013,12 +990,8 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                         cwjsPolicyProductMapper.insert(policyProduct);
                     }
                 }
-
                 this.cwjsPRofit(policy);
-
             }
-
-
         } catch (Exception e) {
             e.printStackTrace();
             return Result.error("政策数据上传失败,请使用正确的模板导入!");
@@ -1029,4 +1002,5 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
 
 
+
 }

+ 99 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/controller/DocumentLibraryController.java

@@ -0,0 +1,99 @@
+package cn.com.ctop.kuaishou.modules.document.controller;
+
+import cn.com.ctop.kuaishou.modules.document.service.DocumentLibraryService;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @Description: 文档库管理
+ * @Author: zzy
+ * @Date: 2021-09-06
+ * @Version: V1.0
+ */
+@RestController
+@RequestMapping("/document/library")
+public class DocumentLibraryController {
+
+    @Resource
+    DocumentLibraryService documentLibraryService;
+
+    /**
+     * 创建文案
+     *
+     * @param
+     * @return
+     */
+    @PostMapping("createdocument")
+    public Result createdocument(MultipartFile file, @RequestParam("accountIds") List<String> accountIds) {
+        return documentLibraryService.createdocument(file, accountIds);
+
+    }
+    /**
+     * 获取文案库列表
+     *
+     * @param
+     * @return
+     */
+    @GetMapping("getDocumentList")
+    public Result getDocumentList(@RequestParam("accountIds") List<String> accountIds,@RequestParam("keywords") String keywords,
+                                  @RequestParam("startDate") String startDate,@RequestParam("endDate") String endDate,
+                                  @RequestParam("status") String status,@RequestParam("pageNumber") int pageNumber,@RequestParam("pageSize") int pageSize) {
+        return documentLibraryService.getDocumentList(accountIds, keywords,startDate,endDate,status,pageNumber,pageSize);
+
+    }
+
+    /**
+     * 编辑文案
+     *
+     * @param
+     * @return
+     */
+    @PostMapping("updateDocument")
+    public Result updateDocument(@RequestParam("accountIds") List<String> accountIds,@RequestParam("copyWriterId") String copyWriterId,@RequestParam("copyWriter") String copyWriter) {
+        return documentLibraryService.updateDocument(accountIds, copyWriterId,copyWriter);
+
+    }
+
+
+    /**
+     * 文案下架
+     *
+     * @param
+     * @return
+     */
+    @GetMapping("updateStatus")
+    public Result updateStatus(@RequestParam("copyWriterId") String copyWriterId,@RequestParam("status") String status) {
+        return documentLibraryService.updateStatus( copyWriterId,status);
+
+    }
+
+    /**
+     * 根据文案查询绑定账户
+     *
+     * @param
+     * @return
+     */
+    @GetMapping("getAcoountId")
+    public Result updateStatus(@RequestParam("copyWriterId") String copyWriterId) {
+        return documentLibraryService.getAcoountId( copyWriterId);
+
+    }
+
+
+    /**
+     * 获取被拒创意
+     *
+     * @param
+     * @return
+     */
+    @GetMapping("getRefusedList")
+    public Result getRefusedList(@RequestParam("copyWriterId") String copyWriterId,@RequestParam("pageNumber") int pageNumber,@RequestParam("pageSize") int pageSize) {
+        return documentLibraryService.getRefusedList(copyWriterId,pageNumber,pageSize);
+
+    }
+
+}

+ 18 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/entity/DocumentLibraryInfo.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.kuaishou.modules.document.entity;
+
+import lombok.Data;
+
+@Data
+public class DocumentLibraryInfo {
+    private  String id;
+    /*文档id*/
+    private  String copyWriterId;
+    /*文案内容*/
+    private  String copyWriter;
+    /*账户id*/
+    private  String accountId;
+    /*0可投放、1已下架*/
+    private  Integer status;
+    /*文案创建时间*/
+    private  String createTime;
+}

+ 22 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/DocumentLibraryMapper.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.kuaishou.modules.document.mapper;
+
+import cn.com.ctop.kuaishou.modules.document.entity.DocumentLibraryInfo;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface DocumentLibraryMapper {
+
+    void saveDocumentLibrary(DocumentLibraryInfo documentLibraryInfo);
+
+    List<JSONObject> getDocumentLibraryList(@Param("list") List<String> list, @Param("keywords") String keywords, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("status") String status);
+
+    void updateStatus(@Param("copyWriterId")String copyWriterId, @Param("status")String status);
+
+    List<JSONObject> getRefusedList(@Param("copyWriterId")String copyWriterId);
+
+    List<String> getAcoountId(@Param("copyWriterId")String copyWriterId);
+}

+ 55 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/xml/DocumentLibraryMapper.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.document.mapper.DocumentLibraryMapper">
+
+
+    <insert id="saveDocumentLibrary" parameterType="cn.com.ctop.kuaishou.modules.document.entity.DocumentLibraryInfo">
+        insert into ctop_document_library (copy_writer_id,copy_writer,account_id,status,create_time) values
+        (#{copyWriterId},#{copyWriter},#{accountId},#{status},#{createTime})
+    </insert>
+
+
+    <select id="getDocumentLibraryList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t.copy_writer_id as 'copyWriterId',t.copy_writer,t.status,COUNT(t1.id) as 'relatedSize',COUNT(if(t2.status= 42 ,TRUE,NULL)) as 'refusedSize'  from
+        (SELECT DISTINCT copy_writer_id,copy_writer,status,create_time from ctop_document_library
+        <where>
+            <if test="keywords !=null and keywords !=''">
+                and copy_writer like CONCAT('%',CONCAT(#{keywords},'%'))
+            </if>
+            <if test="startDate !=null and startDate !='' and endDate !=null and endDate !=''">
+                and create_time BETWEEN  #{startDate} and #{endDate}
+            </if>
+            <if test='status !=null and status !="" and status !=2'>
+                and status =#{status}
+            </if>
+            <if test="list!=null and list.size() > 0">
+                and account_id in
+                <foreach item="item" collection="list" separator="," open="(" close=")" index="">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        ) t
+        LEFT JOIN ctop_document_library_center t1 on t.copy_writer_id=t1.copy_writer_id
+        LEFT JOIN ctop_kuaishou_creative t2 on t1.creative_id=t2.creative_id
+        GROUP BY t.copy_writer_id
+        order by t.create_time desc
+    </select>
+
+
+    <update id="updateStatus" >
+        update  ctop_document_library set status=#{status} where copy_writer_id=#{copyWriterId}
+    </update>
+
+    <select id="getRefusedList" resultType="com.alibaba.fastjson.JSONObject" parameterType="String">
+        SELECT t2.auth_name as 'accountName',t1.unit_id as 'unitId',t1.creative_name as 'creativeName',t1.review_detail as 'reviewDetail' FROM ctop_document_library_center t
+        LEFT JOIN ctop_kuaishou_creative t1 on t.creative_id = t1.creative_id
+        LEFT JOIN ctop_user_allocation t2 on t1.account_id = t2.account_id
+        where t.copy_writer_id =#{copyWriterId} and t1.status=42
+    </select>
+
+    <select id="getAcoountId" parameterType="String" resultType="String">
+        select account_id as 'accountId' from  ctop_document_library where copy_writer_id=#{copyWriterId}
+    </select>
+
+</mapper>

+ 28 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/service/DocumentLibraryService.java

@@ -0,0 +1,28 @@
+package cn.com.ctop.kuaishou.modules.document.service;
+
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * @Description: 文档库管理
+ * @Author: zzy
+ * @Date: 2021-09-06
+ * @Version: V1.0
+ */
+public interface DocumentLibraryService {
+
+    Result createdocument(MultipartFile file, @Param("accountIds") List<String> accountIds);
+
+    Result getDocumentList(List<String> accountIds, String keywords, String startDate, String endDate, String status,int pageNumber,int pageSize);
+
+    Result updateDocument(List<String> accountIds, String copyWriterId,String copyWriter);
+
+    Result updateStatus(String copyWriterId, String status);
+
+    Result getRefusedList(String copyWriterId, int pageNumber, int pageSize);
+
+    Result getAcoountId(String copyWriterId);
+}

+ 208 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/service/impl/DocumentLibraryServiceImpl.java

@@ -0,0 +1,208 @@
+package cn.com.ctop.kuaishou.modules.document.service.impl;
+
+import cn.com.ctop.kuaishou.modules.document.entity.DocumentLibraryInfo;
+import cn.com.ctop.kuaishou.modules.document.mapper.DocumentLibraryMapper;
+import cn.com.ctop.kuaishou.modules.document.service.DocumentLibraryService;
+import cn.com.ctop.kuaishou.modules.utils.ExcelUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @Description: 文档库管理
+ * @Author: zzy
+ * @Date: 2021-09-06
+ * @Version: V1.0
+ */
+@Service
+@Slf4j
+public class DocumentLibraryServiceImpl implements DocumentLibraryService {
+
+    @Resource
+    DocumentLibraryMapper documentLibraryMapper;
+
+    /**
+     * 创建文案
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public Result createdocument(MultipartFile file, List<String> accountIds) {
+        Result result = new Result();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        List<String> documentList = new ArrayList<>();
+        try {
+            documentList = ExcelUtil.readExcel(file);
+        } catch (Exception e) {
+            log.info("读取excel错误:{}", e.toString());
+        }
+
+        try {
+            if (accountIds != null && !documentList.isEmpty() && !accountIds.isEmpty()) {
+
+                for (String docu : documentList) {
+                    DocumentLibraryInfo documentLibraryInfo = new DocumentLibraryInfo();
+                    documentLibraryInfo.setCopyWriter(docu);
+                    documentLibraryInfo.setCopyWriterId(UUID.randomUUID().toString());
+                    documentLibraryInfo.setCreateTime(formatter.format(new Date()));
+                    documentLibraryInfo.setStatus(0);
+                    if (docu != null && docu != "" && docu.length() <= 30) {
+                        for (String accountId : accountIds) {
+                            documentLibraryInfo.setAccountId(accountId);
+                            documentLibraryMapper.saveDocumentLibrary(documentLibraryInfo);
+                        }
+                    }
+
+
+                }
+            }
+            result.success("添加成功");
+            return result;
+        } catch (Exception e) {
+            log.info("添加文案失败:{}", e.toString());
+            result.error500("添加失败");
+            return result;
+        }
+
+
+    }
+
+    /**
+     * 获取文案库列表
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public Result getDocumentList(List<String> accountIds, String keywords, String startDate, String endDate, String status, int pageNumber, int pageSize) {
+        Result result = new Result();
+        List<JSONObject> documentLibraryList = new ArrayList<>();
+        try {
+            if (startDate != null && startDate != "" && endDate != null && endDate != "") {
+                startDate = startDate + " 00:00:00";
+                endDate = endDate + " 23:59:59";
+            }
+            PageHelper.startPage(pageNumber, pageSize);
+            documentLibraryList = documentLibraryMapper.getDocumentLibraryList(accountIds, keywords, startDate, endDate, status);
+            PageInfo pageInfo = new PageInfo(documentLibraryList);
+            result.setSuccess(true);
+            result.setResult(pageInfo);
+        } catch (Exception e) {
+            result.error500("查询数据错误");
+            log.info("查询数据错误:{}", e.toString());
+        }
+
+        return result;
+    }
+
+    /**
+     * 编辑文案
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public Result updateDocument(List<String> accountIds, String copyWriterId, String copyWriter) {
+        Result result = new Result();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            if (accountIds != null && !accountIds.isEmpty()) {
+                DocumentLibraryInfo documentLibraryInfo = new DocumentLibraryInfo();
+                documentLibraryInfo.setCopyWriter(copyWriter);
+                documentLibraryInfo.setCopyWriterId(copyWriterId);
+                documentLibraryInfo.setCreateTime(formatter.format(new Date()));
+                documentLibraryInfo.setStatus(0);
+                for (String accountId : accountIds) {
+                    documentLibraryInfo.setAccountId(accountId);
+                    List<String> dataByAccountId = documentLibraryMapper.getDataByAccountId(accountId, copyWriterId);
+                    if (dataByAccountId == null || dataByAccountId.size() == 0) {
+                        documentLibraryMapper.saveDocumentLibrary(documentLibraryInfo);
+                    }
+
+                }
+            }
+            result.success("添加成功");
+        } catch (Exception e) {
+            log.info("添加文案失败:{}", e.toString());
+            result.error500("添加失败");
+            return result;
+        }
+
+        return result;
+    }
+
+    /**
+     * 文案下架
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public Result updateStatus(String copyWriterId, String status) {
+        Result result = new Result();
+        try {
+            documentLibraryMapper.updateStatus(copyWriterId, status);
+            result.success("下架成功");
+        } catch (Exception e) {
+            log.info("下架失败:{}", e.toString());
+            result.error500("下架失败");
+        }
+        return result;
+    }
+
+    /**
+     * 获取被拒创意
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public Result getRefusedList(String copyWriterId, int pageNumber, int pageSize) {
+        Result result = new Result();
+        List<JSONObject> documentLibraryList = new ArrayList<>();
+        try {
+            PageHelper.startPage(pageNumber, pageSize);
+            documentLibraryList = documentLibraryMapper.getRefusedList(copyWriterId);
+            PageInfo pageInfo = new PageInfo(documentLibraryList);
+            result.setSuccess(true);
+            result.setResult(pageInfo);
+        } catch (Exception e) {
+            result.error500("查询数据错误");
+            log.info("查询数据错误:{}", e.toString());
+        }
+        return result;
+    }
+
+    /**
+     * 根据文案查询绑定账户
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public Result getAcoountId(String copyWriterId) {
+        Result result = new Result();
+        List<String> documentLibraryList = new ArrayList<>();
+        try {
+            documentLibraryList = documentLibraryMapper.getAcoountId(copyWriterId);
+            result.setSuccess(true);
+            result.setResult(documentLibraryList);
+        } catch (Exception e) {
+            result.error500("查询数据错误");
+            log.info("查询数据错误:{}", e.toString());
+        }
+        return result;
+    }
+}

+ 170 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/utils/ExcelUtil.java

@@ -0,0 +1,170 @@
+package cn.com.ctop.kuaishou.modules.utils;
+
+import cn.com.ctop.common.module.utils.Check;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ExcelUtil {
+
+    private final static String xls = "xls";
+    private final static String xlsx = "xlsx";
+    private final static String DATE_FORMAT = "yyyy/MM/dd";
+
+    /**
+     * 读入excel文件,解析后返回
+     *
+     * @param file
+     * @throws IOException
+     */
+    public static List<String> readExcel(MultipartFile file) throws IOException {
+        //检查文件
+        checkFile(file);
+        //获得Workbook工作薄对象
+        Workbook workbook = getWorkBook(file);
+        //创建返回对象,把每行中的值作为一个数组,所有行作为一个集合返回
+//    List<String[]> list = new ArrayList<String[]>();
+        List<String> list = new ArrayList<>();
+        if (workbook != null) {
+            for (int sheetNum = 0; sheetNum < workbook.getNumberOfSheets(); sheetNum++) {
+                //获得当前sheet工作表
+                Sheet sheet = workbook.getSheetAt(sheetNum);
+                if (sheet == null) {
+                    continue;
+                }
+                //获得当前sheet的开始行
+                int firstRowNum = sheet.getFirstRowNum();
+                //获得当前sheet的结束行
+                int lastRowNum = sheet.getLastRowNum();
+                //循环所有行
+                for (int rowNum = firstRowNum; rowNum <= lastRowNum; rowNum++) {
+                    //获得当前行
+                    Row row = sheet.getRow(rowNum);
+                    if (row == null) {
+                        continue;
+                    }
+                    //获得当前行的开始列
+                    int firstCellNum = row.getFirstCellNum();
+                    //获得当前行的列数
+                    int lastCellNum = row.getPhysicalNumberOfCells();
+//          String[] cells = new String[row.getPhysicalNumberOfCells()];
+                    //循环当前行
+                    String cellValue = getCellValue(row.getCell(firstCellNum));
+//                        String cellValue = getCellValue(cell);
+                    if (!Check.isNull(cellValue)) { //只要当前行的第一列
+                        list.add(cellValue);
+                    }
+//                    for(int cellNum = firstCellNum; cellNum <= lastCellNum;cellNum++){
+//                        Cell cell = row.getCell(cellNum);
+////            cells[cellNum] = getCellValue(cell);
+//                        String cellValue = getCellValue(row.getCell(firstCellNum));
+////                        String cellValue = getCellValue(cell);
+//                        if(!Check.isNull(cellValue)){
+//                            list.add(cellValue);
+//                        }
+//                    }
+
+                }
+            }
+            workbook.close();
+        }
+        return list;
+    }
+
+    //校验文件是否合法
+    public static void checkFile(MultipartFile file) throws IOException {
+        //判断文件是否存在
+        if (null == file) {
+            throw new FileNotFoundException("文件不存在!");
+        }
+        //获得文件名
+        String fileName = file.getOriginalFilename();
+        //判断文件是否是excel文件
+        if (!fileName.endsWith(xls) && !fileName.endsWith(xlsx)) {
+            throw new IOException(fileName + "不是excel文件");
+        }
+    }
+
+    public static Workbook getWorkBook(MultipartFile file) {
+        //获得文件名
+        String fileName = file.getOriginalFilename();
+        //创建Workbook工作薄对象,表示整个excel
+        Workbook workbook = null;
+        try {
+            //获取excel文件的io流
+            InputStream is = file.getInputStream();
+            //根据文件后缀名不同(xls和xlsx)获得不同的Workbook实现类对象
+            if (fileName.endsWith(xls)) {
+                //2003
+                workbook = new HSSFWorkbook(is);
+            } else if (fileName.endsWith(xlsx)) {
+                //2007
+                workbook = new XSSFWorkbook(is);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return workbook;
+    }
+
+    public static String getCellValue(Cell cell) {
+        String cellValue = "";
+        if (cell == null) {
+            return cellValue;
+        }
+        //如果当前单元格内容为日期类型,需要特殊处理
+        String dataFormatString = cell.getCellStyle().getDataFormatString();
+        if ("m/d/yy".equals(dataFormatString)) {
+            cellValue = new SimpleDateFormat(DATE_FORMAT).format(cell.getDateCellValue());
+            return cellValue;
+        }
+        /**
+         *     _NONE(-1),
+         *     NUMERIC(0),
+         *     STRING(1),
+         *     FORMULA(2),
+         *     BLANK(3),
+         *     BOOLEAN(4),
+         *     ERROR(5);
+         */
+
+        CellType cellType = cell.getCellTypeEnum();
+        //把数字当成String来读,避免出现1读成1.0的情况
+        if (cellType == CellType.NUMERIC) {
+            cell.setCellType(CellType.STRING);
+        }
+        //判断数据的类型
+        switch (cell.getCellTypeEnum()) {
+            case NUMERIC: //数字
+                cellValue = String.valueOf(cell.getNumericCellValue());
+                break;
+            case STRING: //字符串
+                cellValue = String.valueOf(cell.getStringCellValue());
+                break;
+            case BOOLEAN: //Boolean
+                cellValue = String.valueOf(cell.getBooleanCellValue());
+                break;
+            case FORMULA: //公式
+                cellValue = String.valueOf(cell.getCellFormula());
+                break;
+            case _NONE: //空值
+                cellValue = "";
+                break;
+            case ERROR: //故障
+                cellValue = "非法字符";
+                break;
+            default:
+                cellValue = "未知类型";
+                break;
+        }
+        return cellValue;
+    }
+}