Jelajahi Sumber

Merge remote-tracking branch 'origin/test' into test

785834757 1 tahun lalu
induk
melakukan
31f4d91c6e

+ 0 - 24
sql/Online.sql

@@ -1,24 +0,0 @@
-DROP TABLE IF EXISTS `sys_message`;
-CREATE TABLE `sys_message`  (
-                                `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
-                                `classify` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '消息分类 1-公告 2-系统通知 3-事件触发',
-                                `type` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '消息类型 1-增员消息 2-审批消息 3-待办消息',
-                                `title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '消息标题',
-                                `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '消息内容',
-                                `jump` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '是否支持跳转 0-不支持 1-支持',
-                                `jump_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '跳转目标路径',
-                                `receiver_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '消息接收方',
-                                `sender_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '消息发送方',
-                                `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
-                                `send_time` datetime(0) NULL DEFAULT NULL COMMENT '发送时间',
-                                `state` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '状态 0-未读  1-已读',
-                                `high_light` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '高亮字段',
-                                `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
-                                `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改者',
-                                `update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
-                                PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '核心系统消息列表' ROW_FORMAT = Dynamic;
-
-
-ALTER TABLE `agent`.`ins_area_company`
-    ADD COLUMN `extend_info` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '扩展字段' AFTER `code_valid_status`;

+ 1 - 0
src/main/java/com/ydtech/modules/admin/controller/quoteCount/QuoteCountController.java

@@ -51,6 +51,7 @@ public class QuoteCountController {
                     companyQutationCountDataQueryDto.setUserIds(kztGetDeptUtilsDto.getIds());
                 }
             }
+            companyQutationCountDataQueryDto.filterTime();
             BasePageResult<CompanyQutationCountDataDto> result = companyDataReportService.queryCompanyQutationCountDataPage(companyQutationCountDataQueryDto);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){

+ 55 - 5
src/main/java/com/ydtech/modules/admin/controller/taskStatistics/TaskStatisticsController.java

@@ -81,6 +81,7 @@ public class TaskStatisticsController {
                 taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
             }
         }
+        taskStatisticsVo.filterTime();
         return this.taskStatisticsService.ordersDetailsExcel(taskStatisticsVo);
     }
 
@@ -103,6 +104,7 @@ public class TaskStatisticsController {
                     taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
                 }
             }
