소스 검색

运营转户操作

sunzhen 5 년 전
부모
커밋
11f0af6e3a
13개의 변경된 파일1546개의 추가작업 그리고 184개의 파일을 삭제
  1. 243 0
      performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/controller/PerformanceAccountController.java
  2. 77 0
      performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/entity/PerformanceAccount.java
  3. 17 0
      performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/mapper/PerformanceAccountMapper.java
  4. 5 0
      performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/mapper/xml/PerformanceAccountMapper.xml
  5. 14 0
      performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/service/IPerformanceAccountService.java
  6. 19 0
      performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/service/impl/PerformanceAccountServiceImpl.java
  7. 203 0
      performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/vue/PerformanceAccountList.vue
  8. 171 0
      performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/vue/modules/PerformanceAccountModal.vue
  9. 178 0
      performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/vue/modules/PerformanceAccountModal__Style#Drawer.vue
  10. 1 0
      performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/controller/PerformanceOptimizerController.java
  11. 569 184
      performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/service/impl/PerformanceOptimizerServiceImpl.java
  12. 8 0
      performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/UserEfficientVideoMapMapper.java
  13. 41 0
      performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/xml/UserEfficientVideoMapMapper.xml

+ 243 - 0
performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/controller/PerformanceAccountController.java

@@ -0,0 +1,243 @@
+package cn.com.ctop.performanceaccount.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.util.oConvertUtils;
+import cn.com.ctop.performanceaccount.entity.PerformanceAccount;
+import cn.com.ctop.performanceaccount.service.IPerformanceAccountService;
+import java.util.Date;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+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 com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+ /**
+ * 运营明细表
+ * @author jeecg-boot
+ * @date   2020-04-05
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="运营明细表")
+@RestController
+@RequestMapping("/performanceaccount/performanceAccount")
+public class PerformanceAccountController {
+	@Autowired
+	private IPerformanceAccountService performanceAccountService;
+	
+	/**
+	  * 分页列表查询
+	 * @param performanceAccount
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "运营明细表-分页列表查询")
+	@ApiOperation(value="运营明细表-分页列表查询", notes="运营明细表-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<PerformanceAccount>> queryPageList(PerformanceAccount performanceAccount,
+									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+									  HttpServletRequest req) {
+		Result<IPage<PerformanceAccount>> result = new Result<IPage<PerformanceAccount>>();
+		QueryWrapper<PerformanceAccount> queryWrapper = QueryGenerator.initQueryWrapper(performanceAccount, req.getParameterMap());
+		Page<PerformanceAccount> page = new Page<PerformanceAccount>(pageNo, pageSize);
+		IPage<PerformanceAccount> pageList = performanceAccountService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+	
+	/**
+	  *   添加
+	 * @param performanceAccount
+	 * @return
+	 */
+	@AutoLog(value = "运营明细表-添加")
+	@ApiOperation(value="运营明细表-添加", notes="运营明细表-添加")
+	@PostMapping(value = "/add")
+	public Result<PerformanceAccount> add(@RequestBody PerformanceAccount performanceAccount) {
+		Result<PerformanceAccount> result = new Result<PerformanceAccount>();
+		try {
+			performanceAccountService.save(performanceAccount);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+	
+	/**
+	  *  编辑
+	 * @param performanceAccount
+	 * @return
+	 */
+	@AutoLog(value = "运营明细表-编辑")
+	@ApiOperation(value="运营明细表-编辑", notes="运营明细表-编辑")
+	@PutMapping(value = "/edit")
+	public Result<PerformanceAccount> edit(@RequestBody PerformanceAccount performanceAccount) {
+		Result<PerformanceAccount> result = new Result<PerformanceAccount>();
+		PerformanceAccount performanceAccountEntity = performanceAccountService.getById(performanceAccount.getId());
+		if(performanceAccountEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = performanceAccountService.updateById(performanceAccount);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+		
+		return result;
+	}
+	
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "运营明细表-通过id删除")
+	@ApiOperation(value="运营明细表-通过id删除", notes="运营明细表-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			performanceAccountService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+	
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "运营明细表-批量删除")
+	@ApiOperation(value="运营明细表-批量删除", notes="运营明细表-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<PerformanceAccount> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<PerformanceAccount> result = new Result<PerformanceAccount>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.performanceAccountService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+	
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "运营明细表-通过id查询")
+	@ApiOperation(value="运营明细表-通过id查询", notes="运营明细表-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<PerformanceAccount> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<PerformanceAccount> result = new Result<PerformanceAccount>();
+		PerformanceAccount performanceAccount = performanceAccountService.getById(id);
+		if(performanceAccount==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(performanceAccount);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+      // Step.1 组装查询条件
+      QueryWrapper<PerformanceAccount> queryWrapper = null;
+      try {
+          String paramsStr = request.getParameter("paramsStr");
+          if (oConvertUtils.isNotEmpty(paramsStr)) {
+              String deString = URLDecoder.decode(paramsStr, "UTF-8");
+              PerformanceAccount performanceAccount = JSON.parseObject(deString, PerformanceAccount.class);
+              queryWrapper = QueryGenerator.initQueryWrapper(performanceAccount, request.getParameterMap());
+          }
+      } catch (UnsupportedEncodingException e) {
+          e.printStackTrace();
+      }
+
+      //Step.2 AutoPoi 导出Excel
+      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+      List<PerformanceAccount> pageList = performanceAccountService.list(queryWrapper);
+      //导出文件名称
+      mv.addObject(NormalExcelConstants.FILE_NAME, "运营明细表列表");
+      mv.addObject(NormalExcelConstants.CLASS, PerformanceAccount.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) {
+      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+      Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+          MultipartFile file = entity.getValue();
+          ImportParams params = new ImportParams();
+          params.setTitleRows(2);
+          params.setHeadRows(1);
+          params.setNeedSave(true);
+          try {
+              List<PerformanceAccount> listPerformanceAccounts = ExcelImportUtil.importExcel(file.getInputStream(), PerformanceAccount.class, params);
+              performanceAccountService.saveBatch(listPerformanceAccounts);
+              return Result.ok("文件导入成功!数据行数:" + listPerformanceAccounts.size());
+          } catch (Exception e) {
+              log.error(e.getMessage(),e);
+              return Result.error("文件导入失败:"+e.getMessage());
+          } finally {
+              try {
+                  file.getInputStream().close();
+              } catch (IOException e) {
+                  e.printStackTrace();
+              }
+          }
+      }
+      return Result.ok("文件导入失败!");
+  }
+
+}

+ 77 - 0
performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/entity/PerformanceAccount.java

@@ -0,0 +1,77 @@
+package cn.com.ctop.performanceaccount.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 运营明细表
+ * @author jeecg-boot
+ * @date   2020-04-05
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_performance_account")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_performance_account对象", description="运营明细表")
+public class PerformanceAccount {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Integer id;
+	/**账户id*/
+	@Excel(name = "账户id", width = 15)
+    @ApiModelProperty(value = "账户id")
+	private Long accountId;
+	/**账户期间消耗*/
+	@Excel(name = "账户期间消耗", width = 15)
+    @ApiModelProperty(value = "账户期间消耗")
+	private java.math.BigDecimal cost;
+	/**年*/
+	@Excel(name = "年", width = 15)
+    @ApiModelProperty(value = "年")
+	private Integer year;
+	/**1头条2快手*/
+	@Excel(name = "1头条2快手", width = 15)
+    @ApiModelProperty(value = "1头条2快手")
+	private Integer mediaType;
+	/**季度*/
+	@Excel(name = "季度", width = 15)
+    @ApiModelProperty(value = "季度")
+	private Integer quarter;
+	/**账户所属人*/
+	@Excel(name = "账户所属人", width = 15)
+    @ApiModelProperty(value = "账户所属人")
+	private String userId;
+	/**账户消耗计算开始时间*/
+	@Excel(name = "账户消耗计算开始时间", width = 15, format = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "账户消耗计算开始时间")
+	private String startDate;
+	/**账户消耗计算结束时间*/
+	@Excel(name = "账户消耗计算结束时间", width = 15, format = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "账户消耗计算结束时间")
+	private String endDate;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

+ 17 - 0
performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/mapper/PerformanceAccountMapper.java

@@ -0,0 +1,17 @@
+package cn.com.ctop.performanceaccount.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import cn.com.ctop.performanceaccount.entity.PerformanceAccount;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 运营明细表
+ * @author: jeecg-boot
+ * @date:   2020-04-05
+ * @cersion: V1.0
+ */
+public interface PerformanceAccountMapper extends BaseMapper<PerformanceAccount> {
+
+}

+ 5 - 0
performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/mapper/xml/PerformanceAccountMapper.xml

@@ -0,0 +1,5 @@
+<?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.performanceaccount.mapper.PerformanceAccountMapper">
+
+</mapper>

+ 14 - 0
performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/service/IPerformanceAccountService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.performanceaccount.service;
+
+import cn.com.ctop.performanceaccount.entity.PerformanceAccount;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 运营明细表
+ * @author jeecg-boot
+ * @date   2020-04-05
+ * @version V1.0
+ */
+public interface IPerformanceAccountService extends IService<PerformanceAccount> {
+
+}

+ 19 - 0
performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/service/impl/PerformanceAccountServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.performanceaccount.service.impl;
+
+import cn.com.ctop.performanceaccount.entity.PerformanceAccount;
+import cn.com.ctop.performanceaccount.mapper.PerformanceAccountMapper;
+import cn.com.ctop.performanceaccount.service.IPerformanceAccountService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * 运营明细表
+ * @author jeecg-boot
+ * @date   2020-04-05
+ * @version V1.0
+ */
+@Service
+public class PerformanceAccountServiceImpl extends ServiceImpl<PerformanceAccountMapper, PerformanceAccount> implements IPerformanceAccountService {
+
+}

+ 203 - 0
performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/vue/PerformanceAccountList.vue

@@ -0,0 +1,203 @@
+<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="账户id">
+              <a-input placeholder="请输入账户id" v-model="queryParam.accountId"></a-input>
+            </a-form-item>
+          </a-col>
+          <a-col :md="6" :sm="8">
+            <a-form-item label="账户期间消耗">
+              <a-input placeholder="请输入账户期间消耗" v-model="queryParam.cost"></a-input>
+            </a-form-item>
+          </a-col>
+        <template v-if="toggleSearchStatus">
+        <a-col :md="6" :sm="8">
+            <a-form-item label="年">
+              <a-input placeholder="请输入年" v-model="queryParam.year"></a-input>
+            </a-form-item>
+          </a-col>
+          <a-col :md="6" :sm="8">
+            <a-form-item label="1头条2快手">
+              <a-input placeholder="请输入1头条2快手" v-model="queryParam.mediaType"></a-input>
+            </a-form-item>
+          </a-col>
+          <a-col :md="6" :sm="8">
+            <a-form-item label="季度">
+              <a-input placeholder="请输入季度" v-model="queryParam.quarter"></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 -->
+
+    <!-- 表单区域 -->
+    <performanceAccount-modal ref="modalForm" @ok="modalFormOk"></performanceAccount-modal>
+  </a-card>
+</template>
+
+<script>
+  import PerformanceAccountModal from './modules/PerformanceAccountModal'
+  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+
+  export default {
+    name: "PerformanceAccountList",
+    mixins:[JeecgListMixin],
+    components: {
+      PerformanceAccountModal
+    },
+    data () {
+      return {
+        description: '运营明细表管理页面',
+        // 表头
+        columns: [
+          {
+            title: '#',
+            dataIndex: '',
+            key:'rowIndex',
+            width:60,
+            align:"center",
+            customRender:function (t,r,index) {
+              return parseInt(index)+1;
+            }
+           },
+		   {
+            title: '账户id',
+            align:"center",
+            dataIndex: 'accountId'
+           },
+		   {
+            title: '账户期间消耗',
+            align:"center",
+            dataIndex: 'cost'
+           },
+		   {
+            title: '年',
+            align:"center",
+            dataIndex: 'year'
+           },
+		   {
+            title: '1头条2快手',
+            align:"center",
+            dataIndex: 'mediaType'
+           },
+		   {
+            title: '季度',
+            align:"center",
+            dataIndex: 'quarter'
+           },
+		   {
+            title: '账户所属人',
+            align:"center",
+            dataIndex: 'userId'
+           },
+		   {
+            title: '账户消耗计算开始时间',
+            align:"center",
+            dataIndex: 'startDate'
+           },
+		   {
+            title: '账户消耗计算结束时间',
+            align:"center",
+            dataIndex: 'endDate'
+           },
+          {
+            title: '操作',
+            dataIndex: 'action',
+            align:"center",
+            scopedSlots: { customRender: 'action' },
+          }
+        ],
+		url: {
+          list: "/performanceaccount/performanceAccount/list",
+          delete: "/performanceaccount/performanceAccount/delete",
+          deleteBatch: "/performanceaccount/performanceAccount/deleteBatch",
+          exportXlsUrl: "performanceaccount/performanceAccount/exportXls",
+          importExcelUrl: "performanceaccount/performanceAccount/importExcel",
+       },
+    }
+  },
+  computed: {
+    importExcelUrl: function(){
+      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
+    }
+  },
+    methods: {
+     
+    }
+  }
+</script>
+<style scoped>
+  @import '~@assets/less/common.less'
+</style>

+ 171 - 0
performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/vue/modules/PerformanceAccountModal.vue

@@ -0,0 +1,171 @@
+<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="账户id">
+          <a-input placeholder="请输入账户id" v-decorator="['accountId', validatorRules.accountId ]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="账户期间消耗">
+          <a-input-number v-decorator="[ 'cost', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="年">
+          <a-input-number v-decorator="[ 'year', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="1头条2快手">
+          <a-input-number v-decorator="[ 'mediaType', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="季度">
+          <a-input-number v-decorator="[ 'quarter', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="账户所属人">
+          <a-input placeholder="请输入账户所属人" v-decorator="['userId', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="账户消耗计算开始时间">
+          <a-date-picker v-decorator="[ 'startDate', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="账户消耗计算结束时间">
+          <a-date-picker v-decorator="[ 'endDate', {}]" />
+        </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: "PerformanceAccountModal",
+    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:{
+        accountId:{rules: [{ required: true, message: '请输入账户id!' }]},
+        },
+        url: {
+          add: "/performanceaccount/performanceAccount/add",
+          edit: "/performanceaccount/performanceAccount/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,'accountId','cost','year','mediaType','quarter','userId'))
+		  //时间格式化
+          this.form.setFieldsValue({startDate:this.model.startDate?moment(this.model.startDate):null})
+          this.form.setFieldsValue({endDate:this.model.endDate?moment(this.model.endDate):null})
+        });
+
+      },
+      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);
+            //时间格式化
+            formData.startDate = formData.startDate?formData.startDate.format():null;
+            formData.endDate = formData.endDate?formData.endDate.format():null;
+            
+            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>

+ 178 - 0
performance-appraisal/src/main/java/cn/com/ctop/performanceaccount/vue/modules/PerformanceAccountModal__Style#Drawer.vue

@@ -0,0 +1,178 @@
+<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="账户id">
+          <a-input placeholder="请输入账户id" v-decorator="['accountId', validatorRules.accountId ]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="账户期间消耗">
+          <a-input-number v-decorator="[ 'cost', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="年">
+          <a-input-number v-decorator="[ 'year', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="1头条2快手">
+          <a-input-number v-decorator="[ 'mediaType', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="季度">
+          <a-input-number v-decorator="[ 'quarter', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="账户所属人">
+          <a-input placeholder="请输入账户所属人" v-decorator="['userId', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="账户消耗计算开始时间">
+          <a-date-picker v-decorator="[ 'startDate', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="账户消耗计算结束时间">
+          <a-date-picker v-decorator="[ 'endDate', {}]" />
+        </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: "PerformanceAccountModal",
+    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:{
+        accountId:{rules: [{ required: true, message: '请输入账户id!' }]},
+        },
+        url: {
+          add: "/performanceaccount/performanceAccount/add",
+          edit: "/performanceaccount/performanceAccount/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,'accountId','cost','year','mediaType','quarter','userId'))
+		  //时间格式化
+          this.form.setFieldsValue({startDate:this.model.startDate?moment(this.model.startDate):null})
+          this.form.setFieldsValue({endDate:this.model.endDate?moment(this.model.endDate):null})
+        });
+
+      },
+      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);
+            //时间格式化
+            formData.startDate = formData.startDate?formData.startDate.format():null;
+            formData.endDate = formData.endDate?formData.endDate.format():null;
+            
+            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>

+ 1 - 0
performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/controller/PerformanceOptimizerController.java

@@ -304,6 +304,7 @@ public class PerformanceOptimizerController {
 
         Map<String,String> map = DateUtils.quarterStartEndDate(year, quarter);
         performanceOptimizerService.toutiaoYunyingQuarterPerformance(year, quarter, map.get("startDate"), map.get("endDate"));
+        performanceOptimizerService.kuaishouYunyingQuarterPerformance(year, quarter, map.get("startDate"), map.get("endDate"));
     }
 
     /**

+ 569 - 184
performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/service/impl/PerformanceOptimizerServiceImpl.java

@@ -3,6 +3,8 @@ package cn.com.ctop.performanceappraisal.service.impl;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.performanceaccount.entity.PerformanceAccount;
+import cn.com.ctop.performanceaccount.mapper.PerformanceAccountMapper;
 import cn.com.ctop.performanceappraisal.entity.OptimizerConfig;
 import cn.com.ctop.performanceappraisal.entity.PerformanceConfig;
 import cn.com.ctop.performanceappraisal.entity.PerformanceOptimizer;
@@ -21,13 +23,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 优化师绩效信息
@@ -46,9 +50,11 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
     @Autowired
     private UserEfficientVideoMapMapper userEfficientVideoMapMapper;
     @Autowired
-    PerformanceMapper performanceMapper;
+    private PerformanceMapper performanceMapper;
     @Autowired
-    PerformanceOptimizerMapper performanceOptimizerMapper;
+    private PerformanceOptimizerMapper performanceOptimizerMapper;
+    @Autowired
+    private PerformanceAccountMapper performanceAccountMapper;
 
 
     public void YunyingPerformance(Integer year, Integer quarter, String startDate, String endDate){
@@ -64,10 +70,10 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
     public Map<String, Object> kuaishouYunyingQuarterPerformance(Integer year, Integer quarter, String startDate, String endDate){
         Map<String, Object> result = new HashMap<>();
         //获取快手所有运营的数据
-        List<UserDto2> userList = userEfficientVideoMapMapper.getAllKuaishouYunyingDepartUserInfo();
+        //List<UserDto2> userList = userEfficientVideoMapMapper.getAllKuaishouYunyingDepartUserInfo();
         Integer mediaType = 2;
         //循环所有快手运营
-        for(UserDto2 userDto:userList){
+        //for(UserDto2 userDto:userList){
             //userDto.setUserId("ce2cb485afd44d0e8563b4daa5ea6fcb");
             //String orgCode = userEfficientVideoMapMapper.getDepartIdByUserId(userDto.getUserId());
             //华北
@@ -78,8 +84,7 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
                 ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_OPTINIZER_CONFIG_IS_NULL.getCode());
                 return result;
             }
-            //:查询当前用户截止到目前当前季度的消耗统计数据
-            List<OptimizerCostDetailVO> vos = getOptimizerTotalCostDetailGroupByUserId(mediaType + "", userDto.getUserId(), year, quarter, startDate, endDate);
+
             //if (null == vos || vos.size() <= 0) {
             //    ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_OPTINIZER_PERSONNAL_DATA_IS_NULL.getCode());
             //    return result;
@@ -90,7 +95,7 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
             //ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
 
             //获取消耗统计数据信息--该统计是按照user_allocation来统计的数据,不包含转户的情况
-            log.info(userDto.getUserId());
+            //log.info(userDto.getUserId());
             //增加转户的情况
             //原则a:1. 该季度内最终转给此运营的户,将该户在本季度中不在的时间计算出来,然后计算这段时间内的总消耗,并在总数中减去
             //2. 季度期间在过此运营负责过的户,将在本季度中在的时间计算出来,然后计算总消耗并在总数中增加上
@@ -98,229 +103,609 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
             //原则b:1.找出改运营手下所有账户,循环每一个账户,然后进行转户判断
             //2.将该账户下所有转户信息拉取出来,去除受让时间小于季度开始时间 以及 转让时间大于季度结束时间的条目(sql去掉),得到该账户所有信息
             //3. 创建userMap,根据userId获取自己季度内的各时间段
-            BigDecimal totalRoyal = BigDecimal.ZERO;
-            BigDecimal totalRoyalty = BigDecimal.ZERO;
-            BigDecimal totalCost = BigDecimal.ZERO;
-            if(vos.size() != 0){
-                OptimizerCostDetailVO vo = vos.get(0);
-                //循环accountId
-                List<String> accountList = userEfficientVideoMapMapper.getAccountIdByUserId(userDto.getUserId());
-                Map<String, List<Map<String, String>>> accountRangeMap = new HashMap<>();
-
-                for(int i=0; i<accountList.size();i++){
-                    List<TransferorAccountDTO> transferorAccountDTOList = userEfficientVideoMapMapper.accountTransforerListByUserId(accountList.get(i), startDate, endDate);
-
-                    if(transferorAccountDTOList.size() == 0){
-                        accountRangeMap.put(accountList.get(i),null);
-                        continue;
+            //:查询当前用户截止到目前当前季度的消耗统计数据
+            //List<OptimizerCostDetailVO> vos = getOptimizerTotalCostDetailGroupByUserId(mediaType + "", userDto.getUserId(), year, quarter, startDate, endDate);
+            //BigDecimal totalRoyal = BigDecimal.ZERO;
+            //BigDecimal totalRoyalty = BigDecimal.ZERO;
+            //BigDecimal totalCost = BigDecimal.ZERO;
+            //if(vos.size() != 0){
+            //    OptimizerCostDetailVO vo = vos.get(0);
+            //    //循环accountId
+            //    List<String> accountList = userEfficientVideoMapMapper.getAccountIdByUserId(userDto.getUserId());
+            //    Map<String, List<Map<String, String>>> accountRangeMap = new HashMap<>();
+            //
+            //    for(int i=0; i<accountList.size();i++){
+            //        List<TransferorAccountDTO> transferorAccountDTOList = userEfficientVideoMapMapper.accountTransforerListByUserId(accountList.get(i), startDate, endDate);
+            //
+            //        if(transferorAccountDTOList.size() == 0){
+            //            accountRangeMap.put(accountList.get(i),null);
+            //            continue;
+            //        }
+            //        Map<String, String> DateMap = new HashMap<>();
+            //
+            //        for(int j=0; j<transferorAccountDTOList.size(); j++){
+            //            String transferor = transferorAccountDTOList.get(j).getTransferor();
+            //            //String assignee = transferorAccountDTOList.get(j).getAssignee();
+            //            //如果转让人不是本人,则跳过;按照转让人的逻辑走,因为受让人在下一次转户的时候也会变成转让人
+            //            if( transferor.equals(userDto.getUserId()) ){
+            //                if (j==0){
+            //                    DateMap.put("startDate", startDate);
+            //                }else {
+            //                    DateMap.put("startDate", transferorAccountDTOList.get(j-1).getAssigneeDate());
+            //                }
+            //                DateMap.put("endDate",transferorAccountDTOList.get(j).getTransferorDate());
+            //            }
+            //
+            //            //判断:如果转让人不是本人,受让人也不是,则跳过
+            //            if(DateMap.size() == 0 &&  j != (transferorAccountDTOList.size()-1)     ){   //!assignee.equals(userDto.getUserId())
+            //                continue;
+            //            }
+            //
+            //            if (accountRangeMap.get(accountList.get(i)) != null){
+            //                accountRangeMap.get(accountList.get(i)).add(DateMap);
+            //
+            //                if(j == (transferorAccountDTOList.size()-1)){
+            //                    DateMap.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
+            //                    DateMap.put("endDate", endDate);
+            //                }
+            //            }else{
+            //                List<Map<String, String>> userAccountList = new ArrayList<>();
+            //                if(DateMap.size()!= 0 ){
+            //                    userAccountList.add(DateMap);
+            //                }
+            //
+            //                Map<String, String> DateMap2 = new HashMap<>();
+            //                if(j == (transferorAccountDTOList.size()-1)){
+            //                    DateMap2.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
+            //                    DateMap2.put("endDate", endDate);
+            //                    userAccountList.add(DateMap2);
+            //                }
+            //                accountRangeMap.put(accountList.get(i), userAccountList);
+            //            }
+            //        }
+            //    }
+            //
+            //    for(Map.Entry<String, List<Map<String, String>>> entry : accountRangeMap.entrySet()){
+            //        String mapKey = entry.getKey();
+            //        List<Map<String, String>> mapValue = entry.getValue();
+            //        if (mapValue == null){
+            //            totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getAccountSumCharge(mapKey,startDate,endDate)==null?BigDecimal.ZERO: userEfficientVideoMapMapper.getAccountSumCharge(mapKey,startDate,endDate));
+            //        }else{
+            //            for (Map<String, String> map:mapValue){
+            //                totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getAccountSumCharge(mapKey,map.get("startDate"),map.get("endDate"))==null?BigDecimal.ZERO: userEfficientVideoMapMapper.getAccountSumCharge(mapKey,startDate,endDate));
+            //            }
+            //        }
+            //    }
+            //
+            //    //BigDecimal totalCost = vo.getTotalCost();
+            //    totalCost = totalRoyal;//新增
+            //    //个人季度任务
+            //    BigDecimal personalTask = config.getPersonalTask();
+            //    //判断个人任务是否完成 ,如果完成则给到千分之5,如果未完成,则给到千分之3的绩效
+            //
+            //    if(!userDto.getRoleCode().equals("operationAssistant")){
+            //        if (totalCost.compareTo(personalTask) > 0 ) {
+            //            totalRoyalty = totalCost.multiply(config.getMediaTaskFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
+            //        } else {
+            //            totalRoyalty = totalCost.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
+            //        }
+            //    }
+            //}
+            //
+            ////运营绩效数据入库
+            //PerformanceOptimizer performanceOptimizer = new PerformanceOptimizer();
+            //performanceOptimizer.setAppType(mediaType);
+            //performanceOptimizer.setQuarter(quarter + "");
+            //performanceOptimizer.setYear(year + "");
+            //performanceOptimizer.setRealname(userDto.getRealname());
+            //performanceOptimizer.setTotalCost(totalCost);
+            //performanceOptimizer.setTotalRoyalty(totalRoyalty);
+            //performanceOptimizer.setUserId(userDto.getUserId());
+            //performanceOptimizerMapper.insert(performanceOptimizer);
+
+
+            ///////////////方法2
+            //1。获取所有快手账户
+            //2。循环每个账户,然后查找每个账户下在本季度是否有转户的情况存在;
+
+            //创建map,Map<String人,Map<String账户,时间段List<Map<String开始时间,String结束时间>>>>
+            Map<String,Map<String,List<Map<String,String>>>> userAccountMap = new HashMap<>();
+
+            //获取所有快手的账户
+            List<String> accountList = userEfficientVideoMapMapper.getAccountListByMediaId(mediaType);
+            //循环所有账户
+            for(String account:accountList){
+                String userId = userEfficientVideoMapMapper.getAccountUserId(account);
+                //判断本季度内是否有转户情况存在
+                List<TransferorAccountDTO> transferorAccountDTOList = userEfficientVideoMapMapper.accountTransforerListByUserId(account, startDate, endDate);
+
+                //如果此账户没有转户情况发生,则存入userAccountMap当中
+                if(transferorAccountDTOList.size() == 0){
+                    if(userAccountMap.get(userId) == null){
+                        Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                        List<Map<String,String>> dateList = new ArrayList<>();
+                        Map<String,String> dateMap = new HashMap<>();
+
+                        dateMap.put("startDate", startDate);
+                        dateMap.put("endDate",endDate);
+                        dateList.add(dateMap);
+                        accountMap.put(account, dateList);
+                        userAccountMap.put(userId, accountMap);
+                    }else{
+                        Map<String,List<Map<String,String>>> accountMap = userAccountMap.get(userId);
+                        //如果此账户本季度没有转户行为,直接创建账户即可,不用再做判断
+                        List<Map<String,String>> dateList = new ArrayList<>();
+                        Map<String,String> dateMap = new HashMap<>();
+                        dateMap.put("startDate", startDate);
+                        dateMap.put("endDate",endDate);
+                        dateList.add(dateMap);
+                        accountMap.put(account, dateList);
                     }
-                    Map<String, String> DateMap = new HashMap<>();
+                }else{//如果此账户有转户情况
 
+                    //循环所有转户信息
                     for(int j=0; j<transferorAccountDTOList.size(); j++){
-                        String transferor = transferorAccountDTOList.get(j).getTransferor();
-                        //String assignee = transferorAccountDTOList.get(j).getAssignee();
-                        //如果转让人不是本人,则跳过;按照转让人的逻辑走,因为受让人在下一次转户的时候也会变成转让人
-                        if( transferor.equals(userDto.getUserId()) ){
-                            if (j==0){
-                                DateMap.put("startDate", startDate);
-                            }else {
-                                DateMap.put("startDate", transferorAccountDTOList.get(j-1).getAssigneeDate());
+                        if ( j==0 ){
+                            Map<String,String> dateMap = new HashMap<>();
+                            dateMap.put("startDate", startDate);
+                            dateMap.put("endDate",transferorAccountDTOList.get(j).getTransferorDate());
+                            String transferorUserId = transferorAccountDTOList.get(j).getTransferor();
+                            //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
+                            if(userAccountMap.get(transferorUserId) == null){
+                                Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                                List<Map<String,String>> dateList = new ArrayList<>();
+                                dateList.add(dateMap);
+                                accountMap.put(account, dateList);
+                                userAccountMap.put(transferorUserId, accountMap);
+                            }else{//如果已经有了这个userId,则需要判断是否有此账户
+
+                                if( userAccountMap.get(transferorUserId).get(account)==null ){
+                                    Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                                    List<Map<String,String>> dateList = new ArrayList<>();
+                                    dateList.add(dateMap);
+                                    accountMap.put(account, dateList);
+                                    userAccountMap.put(transferorUserId, accountMap);
+                                }else{
+                                    List<Map<String,String>> dateList = userAccountMap.get(transferorUserId).get(account);
+                                    dateList.add(dateMap);
+                                }
                             }
-                            DateMap.put("endDate",transferorAccountDTOList.get(j).getTransferorDate());
-                        }
-
-                        //判断:如果转让人不是本人,受让人也不是,则跳过
-                        if(DateMap.size() == 0 &&  j != (transferorAccountDTOList.size()-1)     ){   //!assignee.equals(userDto.getUserId())
-                            continue;
-                        }
-
-                        if (accountRangeMap.get(accountList.get(i)) != null){
-                            accountRangeMap.get(accountList.get(i)).add(DateMap);
 
-                            if(j == (transferorAccountDTOList.size()-1)){
-                                DateMap.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
-                                DateMap.put("endDate", endDate);
+                            if(j == transferorAccountDTOList.size()-1){
+                                Map<String,String> dateMap2 = new HashMap<>();
+                                dateMap2.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
+                                dateMap2.put("endDate",endDate);
+                                String assigneeUserId = transferorAccountDTOList.get(j).getAssignee();
+                                //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
+                                if(userAccountMap.get(assigneeUserId) == null){
+                                    Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                                    List<Map<String,String>> dateList = new ArrayList<>();
+                                    dateList.add(dateMap2);
+                                    accountMap.put(account, dateList);
+                                    userAccountMap.put(assigneeUserId, accountMap);
+                                }else{//如果已经有了这个userId,则需要判断是否有此账户
+                                    if( userAccountMap.get(assigneeUserId).get(account)==null ){
+                                        Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                                        List<Map<String,String>> dateList = new ArrayList<>();
+                                        dateList.add(dateMap2);
+                                        accountMap.put(account, dateList);
+                                        userAccountMap.put(assigneeUserId, accountMap);
+                                    }else{
+                                        List<Map<String,String>> dateList = userAccountMap.get(assigneeUserId).get(account);
+                                        dateList.add(dateMap2);
+                                    }
+                                }
                             }
+
                         }else{
-                            List<Map<String, String>> userAccountList = new ArrayList<>();
-                            if(DateMap.size()!= 0 ){
-                                userAccountList.add(DateMap);
+                            Map<String,String> dateMap = new HashMap<>();
+                            dateMap.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
+                            if( j == (transferorAccountDTOList.size()-1) ){
+                                dateMap.put("endDate",endDate);
+                            }else{
+                                dateMap.put("endDate",transferorAccountDTOList.get(j+1).getTransferorDate());
                             }
 
-                            Map<String, String> DateMap2 = new HashMap<>();
-                            if(j == (transferorAccountDTOList.size()-1)){
-                                DateMap2.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
-                                DateMap2.put("endDate", endDate);
-                                userAccountList.add(DateMap2);
+                            String assigneeUserId = transferorAccountDTOList.get(j).getAssignee();
+                            //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
+                            if(userAccountMap.get(assigneeUserId) == null){
+                                Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                                List<Map<String,String>> dateList = new ArrayList<>();
+                                dateList.add(dateMap);
+                                accountMap.put(account, dateList);
+                                userAccountMap.put(assigneeUserId, accountMap);
+                            }else{//如果已经有了这个userId,则需要判断是否有此账户
+
+                                if( userAccountMap.get(assigneeUserId).get(account)==null ){
+                                    Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                                    List<Map<String,String>> dateList = new ArrayList<>();
+                                    dateList.add(dateMap);
+                                    accountMap.put(account, dateList);
+                                    userAccountMap.put(assigneeUserId, accountMap);
+                                }else{
+                                    List<Map<String,String>> dateList = userAccountMap.get(assigneeUserId).get(account);
+                                    dateList.add(dateMap);
+                                }
+
                             }
-                            accountRangeMap.put(accountList.get(i), userAccountList);
-                        }
-                    }
-                }
 
-                for(Map.Entry<String, List<Map<String, String>>> entry : accountRangeMap.entrySet()){
-                    String mapKey = entry.getKey();
-                    List<Map<String, String>> mapValue = entry.getValue();
-                    if (mapValue == null){
-                        totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getAccountSumCharge(mapKey,startDate,endDate)==null?BigDecimal.ZERO: userEfficientVideoMapMapper.getAccountSumCharge(mapKey,startDate,endDate));
-                    }else{
-                        for (Map<String, String> map:mapValue){
-                            totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getAccountSumCharge(mapKey,map.get("startDate"),map.get("endDate"))==null?BigDecimal.ZERO: userEfficientVideoMapMapper.getAccountSumCharge(mapKey,startDate,endDate));
                         }
+
+                    } //转户列表循环结束
+                } //else判断
+
+            }//账户循环结束
+
+            for(Map.Entry<String,Map<String,List<Map<String,String>>>> entry : userAccountMap.entrySet()){
+                String userAccountKey = entry.getKey();
+                Map<String,List<Map<String,String>>> userAccountValue =  entry.getValue();
+                BigDecimal totalCharge = BigDecimal.ZERO;
+                BigDecimal totalPerformance = BigDecimal.ZERO;
+
+                for(Map.Entry<String,List<Map<String,String>>> entryAccount: userAccountValue.entrySet()){
+                    String acountKey = entryAccount.getKey();
+                    List<Map<String,String>> accountValue = entryAccount.getValue();
+
+                    for(Map<String,String> dateMap:accountValue) {
+                        //当前消耗
+                        BigDecimal charge = userEfficientVideoMapMapper.getAccountSumCharge(acountKey, dateMap.get("startDate"), dateMap.get("endDate")) == null ? BigDecimal.ZERO : userEfficientVideoMapMapper.getAccountSumCharge(acountKey, dateMap.get("startDate"), dateMap.get("endDate"));
+                        //此人总消耗
+                        totalCharge = totalCharge.add(charge);
+
+                        PerformanceAccount performanceAccount = new PerformanceAccount();
+                        performanceAccount.setAccountId(Long.parseLong(acountKey));
+                        performanceAccount.setCost(charge);
+                        performanceAccount.setYear(year);
+                        performanceAccount.setQuarter(quarter);
+                        performanceAccount.setMediaType(mediaType);
+                        performanceAccount.setUserId(userAccountKey);
+                        performanceAccount.setStartDate(dateMap.get("startDate"));
+                        performanceAccount.setEndDate(dateMap.get("endDate"));
+                        performanceAccountMapper.insert(performanceAccount);
                     }
                 }
 
-                //BigDecimal totalCost = vo.getTotalCost();
-                totalCost = totalRoyal;//新增
+                //运营绩效数据入库
+                PerformanceOptimizer performance = new PerformanceOptimizer();
+                performance.setAppType(mediaType);
+                performance.setQuarter(quarter + "");
+                performance.setYear(year + "");
+                performance.setRealname(userEfficientVideoMapMapper.getrealnameByUserId(userAccountKey));
+                performance.setUserId(userAccountKey);
+                performance.setTotalCost(totalCharge);
+
                 //个人季度任务
                 BigDecimal personalTask = config.getPersonalTask();
                 //判断个人任务是否完成 ,如果完成则给到千分之5,如果未完成,则给到千分之3的绩效
-
-                if(!userDto.getRoleCode().equals("operationAssistant")){
-                    if (totalCost.compareTo(personalTask) > 0 ) {
-                        totalRoyalty = totalCost.multiply(config.getMediaTaskFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
+                String roleCode = userEfficientVideoMapMapper.getRoleCodeByUserId(userAccountKey);
+                if(!roleCode.equals("operationAssistant")){
+                    if (totalCharge.compareTo(personalTask) > 0 ) {
+                        totalPerformance = totalCharge.multiply(config.getMediaTaskFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
                     } else {
-                        totalRoyalty = totalCost.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
+                        totalPerformance = totalCharge.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
                     }
                 }
+                performance.setTotalRoyalty(totalPerformance);
+                performanceOptimizerMapper.insert(performance);
             }
 
-            //运营绩效数据入库
-            PerformanceOptimizer performanceOptimizer = new PerformanceOptimizer();
-            performanceOptimizer.setAppType(mediaType);
-            performanceOptimizer.setQuarter(quarter + "");
-            performanceOptimizer.setYear(year + "");
-            performanceOptimizer.setRealname(userDto.getRealname());
-            performanceOptimizer.setTotalCost(totalCost);
-            performanceOptimizer.setTotalRoyalty(totalRoyalty);
-            performanceOptimizer.setUserId(userDto.getUserId());
-            performanceOptimizerMapper.insert(performanceOptimizer);
-        }
+
+
+        //}
         return result;
     }
 
     //头条运营季度绩效计算
     public void toutiaoYunyingQuarterPerformance(Integer year, Integer quarter, String startDate, String endDate){
-        Map<String, Object> result = new HashMap<>();
-        //获取快手所有运营的数据
-        List<UserDto2> userList = userEfficientVideoMapMapper.getAllToutiaoYunyingDepartUserInfo();
-        Integer mediaType = 1;
-        //循环所有toutiao运营
-        for(UserDto2 userDto:userList){
-            //查询当前媒体配置信息
-            OptimizerConfig config = optimizerConfigService.getEnabledConfigByMediaType(mediaType + "", CtopAdConstant.CTOP_ORGCODE_NORTH_CHINA_PREFIX);
+        //Map<String, Object> result = new HashMap<>();
+        ////获取快手所有运营的数据
+        //List<UserDto2> userList = userEfficientVideoMapMapper.getAllToutiaoYunyingDepartUserInfo();
+        //Integer mediaType = 1;
+        ////循环所有toutiao运营
+        //for(UserDto2 userDto:userList){
+        //    //查询当前媒体配置信息
+        //    OptimizerConfig config = optimizerConfigService.getEnabledConfigByMediaType(mediaType + "", CtopAdConstant.CTOP_ORGCODE_NORTH_CHINA_PREFIX);
+        //
+        //    if (null == config) {
+        //        ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_OPTINIZER_CONFIG_IS_NULL.getCode());
+        //        return ;
+        //    }
+        //
+        //    log.info(userDto.getUserId());
+        //    //增加转户的情况
+        //    //原则a:1. 该季度内最终转给此运营的户,将该户在本季度中不在的时间计算出来,然后计算这段时间内的总消耗,并在总数中减去
+        //    //2. 季度期间在过此运营负责过的户,将在本季度中在的时间计算出来,然后计算总消耗并在总数中增加上
+        //
+        //    //原则b:1.找出改运营手下所有账户,循环每一个账户,然后进行转户判断
+        //    //2.将该账户下所有转户信息拉取出来,去除受让时间小于季度开始时间 以及 转让时间大于季度结束时间的条目(sql去掉),得到该账户所有信息
+        //    //3. 创建userMap,根据userId获取自己季度内的各时间段
+        //    BigDecimal totalRoyal = BigDecimal.ZERO;
+        //    BigDecimal totalRoyalty = BigDecimal.ZERO;
+        //    BigDecimal totalCost = BigDecimal.ZERO;
+        //
+        //    //循环accountId
+        //    List<String> accountList = userEfficientVideoMapMapper.getAccountIdByUserId(userDto.getUserId());
+        //    Map<String, List<Map<String, String>>> accountRangeMap = new HashMap<>();
+        //    if(accountList.size()!=0){
+        //        for(int i=0; i<accountList.size();i++){
+        //            List<TransferorAccountDTO> transferorAccountDTOList = userEfficientVideoMapMapper.accountTransforerListByUserId(accountList.get(i), startDate, endDate);
+        //
+        //            if(transferorAccountDTOList.size() == 0){
+        //                accountRangeMap.put(accountList.get(i),null);
+        //                continue;
+        //            }
+        //            Map<String, String> DateMap = new HashMap<>();
+        //
+        //            for(int j=0; j<transferorAccountDTOList.size(); j++){
+        //                String transferor = transferorAccountDTOList.get(j).getTransferor();
+        //                //如果转让人不是本人,则跳过;按照转让人的逻辑走,因为受让人在下一次转户的时候也会变成转让人
+        //                if( transferor.equals(userDto.getUserId()) ){
+        //                    if (j==0){
+        //                        DateMap.put("startDate", startDate);
+        //                    }else {
+        //                        DateMap.put("startDate", transferorAccountDTOList.get(j-1).getAssigneeDate());
+        //                    }
+        //                    DateMap.put("endDate",transferorAccountDTOList.get(j).getTransferorDate());
+        //                }
+        //
+        //                //判断:如果转让人不是本人,受让人也不是,则跳过
+        //                if(DateMap.size() == 0 &&  j != (transferorAccountDTOList.size()-1)     ){
+        //                    continue;
+        //                }
+        //
+        //                if (accountRangeMap.get(accountList.get(i)) != null){
+        //                    accountRangeMap.get(accountList.get(i)).add(DateMap);
+        //
+        //                    if(j == (transferorAccountDTOList.size()-1)){
+        //                        DateMap.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
+        //                        DateMap.put("endDate", endDate);
+        //                    }
+        //                }else{
+        //                    List<Map<String, String>> userAccountList = new ArrayList<>();
+        //                    if(DateMap.size()!= 0 ){
+        //                        userAccountList.add(DateMap);
+        //                    }
+        //
+        //                    Map<String, String> DateMap2 = new HashMap<>();
+        //                    if(j == (transferorAccountDTOList.size()-1)){
+        //                        DateMap2.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
+        //                        DateMap2.put("endDate", endDate);
+        //                        userAccountList.add(DateMap2);
+        //                    }
+        //                    accountRangeMap.put(accountList.get(i), userAccountList);
+        //                }
+        //            }
+        //        }
+        //    }else{
+        //        continue;
+        //    }
+        //
+        //        for(Map.Entry<String, List<Map<String, String>>> entry : accountRangeMap.entrySet()){
+        //            String mapKey = entry.getKey();
+        //            List<Map<String, String>> mapValue = entry.getValue();
+        //            if (mapValue == null){
+        //                totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,startDate,endDate)==null?BigDecimal.ZERO : userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,startDate,endDate) );
+        //            }else{
+        //                for (Map<String, String> map:mapValue){
+        //                    totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,map.get("startDate"),map.get("endDate"))==null?BigDecimal.ZERO: userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,startDate,endDate));
+        //                }
+        //            }
+        //        }
+        //
+        //        totalCost = totalRoyal;//新增
+        //        //个人季度任务
+        //        BigDecimal personalTask = config.getPersonalTask();
+        //        //判断个人任务是否完成 ,如果完成则给到千分之5,如果未完成,则给到千分之3的绩效
+        //
+        //        if(!userDto.getRoleCode().equals("operationAssistant")){
+        //            if (totalCost.compareTo(personalTask) > 0 ) {
+        //                totalRoyalty = totalCost.multiply(config.getMediaTaskFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
+        //            } else {
+        //                totalRoyalty = totalCost.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
+        //            }
+        //        }
+        //
+        //
+        //    //运营绩效数据入库
+        //    PerformanceOptimizer performanceOptimizer = new PerformanceOptimizer();
+        //    performanceOptimizer.setAppType(mediaType);
+        //    performanceOptimizer.setQuarter(quarter + "");
+        //    performanceOptimizer.setYear(year + "");
+        //    performanceOptimizer.setRealname(userDto.getRealname());
+        //    performanceOptimizer.setTotalCost(totalCost);
+        //    performanceOptimizer.setTotalRoyalty(totalRoyalty);
+        //    performanceOptimizer.setUserId(userDto.getUserId());
+        //    performanceOptimizerMapper.insert(performanceOptimizer);
+        //}
 
-            if (null == config) {
-                ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_OPTINIZER_CONFIG_IS_NULL.getCode());
-                return ;
-            }
 
-            log.info(userDto.getUserId());
-            //增加转户的情况
-            //原则a:1. 该季度内最终转给此运营的户,将该户在本季度中不在的时间计算出来,然后计算这段时间内的总消耗,并在总数中减去
-            //2. 季度期间在过此运营负责过的户,将在本季度中在的时间计算出来,然后计算总消耗并在总数中增加上
 
-            //原则b:1.找出改运营手下所有账户,循环每一个账户,然后进行转户判断
-            //2.将该账户下所有转户信息拉取出来,去除受让时间小于季度开始时间 以及 转让时间大于季度结束时间的条目(sql去掉),得到该账户所有信息
-            //3. 创建userMap,根据userId获取自己季度内的各时间段
-            BigDecimal totalRoyal = BigDecimal.ZERO;
-            BigDecimal totalRoyalty = BigDecimal.ZERO;
-            BigDecimal totalCost = BigDecimal.ZERO;
-
-            //循环accountId
-            List<String> accountList = userEfficientVideoMapMapper.getAccountIdByUserId(userDto.getUserId());
-            Map<String, List<Map<String, String>>> accountRangeMap = new HashMap<>();
-            if(accountList.size()!=0){
-                for(int i=0; i<accountList.size();i++){
-                    List<TransferorAccountDTO> transferorAccountDTOList = userEfficientVideoMapMapper.accountTransforerListByUserId(accountList.get(i), startDate, endDate);
-
-                    if(transferorAccountDTOList.size() == 0){
-                        accountRangeMap.put(accountList.get(i),null);
-                        continue;
-                    }
-                    Map<String, String> DateMap = new HashMap<>();
 
-                    for(int j=0; j<transferorAccountDTOList.size(); j++){
-                        String transferor = transferorAccountDTOList.get(j).getTransferor();
-                        //如果转让人不是本人,则跳过;按照转让人的逻辑走,因为受让人在下一次转户的时候也会变成转让人
-                        if( transferor.equals(userDto.getUserId()) ){
-                            if (j==0){
-                                DateMap.put("startDate", startDate);
-                            }else {
-                                DateMap.put("startDate", transferorAccountDTOList.get(j-1).getAssigneeDate());
+        //方法2
+        //1。获取所有快手账户
+        //2。循环每个账户,然后查找每个账户下在本季度是否有转户的情况存在;
+        Integer mediaType = 1;
+        //创建map,Map<String人,Map<String账户,时间段List<Map<String开始时间,String结束时间>>>>
+        Map<String,Map<String,List<Map<String,String>>>> userAccountMap = new HashMap<>();
+        OptimizerConfig config = optimizerConfigService.getEnabledConfigByMediaType(mediaType + "", CtopAdConstant.CTOP_ORGCODE_NORTH_CHINA_PREFIX);
+        //获取所有头条的账户
+        List<String> accountList = userEfficientVideoMapMapper.getAccountListByMediaId(mediaType);
+        //循环所有账户
+        for(String account:accountList){
+            String userId = userEfficientVideoMapMapper.getAccountUserId(account);
+            //判断本季度内是否有转户情况存在
+            List<TransferorAccountDTO> transferorAccountDTOList = userEfficientVideoMapMapper.accountTransforerListByUserId(account, startDate, endDate);
+
+            //如果此账户没有转户情况发生,则存入userAccountMap当中
+            if(transferorAccountDTOList.size() == 0){
+                if(userAccountMap.get(userId) == null){
+                    Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                    List<Map<String,String>> dateList = new ArrayList<>();
+                    Map<String,String> dateMap = new HashMap<>();
+
+                    dateMap.put("startDate", startDate);
+                    dateMap.put("endDate",endDate);
+                    dateList.add(dateMap);
+                    accountMap.put(account, dateList);
+                    userAccountMap.put(userId, accountMap);
+                }else{
+                    Map<String,List<Map<String,String>>> accountMap = userAccountMap.get(userId);
+                    //如果此账户本季度没有转户行为,直接创建账户即可,不用再做判断
+                    List<Map<String,String>> dateList = new ArrayList<>();
+                    Map<String,String> dateMap = new HashMap<>();
+                    dateMap.put("startDate", startDate);
+                    dateMap.put("endDate",endDate);
+                    dateList.add(dateMap);
+                    accountMap.put(account, dateList);
+                }
+            }else{//如果此账户有转户情况
+
+                //循环所有转户信息
+                for(int j=0; j<transferorAccountDTOList.size(); j++){
+                    if ( j==0 ){
+                        Map<String,String> dateMap = new HashMap<>();
+                        dateMap.put("startDate", startDate);
+                        dateMap.put("endDate",transferorAccountDTOList.get(j).getTransferorDate());
+                        String transferorUserId = transferorAccountDTOList.get(j).getTransferor();
+                        //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
+                        if(userAccountMap.get(transferorUserId) == null){
+                            Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                            List<Map<String,String>> dateList = new ArrayList<>();
+                            dateList.add(dateMap);
+                            accountMap.put(account, dateList);
+                            userAccountMap.put(transferorUserId, accountMap);
+                        }else{//如果已经有了这个userId,则需要判断是否有此账户
+
+                            if( userAccountMap.get(transferorUserId).get(account)==null ){
+                                Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                                List<Map<String,String>> dateList = new ArrayList<>();
+                                dateList.add(dateMap);
+                                accountMap.put(account, dateList);
+                                userAccountMap.put(transferorUserId, accountMap);
+                            }else{
+                                List<Map<String,String>> dateList = userAccountMap.get(transferorUserId).get(account);
+                                dateList.add(dateMap);
                             }
-                            DateMap.put("endDate",transferorAccountDTOList.get(j).getTransferorDate());
                         }
 
-                        //判断:如果转让人不是本人,受让人也不是,则跳过
-                        if(DateMap.size() == 0 &&  j != (transferorAccountDTOList.size()-1)     ){
-                            continue;
+                        if(j == transferorAccountDTOList.size()-1){
+                            Map<String,String> dateMap2 = new HashMap<>();
+                            dateMap2.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
+                            dateMap2.put("endDate",endDate);
+                            String assigneeUserId = transferorAccountDTOList.get(j).getAssignee();
+                            //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
+                            if(userAccountMap.get(assigneeUserId) == null){
+                                Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                                List<Map<String,String>> dateList = new ArrayList<>();
+                                dateList.add(dateMap2);
+                                accountMap.put(account, dateList);
+                                userAccountMap.put(assigneeUserId, accountMap);
+                            }else{//如果已经有了这个userId,则需要判断是否有此账户
+                                if( userAccountMap.get(assigneeUserId).get(account)==null ){
+                                    Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                                    List<Map<String,String>> dateList = new ArrayList<>();
+                                    dateList.add(dateMap2);
+                                    accountMap.put(account, dateList);
+                                    userAccountMap.put(assigneeUserId, accountMap);
+                                }else{
+                                    List<Map<String,String>> dateList = userAccountMap.get(assigneeUserId).get(account);
+                                    dateList.add(dateMap2);
+                                }
+                            }
                         }
 
-                        if (accountRangeMap.get(accountList.get(i)) != null){
-                            accountRangeMap.get(accountList.get(i)).add(DateMap);
-
-                            if(j == (transferorAccountDTOList.size()-1)){
-                                DateMap.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
-                                DateMap.put("endDate", endDate);
-                            }
+                    }else{
+                        Map<String,String> dateMap = new HashMap<>();
+                        dateMap.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
+                        if( j == (transferorAccountDTOList.size()-1) ){
+                            dateMap.put("endDate",endDate);
                         }else{
-                            List<Map<String, String>> userAccountList = new ArrayList<>();
-                            if(DateMap.size()!= 0 ){
-                                userAccountList.add(DateMap);
-                            }
+                            dateMap.put("endDate",transferorAccountDTOList.get(j+1).getTransferorDate());
+                        }
 
-                            Map<String, String> DateMap2 = new HashMap<>();
-                            if(j == (transferorAccountDTOList.size()-1)){
-                                DateMap2.put("startDate", transferorAccountDTOList.get(j).getAssigneeDate());
-                                DateMap2.put("endDate", endDate);
-                                userAccountList.add(DateMap2);
+                        String assigneeUserId = transferorAccountDTOList.get(j).getAssignee();
+                        //判断:如果userAccountMap中没有assigneeUserId,则直接创建;
+                        if(userAccountMap.get(assigneeUserId) == null){
+                            Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                            List<Map<String,String>> dateList = new ArrayList<>();
+                            dateList.add(dateMap);
+                            accountMap.put(account, dateList);
+                            userAccountMap.put(assigneeUserId, accountMap);
+                        }else{//如果已经有了这个userId,则需要判断是否有此账户
+
+                            if( userAccountMap.get(assigneeUserId).get(account)==null ){
+                                Map<String,List<Map<String,String>>> accountMap = new HashMap<>();
+                                List<Map<String,String>> dateList = new ArrayList<>();
+                                dateList.add(dateMap);
+                                accountMap.put(account, dateList);
+                                userAccountMap.put(assigneeUserId, accountMap);
+                            }else{
+                                List<Map<String,String>> dateList = userAccountMap.get(assigneeUserId).get(account);
+                                dateList.add(dateMap);
                             }
-                            accountRangeMap.put(accountList.get(i), userAccountList);
-                        }
-                    }
-                }
-            }else{
-                continue;
-            }
 
-                for(Map.Entry<String, List<Map<String, String>>> entry : accountRangeMap.entrySet()){
-                    String mapKey = entry.getKey();
-                    List<Map<String, String>> mapValue = entry.getValue();
-                    if (mapValue == null){
-                        totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,startDate,endDate)==null?BigDecimal.ZERO : userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,startDate,endDate) );
-                    }else{
-                        for (Map<String, String> map:mapValue){
-                            totalRoyal = totalRoyal.add( userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,map.get("startDate"),map.get("endDate"))==null?BigDecimal.ZERO: userEfficientVideoMapMapper.getToutiaoAccountSumCharge(mapKey,startDate,endDate));
                         }
-                    }
-                }
-
-                totalCost = totalRoyal;//新增
-                //个人季度任务
-                BigDecimal personalTask = config.getPersonalTask();
-                //判断个人任务是否完成 ,如果完成则给到千分之5,如果未完成,则给到千分之3的绩效
 
-                if(!userDto.getRoleCode().equals("operationAssistant")){
-                    if (totalCost.compareTo(personalTask) > 0 ) {
-                        totalRoyalty = totalCost.multiply(config.getMediaTaskFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
-                    } else {
-                        totalRoyalty = totalCost.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
                     }
-                }
 
+                } //转户列表循环结束
+            } //else判断
+
+        }//账户循环结束
+
+        for(Map.Entry<String,Map<String,List<Map<String,String>>>> entry : userAccountMap.entrySet()){
+            String userAccountKey = entry.getKey();
+            Map<String,List<Map<String,String>>> userAccountValue =  entry.getValue();
+            BigDecimal totalCharge = BigDecimal.ZERO;
+            BigDecimal totalPerformance = BigDecimal.ZERO;
+
+            for(Map.Entry<String,List<Map<String,String>>> entryAccount: userAccountValue.entrySet()){
+                String acountKey = entryAccount.getKey();
+                List<Map<String,String>> accountValue = entryAccount.getValue();
+
+                for(Map<String,String> dateMap:accountValue) {
+                    //当前消耗
+                    BigDecimal charge = userEfficientVideoMapMapper.getToutiaoAccountSumCharge(acountKey, dateMap.get("startDate"), dateMap.get("endDate")) == null ? BigDecimal.ZERO : userEfficientVideoMapMapper.getToutiaoAccountSumCharge(acountKey, dateMap.get("startDate"), dateMap.get("endDate"));
+                    //此人总消耗
+                    totalCharge = totalCharge.add(charge);
+
+                    PerformanceAccount performanceAccount = new PerformanceAccount();
+                    performanceAccount.setAccountId(Long.parseLong(acountKey));
+                    performanceAccount.setCost(charge);
+                    performanceAccount.setYear(year);
+                    performanceAccount.setQuarter(quarter);
+                    performanceAccount.setMediaType(mediaType);
+                    performanceAccount.setUserId(userAccountKey);
+                    performanceAccount.setStartDate(dateMap.get("startDate"));
+                    performanceAccount.setEndDate(dateMap.get("endDate"));
+                    performanceAccountMapper.insert(performanceAccount);
+                }
+            }
 
             //运营绩效数据入库
-            PerformanceOptimizer performanceOptimizer = new PerformanceOptimizer();
-            performanceOptimizer.setAppType(mediaType);
-            performanceOptimizer.setQuarter(quarter + "");
-            performanceOptimizer.setYear(year + "");
-            performanceOptimizer.setRealname(userDto.getRealname());
-            performanceOptimizer.setTotalCost(totalCost);
-            performanceOptimizer.setTotalRoyalty(totalRoyalty);
-            performanceOptimizer.setUserId(userDto.getUserId());
-            performanceOptimizerMapper.insert(performanceOptimizer);
+            PerformanceOptimizer performance = new PerformanceOptimizer();
+            performance.setAppType(mediaType);
+            performance.setQuarter(quarter + "");
+            performance.setYear(year + "");
+            performance.setRealname(userEfficientVideoMapMapper.getrealnameByUserId(userAccountKey));
+            performance.setUserId(userAccountKey);
+            performance.setTotalCost(totalCharge);
+
+            //个人季度任务
+            BigDecimal personalTask = config.getPersonalTask();
+            //判断个人任务是否完成 ,如果完成则给到千分之5,如果未完成,则给到千分之3的绩效
+            String roleCode = userEfficientVideoMapMapper.getRoleCodeByUserId(userAccountKey);
+            if(!roleCode.equals("operationAssistant")){
+                if (totalCharge.compareTo(personalTask) > 0 ) {
+                    totalPerformance = totalCharge.multiply(config.getMediaTaskFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
+                } else {
+                    totalPerformance = totalCharge.multiply(config.getMediaTaskNoFinishRate()).divide(new BigDecimal("1000")).setScale(2, RoundingMode.HALF_UP);
+                }
+            }
+            performance.setTotalRoyalty(totalPerformance);
+            performanceOptimizerMapper.insert(performance);
         }
+
         return;
     }
 

+ 8 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/UserEfficientVideoMapMapper.java

@@ -204,5 +204,13 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
     BigDecimal getYunyingRoyalty(@Param("userId")String userId, @Param("year")Integer year, @Param("quarter")Integer quarter);
 
+    List<String> getAccountListByMediaId(@Param("mediaId")Integer mediaId);
+
+    String getAccountUserId(@Param("accountId")String userId);
+
+    String getrealnameByUserId(@Param("userId")String userId);
+
+    String getRoleCodeByUserId(@Param("userId")String userId);
+
 }
 

+ 41 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/xml/UserEfficientVideoMapMapper.xml

@@ -1309,6 +1309,7 @@
         account_id = #{accountId}
         and assignee_date &gt;= #{startDate}
         and transferor_date &lt;= #{endDate}
+        and status =1
         order by transferor_date asc
     </select>
 
@@ -1400,4 +1401,44 @@
         and quarter = #{quarter}
     </select>
 
+    <!-- 获取单一媒体下所有已绑定的账户 -->
+    <select id="getAccountListByMediaId" resultType="string">
+    select
+    account_id
+    from ctop_user_allocation
+    where
+    media_id = #{mediaId}
+    and user_id not in ('e9ca23d68d884d4ebb19d07889727dae')
+    group by account_id
+    </select>
+
+    <!-- 获取账户的持有人 -->
+    <select id="getAccountUserId" resultType="java.lang.String">
+        select
+        user_id
+        from
+        ctop_user_allocation
+        where
+        account_id = #{accountId}
+        limit 1
+    </select>
+
+    <select id="getrealnameByUserId" resultType="java.lang.String">
+        select
+        realname
+        from sys_user
+        where
+        id = #{userId}
+    </select>
+
+    <select id="getRoleCodeByUserId" resultType="java.lang.String">
+        select
+        role_code
+        from
+        sys_role a
+        left join sys_user_role b on a.id = b.role_id
+        where b.user_id = #{userId}
+    </select>
+
+
 </mapper>