Pārlūkot izejas kodu

Merge branch 'master' of http://git.tjyourong.com.cn/ctop/adsp-boot

yumeng 3 gadi atpakaļ
vecāks
revīzija
39f2dca0a2
16 mainītis faili ar 1038 papildinājumiem un 644 dzēšanām
  1. 0 235
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/JhsBakendDataController.java
  2. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/BytedanceCustomerDdTbtjData.java
  3. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/JhsBakendData.java
  4. 0 152
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/media/vue/MediaList.vue
  5. 0 124
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/media/vue/modules/MediaModal.vue
  6. 0 131
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/media/vue/modules/MediaModal__Style#Drawer.vue
  7. 34 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouAccountCleanJob.java
  8. 1 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAccountAudienceReportJob.java
  9. 151 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/controller/KuaiShouAccountCleanController.java
  10. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/entity/KuaiShouAccountCleanLogInfo.java
  11. 59 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/entity/KuaiShouAccountCleanTemplateInfo.java
  12. 57 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/mapper/KuaishouAccountCleanTemplateMapper.java
  13. 193 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/mapper/xml/KuaishouAccountCleanTemplateMapper.xml
  14. 91 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/service/KuaiShouAccountCleanService.java
  15. 426 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/service/impl/KuaiShouAccountCleanServiceImpl.java
  16. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceVideoReportMapper.xml

+ 0 - 235
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/JhsBakendDataController.java

@@ -1,235 +0,0 @@
-package org.jeecg.modules.ctop.controller;
-
-import cn.com.ctop.common.module.utils.QueryGenerator;
-import com.alibaba.excel.event.AnalysisEventListener;
-import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.ctop.entity.JhsBakendData;
-import org.jeecg.modules.ctop.service.IJhsBakendDataService;
-import org.jeecg.modules.excelutil.ExcelUtils;
-import org.jeecg.modules.excelutil.JhsBakendDataExcelListener;
-import org.jeecg.modules.excelutil.entity.JhsBakendDataEntity;
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
-import org.jeecgframework.poi.excel.entity.ExportParams;
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
-import org.springframework.web.servlet.ModelAndView;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
- /**
- * 聚划算后端数据
- * @author jeecg-boot
- * @date   2020-09-07
- * @version V1.0
- */
-@Slf4j
-@Api(tags="聚划算后端数据")
-@RestController
-@RequestMapping("/okr/jhsBakendData")
-public class JhsBakendDataController {
-	@Autowired
-	private IJhsBakendDataService jhsBakendDataService;
-
-	/**
-	  * 分页列表查询
-	 * @param jhsBakendData
-	 * @param pageNo
-	 * @param pageSize
-	 * @param req
-	 * @return
-	 */
-	@GetMapping(value = "/list")
-	public Result<IPage<JhsBakendData>> queryPageList(JhsBakendData jhsBakendData,
-													  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-													  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-													  HttpServletRequest req) {
-		Result<IPage<JhsBakendData>> result = new Result<>();
-		QueryWrapper<JhsBakendData> queryWrapper = QueryGenerator.initQueryWrapper(jhsBakendData, req.getParameterMap());
-		Page<JhsBakendData> page = new Page<JhsBakendData>(pageNo, pageSize);
-		IPage<JhsBakendData> pageList = jhsBakendDataService.page(page, queryWrapper);
-		result.setSuccess(true);
-		result.setResult(pageList);
-		return result;
-	}
-
-	/**
-	  *   添加
-	 * @param jhsBakendData
-	 * @return
-	 */
-	@ApiOperation(value="聚划算后端数据-添加", notes="聚划算后端数据-添加")
-	@PostMapping(value = "/add")
-	public Result<JhsBakendData> add(@RequestBody JhsBakendData jhsBakendData) {
-		Result<JhsBakendData> result = new Result<>();
-		try {
-			jhsBakendDataService.save(jhsBakendData);
-			result.success("添加成功!");
-		} catch (Exception e) {
-			log.error(e.getMessage(),e);
-			result.error500("操作失败");
-		}
-		return result;
-	}
-
-	/**
-	  *  编辑
-	 * @param jhsBakendData
-	 * @return
-	 */
-	@ApiOperation(value="聚划算后端数据-编辑", notes="聚划算后端数据-编辑")
-	@PutMapping(value = "/edit")
-	public Result<JhsBakendData> edit(@RequestBody JhsBakendData jhsBakendData) {
-		Result<JhsBakendData> result = new Result<JhsBakendData>();
-		JhsBakendData jhsBakendDataEntity = jhsBakendDataService.getById(jhsBakendData.getId());
-		if(jhsBakendDataEntity==null) {
-			result.error500("未找到对应实体");
-		}else {
-			boolean ok = jhsBakendDataService.updateById(jhsBakendData);
-			if(ok) {
-				result.success("修改成功!");
-			}
-		}
-
-		return result;
-	}
-
-	/**
-	  *   通过id删除
-	 * @param id
-	 * @return
-	 */
-	@ApiOperation(value="聚划算后端数据-通过id删除", notes="聚划算后端数据-通过id删除")
-	@DeleteMapping(value = "/delete")
-	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
-		try {
-			jhsBakendDataService.removeById(id);
-		} catch (Exception e) {
-			log.error("删除失败",e.getMessage());
-			return Result.error("删除失败!");
-		}
-		return Result.ok("删除成功!");
-	}
-
-	/**
-	  *  批量删除
-	 * @param ids
-	 * @return
-	 */
-	@ApiOperation(value="聚划算后端数据-批量删除", notes="聚划算后端数据-批量删除")
-	@DeleteMapping(value = "/deleteBatch")
-	public Result<JhsBakendData> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		Result<JhsBakendData> result = new Result<>();
-		if(ids==null || "".equals(ids.trim())) {
-			result.error500("参数不识别!");
-		}else {
-			this.jhsBakendDataService.removeByIds(Arrays.asList(ids.split(",")));
-			result.success("删除成功!");
-		}
-		return result;
-	}
-
-	/**
-	  * 通过id查询
-	 * @param id
-	 * @return
-	 */
-	@ApiOperation(value="聚划算后端数据-通过id查询", notes="聚划算后端数据-通过id查询")
-	@GetMapping(value = "/queryById")
-	public Result<JhsBakendData> queryById(@RequestParam(name="id",required=true) String id) {
-		Result<JhsBakendData> result = new Result<>();
-		JhsBakendData jhsBakendData = jhsBakendDataService.getById(id);
-		if(jhsBakendData==null) {
-			result.error500("未找到对应实体");
-		}else {
-			result.setResult(jhsBakendData);
-			result.setSuccess(true);
-		}
-		return result;
-	}
-
-  /**
-      * 导出excel
-   *
-   * @param request
-   * @param response
-   */
-  @RequestMapping(value = "/exportXls")
-  public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
-      // Step.1 组装查询条件
-      QueryWrapper<JhsBakendData> queryWrapper = null;
-      try {
-          String paramsStr = request.getParameter("paramsStr");
-          if (oConvertUtils.isNotEmpty(paramsStr)) {
-              String deString = URLDecoder.decode(paramsStr, "UTF-8");
-              JhsBakendData jhsBakendData = JSON.parseObject(deString, JhsBakendData.class);
-              queryWrapper = QueryGenerator.initQueryWrapper(jhsBakendData, request.getParameterMap());
-          }
-      } catch (UnsupportedEncodingException e) {
-          e.printStackTrace();
-      }
-
-      //Step.2 AutoPoi 导出Excel
-      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
-      List<JhsBakendData> pageList = jhsBakendDataService.list(queryWrapper);
-      //导出文件名称
-      mv.addObject(NormalExcelConstants.FILE_NAME, "聚划算后端数据列表");
-      mv.addObject(NormalExcelConstants.CLASS, JhsBakendData.class);
-      mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("聚划算后端数据列表数据", "导出人:Jeecg", "导出信息"));
-      mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
-      return mv;
-  }
-
-  /**
-      * 通过excel导入数据
-   *
-   * @param request
-   * @param response
-   * @return
-   */
-  @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-  public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-	  //1.读Excel
-	  MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
-	  Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
-	  for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
-		  FileInputStream fis = null;
-		  try {
-			  MultipartFile file = entity.getValue();
-			  fis = (FileInputStream) file.getInputStream();
-			  AnalysisEventListener listener = new JhsBakendDataExcelListener();
-			  Boolean flag = ExcelUtils.readExcel(fis, JhsBakendDataEntity.class, listener);
-		  } catch (Exception e) {
-			  e.printStackTrace();
-		  } finally {
-			  if (fis != null) {
-				  try {
-					  fis.close();
-				  } catch (IOException e) {
-					  e.printStackTrace();
-				  }
-			  }
-		  }
-	  }
-	  return Result.ok("文件导入成功!");
-  }
-
-}

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/BytedanceCustomerDdTbtjData.java

@@ -34,4 +34,5 @@ public class BytedanceCustomerDdTbtjData {
 	private Date createTime;
 	/**updateTime*/
 	private Date updateTime;
+
 }

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/JhsBakendData.java

@@ -52,4 +52,5 @@ public class JhsBakendData {
 
 	public JhsBakendData() {
 	}
+
 }

+ 0 - 152
jeecg-boot-module-system/src/main/java/org/jeecg/modules/media/vue/MediaList.vue

@@ -1,152 +0,0 @@
-<template>
-    <a-card :bordered="false">
-
-        <!-- 查询区域 -->
-        <div class="table-page-search-wrapper">
-            <a-form layout="inline">
-                <a-row :gutter="24">
-
-                    <a-col :md="6" :sm="8">
-                        <a-form-item label="媒体名称">
-                            <a-input placeholder="请输入媒体名称" v-model="queryParam.name"></a-input>
-                        </a-form-item>
-                    </a-col>
-</template>
-<a-col :md="6" :sm="8">
-            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
-              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
-              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
-              <a @click="handleToggleSearch" style="margin-left: 8px">
-                {{ toggleSearchStatus ? '收起' : '展开' }}
-                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
-              </a>
-            </span>
-</a-col>
-
-</a-row>
-</a-form>
-</div>
-
-<!-- 操作按钮区域 -->
-<div class="table-operator">
-    <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
-    <a-button type="primary" icon="download" @click="handleExportXls('媒体表')">导出</a-button>
-    <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
-              @change="handleImportExcel">
-        <a-button type="primary" icon="import">导入</a-button>
-    </a-upload>
-    <a-dropdown v-if="selectedRowKeys.length > 0">
-        <a-menu slot="overlay">
-            <a-menu-item key="1" @click="batchDel">
-                <a-icon type="delete"/>
-                删除
-            </a-menu-item>
-        </a-menu>
-        <a-button style="margin-left: 8px"> 批量操作
-            <a-icon type="down"/>
-        </a-button>
-    </a-dropdown>
-</div>
-
-<!-- table区域-begin -->
-<div>
-    <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
-        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
-        selectedRowKeys.length }}</a>项
-        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
-    </div>
-
-    <a-table
-            ref="table"
-            size="middle"
-            bordered
-            rowKey="id"
-            :columns="columns"
-            :dataSource="dataSource"
-            :pagination="ipagination"
-            :loading="loading"
-            :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
-            @change="handleTableChange">
-
-        <span slot="action" slot-scope="text, record">
-          <a @click="handleEdit(record)">编辑</a>
-
-          <a-divider type="vertical"/>
-          <a-dropdown>
-            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
-            <a-menu slot="overlay">
-              <a-menu-item>
-                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
-                  <a>删除</a>
-                </a-popconfirm>
-              </a-menu-item>
-            </a-menu>
-          </a-dropdown>
-        </span>
-
-    </a-table>
-</div>
-<!-- table区域-end -->
-
-<!-- 表单区域 -->
-<media-modal ref="modalForm" @ok="modalFormOk"></media-modal>
-</a-card>
-</template>
-
-<script>
-    import MediaModal from './modules/MediaModal'
-    import {JeecgListMixin} from '@/mixins/JeecgListMixin'
-
-    export default {
-        name: "MediaList",
-        mixins: [JeecgListMixin],
-        components: {
-            MediaModal
-        },
-        data() {
-            return {
-                description: '媒体表管理页面',
-                // 表头
-                columns: [
-                    {
-                        title: '#',
-                        dataIndex: '',
-                        key: 'rowIndex',
-                        width: 60,
-                        align: "center",
-                        customRender: function (t, r, index) {
-                            return parseInt(index) + 1;
-                        }
-                    },
-                    {
-                        title: '媒体名称',
-                        align: "center",
-                        dataIndex: 'name'
-                    },
-                    {
-                        title: '操作',
-                        dataIndex: 'action',
-                        align: "center",
-                        scopedSlots: {customRender: 'action'},
-                    }
-                ],
-                url: {
-                    list: "/media/media/list",
-                    delete: "/media/media/delete",
-                    deleteBatch: "/media/media/deleteBatch",
-                    exportXlsUrl: "media/media/exportXls",
-                    importExcelUrl: "media/media/importExcel",
-                },
-            }
-        },
-        computed: {
-            importExcelUrl: function () {
-                return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
-            }
-        },
-        methods: {}
-    }
-</script>
-<style scoped>
-    @import '~@assets/less/common.less'
-</style>

+ 0 - 124
jeecg-boot-module-system/src/main/java/org/jeecg/modules/media/vue/modules/MediaModal.vue

@@ -1,124 +0,0 @@
-<template>
-    <a-modal
-            :title="title"
-            :width="800"
-            :visible="visible"
-            :confirmLoading="confirmLoading"
-            @ok="handleOk"
-            @cancel="handleCancel"
-            cancelText="关闭">
-
-        <a-spin :spinning="confirmLoading">
-            <a-form :form="form">
-
-                <a-form-item
-                        :labelCol="labelCol"
-                        :wrapperCol="wrapperCol"
-                        label="媒体名称">
-                    <a-input placeholder="请输入媒体名称" v-decorator="['name', validatorRules.name ]"/>
-                </a-form-item>
-
-            </a-form>
-        </a-spin>
-    </a-modal>
-</template>
-
-<script>
-    import {httpAction} from '@/api/manage'
-    import pick from 'lodash.pick'
-    import moment from "moment"
-
-    export default {
-        name: "MediaModal",
-        data() {
-            return {
-                title: "操作",
-                visible: false,
-                model: {},
-                labelCol: {
-                    xs: {span: 24},
-                    sm: {span: 5},
-                },
-                wrapperCol: {
-                    xs: {span: 24},
-                    sm: {span: 16},
-                },
-
-                confirmLoading: false,
-                form: this.$form.createForm(this),
-                validatorRules: {
-                    name: {rules: [{required: true, message: '请输入媒体名称!'}]},
-                },
-                url: {
-                    add: "/media/media/add",
-                    edit: "/media/media/edit",
-                },
-            }
-        },
-        created() {
-        },
-        methods: {
-            add() {
-                this.edit({});
-            },
-            edit(record) {
-                this.form.resetFields();
-                this.model = Object.assign({}, record);
-                this.visible = true;
-                this.$nextTick(() => {
-                    this.form.setFieldsValue(pick(this.model, 'name'))
-                    //时间格式化
-                });
-
-            },
-            close() {
-                this.$emit('close');
-                this.visible = false;
-            },
-            handleOk() {
-                const that = this;
-                // 触发表单验证
-                this.form.validateFields((err, values) => {
-                    if (!err) {
-                        that.confirmLoading = true;
-                        let httpurl = '';
-                        let method = '';
-                        if (!this.model.id) {
-                            httpurl += this.url.add;
-                            method = 'post';
-                        } else {
-                            httpurl += this.url.edit;
-                            method = 'put';
-                        }
-                        let formData = Object.assign(this.model, values);
-                        //时间格式化
-
-                        console.log(formData)
-                        httpAction(httpurl, formData, method).then((res) => {
-                            if (res.success) {
-                                that.$message.success(res.message);
-                                that.$emit('ok');
-                            } else {
-                                that.$message.warning(res.message);
-                            }
-                        }).finally(() => {
-                            that.confirmLoading = false;
-                            that.close();
-                        })
-
-
-                    }
-                })
-            },
-            handleCancel() {
-                this.close()
-            },
-
-
-        }
-    }
-</script>
-
-<style lang="less" scoped>
-
-</style>

+ 0 - 131
jeecg-boot-module-system/src/main/java/org/jeecg/modules/media/vue/modules/MediaModal__Style#Drawer.vue

@@ -1,131 +0,0 @@
-<template>
-    <a-drawer
-            :title="title"
-            :width="800"
-            placement="right"
-            :closable="false"
-            @close="close"
-            :visible="visible"
-    >
-
-        <a-spin :spinning="confirmLoading">
-            <a-form :form="form">
-
-                <a-form-item
-                        :labelCol="labelCol"
-                        :wrapperCol="wrapperCol"
-                        label="媒体名称">
-                    <a-input placeholder="请输入媒体名称" v-decorator="['name', validatorRules.name ]"/>
-                </a-form-item>
-
-            </a-form>
-        </a-spin>
-        <a-button type="primary" @click="handleOk">确定</a-button>
-        <a-button type="primary" @click="handleCancel">取消</a-button>
-    </a-drawer>
-</template>
-
-<script>
-    import {httpAction} from '@/api/manage'
-    import pick from 'lodash.pick'
-    import moment from "moment"
-
-    export default {
-        name: "MediaModal",
-        data() {
-            return {
-                title: "操作",
-                visible: false,
-                model: {},
-                labelCol: {
-                    xs: {span: 24},
-                    sm: {span: 5},
-                },
-                wrapperCol: {
-                    xs: {span: 24},
-                    sm: {span: 16},
-                },
-
-                confirmLoading: false,
-                form: this.$form.createForm(this),
-                validatorRules: {
-                    name: {rules: [{required: true, message: '请输入媒体名称!'}]},
-                },
-                url: {
-                    add: "/media/media/add",
-                    edit: "/media/media/edit",
-                },
-            }
-        },
-        created() {
-        },
-        methods: {
-            add() {
-                this.edit({});
-            },
-            edit(record) {
-                this.form.resetFields();
-                this.model = Object.assign({}, record);
-                this.visible = true;
-                this.$nextTick(() => {
-                    this.form.setFieldsValue(pick(this.model, 'name'))
-                    //时间格式化
-                });
-
-            },
-            close() {
-                this.$emit('close');
-                this.visible = false;
-            },
-            handleOk() {
-                const that = this;
-                // 触发表单验证
-                this.form.validateFields((err, values) => {
-                    if (!err) {
-                        that.confirmLoading = true;
-                        let httpurl = '';
-                        let method = '';
-                        if (!this.model.id) {
-                            httpurl += this.url.add;
-                            method = 'post';
-                        } else {
-                            httpurl += this.url.edit;
-                            method = 'put';
-                        }
-                        let formData = Object.assign(this.model, values);
-                        //时间格式化
-
-                        console.log(formData)
-                        httpAction(httpurl, formData, method).then((res) => {
-                            if (res.success) {
-                                that.$message.success(res.message);
-                                that.$emit('ok');
-                            } else {
-                                that.$message.warning(res.message);
-                            }
-                        }).finally(() => {
-                            that.confirmLoading = false;
-                            that.close();
-                        })
-
-
-                    }
-                })
-            },
-            handleCancel() {
-                this.close()
-            },
-
-
-        }
-    }
-</script>
-
-<style lang="less" scoped>
-    /** Button按钮间距 */
-    .ant-btn {
-        margin-left: 30px;
-        margin-bottom: 30px;
-        float: right;
-    }
-</style>

+ 34 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouAccountCleanJob.java

@@ -0,0 +1,34 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.clean.service.KuaiShouAccountCleanService;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+@Slf4j
+public class KuaiShouAccountCleanJob {
+
+    @Resource
+    KuaiShouAccountCleanService kuaiShouAccountCleanService;
+
+    /**
+     * 账户清理
+     *
+     * @param
+     * @return
+     * @throws
+     * @author ZZY
+     */
+    @XxlJob("accountClean")
+    public void execute() throws Exception {
+        try {
+            kuaiShouAccountCleanService.cleanAccount();
+        } catch (Exception e) {
+            log.info("清理完成完成");
+        }
+
+    }
+}

+ 1 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAccountAudienceReportJob.java

@@ -34,7 +34,7 @@ public class KuaishouDailyAccountAudienceReportJob {
     @XxlJob("kuaishouAccountAudienceReportJob")
     public void execute() throws Exception {
         //查询两天前数据  策略
-        String date = DateUtils.getLastDay(DateUtils.date2Str(), 2);
+        String date = DateUtils.getLastDay(DateUtils.date2Str(), 1);
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         if (null == tokens || tokens.isEmpty()) {
             XxlJobHelper.log("定时获取人群分析报表数据异常:未获取到可用的token");

+ 151 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/controller/KuaiShouAccountCleanController.java

@@ -0,0 +1,151 @@
+package cn.com.ctop.kuaishou.modules.clean.controller;
+
+import cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanTemplateInfo;
+import cn.com.ctop.kuaishou.modules.clean.service.KuaiShouAccountCleanService;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+/**
+ * @Description: 快手-账户清理
+ * @Author: zzy
+ * @Date: 2021-07-20
+ * @Version: V1.0
+ */
+@RestController
+@RequestMapping("/accountClean")
+public class KuaiShouAccountCleanController {
+
+
+    @Resource
+    KuaiShouAccountCleanService kuaiShouAccountCleanService;
+
+    /**
+     * 创建规则模板
+     *
+     * @param kuaiShouAccountCleanTemplateInfo
+     * @return
+     */
+    @PostMapping("/createTemplate")
+    public Result createCleanTemplate(@RequestBody KuaiShouAccountCleanTemplateInfo kuaiShouAccountCleanTemplateInfo){
+        return   kuaiShouAccountCleanService.createCleanTemplate(kuaiShouAccountCleanTemplateInfo);
+    }
+
+    /**
+     * 根据模板名称查询
+     *
+     * @param templateName
+     * @return
+     */
+    @GetMapping("/getTemplateNameSize")
+    public Result getTemplateName(@Param("templateName")String templateName){
+        return   kuaiShouAccountCleanService.getTemplateName(templateName);
+    }
+
+    /**
+     * 查询模板列表
+     *
+     * @param templateName 模板名称  createUser创建人  userId当前登录人id
+     * @return
+     */
+    @GetMapping("/getTemplateList")
+    public Result getTemplateList(@Param("templateName")String templateName,@Param("createUser")String createUser,@Param("userId")String userId,
+                                  @Param("pageNum")String pageNum,@Param("pageSize")String pageSize  ){
+        return   kuaiShouAccountCleanService.getTemplateList(templateName,createUser,userId,pageNum,pageSize);
+    }
+
+    /**
+     * 预览模板
+     *
+     * @param templateId 模板id
+     * @return
+     */
+    @GetMapping("/previewTemplate")
+    public Result previewTemplate(@Param("templateId")String templateId){
+        return   kuaiShouAccountCleanService.previewTemplate(templateId);
+    }
+
+    /**
+     * 推送模板
+     *
+     * @param templateId 模板id,accountId 账户id
+     * @return
+     */
+    @GetMapping("/pushTemplate")
+    public Result pushTemplate(@Param("templateId")String templateId,@Param("accountId")String accountId){
+        return   kuaiShouAccountCleanService.pushTemplate(templateId,accountId);
+    }
+
+    /**
+     * 修改模板
+     *
+     * @param kuaiShouAccountCleanTemplateInfo
+     * @return
+     */
+    @PostMapping("/updateTemplate")
+    public Result updateTemplate(@RequestBody KuaiShouAccountCleanTemplateInfo kuaiShouAccountCleanTemplateInfo){
+        return   kuaiShouAccountCleanService.updateTemplate(kuaiShouAccountCleanTemplateInfo);
+    }
+
+
+    /**
+     * 查询个人清理模板列表
+     *
+     * @param accountId  账户id  userName运营名称  userId当前登录人id
+     * @return
+     */
+    @GetMapping("/getMyselfTemplateList")
+    public Result getMyselfTemplateList(@Param("accountId")String accountId,@Param("userName")String userName,@Param("userId")String userId,
+                                        @Param("pageNum")String pageNum,@Param("pageSize")String pageSize  ){
+        return   kuaiShouAccountCleanService.getMyselfTemplateList(accountId,userName,userId,pageNum,pageSize);
+    }
+
+    /**
+     * 开启/暂停模板
+     *
+     * @param templateId 模板id   status状态  0-开始   1-暂停
+     * @return
+     */
+    @GetMapping("/updateTemplateStatus")
+    public Result updateTemplateStatus(@Param("templateId")String templateId,@Param("status")String status){
+        return   kuaiShouAccountCleanService.updateTemplateStatus(templateId,status);
+    }
+
+
+    /**
+     * 解除模板绑定
+     *
+     * @param templateId 模板id,accountId 账户id
+     * @return
+     */
+    @GetMapping("/removeBinding")
+    public Result removeBinding(@Param("templateId")String templateId,@Param("accountId")String accountId){
+        return   kuaiShouAccountCleanService.removeBinding(templateId,accountId);
+    }
+
+
+    /**
+     * 查询清理记录
+     *
+     * @param templateId 模板名称  userId 账户id
+     * @return
+     */
+    @GetMapping("/getCleanUpLog")
+    public Result getCleanUpLog(@Param("templateId")String templateId,@Param("userId")String userId,
+                                @Param("pageNum")String pageNum,@Param("pageSize")String pageSize  ){
+        return   kuaiShouAccountCleanService.getCleanUpLog(templateId,userId,pageNum,pageSize);
+    }
+
+    /**
+     * 执行清理计划
+     *
+     * @param
+     * @return
+     */
+    @GetMapping("/cleanAccount")
+    public Result cleanAccount(){
+        return   kuaiShouAccountCleanService.cleanAccount();
+    }
+}

+ 23 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/entity/KuaiShouAccountCleanLogInfo.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.clean.entity;
+
+import lombok.Data;
+
+@Data
+public class KuaiShouAccountCleanLogInfo {
+    //主键
+    private  String id;
+    //账户id
+    private  String accountId;
+    //账户id
+    private  String templateId;
+    //账户id
+    private  String createTemplateId;
+    //运营
+    private  String userName;
+    //操作类型  1-投放、2-暂停、3-删除
+    private  String operationType;
+    //创建时间
+    private  String createTime;
+    //执行信息
+    private  String executiveInformation;
+}

+ 59 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/entity/KuaiShouAccountCleanTemplateInfo.java

@@ -0,0 +1,59 @@
+package cn.com.ctop.kuaishou.modules.clean.entity;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class KuaiShouAccountCleanTemplateInfo {
+    //id
+    private String id;
+    //模板名称
+    private String templateName;
+
+    //应用媒体
+    private String appliedMedia;
+    //清理时间范围  1   3   7  15
+    private String cleanTime;
+    //优化目标
+    // activation:激活数 bclick:行为数  formSize :表单数 pay:付费  roi:首日roi
+    // evocativeApplication:唤起应用  effectiveClues:有效线索 creditApp:授信-APP creditGrant:授信-落地页
+    // finishedPieceApp:完件数-APP  finishedPieceGrant:完件数-落地页   ordersSubmitted:订单提交 registered:注册
+    private String optimizationObjective;
+
+    //累计消耗
+    private BigDecimal charge;
+
+    //累计转化数
+    private String conversion;
+
+    //推广组状态 1 - 投放中;2 - 已暂停;3 - 不限
+    private String promotionGroupStatus;
+
+    //执行操作    1-投放、2-暂停、3-删除
+    private String performOperations;
+
+    //模板状态 0-运行  1-暂停
+    private String status;
+
+    //创建人
+    private String createUser;
+
+    //创建人id
+    private String createId;
+
+    //创建时间
+    private String createTime;
+
+    //账户id
+    private String accountId;
+
+    //运营名称
+    private String userName;
+
+    //账户状态 0 启动 1 禁用
+    private String accountStatus;
+
+    //账户名称
+    private String accountName;
+}

+ 57 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/mapper/KuaishouAccountCleanTemplateMapper.java

@@ -0,0 +1,57 @@
+package cn.com.ctop.kuaishou.modules.clean.mapper;
+
+import cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanLogInfo;
+import cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanTemplateInfo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 快手-账户清理
+ * @Author: zzy
+ * @Date: 2021-07-20
+ * @Version: V1.0
+ */
+@Mapper
+public interface KuaishouAccountCleanTemplateMapper {
+    //创建模板
+    void saveAccountCleanTemplate(KuaiShouAccountCleanTemplateInfo kuaiShouAccountCleanTemplateInfo);
+    //根据id 创建人查询模板列表
+    List<KuaiShouAccountCleanTemplateInfo> getTemplateList(@Param("templateName") String templateName, @Param("createUser") String createUser, @Param("createId") String createId);
+    //根据id查询数据
+    KuaiShouAccountCleanTemplateInfo getInfoById(@Param("templateId") String templateId);
+    //查询账户关联模板个数
+    int getAccountAssociatedSize(@Param("accountId") String accountId);
+    //推送模板保存关联关系
+    void savePushTemplateAssociated(@Param("templateId") String templateId, @Param("accountId") String accountId, @Param("createTime") String createTime);
+    //修改模板
+    void updateTemplate(KuaiShouAccountCleanTemplateInfo kuaiShouAccountCleanTemplateInfo);
+    //根据模板id修改模板状态
+    void updateTemplateStatus(@Param("templateId") String templateId, @Param("status") String status);
+    //根据id和accountId 删除关联表信息
+    void removeBinding(@Param("templateId") String templateId, @Param("accountId") String accountId);
+    //查询清理日志记录
+    List<KuaiShouAccountCleanLogInfo> getCleanUpLog(@Param("templateId") String templateId, @Param("userId") String userId);
+
+    //根据账户id 运营名称 查询个人模板信息
+    List<KuaiShouAccountCleanTemplateInfo> getMyselfTemplateList(@Param("accountId") String accountId, @Param("userName") String userName, @Param("createId") String createId);
+
+    //查询所有启用的模板
+    List<KuaiShouAccountCleanTemplateInfo> getTemplateListBystatus();
+    //根据规则模板查询相应组信息
+    String getGroupMessage(@Param("template") KuaiShouAccountCleanTemplateInfo kuaiShouAccountCleanTemplateInfo, @Param("optimizationObjective") String optimizationObjective, @Param("startDate") String startDate, @Param("unitId") String unitId);
+    List<Map> getGroupByAccount(@Param("accountId") String accountId);
+
+    //保存操作日志
+    void saveCleamLog(KuaiShouAccountCleanLogInfo kuaiShouAccountCleanLogInfo);
+
+    Map<String,String> getUserNameByAccountId(@Param("accountId") String accountId);
+
+    String getUserRealName(@Param("userId") String userId);
+    /**
+     * 根据模板名称查询
+     */
+    int getTemplateName(@Param("templateName") String templateName);
+}

+ 193 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/mapper/xml/KuaishouAccountCleanTemplateMapper.xml

@@ -0,0 +1,193 @@
+<?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.clean.mapper.KuaishouAccountCleanTemplateMapper">
+
+
+    <resultMap id="templateResultMap" type="cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanTemplateInfo">
+        <id column="id" property="id"/>
+        <result column="template_name" property="templateName"/>
+        <result column="applied_media" property="appliedMedia"/>
+        <result column="clean_time" property="cleanTime"/>
+        <result column="optimization_objective" property="optimizationObjective"/>
+        <result column="charge" property="charge"/>
+        <result column="conversion" property="conversion"/>
+        <result column="promotion_group_status" property="promotionGroupStatus"/>
+        <result column="perform_operations" property="performOperations"/>
+        <result column="status" property="status"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_id" property="createId"/>
+        <result column="create_time" property="createTime"/>
+        <result column="account_id" property="accountId"/>
+        <result column="user_name" property="userName"/>
+        <result column="account_status" property="accountStatus"/>
+        <result column="account_name" property="accountName"/>
+    </resultMap>
+
+    <resultMap id="logResultMap" type="cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanLogInfo">
+        <id column="id" property="id"/>
+        <result column="account_id" property="accountId"/>
+        <result column="template_id" property="templateId"/>
+        <result column="create_template_id" property="createTemplateId"/>
+        <result column="user_name" property="userName"/>
+        <result column="operation_type" property="operationType"/>
+        <result column="create_time" property="createTime"/>
+        <result column="executive_information" property="executiveInformation"/>
+    </resultMap>
+    <!--保存清理模板-->
+    <insert id="saveAccountCleanTemplate" parameterType="cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanTemplateInfo">
+    insert into ctop_kuaishou_account_clean_template values (#{id},#{templateName},#{appliedMedia},#{cleanTime},#{optimizationObjective},#{charge},
+    #{conversion},#{promotionGroupStatus},#{performOperations},#{status},#{createUser},#{createId},#{createTime})
+  </insert>
+
+    <!--根据创建人查询模板-->
+    <select id="getTemplateList" resultMap="templateResultMap">
+        select t.id,t.template_name,t.applied_media,t.create_user,t.status from ctop_kuaishou_account_clean_template t
+        <where>
+            <if test="templateName!=null and templateName!=''">
+                t.template_name like CONCAT(CONCAT('%', #{templateName}), '%')
+            </if>
+
+            <if test="createUser!=null and createUser!=''">
+                and t.create_user=#{createUser}
+            </if>
+            <if test="createId!=null and createId!=''">
+                and t.create_id=#{createId}
+            </if>
+        </where>
+        order by create_time desc
+    </select>
+
+    <select id="getInfoById" parameterType="String" resultMap="templateResultMap">
+      select  t.id,t.template_name,t.clean_time,t.optimization_objective,t.charge,t.conversion,t.promotion_group_status,t.perform_operations  from ctop_kuaishou_account_clean_template t
+      where t.id=#{templateId}
+   </select>
+
+    <select id="getAccountAssociatedSize" resultType="int">
+        select count(*) from ctop_kuaishou_account_clean_center where account_id=#{accountId}
+  </select>
+
+    <insert id="savePushTemplateAssociated">
+    insert into ctop_kuaishou_account_clean_center (account_id,template_id,create_time)values (#{accountId},#{templateId},#{createTime})
+  </insert>
+
+    <update id="updateTemplate">
+    update ctop_kuaishou_account_clean_template set
+    template_name=#{templateName},clean_time=#{cleanTime},
+    optimization_objective=#{optimizationObjective},charge=#{charge},
+    conversion=#{conversion},promotion_group_status=#{promotionGroupStatus},
+    perform_operations=#{performOperations}
+    where id=#{id}
+  </update>
+    <update id="updateTemplateStatus">
+    update ctop_kuaishou_account_clean_template set status=#{status}
+    where id=#{templateId}
+  </update>
+
+    <delete id="removeBinding">
+    delete  from ctop_kuaishou_account_clean_center where account_id=#{accountId} and template_id=#{templateId}
+  </delete>
+
+    <select id="getCleanUpLog" parameterType="cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanLogInfo"
+            resultMap="logResultMap">
+        select * from ctop_kuaishou_account_clean_logs t
+        <where>
+            <if test="templateId!=null and templateId!=''">
+                t.template_id=#{templateId}
+            </if>
+
+            <if test="userId!=null and userId!=''">
+                and t.create_template_id =#{userId}
+            </if>
+        </where>
+    </select>
+
+
+    <!--根据账户id 运营名称 查询个人模板信息-->
+    <select id="getMyselfTemplateList" resultMap="templateResultMap">
+        select t.status,t.id,t.template_name,t.applied_media,t2.account_id,t3.auth_name as
+        account_name,t3.account_status,t.create_user as 'user_name' from ctop_kuaishou_account_clean_template t
+        LEFT JOIN ctop_kuaishou_account_clean_center t2 on t.id=t2.template_id
+        LEFT JOIN ctop_user_allocation t3 on t2.account_id=t3.account_id
+        <where>
+            t2.account_id is not null
+            <if test="accountId!=null and accountId!=''">
+                and t2.account_id=#{accountId}
+            </if>
+
+            <if test="userName!=null and userName!=''">
+                and t.create_user like concat('%',#{userName},'%')
+            </if>
+            <if test="createId!=null and createId!=''">
+                and t.create_id=#{createId}
+            </if>
+        </where>
+
+    </select>
+
+    <select id="getTemplateListBystatus" resultMap="templateResultMap">
+       select  t.id,t.template_name,t.clean_time,t.optimization_objective,t.charge,t.conversion,t.promotion_group_status,t.perform_operations,t2.account_id,t.create_id,t.create_user  from ctop_kuaishou_account_clean_template t
+       left join  ctop_kuaishou_account_clean_center t2 on t.id=t2.template_id where t.status='0'
+  </select>
+
+    <select id="getGroupMessage" resultType="String">
+
+        SELECT t.unit_id from ctop_kuaishou_group t LEFT JOIN ctop_kuaishou_report_daily_group t2
+        on t.unit_id=t2.unit_id
+        where t.account_id=#{template.accountId}
+        and t.group_create_time &lt;= #{startDate}
+        and t2.stat_date &gt;= #{startDate}
+        and t.unit_id=#{unitId}
+        <if test='template.promotionGroupStatus!=null and template.promotionGroupStatus!="" and template.promotionGroupStatus!="3"'>
+            and t.put_status=#{template.promotionGroupStatus}
+        </if>
+        group by t.unit_id
+        having sum(t2.charge) &lt;= #{template.charge}
+        <if test='optimizationObjective=="activation"'>
+            /* 激活数*/
+            and sum(t2.activation) &lt; #{template.conversion}
+        </if>
+
+
+        <if test='optimizationObjective=="formSize"'>
+            /*表单数*/
+            and  sum(t2.form_count) &lt; #{template.conversion}
+        </if>
+
+        <if test='optimizationObjective=="pay"'>
+            /*付费数*/
+            and  sum(t2.event_pay) &lt; #{template.conversion}
+        </if>
+
+
+        <if test='optimizationObjective=="evocativeApplication"'>
+            /*唤起应用*/
+            and sum(t2.event_app_invoked) &lt; #{template.conversion}
+        </if>
+
+        <if test='optimizationObjective=="registered"'>
+            /*注册*/
+            and sum(t2.event_register) &lt; #{template.conversion}
+        </if>
+
+    </select>
+
+    <select id="getUserNameByAccountId" resultType="Map">
+       select t.user_name as userName,t.auth_name as authName from ctop_user_allocation t where t.account_id=#{accountId}
+  </select>
+
+    <insert id="saveCleamLog">
+    insert into ctop_kuaishou_account_clean_logs (template_id,account_id,create_template_id,user_name,operation_type,create_time,executive_information) values (#{templateId},#{accountId},#{createTemplateId},#{userName},#{operationType},#{createTime},#{executiveInformation})
+  </insert>
+
+    <select id="getUserRealName" resultType="String">
+        select t.realname from sys_user t where t.id=#{userId}
+    </select>
+
+    <select id="getTemplateName" parameterType="String" resultType="int">
+         select count(*) from ctop_kuaishou_account_clean_template t  where t.template_name=#{templateName}
+    </select>
+
+    <select id="getGroupByAccount" resultType="Map">
+        select  t.unit_id as 'unitId',t.ocpx_action_type  as 'type' from ctop_kuaishou_group t  where t.account_id=#{accountId}
+    </select>
+</mapper>

+ 91 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/service/KuaiShouAccountCleanService.java

@@ -0,0 +1,91 @@
+package cn.com.ctop.kuaishou.modules.clean.service;
+
+import cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanTemplateInfo;
+import org.jeecg.common.api.vo.Result;
+/**
+ * @Description: 快手-账户清理
+ * @Author: zzy
+ * @Date: 2021-07-20
+ * @Version: V1.0
+ */
+public interface KuaiShouAccountCleanService {
+    /**
+     * 创建规则模板
+     *
+     * @param kuaiShouAccountCleanTemplateInfo
+     * @return
+     */
+    Result createCleanTemplate(KuaiShouAccountCleanTemplateInfo kuaiShouAccountCleanTemplateInfo);
+    /**
+     * 查询模板列表
+     *
+     * @param templateId 模板id  createUser创建人
+     * @return
+     */
+    Result getTemplateList(String templateId, String createUser, String userId, String pageNum, String pageSize);
+    /**
+     * 预览模板
+     *
+     * @param templateId 模板id
+     * @return
+     */
+    Result previewTemplate(String templateId);
+    /**
+     * 推送模板
+     *
+     * @param templateId 模板id,accountId 账户id
+     * @return
+     */
+    Result pushTemplate(String templateId, String accountId);
+    /**
+     * 修改模板
+     *
+     * @param kuaiShouAccountCleanTemplateInfo
+     * @return
+     */
+    Result updateTemplate(KuaiShouAccountCleanTemplateInfo kuaiShouAccountCleanTemplateInfo);
+    /**
+     * 开启/暂停模板
+     *
+     * @param templateId 模板id   status状态  0-开始   1-暂停
+     * @return
+     */
+    Result updateTemplateStatus(String templateId, String status);
+    /**
+     * 解除模板绑定
+     *
+     * @param templateId 模板id,accountId 账户id
+     * @return
+     */
+    Result removeBinding(String templateId, String accountId);
+    /**
+     * 查询清理记录
+     *
+     * @param templateId 模板名称  userId 账户id
+     * @return
+     */
+    Result getCleanUpLog(String templateId, String userId, String pageNum, String pageSize);
+    /**
+     * 查询个人清理模板列表
+     *
+     * @param accountId  账户id  userName运营名称  userId当前登录人id
+     * @return
+     */
+    Result getMyselfTemplateList(String accountId, String userName, String userId, String pageNum, String pageSize);
+
+
+    /**
+     * 根据清理模板清理账户
+     *
+     * @param
+     * @return
+     */
+    Result cleanAccount();
+    /**
+     * 根据模板名称查询
+     *
+     * @param templateName
+     * @return
+     */
+    Result getTemplateName(String templateName);
+}

+ 426 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/clean/service/impl/KuaiShouAccountCleanServiceImpl.java

@@ -0,0 +1,426 @@
+package cn.com.ctop.kuaishou.modules.clean.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.service.ISysRoleExtService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
+import cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanLogInfo;
+import cn.com.ctop.kuaishou.modules.clean.entity.KuaiShouAccountCleanTemplateInfo;
+import cn.com.ctop.kuaishou.modules.clean.mapper.KuaishouAccountCleanTemplateMapper;
+import cn.com.ctop.kuaishou.modules.clean.service.KuaiShouAccountCleanService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jsoup.helper.StringUtil;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * @Description: 快手-账户清理
+ * @Author: zzy
+ * @Date: 2021-07-20
+ * @Version: V1.0
+ */
+@Service
+@Slf4j
+public class KuaiShouAccountCleanServiceImpl implements KuaiShouAccountCleanService {
+
+    @Resource
+    KuaishouAccountCleanTemplateMapper kuaishouAccountCleanTemplateMapper;
+
+    @Resource
+    private ISysRoleExtService sysRoleService;
+
+    @Resource
+    CtopOauthTokenMapper ctopOauthTokenMapper;
+
+    @Resource
+    IKuaiShouUpdateService iKuaiShouUpdateService;
+
+    /**
+     * 创建规则模板
+     *
+     * @param kuaiShouAccountCleanTemplateInfo
+     * @return
+     */
+    @Override
+    public Result createCleanTemplate(KuaiShouAccountCleanTemplateInfo kuaiShouAccountCleanTemplateInfo) {
+        Result result = new Result();
+        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Random rand = new Random();
+        int id = 100000 + rand.nextInt(99900000);
+
+        //设置6-8位数字
+        kuaiShouAccountCleanTemplateInfo.setId(String.valueOf(id));
+        //设置应用媒体 固定写死
+        kuaiShouAccountCleanTemplateInfo.setAppliedMedia("快手");
+        //未绑定账户  设置暂停状态
+        kuaiShouAccountCleanTemplateInfo.setStatus(String.valueOf(0));
+        //设置创建日期
+        kuaiShouAccountCleanTemplateInfo.setCreateTime(sd.format(new Date()));
+        try {
+            String userRealName = kuaishouAccountCleanTemplateMapper.getUserRealName(kuaiShouAccountCleanTemplateInfo.getCreateId());
+            kuaiShouAccountCleanTemplateInfo.setCreateUser(userRealName);
+            kuaishouAccountCleanTemplateMapper.saveAccountCleanTemplate(kuaiShouAccountCleanTemplateInfo);
+            result.success("创建模板成功");
+        } catch (Exception e) {
+            log.info("保存模板失败:{}", e.toString());
+            result.error500("创建模板失败");
+        }
+        return result;
+    }
+
+    /**
+     * 查询模板列表
+     *
+     * @param templateName 模板名称  createUser创建人
+     * @return
+     */
+    @Override
+    public Result getTemplateList(String templateName, String createUser, String userId, String pageNum, String pageSize) {
+        Result result = new Result();
+        PageHelper pageHelper = new PageHelper();
+        List<KuaiShouAccountCleanTemplateInfo> templateList = new ArrayList<>();
+        try {
+            //查询当前登录人角色
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            PageHelper.startPage(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
+            if (roleCode != null && roleCode.equals("admin")) {
+                //管理员查询全部
+                templateList = kuaishouAccountCleanTemplateMapper.getTemplateList(templateName, createUser, null);
+            } else {
+                //其他角色查询自己拥有的
+                templateList = kuaishouAccountCleanTemplateMapper.getTemplateList(templateName, createUser, userId);
+            }
+            PageInfo pageInfo = new PageInfo(templateList);
+            result.success("查询成功");
+            result.setResult(pageInfo);
+        } catch (Exception e) {
+            log.info("查询失败:{}", e.toString());
+            result.error500("查询失败");
+        }
+        return result;
+    }
+
+    /**
+     * 预览模板
+     *
+     * @param templateId 模板id
+     * @return
+     */
+    @Override
+    public Result previewTemplate(String templateId) {
+        Result result = new Result();
+        try {
+            KuaiShouAccountCleanTemplateInfo infoById = kuaishouAccountCleanTemplateMapper.getInfoById(templateId);
+            result.success("查询成功");
+            result.setResult(infoById);
+        } catch (Exception e) {
+            log.info("查询失败:{}", e.toString());
+            result.error500("查询失败");
+        }
+        return result;
+    }
+
+    /**
+     * 推送模板
+     *
+     * @param templateId 模板id,accountId 账户id
+     * @return
+     */
+    @Override
+    public Result pushTemplate(String templateId, String accountId) {
+        Result result = new Result();
+        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
+        try {
+            //查询模板关联个数
+            int accountAssociatedSize = kuaishouAccountCleanTemplateMapper.getAccountAssociatedSize(accountId);
+            //无关联模板 推送模板
+            if (accountAssociatedSize == 0) {
+                kuaishouAccountCleanTemplateMapper.savePushTemplateAssociated(templateId, accountId, sd.format(new Date()));
+                //修改模板状态,改为开启
+                kuaishouAccountCleanTemplateMapper.updateTemplateStatus(templateId, "0");
+                result.success("推送成功");
+            } else {
+                result.success("推送失败,此账户已关联模板");
+            }
+        } catch (Exception e) {
+            log.info("推送失败:{}", e.toString());
+            result.error500("推送失败");
+        }
+        return result;
+    }
+
+    /**
+     * 修改模板
+     *
+     * @param kuaiShouAccountCleanTemplateInfo
+     * @return
+     */
+    @Override
+    public Result updateTemplate(KuaiShouAccountCleanTemplateInfo kuaiShouAccountCleanTemplateInfo) {
+        Result result = new Result();
+        try {
+            if (!StringUtils.isBlank(kuaiShouAccountCleanTemplateInfo.getId())) {
+                kuaishouAccountCleanTemplateMapper.updateTemplate(kuaiShouAccountCleanTemplateInfo);
+                result.success("修改成功");
+            } else {
+                result.success("id不能为空");
+            }
+        } catch (Exception e) {
+            log.info("修改失败:{}", e.toString());
+            result.error500("修改失败");
+        }
+        return result;
+    }
+
+    /**
+     * 开启/暂停模板
+     *
+     * @param templateId 模板id   status状态  0-开始   1-暂停
+     * @return
+     */
+    @Override
+    public Result updateTemplateStatus(String templateId, String status) {
+        Result result = new Result();
+        String message = "修改";
+        if (status.equals("0")) {
+            message = "开启";
+        }
+        if (status.equals("1")) {
+            message = "关闭";
+        }
+        try {
+            //修改模板状态
+            kuaishouAccountCleanTemplateMapper.updateTemplateStatus(templateId, status);
+            result.success(message + "成功");
+        } catch (Exception e) {
+            log.info(message + "失败:{}", e.toString());
+            result.error500(message + "失败");
+        }
+        return result;
+    }
+
+    /**
+     * 解除模板绑定
+     *
+     * @param templateId 模板id,accountId 账户id
+     * @return
+     */
+    @Override
+    public Result removeBinding(String templateId, String accountId) {
+        Result result = new Result();
+        try {
+            kuaishouAccountCleanTemplateMapper.removeBinding(templateId, accountId);
+            result.success("解除绑定成功");
+        } catch (Exception e) {
+            log.info("解除绑定失败:{}", e.toString());
+            result.error500("解除绑定失败");
+        }
+        return result;
+    }
+
+    @Override
+    public Result getCleanUpLog(String templateId, String userId, String pageNum, String pageSize) {
+        Result result = new Result();
+        List<KuaiShouAccountCleanLogInfo> cleanUpLog = new ArrayList<>();
+        try {
+            //查询当前登录人角色
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            PageHelper.startPage(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
+            if (roleCode != null && roleCode.equals("admin")) {
+                cleanUpLog = kuaishouAccountCleanTemplateMapper.getCleanUpLog(templateId, null);
+            } else {
+                cleanUpLog = kuaishouAccountCleanTemplateMapper.getCleanUpLog(templateId, userId);
+            }
+            PageHelper.startPage(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
+
+            PageInfo pageInfo = new PageInfo(cleanUpLog);
+            result.success("查询成功");
+            result.setResult(pageInfo);
+        } catch (Exception e) {
+            log.info("查询失败:{}", e.toString());
+            result.error500("查询失败");
+        }
+        return result;
+    }
+
+    /**
+     * 查询个人清理模板列表
+     *
+     * @param accountId 账户id  userName运营名称  userId当前登录人id
+     * @return
+     */
+    @Override
+    public Result getMyselfTemplateList(String accountId, String userName, String userId, String pageNum, String pageSize) {
+        Result result = new Result();
+        PageHelper pageHelper = new PageHelper();
+        List<KuaiShouAccountCleanTemplateInfo> templateList = new ArrayList<>();
+        try {
+            //查询当前登录人角色
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            PageHelper.startPage(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
+            if (roleCode != null && roleCode.equals("admin")) {
+                //管理员查询全部
+                templateList = kuaishouAccountCleanTemplateMapper.getMyselfTemplateList(accountId, userName, null);
+            } else {
+                //其他角色查询自己拥有的
+                templateList = kuaishouAccountCleanTemplateMapper.getMyselfTemplateList(accountId, userName, userId);
+            }
+            PageInfo pageInfo = new PageInfo(templateList);
+            result.success("查询成功");
+            result.setResult(pageInfo);
+        } catch (Exception e) {
+            log.info("查询失败:{}", e.toString());
+            result.error500("查询失败");
+        }
+        return result;
+    }
+
+    /**
+     * 根据清理模板清理账户
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public Result cleanAccount() {
+        Result result = new Result();
+        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Map optimizationObjectiveMap = new HashMap();
+        //优化目标 activation:激活数 bclick:行为数  formSize :表单数 pay:付费  roi:首日roi   evocativeApplication:唤起应用
+        // effectiveClues:有效线索 creditApp:授信-APP creditGrant:授信-落地页  finishedPieceApp:完件数-APP  finishedPieceGrant:完件数-落地页  registered:注册
+        optimizationObjectiveMap.put("180", "activation");
+        optimizationObjectiveMap.put("53", "formSize");
+        optimizationObjectiveMap.put("190", "pay");
+        optimizationObjectiveMap.put("324", "evocativeApplication");
+        optimizationObjectiveMap.put("396", "registered");
+        try {
+            //查询需要执行的规则模板
+            List<KuaiShouAccountCleanTemplateInfo> templateListBystatus = kuaishouAccountCleanTemplateMapper.getTemplateListBystatus();
+            if (!templateListBystatus.isEmpty()) {
+                templateListBystatus.stream().forEach(ob -> {
+                    AtomicInteger count= new AtomicInteger();
+                    if (ob.getAccountId() != null) {
+                        StringBuilder unitIds = new StringBuilder();
+                        //获取各项优化目标
+                        List<String> optimizationObjectiveList = Arrays.asList(ob.getOptimizationObjective().split(","));
+                        //获取清理时间范围
+                        String cleanTime = ob.getCleanTime();
+                        //计算最早清理时间
+                        Calendar calendar = Calendar.getInstance();//此时打印它获取的是系统当前时间
+                        calendar.add(Calendar.DATE, -Integer.parseInt(cleanTime));
+                        String startDate = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
+                        AtomicReference<Boolean> falg = new AtomicReference<>(true);
+                        //查询改账户下所有组
+                        List<Map> groupByAccount = kuaishouAccountCleanTemplateMapper.getGroupByAccount(ob.getAccountId());
+                        if (!groupByAccount.isEmpty()) {
+                            groupByAccount.stream().forEach(obj -> {
+                                if (obj.get("unitId") != null && obj.get("type") != null) {
+                                    String unitId = Long.toString((Long) obj.get("unitId")) ;
+                                    //OCPM
+                                    String type = Integer.toString((Integer) obj.get("type")) ;
+                                    if(optimizationObjectiveMap.get(type)!=null){
+                                        String optimizationObjective= (String) optimizationObjectiveMap.get(type);
+                                        //查询组是否符合清理规则
+                                        String groupMessage = kuaishouAccountCleanTemplateMapper.getGroupMessage(ob, optimizationObjective, startDate,unitId);
+                                        if(groupMessage!=null){
+                                            count.getAndIncrement();
+                                            //符合清理规则清理
+                                            //获取Token
+                                            CtopOauthToken ctopOauthToken = ctopOauthTokenMapper.selectByAccountId(Long.parseLong(ob.getAccountId()));
+                                            if (ctopOauthToken != null) {
+                                                //修改广告组状态
+                                                Map<String, Object> resultMap = iKuaiShouUpdateService.updateUnitStatus(ctopOauthToken.getAccessToken(), Long.parseLong(ob.getAccountId()), Long.parseLong(unitId), Integer.parseInt(ob.getPerformOperations()), null);
+                                                Boolean resultFlag = (Boolean) resultMap.get("success");
+                                                //判断有没有失败
+                                                if (resultFlag) {
+                                                    //清理成功
+                                                    unitIds.append(unitId).append(",");
+                                                    log.info("组"+unitId+"已被清理");
+                                                }else {
+                                                    //清理失败
+                                                    log.info("组"+unitId+"清理失败:{}",resultMap.get("message"));
+                                                    falg.set(false);
+                                                }
+                                            }
+                                        }
+                                    }
+
+                                }
+                            });
+                        }
+
+
+                        if (count.get()>0 && falg.get()) {
+                            //修改成功插入日志记录
+                            KuaiShouAccountCleanLogInfo kuaiShouAccountCleanLogInfo = new KuaiShouAccountCleanLogInfo();
+                            //设置账户id
+                            kuaiShouAccountCleanLogInfo.setAccountId(ob.getAccountId());
+                            // 1-投放、2-暂停、3-删除
+                            kuaiShouAccountCleanLogInfo.setOperationType(ob.getPerformOperations());
+                            //设置运营
+//                            Map<String, String> map = kuaishouAccountCleanTemplateMapper.getUserNameByAccountId(ob.getAccountId());
+//                            String authName = "";
+//                            if (map != null) {
+//                                kuaiShouAccountCleanLogInfo.setUserName(map.get("userName"));
+//                                authName = map.get("authName");
+//                            }
+                            //设置时间
+                            kuaiShouAccountCleanLogInfo.setCreateTime(sd.format(new Date()));
+                            //操作类型
+                            String operationType = null;
+                            if (ob.getPerformOperations().equals("2")) {
+                                operationType = "暂停";
+                            }
+                            if (ob.getPerformOperations().equals("3")) {
+                                operationType = "删除";
+                            }
+                            //执行信息
+                            String textMessage = "清理规则执行:  账户:" + ob.getAccountId() + ", 授权名称: " + ob.getCreateUser() + ",推广组:" + unitIds + "已经被清理规则" + operationType;
+                            kuaiShouAccountCleanLogInfo.setExecutiveInformation(textMessage);
+                            kuaiShouAccountCleanLogInfo.setTemplateId(ob.getId());
+                            kuaiShouAccountCleanLogInfo.setCreateTemplateId(ob.getCreateId());
+                            kuaiShouAccountCleanLogInfo.setUserName(ob.getCreateUser());
+                            kuaishouAccountCleanTemplateMapper.saveCleamLog(kuaiShouAccountCleanLogInfo);
+                        }
+                    }
+                });
+            }
+
+            result.success("执行计划成功");
+        } catch (Exception e) {
+            log.info("执行计划失败:{}", e.toString());
+            result.error500("执行计划失败");
+        }
+        return result;
+    }
+
+    /**
+     * 根据模板名称查询
+     *
+     * @param templateName
+     * @return
+     */
+    @Override
+    public Result getTemplateName(String templateName) {
+        Result result = new Result();
+        try {
+            int number = kuaishouAccountCleanTemplateMapper.getTemplateName(templateName.trim());
+            result.setResult(number);
+        } catch (Exception e) {
+            log.info("查询失败:{}", e.toString());
+            result.error500("查询失败");
+        }
+        return result;
+    }
+
+
+}

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceVideoReportMapper.xml

@@ -16,7 +16,7 @@
         t1.material_name AS materialName,
         t1.project_name AS projectName,
         t1.material_create_time AS createTime,
-        sum (t1.material_show) as showMaterial,
+        sum(t1.material_show) as showMaterial,
         ${filed}
         FROM
         etl_report_bytedance_video t1