+            taskStatisticsVo.filterTime();
             IPage<TaskStatisticsDto> result = taskStatisticsService.queryPageElectric(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -117,7 +119,17 @@ public class TaskStatisticsController {
      **/
     @PostMapping("/electricExcel")
     @ApiOperation(value = "任务统计-电销导出")
-    public HttpResult electricExcel(@RequestBody TaskStatisticsVo taskStatisticsVo) {
+    public HttpResult electricExcel(@RequestBody TaskStatisticsVo taskStatisticsVo, HttpServletRequest httpServerRequest) {
+        taskStatisticsVo.filterTime();
+        KztGetDeptUtils kztGetDeptUtils = new KztGetDeptUtils();
+        KztGetDeptUtilsDto kztGetDeptUtilsDto = kztGetDeptUtils.KztGetDeptIds(httpServerRequest.getRequestURL().toString());
+        if(ObjectUtils.isNotEmpty(kztGetDeptUtilsDto)){
+            if("1".equals(kztGetDeptUtilsDto.getType())){
+                taskStatisticsVo.setDeptIds(kztGetDeptUtilsDto.getIds());
+            } else if ("2".equals(kztGetDeptUtilsDto.getType())) {
+                taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
+            }
+        }
         return this.taskStatisticsService.electricExcel(taskStatisticsVo);
     }
 
@@ -139,6 +151,7 @@ public class TaskStatisticsController {
                     taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
                 }
             }
+            taskStatisticsVo.filterTime();
             IPage<TaskStatisticsDto> result = taskStatisticsService.insuranceCompanyQueryPage(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -164,6 +177,7 @@ public class TaskStatisticsController {
                     taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
                 }
             }
+            taskStatisticsVo.filterTime();
             IPage<TaskStatisticsDto> result = taskStatisticsService.agentStatisticsQueryPage(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -179,7 +193,18 @@ public class TaskStatisticsController {
      **/
     @PostMapping("/agentExcel")
     @ApiOperation(value = "任务统计-代理人导出")
-    public HttpResult channelAgentExcel(@RequestBody TaskStatisticsVo taskStatisticsVo) {
+    public HttpResult channelAgentExcel(@RequestBody TaskStatisticsVo taskStatisticsVo, HttpServletRequest httpServerRequest) {
+        taskStatisticsVo.filterTime();
+
+        KztGetDeptUtils kztGetDeptUtils = new KztGetDeptUtils();
+        KztGetDeptUtilsDto kztGetDeptUtilsDto = kztGetDeptUtils.KztGetDeptIds(httpServerRequest.getRequestURL().toString());
+        if(ObjectUtils.isNotEmpty(kztGetDeptUtilsDto)){
+            if("1".equals(kztGetDeptUtilsDto.getType())){
+                taskStatisticsVo.setDeptIds(kztGetDeptUtilsDto.getIds());
+            } else if ("2".equals(kztGetDeptUtilsDto.getType())) {
+                taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
+            }
+        }
         return this.taskStatisticsService.agentExcel(taskStatisticsVo);
     }
 
@@ -201,6 +226,7 @@ public class TaskStatisticsController {
                     taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
                 }
             }
+            taskStatisticsVo.filterTime();
             IPage<TaskStatisticsDto> result = taskStatisticsService.costCenter(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -225,6 +251,7 @@ public class TaskStatisticsController {
                     taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
                 }
             }
+            taskStatisticsVo.filterTime();
             IPage<TaskStatisticsDto> result = taskStatisticsService.costReviewer(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -299,6 +326,7 @@ public class TaskStatisticsController {
                 taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
             }
         }
+        taskStatisticsVo.filterTime();
         return this.taskStatisticsService.costCenterDetailsExcel(taskStatisticsVo);
     }
 
@@ -353,6 +381,7 @@ public class TaskStatisticsController {
     @PostMapping("/insuranceCompanyExcel")
     @ApiOperation(value = "任务统计-保险公司-导出")
     public HttpResult insuranceCompanyExcel(@RequestBody TaskStatisticsVo taskStatisticsVo) {
+        taskStatisticsVo.filterTime();
         return this.taskStatisticsService.insuranceCompanyExcel(taskStatisticsVo);
     }
 
@@ -374,6 +403,7 @@ public class TaskStatisticsController {
                     taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
                 }
             }
+            taskStatisticsVo.filterTime();
             IPage<TaskStatisticsDto> result = taskStatisticsService.getBusinessData(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -398,6 +428,7 @@ public class TaskStatisticsController {
                 taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
             }
         }
+        taskStatisticsVo.filterTime();
         return this.taskStatisticsService.getBusinessDataExcel(taskStatisticsVo);
     }
 
@@ -419,6 +450,7 @@ public class TaskStatisticsController {
                     taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
                 }
             }
+            taskStatisticsVo.filterTime();
             TaskStatisticsDto result = taskStatisticsService.getCountBusinessData(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -457,7 +489,18 @@ public class TaskStatisticsController {
      **/
     @PostMapping("/channelExcel")
     @ApiOperation(value = "任务统计-渠道导出")
-    public HttpResult channelExcel(@RequestBody TaskStatisticsVo taskStatisticsVo) {
+    public HttpResult channelExcel(@RequestBody TaskStatisticsVo taskStatisticsVo, HttpServletRequest httpServerRequest) {
+        taskStatisticsVo.filterTime();
+        KztGetDeptUtils kztGetDeptUtils = new KztGetDeptUtils();
+        KztGetDeptUtilsDto kztGetDeptUtilsDto = kztGetDeptUtils.KztGetDeptIds(httpServerRequest.getRequestURL().toString());
+        if(ObjectUtils.isNotEmpty(kztGetDeptUtilsDto)){
+            if("1".equals(kztGetDeptUtilsDto.getType())){
+                taskStatisticsVo.setDeptIds(kztGetDeptUtilsDto.getIds());
+            } else if ("2".equals(kztGetDeptUtilsDto.getType())) {
+                taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
+            }
+        }
+
         return this.taskStatisticsService.channelExcel(taskStatisticsVo);
     }
 
@@ -470,7 +513,7 @@ public class TaskStatisticsController {
     @ApiOperation(value = "控制台-业务数据-代理人")
     public HttpResult<IPage<BusinessAgentData>> getBusinessAgentData(@RequestBody TaskStatisticsVo taskStatisticsVo) {
         try{
-
+            taskStatisticsVo.filterTime();
             IPage<BusinessAgentData> result = taskStatisticsService.getBusinessAgentData(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -495,6 +538,7 @@ public class TaskStatisticsController {
                 taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
             }
         }
+        taskStatisticsVo.filterTime();
         return this.taskStatisticsService.getBusinessAgentExcel(taskStatisticsVo);
     }
 
@@ -516,6 +560,7 @@ public class TaskStatisticsController {
                 taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
             }
         }
+        taskStatisticsVo.filterTime();
         return this.taskStatisticsService.getChannelExcel(taskStatisticsVo);
     }
 
@@ -530,7 +575,7 @@ public class TaskStatisticsController {
     @ApiOperation(value = "任控制台-业务数据-渠道")
     public HttpResult<IPage<BusinessAgentData>> getBusinessElectricData(@RequestBody TaskStatisticsVo taskStatisticsVo) {
         try{
-
+            taskStatisticsVo.filterTime();
             IPage<BusinessAgentData> result = taskStatisticsService.getBusinessElectricData(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -547,6 +592,7 @@ public class TaskStatisticsController {
     @ApiOperation(value = "控制台-业务数据-代理人-合计")
     public HttpResult<BusinessAgentData> getBusinessAgentDataTotal(@RequestBody TaskStatisticsVo taskStatisticsVo) {
         try{
+            taskStatisticsVo.filterTime();
             BusinessAgentData result = taskStatisticsService.getBusinessAgentDataTotal(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -563,6 +609,7 @@ public class TaskStatisticsController {
     @ApiOperation(value = "控制台-业务数据-渠道-合计")
     public HttpResult<BusinessAgentData> getBusinesElectricDataTotal(@RequestBody TaskStatisticsVo taskStatisticsVo) {
         try{
+            taskStatisticsVo.filterTime();
             BusinessAgentData result = taskStatisticsService.getBusinessElectricDataTotal(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -579,6 +626,7 @@ public class TaskStatisticsController {
     @ApiOperation(value = "控制台-业务数据-代理人-详情")
     public HttpResult<IPage<BusinessAgentData>> getBusinessAgentDataDetails(@RequestBody TaskStatisticsVo taskStatisticsVo) {
         try{
+            taskStatisticsVo.filterTime();
             IPage<BusinessAgentData> result = taskStatisticsService.getBusinessAgentDataDetails(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -595,6 +643,7 @@ public class TaskStatisticsController {
     @ApiOperation(value = "控制台任务统计 渠道代理人详情")
     public HttpResult<IPage<TaskStatisticsDto>> channelAgentDetails(@RequestBody TaskStatisticsVo taskStatisticsVo) {
         try{
+            taskStatisticsVo.filterTime();
             IPage<TaskStatisticsDto> result = taskStatisticsService.channelAgentDetails(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", result);
         }catch (Exception e){
@@ -612,6 +661,7 @@ public class TaskStatisticsController {
     @ApiOperation(value = "控制台-业务数据-电销-订单详情-详情")
     public HttpResult<PageInfo<BusinessOrderData>> getBusinessOrderDataDetails(@RequestBody TaskStatisticsVo taskStatisticsVo) {
         try {
+            taskStatisticsVo.filterTime();
             PageInfo<BusinessOrderData> businessOrderDataDetails = taskStatisticsService.getBusinessOrderDataDetails(taskStatisticsVo);
             return HttpResult.ok("查询数据成功", businessOrderDataDetails);
         } catch (Exception e) {

+ 1 - 1
src/main/java/com/ydtech/modules/admin/dao/SysDeptMapper.java

@@ -64,7 +64,7 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
 
     List<SysDept> queryFiveLevelDept(@Param("vo") SysDeptVo sysDeptVo);
 
-    List<SysDept> getListByIdsByKzt(List<String> deptIds);
+    List<SysDept> getListByIdsByKzt(@Param("ids") List<String> deptIds);
 }
 
 

+ 53 - 0
src/main/java/com/ydtech/modules/admin/model/SumEntryStatusDo.java

@@ -0,0 +1,53 @@
+package com.ydtech.modules.admin.model;
+
+import com.ydtech.modules.admin.model.vo.TaskStatisticsVo;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+public class SumEntryStatusDo {
+
+    /**
+     * 创建时间
+     * 时间筛选开始
+     */
+    private String createtimeStart;
+
+    /**
+     * 创建时间
+     * 时间筛选结束
+     */
+    private String createtimeEnd;
+
+    /**
+     * 签单时间
+     * 时间筛选开始
+     */
+    private String beginDate;
+
+    /**
+     * 签单时间
+     * 时间筛选开始
+     */
+    private String endDate;
+
+    /**
+     * 用户ID列表
+     */
+    private List<String> userIdList;
+
+    public SumEntryStatusDo(TaskStatisticsVo taskStatisticsVo, List<String> userIdList) {
+        this.createtimeStart = taskStatisticsVo.getCreatetimeStart();
+        this.createtimeEnd = taskStatisticsVo.getCreatetimeEnd();
+        this.beginDate = taskStatisticsVo.getBeginDate();
+        this.endDate = taskStatisticsVo.getEndDate();
+        this.userIdList = userIdList;
+    }
+
+
+}

+ 26 - 0
src/main/java/com/ydtech/modules/admin/model/dto/RecordSummaryDto.java

@@ -0,0 +1,26 @@
+package com.ydtech.modules.admin.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+public class RecordSummaryDto {
+
+    /**
+     * 用户id
+     */
+    private String userId;
+    /**
+     * 代课录单数
+     */
+    private String entryStatus;
+    /**
+     * 外部录单
+     */
+    private String outStatus;
+
+}

+ 13 - 0
src/main/java/com/ydtech/modules/admin/model/report/company/CompanyQutationCountDataQueryDto.java

@@ -1,5 +1,6 @@
 package com.ydtech.modules.admin.model.report.company;
 
+import com.ydtech.utils.StringUtils;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -70,4 +71,16 @@ public class CompanyQutationCountDataQueryDto {
 
     @ApiModelProperty(value = "筛选签单结束时间")
     private String signingTimeEnd;
+
+    public void filterTime() {
+        if(StringUtils.isNotEmpty(this.signingTimeStart) && StringUtils.isNotEmpty(this.signingTimeEnd)) {
+            this.signingTimeStart = this.signingTimeStart + " 00:00:00";
+            this.signingTimeEnd = this.signingTimeEnd + " 23:59:59";
+        }
+        if(StringUtils.isNotEmpty(this.beginDate) && StringUtils.isNotEmpty(this.endDate)) {
+            this.beginDate = this.beginDate + " 00:00:00";
+            this.endDate = this.endDate + " 23:59:59";
+        }
+    }
+
 }

+ 29 - 4
src/main/java/com/ydtech/modules/admin/model/vo/TaskStatisticsVo.java

@@ -1,18 +1,17 @@
 package com.ydtech.modules.admin.model.vo;
 
 
-import com.baomidou.mybatisplus.annotation.TableField;
+import com.ydtech.utils.StringUtils;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import javax.validation.constraints.Min;
 import java.io.Serializable;
-import java.time.LocalDateTime;
 import java.util.List;
 
 /**
- * @description:   任务统计
+ * @description: 任务统计
  * @author: whp
  * @date: 2024/7/25
  **/
@@ -131,7 +130,6 @@ public class TaskStatisticsVo implements Serializable {
     private String deptId;
 
 
-
     @ApiModelProperty(value = "总人数")
     private String totalNumber;
 
@@ -175,4 +173,31 @@ public class TaskStatisticsVo implements Serializable {
 
     @ApiModelProperty(value = "传参任务类型")
     private String taskType;
+
+    @ApiModelProperty(value = "控制台部门关系用户id")
+    private String relationUserId;
+
+    public void filterTime() {
+        if(StringUtils.isNotEmpty(this.createtimeStart) && StringUtils.isNotEmpty(this.createtimeEnd)) {
+            this.createtimeStart = this.createtimeStart + " 00:00:00";
+            this.createtimeEnd = this.createtimeEnd + " 23:59:59";
+        }
+        if(StringUtils.isNotEmpty(this.signingTimeStart) && StringUtils.isNotEmpty(this.signingTimeEnd)) {
+            this.signingTimeStart = this.signingTimeStart + " 00:00:00";
+            this.signingTimeEnd = this.signingTimeEnd + " 23:59:59";
+        }
+        if(StringUtils.isNotEmpty(this.enterTimeStart) && StringUtils.isNotEmpty(this.enterTimeEnd)) {
+            this.enterTimeStart = this.enterTimeStart + " 00:00:00";
+            this.enterTimeEnd = this.enterTimeEnd + " 23:59:59";
+        }
+        if(StringUtils.isNotEmpty(this.beginDate) && StringUtils.isNotEmpty(this.endDate)) {
+            this.beginDate = this.beginDate + " 00:00:00";
+            this.endDate = this.endDate + " 23:59:59";
+        }
+        if(StringUtils.isNotEmpty(this.auditTimeStart) && StringUtils.isNotEmpty(this.auditTimeEnd)) {
+            this.auditTimeStart = this.auditTimeStart + " 00:00:00";
+            this.auditTimeEnd = this.auditTimeEnd + " 23:59:59";
+        }
+    }
+
 }

+ 95 - 71
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptServiceImpl.java

@@ -13,13 +13,11 @@ import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.dao.*;
 import com.ydtech.modules.admin.model.SysArea;
 import com.ydtech.modules.admin.model.SysDept;
-import com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto;
+import com.ydtech.modules.admin.model.SysUser;
 import com.ydtech.modules.admin.model.po.InsDeptDistributionProportion;
 import com.ydtech.modules.admin.model.po.SysUserDeptRelationship;
-import com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo;
-import com.ydtech.modules.admin.model.vo.*;
-import com.ydtech.modules.admin.model.SysUser;
 import com.ydtech.modules.admin.model.po.SysUserTreeShowLevel;
+import com.ydtech.modules.admin.model.vo.*;
 import com.ydtech.modules.admin.service.SysAreaService;
 import com.ydtech.modules.admin.service.SysDeptService;
 import com.ydtech.modules.admin.service.SysUserTreeShowLevelService;
@@ -29,7 +27,6 @@ import com.ydtech.modules.esm.service.EsmRetailService;
 import com.ydtech.modules.protocol.utils.AssertionUtils;
 import com.ydtech.utils.StringUtils;
 import com.ydtech.utils.idgen.IdGenerate;
-import io.lettuce.core.ScriptOutputType;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,7 +36,6 @@ import org.springframework.util.ObjectUtils;
 
 import java.math.BigDecimal;
 import java.util.*;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
 
@@ -132,8 +128,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
             lqw.eq(SysDept::getManagementSource, managementSource);
             //条件
             List<SysDept> conditionList = list(lqw);
-            Map<String, List<SysDept>> conditionMap = conditionList.stream().collect(Collectors.groupingBy(SysDept::getParentId));
-            Map<String, List<SysDept>> map = conditionList.stream().collect(Collectors.groupingBy(SysDept::getParentId));
+            Map<String, List<SysDept>> conditionMap = conditionList.stream()
+                    .collect(Collectors.groupingBy(SysDept::getParentId));
+            Map<String, List<SysDept>> map = conditionList.stream()
+                    .collect(Collectors.groupingBy(SysDept::getParentId));
             //先查第6层
             conditionList.forEach(i ->
                     i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>()))
@@ -147,7 +145,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
                     break;
                 } else {
                     int finalLevel = level;
-                    resultTmp = resultTmp.stream().filter(x -> x.getComlevel().equals(String.valueOf(finalLevel))).collect(Collectors.toList());
+                    resultTmp = resultTmp.stream()
+                            .filter(x -> x.getComlevel().equals(String.valueOf(finalLevel)))
+                            .collect(Collectors.toList());
                     result.clear();
                     result.addAll(resultTmp);
                 }
@@ -309,23 +309,23 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         boolean b = save(sysDept);
 
         //如果是团队并且个代  初始化分销比例
-        if("D".equals(sysDeptVo.getDeptType()) && "2".equals(sysDept.getManagementSource())){
+        if ("D".equals(sysDeptVo.getDeptType()) && "2".equals(sysDept.getManagementSource())) {
             List<InsDeptDistributionProportion> insDeptDistributionProportions = insDeptDistributionProportionMapper.selectList(new LambdaQueryWrapper<>());
             BigDecimal oneProportion = new BigDecimal(0);
             BigDecimal twoProportion = new BigDecimal(0);
             BigDecimal threeProportion = new BigDecimal(0);
 
-            for(int i=1;i<=insDeptDistributionProportions.size();i++){
-                InsDeptDistributionProportion insDeptDistributionProportion = insDeptDistributionProportions.get(i-1);
-                if(i==1){
+            for (int i = 1; i <= insDeptDistributionProportions.size(); i++) {
+                InsDeptDistributionProportion insDeptDistributionProportion = insDeptDistributionProportions.get(i - 1);
+                if (i == 1) {
                     oneProportion = insDeptDistributionProportion.getProportion();
-                }else if(i==2){
+                } else if (i == 2) {
                     twoProportion = insDeptDistributionProportion.getProportion();
-                }else if(i==3){
+                } else if (i == 3) {
                     threeProportion = insDeptDistributionProportion.getProportion();
                 }
             }
-            EsmRetail esmRetail = new EsmRetail(sysDept.getId(),sysDept.getName(),String.valueOf(insDeptDistributionProportions.size()),oneProportion.doubleValue(),twoProportion.doubleValue(),threeProportion.doubleValue());
+            EsmRetail esmRetail = new EsmRetail(sysDept.getId(), sysDept.getName(), String.valueOf(insDeptDistributionProportions.size()), oneProportion.doubleValue(), twoProportion.doubleValue(), threeProportion.doubleValue());
             esmRetail.setId(IdGenerate.nextId());
             esmRetailService.insert(esmRetail);
         }
@@ -428,7 +428,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
 
 
     public String findMaxDeptId(String deptId) {
-        if (deptId == null) return "";
+        if (deptId == null) {
+            return "";
+        }
         String result = "00";
         QueryWrapper<SysDept> qw = new QueryWrapper<>();
         qw.likeRight(StringUtils.isNotEmpty(deptId), "id", deptId + "D%");
@@ -580,7 +582,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         List<SysDept> sysDeptsHX = sysDeptMapper.queryHXDeptTree();
         //查询后线中顶级的数据
         List<SysDept> resultList = new ArrayList<SysDept>();
-        List<SysDept> sysDeptTop = sysDeptsHX.stream().filter(item -> "99".equals(item.getId())).collect(Collectors.toList());
+        List<SysDept> sysDeptTop = sysDeptsHX.stream()
+                .filter(item -> "99".equals(item.getId()))
+                .collect(Collectors.toList());
         for (SysDept dept : sysDeptTop) {
             resultList.add(buildDeptTree(dept, sysDeptsHX));
         }
@@ -614,7 +618,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         List<SysDept> sysDeptAll = sysDeptMapper.queryListByQXDept();
         //查询后线中顶级的数据
         List<SysDept> resultList = new ArrayList<SysDept>();
-        List<SysDept> sysDeptTop = sysDeptAll.stream().filter(item -> "3".equals(item.getComlevel())).collect(Collectors.toList());
+        List<SysDept> sysDeptTop = sysDeptAll.stream()
+                .filter(item -> "3".equals(item.getComlevel()))
+                .collect(Collectors.toList());
         for (SysDept dept : sysDeptTop) {
             resultList.add(buildDeptTree(dept, sysDeptAll));
         }
@@ -633,7 +639,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         SysDeptTreeVo sysDeptTreeVo = BeanUtil.copyProperties(sysDept, SysDeptTreeVo.class);
         List<SysDeptTreeVo> sysDeptTreeVos = BeanUtil.copyToList(sysDeptList, SysDeptTreeVo.class);
         sysDeptTreeVos.add(sysDeptTreeVo);
-        Map<String, List<SysDeptTreeVo>> map = sysDeptTreeVos.stream().sorted(Comparator.comparing(SysDeptTreeVo::getId)).collect(Collectors.groupingBy(SysDeptTreeVo::getParentId));
+        Map<String, List<SysDeptTreeVo>> map = sysDeptTreeVos.stream()
+                .sorted(Comparator.comparing(SysDeptTreeVo::getId))
+                .collect(Collectors.groupingBy(SysDeptTreeVo::getParentId));
         sysDeptTreeVos.forEach(i -> {
             i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>()));
             i.setDeptCount(i.getChildren().size());
@@ -655,7 +663,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
 
         List<SysDeptTreeVo> sysDeptTreeVos = BeanUtil.copyToList(sysDeptList, SysDeptTreeVo.class);
 
-        Map<String, List<SysDeptTreeVo>> map = sysDeptTreeVos.stream().sorted(Comparator.comparing(SysDeptTreeVo::getId))
+        Map<String, List<SysDeptTreeVo>> map = sysDeptTreeVos.stream()
+                .sorted(Comparator.comparing(SysDeptTreeVo::getId))
                 .collect(Collectors.groupingBy(SysDeptTreeVo::getParentId));
         sysDeptTreeVos.forEach(i -> {
             i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>()));
@@ -667,23 +676,31 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
             List<SysDeptTreeVo> children2 = deptTreeVo.getChildren();
             for (SysDeptTreeVo children : children2) {//2
                 List<SysDeptTreeVo> children3 = children.getChildren();
-                if (children3.size()>0) {
-                    children3=children3.stream().filter(SysDeptTreeVo -> SysDeptTreeVo.getComlevel() != null).collect(Collectors.toList());
+                if (children3.size() > 0) {
+                    children3 = children3.stream()
+                            .filter(SysDeptTreeVo -> SysDeptTreeVo.getComlevel() != null)
+                            .collect(Collectors.toList());
                     children.setChildren(children3);
                     for (SysDeptTreeVo child4 : children3) {//3
                         List<SysDeptTreeVo> children4 = child4.getChildren();
-                        if (children4.size()>0) {
-                            children4=children4.stream().filter(SysDeptTreeVo -> SysDeptTreeVo.getComlevel() != null).collect(Collectors.toList());
+                        if (children4.size() > 0) {
+                            children4 = children4.stream()
+                                    .filter(SysDeptTreeVo -> SysDeptTreeVo.getComlevel() != null)
+                                    .collect(Collectors.toList());
                             child4.setChildren(children4);
                             for (SysDeptTreeVo child : children4) {//4
                                 List<SysDeptTreeVo> children5 = child.getChildren();
-                                children5 = children5.stream().filter(SysDeptTreeVo ->SysDeptTreeVo.getComlevel() != null).collect(Collectors.toList());
+                                children5 = children5.stream()
+                                        .filter(SysDeptTreeVo -> SysDeptTreeVo.getComlevel() != null)
+                                        .collect(Collectors.toList());
                                 child.setChildren(children5);
-                                if (children5.size()>0) {
+                                if (children5.size() > 0) {
                                     for (SysDeptTreeVo treeVo : children5) {
                                         List<SysDeptTreeVo> childrenEnd = treeVo.getChildren();
-                                        if (childrenEnd.size()>0) {
-                                            childrenEnd=childrenEnd.stream().filter(SysDeptTreeVo ->SysDeptTreeVo.getComlevel() == null).collect(Collectors.toList());
+                                        if (childrenEnd.size() > 0) {
+                                            childrenEnd = childrenEnd.stream()
+                                                    .filter(SysDeptTreeVo -> SysDeptTreeVo.getComlevel() == null)
+                                                    .collect(Collectors.toList());
                                             treeVo.setChildren(childrenEnd);
                                         }
 
@@ -707,15 +724,17 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         String managementSourceDept = sysDeptMapper.getByOrderNoQueryManagementSource(orderNo);
         return managementSource.equals(managementSourceDept);
     }
+
     /**
      * 数据权限机构数
+     *
      * @return
      */
     @Override
     public List<SysDept> getDataDeptTree(List<String> deptIds) {
         String name = BaseController.getUser().getName();
         List<SysDept> result = new ArrayList<>();
-        if(!deptIds.isEmpty()){
+        if (!deptIds.isEmpty()) {
             List<SysDept> deptList = sysDeptMapper.getListByIdsByKzt(deptIds);
             // 使用一个Map来快速查找部门节点
             Map<String, SysDept> deptMap = new HashMap<>();
@@ -732,14 +751,14 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
             }
 
         } else if ("admin".equals(name)) {
-           String  deptId ="9";
-            if(deptId==null || "".equals(deptId)){
-                deptId="9";
-            }else{
+            String deptId = "9";
+            if (deptId == null || "".equals(deptId)) {
+                deptId = "9";
+            } else {
                 //如果是平台下判断包含D的查询上级id
-                if(deptId.contains("D")){
+                if (deptId.contains("D")) {
                     SysDept dept = baseMapper.selectById(deptId);
-                    deptId =dept==null?"":dept.getParentId();
+                    deptId = dept == null ? "" : dept.getParentId();
                 }
             }
             LambdaQueryWrapper<SysDept> queryWrapper = new LambdaQueryWrapper<>();
@@ -790,7 +809,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         List<SysDept> sysDeptList = baseMapper.getFiveLevelDept(sysDeptVo);
         sysDeptList.add(sysDept);//添加总部 总部没有等级机构
         List<SysDeptTreeVo> sysDeptTreeVos = BeanUtil.copyToList(sysDeptList, SysDeptTreeVo.class);
-        Map<String, List<SysDeptTreeVo>> map = sysDeptTreeVos.stream().sorted(Comparator.comparing(SysDeptTreeVo::getId))
+        Map<String, List<SysDeptTreeVo>> map = sysDeptTreeVos.stream()
+                .sorted(Comparator.comparing(SysDeptTreeVo::getId))
                 .collect(Collectors.groupingBy(SysDeptTreeVo::getParentId));
         sysDeptTreeVos.forEach(i -> {
             i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>()));
@@ -814,12 +834,13 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
     }
 
     /**
-     *  前线只要机构 后线人员(按照领导人)  机构
+     * 前线只要机构 后线人员(按照领导人)  机构
+     *
      * @param sysDeptVo
      * @return
      */
     @Override
-    public KztUserDeptTreeDto  getUserDeptTree(SysDeptVo sysDeptVo) {
+    public KztUserDeptTreeDto getUserDeptTree(SysDeptVo sysDeptVo) {
         String managementSource = sysDeptVo.getManagementSource();
         KztUserDeptTreeDto kztUserDeptTreeDto = new KztUserDeptTreeDto();
         String userId = BaseController.getUserId();
@@ -831,24 +852,24 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         } else {
             kztUserDeptTreeDto.setType("2"); //代理
         }
-            SysUser byUserId = sysUserMapper.getByUserId(userId);
-            List<SysDeptTreeVo> resultDeptList = this.getFiveLevelDeptKzt(byUserId,managementSource);
-            kztUserDeptTreeDto.setDeptList(resultDeptList);
-            if (!userId.contains("M")) {
-              List<SysUser>  resultList =this.getUserTreeHx(byUserId,managementSource);
-                kztUserDeptTreeDto.setUserList(resultList);
-            }
+        SysUser byUserId = sysUserMapper.getByUserId(userId);
+        List<SysDeptTreeVo> resultDeptList = this.getFiveLevelDeptKzt(byUserId, managementSource);
+        kztUserDeptTreeDto.setDeptList(resultDeptList);
+        if (!userId.contains("M")) {
+            List<SysUser> resultList = this.getUserTreeHx(byUserId, managementSource);
+            kztUserDeptTreeDto.setUserList(resultList);
+        }
 
         return kztUserDeptTreeDto;
     }
 
-    private List<SysUser> getUserTreeHx(SysUser sysUser,String managementSource) {
+    private List<SysUser> getUserTreeHx(SysUser sysUser, String managementSource) {
         //获取领导字段不为空的人的ID
         QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
         queryWrapper.isNotNull("leader_id");
 
         HashMap<String, Object> params = new HashMap<>();
-        params.put("managementSource",managementSource);
+        params.put("managementSource", managementSource);
         List<SysUser> users = sysUserMapper.selectByParams(params);
 
         for (SysUser user : users) {
@@ -860,7 +881,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
 
         List<SysUser> allList = new ArrayList<>();
         for (SysUser user : users) {
-            this.addLeadUserList(user,allList);
+            this.addLeadUserList(user, allList);
         }
         List<SysUser> collect = allList.stream()
                 .collect(Collectors.collectingAndThen(
@@ -872,14 +893,14 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
 
         List<SysUser> topUsers = new ArrayList<>(); //存放1级用户,即没有直接上级的用户
         // 根据组织结构展示级别,筛选顶层节点并构建组织结构树
-        if("admin".equals(sysUser.getName())){
+        if ("admin".equals(sysUser.getName())) {
             topUsers.add(sysUserMapper.selectById("99D1501"));
-        }else {
+        } else {
             this.appendName(sysUser);
             topUsers.add(sysUser);
         }
         // 递归构建用户树结构
-        buildUserTree(topUsers, collect,managementSource);
+        buildUserTree(topUsers, collect, managementSource);
         return topUsers;
     }
 
@@ -906,6 +927,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
 
     /**
      * 拼接机构来源
+     *
      * @param users
      */
     private void appendName(SysUser user) {
@@ -933,27 +955,27 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
                         stringBuilder.append("(").append(dept1.getName()).append(dept2.getName()).append(")");
                     }
                 }
-                user.setName(user.getName()+stringBuilder.toString());
+                user.setName(user.getName() + stringBuilder.toString());
             }
         }
     }
 
-    private List<SysDeptTreeVo> getFiveLevelDeptKzt(SysUser byUserId,String managementSource) {
+    private List<SysDeptTreeVo> getFiveLevelDeptKzt(SysUser byUserId, String managementSource) {
         SysDept sysDept = getById("9");
         SysDeptVo sysDeptVo = new SysDeptVo();
         String id = byUserId.getId();
         List<String> deptIds = new ArrayList<>();
-        if("admin".equals(byUserId.getId())){
+        if ("admin".equals(byUserId.getId())) {
             List<SysDept> sysDeptList = baseMapper.getFiveLevelDept(sysDeptVo);
             deptIds.addAll(sysDeptList.stream().map(SysDept::getId).collect(Collectors.toList()));
-        }else {
+        } else {
             List<SysUserDeptRelationship> relationships = sysUserDeptRelationshipMapper.selectList(new QueryWrapper<SysUserDeptRelationship>().eq("user_id", id));
             deptIds.addAll(relationships.stream().map(SysUserDeptRelationship::getDeptId).collect(Collectors.toList()));
         }
-        if(!deptIds.isEmpty()){
+        if (!deptIds.isEmpty()) {
             sysDeptVo.setDeptIds(deptIds);
             List<SysDept> sysDeptList = baseMapper.getFiveLevelDept(sysDeptVo);
-            if("admin".equals(byUserId.getId())){
+            if ("admin".equals(byUserId.getId())) {
                 sysDept.setComlevel("1");
                 sysDeptList.add(sysDept);
                 List<SysDeptTreeVo> sysDeptTreeVos = BeanUtil.copyToList(sysDeptList, SysDeptTreeVo.class);
@@ -962,16 +984,17 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
                         .filter(dept -> !(dept.getComlevel().equals("5") &&
                                 !Objects.equals(dept.getManagementSource(), managementSource)))
                         .collect(Collectors.toList());
-                Map<String, List<SysDeptTreeVo>> map = filteredSysDeptTreeVos.stream().sorted(Comparator.comparing(SysDeptTreeVo::getId))
+                Map<String, List<SysDeptTreeVo>> map = filteredSysDeptTreeVos.stream()
+                        .sorted(Comparator.comparing(SysDeptTreeVo::getId))
                         .collect(Collectors.groupingBy(SysDeptTreeVo::getParentId));
                 filteredSysDeptTreeVos.forEach(i -> {
-                    if(Integer.parseInt(i.getComlevel())<=5){
+                    if (Integer.parseInt(i.getComlevel()) <= 5) {
                         i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>()));
                         i.setDeptCount(i.getChildren().size());
                     }
                 });
                 return map.get(sysDept.getParentId());
-            } else  {
+            } else {
                 List<SysDept> result = new ArrayList<>();
                 List<SysDept> deptList = sysDeptMapper.getListByIds(deptIds);
                 List<SysDept> filteredDeptList = deptList.stream()
@@ -1000,8 +1023,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
                 List<SysDeptTreeVo> sysDeptTreeVos = BeanUtil.copyToList(result, SysDeptTreeVo.class);
                 return sysDeptTreeVos;
             }
-        }else {
-            return  new ArrayList<SysDeptTreeVo>();
+        } else {
+            return new ArrayList<>();
         }
     }
 
@@ -1012,7 +1035,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         // 查找并添加子部门
         for (SysDept potentialChild : deptMap.values()) {
             if (potentialChild.getParentId() != null && potentialChild.getParentId().equals(dept.getId())) {
-                if(StringUtils.isNotEmpty(potentialChild.getComlevel())  && Integer.parseInt(potentialChild.getComlevel())<=5 ){
+                if (StringUtils.isNotEmpty(potentialChild.getComlevel()) && Integer.parseInt(potentialChild.getComlevel()) <= 5) {
                     children.add(potentialChild);
                     buildDeptTreeKzt(potentialChild, deptMap); // 递归构建子部门的子树
                 }
@@ -1027,7 +1050,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
                 if (user.getId().equals(childUser.getLeaderId())) {
                     children.add(childUser);
                     // 递归查找下一级
-                    buildUserTree(children, users,managementSource);
+                    buildUserTree(children, users, managementSource);
                 }
             }
             user.setChildren(children);
@@ -1038,20 +1061,21 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
     public List<SysUser> getLeadListDeptId(String deptId) {
         return sysUserMapper.getLeadListDeptId(deptId);
     }
+
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2024/9/26 18:31
-     *  @Description: 设置领导人
+     * @version
+     * @author: hxl
+     * @Date: 2024/9/26 18:31
+     * @Description: 设置领导人
      */
     @Override
     public void saveLeadId(DeptLeadVo deptLeadVo) {
         SysDept dept = baseMapper.selectById(deptLeadVo.getDeptId());
-        if(StringUtils.isBlank(deptLeadVo.getLeadId())){
+        if (StringUtils.isBlank(deptLeadVo.getLeadId())) {
             dept.setLeaderId("");
             dept.setLeadername("");
             baseMapper.updateById(dept);
-        }else{
+        } else {
             SysUser sysUser = sysUserMapper.selectById(deptLeadVo.getLeadId());
             dept.setLeaderId(deptLeadVo.getLeadId());
             dept.setLeadername(sysUser.getName());

File diff ditekan karena terlalu besar
+ 245 - 318
src/main/java/com/ydtech/modules/admin/service/impl/TaskStatisticsServiceImpl.java


+ 7 - 0
src/main/java/com/ydtech/modules/order/dao/InsAreaCompanyMapper.java

@@ -3,6 +3,7 @@ package com.ydtech.modules.order.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.modules.admin.model.SumEntryStatusDo;
 import com.ydtech.modules.admin.model.SysUser;
 import com.ydtech.modules.admin.model.dto.*;
 import com.ydtech.modules.admin.model.report.company.*;
@@ -421,6 +422,12 @@ public interface InsAreaCompanyMapper extends BaseMapper<InsAreaCompany> {
      */
     HashMap<String,Object> getSumEntryStatus(@Param("taskStatisticsVo") TaskStatisticsVo taskStatisticsVo);
 
+    /**
+     * 代课录单数
+     * @param sumEntryStatusDo 总数查询实体
+     * @return  代课录单数
+     */
+    List<RecordSummaryDto> getSumEntryStatusNew(@Param("sumEntryStatusDo") SumEntryStatusDo sumEntryStatusDo);
     /**
      *
      * @param taskStatisticsVo

+ 1 - 1
src/main/resources/mapper/modules/admin/SysDeptMapper.xml

@@ -187,7 +187,7 @@
             (sd.management_source != '1' or sd.management_source is null)
 
             <if test="ids!=null  and  ids !=''  and ids.size()>0">
-                sd.id  in
+              and  sd.id  in
                 <foreach collection="ids" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>

+ 278 - 297
src/main/resources/mapper/modules/admin/TaskStatisticsMapper.xml

@@ -5,170 +5,167 @@
 <mapper namespace="com.ydtech.modules.admin.dao.TaskStatisticsMapper">
 
     <select id="getBusinessAgentData" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
-        select
-        su.id as "userId",
-        su.name as "userName",
-        sd.id as "deptId",
-        su.leader_name as "leaderName",
-        IFNULL(a.sumpremium,0) as "sumpremium",
-        IFNULL(a.jqpremium,0) as "jqpremium",
-        IFNULL(a.sypremium,0) as "sypremium",
-        IFNULL(a.taxamount,0) as "taxamount",
-        IFNULL(a.jypremium,0) as "jypremium",
-        IFNULL(a.riskCodeJs,0) as "riskCodeJs",
-        IFNULL(a.riskCodeDj,0) as "riskCodeDj" ,
-        IFNULL(a.riskCodeJshang,0) as "riskCodeJshang",
-        IFNULL(a.riskCodeDs,0) as "riskCodeDs",
-        IFNULL(a.riskCodeDsan,0) as "riskCodeDsan",
-        sd.management_source as "managementSource",
-        IFNULL(IFNULL(a.entranceAllFee,0) -IFNULL(a.exportAllFee,0),0)  as  "distributionAmount",
-        (IFNULL(IFNULL(a.entranceAllFee,0) -IFNULL(a.exportAllFee,0),0)) / a.sumpremium as "distributionAmountRate"
-        from sys_user su
-        left join sys_dept sd on sd.id =su.dept_id
-        LEFT JOIN sys_user_role sur ON sur.user_id = su.id
-        left join (
-        select
-        io.userid as "userId",
-        sum(IFNULL(jqpremium, 0) + IFNULL(sypremium, 0)+ IFNULL(jypremium, 0)) as "sumpremium",
-        IFNULL(sum(jqpremium),0) as "jqpremium",
-        IFNULL(sum(sypremium),0) as "sypremium",
-        IFNULL(sum(taxamount),0) as "taxamount",
-        IFNULL(sum(jypremium),0) as "jypremium",
-        COUNT( CASE WHEN iac.product = '交三'  THEN 1 END ) AS "riskCodeJs",
-        COUNT( CASE WHEN iac.product = '单交'  THEN 1 END ) AS "riskCodeDj",
-        COUNT( CASE WHEN iac.product = '交商'  THEN 1 END ) AS "riskCodeJshang",
-        COUNT( CASE WHEN iac.product = '单商'  THEN 1 END ) AS "riskCodeDs",
-        COUNT( CASE WHEN iac.product = '单三'  THEN 1 END ) AS "riskCodeDsan",
-        ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL
-        (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
-        ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
-        +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
-        +IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as "exportAllFee"
-        from ins_area_company iac
-        left join ins_orders io on io.orderno =iac.orderno
-        left join  sys_user  su  on su.id =io.userid
+        SELECT
+        a.userId as "userId",
+        su.name AS "userName",
+        sd.id AS "deptId",
+        su.leader_name AS "leaderName",
+        a.sumpremium,
+        a.jqpremium,
+        a.sypremium,
+        a.taxamount,
+        a.jypremium,
+        a.riskCodeJs,
+        a.riskCodeDj,
+        a.riskCodeJshang,
+        a.riskCodeDs,
+        a.riskCodeDsan,
+        sd.management_source AS "managementSource",
+        a.distributionAmount,
+        CASE WHEN a.sumpremium = 0 THEN 0  ELSE a.distributionAmount / a.sumpremium  END AS "distributionAmountRate"
+        FROM (
+        SELECT
+        io.userid AS "userId",
+        SUM(IFNULL(jqpremium, 0) + IFNULL(sypremium, 0) + IFNULL(jypremium, 0)) AS "sumpremium",
+        IFNULL(SUM(jqpremium), 0) AS "jqpremium",
+        IFNULL(SUM(sypremium), 0) AS "sypremium",
+        IFNULL(SUM(taxamount), 0) AS "taxamount",
+        IFNULL(SUM(jypremium), 0) AS "jypremium",
+        COUNT(CASE WHEN iac.product = '交三' THEN 1 END) AS "riskCodeJs",
+        COUNT(CASE WHEN iac.product = '单交' THEN 1 END) AS "riskCodeDj",
+        COUNT(CASE WHEN iac.product = '交商' THEN 1 END) AS "riskCodeJshang",
+        COUNT(CASE WHEN iac.product = '单商' THEN 1 END) AS "riskCodeDs",
+        COUNT(CASE WHEN iac.product = '单三' THEN 1 END) AS "riskCodeDsan",
+        ROUND(SUM(IFNULL(ifon.jq_costs_premiums, 0) + IFNULL(ifon.sy_costs_premiums, 0) + IFNULL(ifon.no_costs_premiums, 0)), 2) AS "entranceAllFee",
+        ROUND(SUM(IFNULL(jq_export_other_costs_premiums, 0) + IFNULL(jq_export_supervise_costs_premiums, 0) + IFNULL(sy_export_other_costs_premiums, 0) + IFNULL(sy_export_supervise_costs_premiums, 0) + IFNULL(no_export_other_costs_premiums, 0) + IFNULL(no_export_supervise_costs_premiums, 0)), 2) AS "exportAllFee",
+        IFNULL(IFNULL(SUM(IFNULL(ifon.jq_costs_premiums, 0) + IFNULL(ifon.sy_costs_premiums, 0) + IFNULL(ifon.no_costs_premiums, 0)), 0) - IFNULL(SUM(IFNULL(jq_export_other_costs_premiums, 0) + IFNULL(jq_export_supervise_costs_premiums, 0) + IFNULL(sy_export_other_costs_premiums, 0) + IFNULL(sy_export_supervise_costs_premiums, 0) + IFNULL(no_export_other_costs_premiums, 0) + IFNULL(no_export_supervise_costs_premiums, 0)), 0), 0) AS "distributionAmount"
+        FROM
+        ins_area_company iac
+        LEFT JOIN ins_orders io ON io.orderno = iac.orderno
+        LEFT JOIN sys_user su ON su.id = io.userid
         LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
-        <where>
-            iac.orderstatus = '3'
-            and  (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
-            <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
-                AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
-            </if>
-            <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
-                AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
-            </if>
-
-            <if test="vo.userIds  !=null  and vo.userIds!=''  and vo.userIds.size()>0">
-                and su.leader_id in
-                <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-
-        </where>
-        group by io.userid
-        ) a  on  a.userId  =su.id
-        <where>
-            1=1
-            <if test="vo.userId !=null  and vo.userId!=''">
-                and su.id=#{vo.userId}
-            </if>
-
-            <if test="vo.userName !=null  and vo.userName!=''">
-                and su.name=#{vo.userName}
-            </if>
-
-            <if test="vo.managementSource !=null  and vo.managementSource!=''">
-                and sd.management_source=#{vo.managementSource}
-            </if>
-
-            <if test="vo.userIds  !=null  and vo.userIds!=''  and vo.userIds.size()>0">
-                and su.leader_id in
-                <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-
-
-            <if test="vo.leaderName !=null  and vo.leaderName!=''">
-                and su.leader_name=#{vo.leaderName}
-            </if>
-
-            <choose>
-                <when  test='vo.managementSource == "2"'>
-                    and (sur.role_id = 20  or  sur.role_id = 21)
-                </when>
-                <when  test='vo.managementSource == "1"'>
-                    and (sur.role_id = 19  or  sur.role_id = 21)
-                </when>
-                <otherwise>
-                </otherwise>
-            </choose>
-
-            <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
-                AND sd.id in
-                <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-
-            <if test="vo.deptId !=null  and vo.deptId!=''">
-                and sd.id like concat('%',#{vo.deptId},'%')
-            </if>
-        </where>
-        order by  a.sumpremium  desc ,su.id
+        WHERE
+        iac.orderstatus = '3'
+        AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 1)
+        <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
+            AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
+        </if>
+        <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
+            AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
+        </if>
+        <if test="vo.userIds  !=null  and vo.userIds!=''  and vo.userIds.size()>0">
+            AND su.leader_id IN
+            <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY
+        io.userid
+        ) a
+        LEFT JOIN sys_user su ON a.userId = su.id
+        LEFT JOIN sys_dept sd ON sd.id = su.dept_id
+        LEFT JOIN sys_user_role sur ON sur.user_id = su.id
+        WHERE
+        1 = 1
+        <if test="vo.userId !=null  and vo.userId!=''">
+            AND su.id = #{vo.userId}
+        </if>
+        <if test="vo.userName !=null  and vo.userName!=''">
+            AND su.name = #{vo.userName}
+        </if>
+        <if test="vo.managementSource !=null  and vo.managementSource!=''">
+            AND sd.management_source = #{vo.managementSource}
+        </if>
+        <choose>
+            <when test='vo.managementSource == "2"'>
+                AND (sur.role_id = 20 OR sur.role_id = 21)
+            </when>
+            <when test='vo.managementSource == "1"'>
+                AND (sur.role_id = 19 OR sur.role_id = 21)
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+        <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
+            AND sd.id IN
+            <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="vo.deptId !=null  and vo.deptId!=''">
+            AND sd.id LIKE CONCAT('%', #{vo.deptId}, '%')
+        </if>
+        ORDER BY
+        a.sumpremium DESC,
+        a.userId
     </select>
 
     <select id="getBusinessAgentDataTotal" resultType="java.lang.Long">
-        select
+        SELECT
         COUNT(0)
-        from sys_user su
-        left join sys_dept sd on sd.id =su.dept_id
+        FROM (
+        SELECT
+        a.userId as "userId"
+        FROM (
+        SELECT
+        io.userid AS "userId"
+        FROM
+        ins_area_company iac
+        LEFT JOIN ins_orders io ON io.orderno = iac.orderno
+        LEFT JOIN sys_user su ON su.id = io.userid
+        LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
+        WHERE
+        iac.orderstatus = '3'
+        AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 1)
+        <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
+            AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
+        </if>
+        <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
+            AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
+        </if>
+        <if test="vo.userIds  !=null  and vo.userIds!=''  and vo.userIds.size()>0">
+            AND su.leader_id IN
+            <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY
+        io.userid
+        ) a
+        LEFT JOIN sys_user su ON a.userId = su.id
+        LEFT JOIN sys_dept sd ON sd.id = su.dept_id
         LEFT JOIN sys_user_role sur ON sur.user_id = su.id
-        <where>
-            1=1
-            <if test="vo.userId !=null  and vo.userId!=''">
-                and su.id=#{vo.userId}
-            </if>
-            <if test="vo.userIds  !=null  and vo.userIds!=''  and vo.userIds.size()>0">
-                and su.leader_id in
-                <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-            <if test="vo.userName !=null  and vo.userName!=''">
-                and su.name=#{vo.userName}
-            </if>
-
-            <if test="vo.managementSource !=null  and vo.managementSource!=''">
-                and sd.management_source=#{vo.managementSource}
-            </if>
-
-            <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
-                AND sd.id in
-                <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-
-            <if test="vo.leaderName !=null  and vo.leaderName!=''">
-                and su.leader_name=#{vo.leaderName}
-            </if>
-
-            <if test="vo.deptId !=null  and vo.deptId!=''">
-                and sd.id like concat('%',#{vo.deptId},'%')
-            </if>
-            <choose>
-                <when  test='vo.managementSource == "2"'>
-                    and (sur.role_id = 20  or  sur.role_id = 21)
-                </when>
-                <when  test='vo.managementSource == "1"'>
-                    and (sur.role_id = 19  or  sur.role_id = 21)
-                </when>
-                <otherwise>
-                </otherwise>
-            </choose>
-        </where>
+        WHERE
+        1 = 1
+        <if test="vo.userId !=null  and vo.userId!=''">
+            AND su.id = #{vo.userId}
+        </if>
+        <if test="vo.userName !=null  and vo.userName!=''">
+            AND su.name = #{vo.userName}
+        </if>
+        <if test="vo.managementSource !=null  and vo.managementSource!=''">
+            AND sd.management_source = #{vo.managementSource}
+        </if>
+        <choose>
+            <when test='vo.managementSource == "2"'>
+                AND (sur.role_id = 20 OR sur.role_id = 21)
+            </when>
+            <when test='vo.managementSource == "1"'>
+                AND (sur.role_id = 19 OR sur.role_id = 21)
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+        <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
+            AND sd.id IN
+            <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="vo.deptId !=null  and vo.deptId!=''">
+            AND sd.id LIKE CONCAT('%', #{vo.deptId}, '%')
+        </if>
+        ) a
     </select>
 
     <select id="getBusinessAgentDataTotalAdd" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
@@ -185,17 +182,16 @@
             +IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as "exportAllFee"
         from ins_area_company iac
                  left join ins_orders io on io.orderno =iac.orderno
-                 left join sys_user su on io.userid =su.id
-                 left join sys_dept sd on sd.id =su.dept_id
+                 left join sys_dept sd on sd.id =io.deptid
                  LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
         <where>
         iac.orderstatus = '3'
-            and  (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
+            and  (iac.del_flag = '1' )
             <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
-                AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
+                AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
             </if>
             <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
-                AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
+                AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
             </if>
 
             <if test="vo.days !=null  and vo.days !=''  and vo.days != 0 ">
@@ -203,15 +199,15 @@
             </if>
 
             <if test="vo.userName !=null  and vo.userName!=''">
-                and su.name=#{vo.userName}
+                and io.userName=#{vo.userName}
             </if>
 
-            <if test="vo.userId !=null  and vo.userId!=''">
-                and su.id=#{vo.userId}
+            <if test="vo.userId !=null  and vo.userId !=''">
+                and io.userid=#{vo.userId}
             </if>
 
             <if test="vo.userIds  !=null  and vo.userIds!=''  and vo.userIds.size()>0">
-                and su.leader_id in
+                and iac.leader_id in
                 <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
                     #{item}
                 </foreach>
@@ -231,7 +227,7 @@
                 </foreach>
             </if>
             <if test="vo.leaderName !=null  and vo.leaderName!=''">
-                and su.leader_name=#{vo.leaderName}
+                and iac.leader_name=#{vo.leaderName}
             </if>
         </where>
     </select>
@@ -249,33 +245,26 @@
            and  iac.orderstatus ='3'
             and iac.del_flag = '1'
             <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
-                AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
+                AND iac.signing_time  BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
             </if>
             <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
-                AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
+                AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
             </if>
-
             <if test="vo.leaderName !=null  and vo.leaderName!=''">
                 and su.leader_name=#{vo.leaderName}
             </if>
-
             <if test="vo.userName !=null  and vo.userName!=''">
                 and su.name=#{vo.userName}
             </if>
-
             <if test="vo.userId !=null  and vo.userId!=''">
                 and su.id=#{vo.userId}
             </if>
-
             <if test="vo.proportionUserIds  !=null  and vo.proportionUserIds!=''  and vo.proportionUserIds.size()>0">
                 and su.id in
                 <foreach collection="vo.proportionUserIds" item="item" open="(" separator="," close=")">
                     #{item}
                 </foreach>
             </if>
-
-
-
 <!--            <if test="vo.userIds  !=null  and vo.userIds!=''  and vo.userIds.size()>0">-->
 <!--                and su.leader_id in-->
 <!--                <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">-->
@@ -331,10 +320,10 @@
             </if>
 
             <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
-                AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
+                AND iac.signing_time BETWEEN#{vo.signingTimeStart} AND #{vo.signingTimeEnd}
             </if>
             <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
-                AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
+                AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
             </if>
 
             <if test="vo.managementSource !=null  and vo.managementSource!=''">
@@ -372,10 +361,10 @@
                   </if>
 
                   <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
-                      AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
+                      AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND DATE_FORMAT(#{vo.signingTimeEnd}
                   </if>
                   <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
-                      AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
+                      AND iac.createtime BETWEEN  #{vo.enterTimeStart} AND DATE_FORMAT(#{vo.enterTimeEnd}
                   </if>
 
                   <if test="vo.managementSource !=null  and vo.managementSource!=''">
@@ -393,11 +382,15 @@
         COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
         COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
         COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
-        COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
-        COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "closeRate",
-        (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN  iot.order_status = '2'  THEN 1 END ))/ COUNT(
-        CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "contributionRate",
-        COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "quotationRate",
+        COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
+        "passingRate",
+        COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in
+        ('0','1','2','3','4') THEN 1 END ) AS "closeRate",
+        (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/
+        COUNT(
+        CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "contributionRate",
+        COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in
+        ('0','1','2','3','4') THEN 1 END ) AS "quotationRate",
         COUNT(CASE WHEN io.order_source = 0 and iot.order_status = '0' THEN 1 END) as "pcOrderSource",
         COUNT(CASE WHEN io.order_source = 1 and iot.order_status = '0' THEN 1 END) as "appOrderSource",
         COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
@@ -406,7 +399,7 @@
         select iot.suborder,iot.order_status from `ins_orders_track` iot
         GROUP BY iot.suborder ,iot.order_status
         ) iot
-        left join ins_area_company  iac ON iac.id = iot.suborder
+        left join ins_area_company iac ON iac.id = iot.suborder
         LEFT JOIN ins_orders io ON io.orderno = iac.orderno
         LEFT JOIN sys_dept sd ON sd.id = io.deptid
         <where>
@@ -432,12 +425,10 @@
             </if>
 
             <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
-                AND DATE_FORMAT( ica.signing_time, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND
-                #{taskStatisticsVo.createtimeEnd}
+                AND ica.signing_time BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
             </if>
             <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
-                AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate},
-                '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
+                AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
             </if>
         </where>
         GROUP BY
@@ -486,12 +477,10 @@
                 AND su.id = #{vo.userId}
             </if>
             <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
-                AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d')
-                AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
+                AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
             </if>
             <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
-                AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d')
-                AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
+                AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
             </if>
         </where>
         GROUP BY
@@ -530,135 +519,127 @@
 
     <select id="getBusinessAgentDataExcel"  resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
         select
-        su.id as "userId",
-        su.name as "userName",
-        sd.id as "deptId",
-        su.leader_name as "leaderName",
-        IFNULL(a.sumpremium,0) as "sumpremium",
-        IFNULL(a.jqpremium,0) as "jqpremium",
-        IFNULL(a.sypremium,0) as "sypremium",
-        IFNULL(a.taxamount,0) as "taxamount",
-        IFNULL(a.jypremium,0) as "jypremium",
-        IFNULL(a.riskCodeJs,0) as "riskCodeJs",
-        IFNULL(a.riskCodeDj,0) as "riskCodeDj" ,
-        IFNULL(a.riskCodeJshang,0) as "riskCodeJshang",
-        IFNULL(a.riskCodeDs,0) as "riskCodeDs",
-        IFNULL(a.riskCodeDsan,0) as "riskCodeDsan",
-        sd.management_source as "managementSource",
-        IFNULL(IFNULL(a.entranceAllFee,0) -IFNULL(a.exportAllFee,0),0)  as  "distributionAmount",
-        (IFNULL(IFNULL(a.entranceAllFee,0) -IFNULL(a.exportAllFee,0),0)) / a.sumpremium as "distributionAmountRate"
-        from sys_user su
-        left join sys_dept sd on sd.id =su.dept_id
-        LEFT JOIN sys_user_role sur ON sur.user_id = su.id
-        left join (
+        a.userId as "userId",
+        a.userName as "userName",
+        a.deptId as "deptId",
+        a.leaderName as "leaderName",
+        COALESCE(a.sumpremium, 0) as "sumpremium",
+        COALESCE(a.jqpremium, 0) as "jqpremium",
+        COALESCE(a.sypremium, 0) as "sypremium",
+        COALESCE(a.taxamount, 0) as "taxamount",
+        COALESCE(a.jypremium, 0) as "jypremium",
+        COALESCE(a.riskCodeJs, 0) as "riskCodeJs",
+        COALESCE(a.riskCodeDj, 0) as "riskCodeDj",
+        COALESCE(a.riskCodeJshang, 0) as "riskCodeJshang",
+        COALESCE(a.riskCodeDs, 0) as "riskCodeDs",
+        COALESCE(a.riskCodeDsan, 0) as "riskCodeDsan",
+        a.managementSource as "managementSource",
+        COALESCE(a.entranceAllFee - a.exportAllFee, 0) as "distributionAmount",
+        CASE WHEN a.sumpremium > 0 THEN (COALESCE(a.entranceAllFee - a.exportAllFee, 0) / a.sumpremium) ELSE 0 END as "distributionAmountRate"
+        from (
         select
         io.userid as "userId",
-        sum(IFNULL(jqpremium, 0) + IFNULL(sypremium, 0)+ IFNULL(jypremium, 0)) as "sumpremium",
-        IFNULL(sum(jqpremium),0) as "jqpremium",
-        IFNULL(sum(sypremium),0) as "sypremium",
-        IFNULL(sum(taxamount),0) as "taxamount",
-        IFNULL(sum(jypremium),0) as "jypremium",
-        COUNT( CASE WHEN iac.product = '交三'  THEN 1 END ) AS "riskCodeJs",
-        COUNT( CASE WHEN iac.product = '单交'  THEN 1 END ) AS "riskCodeDj",
-        COUNT( CASE WHEN iac.product = '交商'  THEN 1 END ) AS "riskCodeJshang",
-        COUNT( CASE WHEN iac.product = '单商'  THEN 1 END ) AS "riskCodeDs",
-        COUNT( CASE WHEN iac.product = '单三'  THEN 1 END ) AS "riskCodeDsan",
-        ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL
-        (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
-        ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
-        +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
-        +IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as "exportAllFee"
-        from ins_area_company iac
-        left join ins_orders io on io.orderno =iac.orderno
-        left join  sys_user  su  on su.id =io.userid
+        io.username as "userName",
+        sd.id as "deptId",
+        sd.management_source as "managementSource",
+        iac.leader_name as "leaderName",
+        sum(COALESCE(jqpremium, 0) + COALESCE(sypremium, 0) + COALESCE(jypremium, 0)) as "sumpremium",
+        sum(COALESCE(jqpremium, 0)) as "jqpremium",
+        sum(COALESCE(sypremium, 0)) as "sypremium",
+        sum(COALESCE(taxamount, 0)) as "taxamount",
+        sum(COALESCE(jypremium, 0)) as "jypremium",
+        COUNT(CASE WHEN iac.product = '交三' THEN 1 END) AS "riskCodeJs",
+        COUNT(CASE WHEN iac.product = '单交' THEN 1 END) AS "riskCodeDj",
+        COUNT(CASE WHEN iac.product = '交商' THEN 1 END) AS "riskCodeJshang",
+        COUNT(CASE WHEN iac.product = '单商' THEN 1 END) AS "riskCodeDs",
+        COUNT(CASE WHEN iac.product = '单三' THEN 1 END) AS "riskCodeDsan",
+        ROUND(sum(COALESCE(ifon.jq_costs_premiums, 0) + COALESCE(ifon.sy_costs_premiums, 0) + COALESCE(ifon.no_costs_premiums, 0)), 2) as "entranceAllFee",
+        ROUND(sum(COALESCE(jq_export_other_costs_premiums, 0) + COALESCE(jq_export_supervise_costs_premiums, 0)
+        + COALESCE(sy_export_other_costs_premiums, 0) + COALESCE(sy_export_supervise_costs_premiums, 0)
+        + COALESCE(no_export_other_costs_premiums, 0) + COALESCE(no_export_supervise_costs_premiums, 0)), 2) as "exportAllFee"
+        from (
+        select *
+        from ins_area_company
+        where orderstatus = '3'
+        and (del_flag = '1')
+        <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
+            AND signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
+        </if>
+        <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
+            AND createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
+        </if>
+        <if test="vo.userIds  !=null  and vo.userIds!=''  and vo.userIds.size()>0">
+            and leader_id in
+            <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="vo.leaderName !=null  and vo.leaderName!=''">
+            and leader_name=#{vo.leaderName}
+        </if>
+        ) iac
+        left join ins_orders io on io.orderno = iac.orderno
         LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
+        left join sys_dept sd on sd.id = io.deptid
+        LEFT JOIN sys_user_role sur ON sur.user_id = io.userid
         <where>
-            iac.orderstatus = '3'
-            <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
-                AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
-            </if>
-            <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
-                AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
-            </if>
-
-            <if test="vo.userIds  !=null  and vo.userIds!=''  and vo.userIds.size()>0">
-                and su.leader_id in
-                <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-
-        </where>
-        group by io.userid
-        ) a  on  a.userId  =su.id
-        <where>
-            1=1
             <if test="vo.userId !=null  and vo.userId!=''">
-                and su.id=#{vo.userId}
+                and io.userid=#{vo.userId}
             </if>
-
             <if test="vo.userName !=null  and vo.userName!=''">
-                and su.name=#{vo.userName}
+                and io.username=#{vo.userName}
             </if>
-
             <if test="vo.managementSource !=null  and vo.managementSource!=''">
                 and sd.management_source=#{vo.managementSource}
             </if>
-
-            <if test="vo.userIds  !=null  and vo.userIds!=''  and vo.userIds.size()>0">
-                and su.leader_id in
-                <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-
             <choose>
-                <when  test='vo.managementSource == "2"'>
-                    and (sur.role_id = 20  or  sur.role_id = 21)
+                <when test='vo.managementSource == "2"'>
+                    and (sur.role_id = 20 or sur.role_id = 21)
                 </when>
-                <when  test='vo.managementSource == "1"'>
-                    and (sur.role_id = 19  or  sur.role_id = 21)
+                <when test='vo.managementSource == "1"'>
+                    and (sur.role_id = 19 or sur.role_id = 21)
                 </when>
                 <otherwise>
                 </otherwise>
             </choose>
-
             <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
                 AND sd.id in
                 <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
                     #{item}
                 </foreach>
             </if>
-
             <if test="vo.deptId !=null  and vo.deptId!=''">
-                and sd.id like concat('%',#{vo.deptId},'%')
+                and sd.id like concat('%', #{vo.deptId}, '%')
             </if>
         </where>
-        order by  a.sumpremium  desc ,su.id
+        group by io.userid, io.username, io.deptid, iac.leader_name, sd.management_source
+        ) a
+        order by a.sumpremium desc, a.userId
     </select>
 
     <select id="ordersDetailsExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDetailsExcel">
         select
-            io.userid as "userId",
-            iac.leader_name as "leaderName",
-            su.name as "userName",
-            io.licenseno as "licenseno",
-            sd.management_source as "managementSource",
-            io.orderno as "orderno",
-            iot.order_status as "orderStatus",
-            io.order_source  as "orderSource",
-            iac.entry_status  as "entryStatus",
-            ins.namesimple as "partnerCompaniesName",
-            agree.insurance_company as "inscompany"
-        from (select iot.suborder, iot.order_status  from `ins_orders_track` iot GROUP BY iot.suborder, iot.order_status) iot
-                 left join ins_area_company iac ON iac.id = iot.suborder
-                 LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
-                 LEFT JOIN ins_orders io ON io.orderno = iac.orderno
-                 LEFT JOIN sys_dept sd ON sd.id = io.deptid
-                 LEFT JOIN sys_user  su on  su.id =io.userid
-                 LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
+        io.userid as "userId",
+        iac.leader_name as "leaderName",
+        su.name as "userName",
+        io.licenseno as "licenseno",
+        sd.management_source as "managementSource",
+        io.orderno as "orderno",
+        iot.order_status as "orderStatus",
+        io.order_source as "orderSource",
+        iac.entry_status as "entryStatus",
+        ins.namesimple as "partnerCompaniesName",
+        agree.insurance_company as "inscompany"
+        from (select iot.suborder, iot.order_status from `ins_orders_track` iot GROUP BY iot.suborder, iot.order_status)
+        iot
+        left join ins_area_company iac ON iac.id = iot.suborder
+        LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
+        LEFT JOIN ins_orders io ON io.orderno = iac.orderno
+        LEFT JOIN sys_dept sd ON sd.id = io.deptid
+        LEFT JOIN sys_user su on su.id =io.userid
+        LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
         <where>
-             (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
+            (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
             <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
                 and io.deptid like "${taskStatisticsVo.provinceId}%"
             </if>
@@ -677,20 +658,20 @@
             </if>
 
             <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
-                AND   DATE_FORMAT( io.createtime, '%Y-%m-%d')   BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
+                AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
             </if>
             <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
-                AND   DATE_FORMAT( iac.createtime, '%Y-%m-%d')   BETWEEN  DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND  DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
+                AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
             </if>
 
             <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
-                AND sd.id  in
+                AND sd.id in
                 <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
                     #{item}
                 </foreach>
             </if>
             <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
-                AND io.userid  in
+                AND io.userid in
                 <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
                     #{item}
                 </foreach>

File diff ditekan karena terlalu besar
+ 323 - 285
src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml


+ 1 - 1
src/main/resources/mapper/modules/order/InsOrdersMapper.xml

@@ -433,7 +433,7 @@
             </choose>
         </where>
         group by
-        orderno
+        orderno, io.createtime
         order by io.createtime desc
     </select>
 

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini