Просмотр исходного кода

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

Qchen 1 год назад
Родитель
Сommit
d111ed86b8
25 измененных файлов с 1111 добавлено и 418 удалено
  1. 14 14
      src/main/java/com/ydtech/modules/admin/controller/APPPartnerController.java
  2. 4 2
      src/main/java/com/ydtech/modules/admin/controller/SysPcAddressController.java
  3. 4 2
      src/main/java/com/ydtech/modules/admin/controller/websocket/SysGeographyPositionController.java
  4. 4 4
      src/main/java/com/ydtech/modules/admin/dao/SysGeographyPositionRecordMapper.java
  5. 4 4
      src/main/java/com/ydtech/modules/admin/dao/SysPcAddressHistoryMapper.java
  6. 11 0
      src/main/java/com/ydtech/modules/admin/model/PartnerInfoVo.java
  7. 4 0
      src/main/java/com/ydtech/modules/admin/model/SysProportionConfig.java
  8. 7 0
      src/main/java/com/ydtech/modules/admin/model/report/profitAnalysis/ProfitAnalysisDto.java
  9. 4 0
      src/main/java/com/ydtech/modules/admin/model/report/profitAnalysis/ProfitAnalysisQueryDto.java
  10. 1 1
      src/main/java/com/ydtech/modules/admin/service/SysGeographyPositionService.java
  11. 1 1
      src/main/java/com/ydtech/modules/admin/service/SysPcAddressService.java
  12. 160 7
      src/main/java/com/ydtech/modules/admin/service/impl/ProfitAnalysisServiceImpl.java
  13. 190 52
      src/main/java/com/ydtech/modules/admin/service/impl/SysGeographyPositionServiceImpl.java
  14. 111 246
      src/main/java/com/ydtech/modules/admin/service/impl/SysPartnerServiceImpl.java
  15. 189 54
      src/main/java/com/ydtech/modules/admin/service/impl/SysPcAddressServiceImpl.java
  16. 31 0
      src/main/java/com/ydtech/modules/console/dao/ProfitAnalysisMapper.java
  17. 3 0
      src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceNewImpl.java
  18. 3 0
      src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java
  19. 8 6
      src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java
  20. 3 1
      src/main/java/com/ydtech/modules/order/controller/QuoteController.java
  21. 11 1
      src/main/java/com/ydtech/modules/order/service/impl/InsOrdersServiceImpl.java
  22. 6 0
      src/main/resources/mapper/modules/admin/SysGeographyPositionRecordMapper.xml
  23. 12 0
      src/main/resources/mapper/modules/admin/SysPcAddressHistoryMapper.xml
  24. 199 7
      src/main/resources/mapper/modules/console/ProfitAnalysisMapper.xml
  25. 127 16
      src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

+ 14 - 14
src/main/java/com/ydtech/modules/admin/controller/APPPartnerController.java

@@ -31,7 +31,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "APP首页信息")
     @ApiOperation(value = "APP首页信息")
     public HttpResult<AppPartnerNumVo> getHomePage(@RequestParam("type") Integer type) {
     public HttpResult<AppPartnerNumVo> getHomePage(@RequestParam("type") Integer type) {
 
 
-        return HttpResult.ok(this.sysPartnerService.getHomePage(type));
+        return HttpResult.ok("success", this.sysPartnerService.getHomePage(type));
     }
     }
 
 
 
 
@@ -44,7 +44,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "APP个人信息")
     @ApiOperation(value = "APP个人信息")
     public HttpResult<AppUserInfoVo> getUserInfo(@RequestParam("type") Integer type) {
     public HttpResult<AppUserInfoVo> getUserInfo(@RequestParam("type") Integer type) {
 
 
-        return HttpResult.ok(this.sysPartnerService.getUserInfo(type));
+        return HttpResult.ok("success",this.sysPartnerService.getUserInfo(type));
     }
     }
 
 
     /**
     /**
@@ -56,7 +56,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "APP账户金额")
     @ApiOperation(value = "APP账户金额")
     public HttpResult<SysPartnerAccount> getFee() {
     public HttpResult<SysPartnerAccount> getFee() {
 
 
-        return HttpResult.ok(this.sysPartnerService.getFee());
+        return HttpResult.ok("success",this.sysPartnerService.getFee());
     }
     }
 
 
 
 
@@ -69,7 +69,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "APP登陆人下的每个等级合伙人统计信息")
     @ApiOperation(value = "APP登陆人下的每个等级合伙人统计信息")
     public HttpResult<List<AppSysPartnerVo>> partnerInfo(@RequestBody PartnerInfoDto partnerInfoDto) {
     public HttpResult<List<AppSysPartnerVo>> partnerInfo(@RequestBody PartnerInfoDto partnerInfoDto) {
 
 
-        return HttpResult.ok(this.sysPartnerService.partnerInfo(partnerInfoDto));
+        return HttpResult.ok("success",this.sysPartnerService.partnerInfo(partnerInfoDto));
     }
     }
 
 
     /**
     /**
@@ -79,7 +79,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "合伙人工作室详情")
     @ApiOperation(value = "合伙人工作室详情")
     public HttpResult<PartnerLeaderInfoVo> partnerLeaderInfo(@RequestBody PartnerGradeInfo partnerGradeInfo) {
     public HttpResult<PartnerLeaderInfoVo> partnerLeaderInfo(@RequestBody PartnerGradeInfo partnerGradeInfo) {
 
 
-        return HttpResult.ok(this.sysPartnerService.partnerLeaderInfo(partnerGradeInfo));
+        return HttpResult.ok("success",this.sysPartnerService.partnerLeaderInfo(partnerGradeInfo));
     }
     }
 
 
 
 
@@ -91,7 +91,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "筛选合伙人详情")
     @ApiOperation(value = "筛选合伙人详情")
     public HttpResult<FilterPartnerInfoVo> queryFilterPartnerInfo(@RequestBody FilterPartnerInfoDto filterPartnerInfoDto) {
     public HttpResult<FilterPartnerInfoVo> queryFilterPartnerInfo(@RequestBody FilterPartnerInfoDto filterPartnerInfoDto) {
 
 
-        return HttpResult.ok(this.sysPartnerService.queryFilterPartnerInfo(filterPartnerInfoDto));
+        return HttpResult.ok("success",this.sysPartnerService.queryFilterPartnerInfo(filterPartnerInfoDto));
     }
     }
 
 
     /**
     /**
@@ -103,7 +103,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "等级合伙人详情")
     @ApiOperation(value = "等级合伙人详情")
     public HttpResult<PartnerInfoFreeVo> queryPartnerInfo(@RequestBody PartnerGradeInfo partnerGradeInfo) {
     public HttpResult<PartnerInfoFreeVo> queryPartnerInfo(@RequestBody PartnerGradeInfo partnerGradeInfo) {
 
 
-        return HttpResult.ok(this.sysPartnerService.queryPartnerInfo(partnerGradeInfo));
+        return HttpResult.ok("success",this.sysPartnerService.queryPartnerInfo(partnerGradeInfo));
     }
     }
 
 
 
 
@@ -114,14 +114,14 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "查看机构下团队信息")
     @ApiOperation(value = "查看机构下团队信息")
     public HttpResult<APPPartnerInfoFreeVo> getTeamInfo(@RequestBody PartnerGradeInfo partnerGradeInfo) {
     public HttpResult<APPPartnerInfoFreeVo> getTeamInfo(@RequestBody PartnerGradeInfo partnerGradeInfo) {
 
 
-        return HttpResult.ok(this.sysPartnerService.getTeamInfo(partnerGradeInfo));
+        return HttpResult.ok("success",this.sysPartnerService.getTeamInfo(partnerGradeInfo));
     }
     }
 
 
     @PostMapping("/getTeamUserInfo")
     @PostMapping("/getTeamUserInfo")
     @ApiOperation(value = "查看团队下人员信息")
     @ApiOperation(value = "查看团队下人员信息")
     public HttpResult<TeamUserInfosFreeVo> getTeamUserInfo(@RequestBody TeamUserInfosDto teamUserInfosDto) {
     public HttpResult<TeamUserInfosFreeVo> getTeamUserInfo(@RequestBody TeamUserInfosDto teamUserInfosDto) {
 
 
-        return HttpResult.ok(this.sysPartnerService.getTeamUserInfo(teamUserInfosDto));
+        return HttpResult.ok("success",this.sysPartnerService.getTeamUserInfo(teamUserInfosDto));
     }
     }
 
 
     /**
     /**
@@ -137,7 +137,7 @@ public class APPPartnerController extends BaseController {
             commissionInfoDto.setPageSize(10);
             commissionInfoDto.setPageSize(10);
         }
         }
 
 
-        return HttpResult.ok(this.sysPartnerService.getCommissionInfo(commissionInfoDto));
+        return HttpResult.ok("success",this.sysPartnerService.getCommissionInfo(commissionInfoDto));
     }
     }
     /**
     /**
      *  app工作室新增人员统计
      *  app工作室新增人员统计
@@ -146,7 +146,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "app工作室新增人员统计")
     @ApiOperation(value = "app工作室新增人员统计")
     public HttpResult<CountUserVo> getCountUser(@RequestBody CountUserDto countUserDto) {
     public HttpResult<CountUserVo> getCountUser(@RequestBody CountUserDto countUserDto) {
 
 
-        return HttpResult.ok(this.sysPartnerService.getCountUser(countUserDto));
+        return HttpResult.ok("success",this.sysPartnerService.getCountUser(countUserDto));
     }
     }
     /**
     /**
      *  app合伙人新增人员统计
      *  app合伙人新增人员统计
@@ -155,7 +155,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "app合伙人新增人员统计")
     @ApiOperation(value = "app合伙人新增人员统计")
     public HttpResult<PartnerCountVo> getPartnerCount(@RequestBody PartnerCountDto partnerCountDto) {
     public HttpResult<PartnerCountVo> getPartnerCount(@RequestBody PartnerCountDto partnerCountDto) {
 
 
-        return HttpResult.ok(this.sysPartnerService.getPartnerCount(partnerCountDto));
+        return HttpResult.ok("success",this.sysPartnerService.getPartnerCount(partnerCountDto));
     }
     }
     /**
     /**
      * 新增人员占比分析
      * 新增人员占比分析
@@ -164,7 +164,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "新增人员占比分析")
     @ApiOperation(value = "新增人员占比分析")
     public HttpResult<PartnerProportionVo> getPartnerProportion(@RequestBody PartnerCountDto partnerCountDto) {
     public HttpResult<PartnerProportionVo> getPartnerProportion(@RequestBody PartnerCountDto partnerCountDto) {
 
 
-        return HttpResult.ok(this.sysPartnerService.getPartnerProportion(partnerCountDto));
+        return HttpResult.ok("success",this.sysPartnerService.getPartnerProportion(partnerCountDto));
     }
     }
 
 
     /**
     /**
@@ -174,7 +174,7 @@ public class APPPartnerController extends BaseController {
     @ApiOperation(value = "排行榜")
     @ApiOperation(value = "排行榜")
     public HttpResult<List<LevelPartnerVo>> getLevelPartner(@RequestParam("type") @ApiParam("等级:1、2、3、4、5") Integer type) {
     public HttpResult<List<LevelPartnerVo>> getLevelPartner(@RequestParam("type") @ApiParam("等级:1、2、3、4、5") Integer type) {
 
 
-        return HttpResult.ok(this.sysPartnerService.getLevelPartner(type));
+        return HttpResult.ok("success",this.sysPartnerService.getLevelPartner(type));
     }
     }
 
 
 
 

+ 4 - 2
src/main/java/com/ydtech/modules/admin/controller/SysPcAddressController.java

@@ -154,9 +154,11 @@ public class SysPcAddressController extends BaseController{
     @ApiOperation(value = "历史在线人数")
     @ApiOperation(value = "历史在线人数")
     public HttpResult<PcAddressHistoryInfoVo> getPcAddress(@RequestParam(value = "startTime",required = false) String startTime,
     public HttpResult<PcAddressHistoryInfoVo> getPcAddress(@RequestParam(value = "startTime",required = false) String startTime,
                                                            @RequestParam(value = "endTime",required = false) String endTime,
                                                            @RequestParam(value = "endTime",required = false) String endTime,
-                                                           @RequestParam(value = "source",required = false) String source) {
+                                                           @RequestParam(value = "source",required = false) String source,
+                                                           @RequestParam(value = "queryId",required = false) String queryId,
+                                                           @RequestParam(value = "type") Integer type) {
 
 
-        return HttpResult.ok("success", this.sysPcAddressService.getPcAddress(startTime,endTime,source));
+        return HttpResult.ok("success", this.sysPcAddressService.getPcAddress(startTime,endTime,source,queryId,type));
     }
     }
 
 
     @GetMapping("/getOnlinePeople")
     @GetMapping("/getOnlinePeople")

+ 4 - 2
src/main/java/com/ydtech/modules/admin/controller/websocket/SysGeographyPositionController.java

@@ -125,9 +125,11 @@ public class SysGeographyPositionController extends BaseController {
     @ApiOperation(value = "历史在线人数")
     @ApiOperation(value = "历史在线人数")
     public HttpResult<AppGeographyHistoryInfoVo> getGeographyPosition(@RequestParam(value = "startTime",required = false) String startTime,
     public HttpResult<AppGeographyHistoryInfoVo> getGeographyPosition(@RequestParam(value = "startTime",required = false) String startTime,
                                                                       @RequestParam(value = "endTime",required = false) String endTime,
                                                                       @RequestParam(value = "endTime",required = false) String endTime,
-                                                                      @RequestParam(value = "source",required = false) String source) {
+                                                                      @RequestParam(value = "source",required = false) String source,
+                                                                      @RequestParam(value = "queryId",required = false) String queryId,
+                                                                      @RequestParam(value = "type") Integer type) {
 
 
-        return HttpResult.ok("success", this.sysGeographyPositionService.getGeographyPosition(startTime,endTime,source));
+        return HttpResult.ok("success", this.sysGeographyPositionService.getGeographyPosition(startTime,endTime,source,queryId,type));
     }
     }
 
 
     @GetMapping("/getOnlinePeople")
     @GetMapping("/getOnlinePeople")

+ 4 - 4
src/main/java/com/ydtech/modules/admin/dao/SysGeographyPositionRecordMapper.java

@@ -23,13 +23,13 @@ import java.util.List;
 public interface SysGeographyPositionRecordMapper extends BaseMapper<SysGeographyPositionRecord> {
 public interface SysGeographyPositionRecordMapper extends BaseMapper<SysGeographyPositionRecord> {
 
 
 
 
-    List<PcAddressHistoryTimeVo> getGeographyPosition(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect);
+    List<PcAddressHistoryTimeVo> getGeographyPosition(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
 
-    List<SysGeographyPositionRecord> getGeographyPositionRecord(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect);
+    List<SysGeographyPositionRecord> getGeographyPositionRecord(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
 
-    List<PcAddressHistoryTimeVo> getGeographyPositionSection(@Param("startTime")String startTime, @Param("endTime") String endTime, @Param("source") String source,@Param("collect") List<String> collect);
+    List<PcAddressHistoryTimeVo> getGeographyPositionSection(@Param("startTime")String startTime, @Param("endTime") String endTime, @Param("source") String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
 
-    List<SysGeographyPositionRecord> getGeographyPositionHistory(@Param("startTime")String startTime, @Param("endTime") String endTime, @Param("source") String source,@Param("collect") List<String> collect);
+    List<SysGeographyPositionRecord> getGeographyPositionHistory(@Param("startTime")String startTime, @Param("endTime") String endTime, @Param("source") String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
 
     IPage<SysGeographyPositionInfoVo> queryGeographyHistory(Page page, @Param("dto")  PcAddressInfoDto addressInfoDto);
     IPage<SysGeographyPositionInfoVo> queryGeographyHistory(Page page, @Param("dto")  PcAddressInfoDto addressInfoDto);
 }
 }

+ 4 - 4
src/main/java/com/ydtech/modules/admin/dao/SysPcAddressHistoryMapper.java

@@ -18,13 +18,13 @@ import java.util.List;
 */
 */
 public interface SysPcAddressHistoryMapper extends BaseMapper<SysPcAddressHistory> {
 public interface SysPcAddressHistoryMapper extends BaseMapper<SysPcAddressHistory> {
 
 
-    List<PcAddressHistoryTimeVo> getPcAddress(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect);
+    List<PcAddressHistoryTimeVo> getPcAddress(@Param("dates") String dates, @Param("source")String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
 
-    List<SysPcAddressHistory> getPcAddressInfo(@Param("dates") String dates, @Param("source") String source,@Param("collect") List<String> collect);
+    List<SysPcAddressHistory> getPcAddressInfo(@Param("dates") String dates, @Param("source") String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
 
-    List<PcAddressHistoryTimeVo> getPcAddressSection(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source,@Param("collect") List<String> collect);
+    List<PcAddressHistoryTimeVo> getPcAddressSection(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
 
-    List<SysPcAddressHistory> getPcAddressHistory(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source,@Param("collect") List<String> collect);
+    List<SysPcAddressHistory> getPcAddressHistory(@Param("startTime")String startTime, @Param("endTime") String endTime,@Param("source") String source,@Param("collect") List<String> collect,@Param("queryId") String queryId);
 
 
     IPage<SysPcAddressHistory> queryAddressHistory(Page page, @Param("dto") PcAddressInfoDto addressInfoDto);
     IPage<SysPcAddressHistory> queryAddressHistory(Page page, @Param("dto") PcAddressInfoDto addressInfoDto);
 }
 }

+ 11 - 0
src/main/java/com/ydtech/modules/admin/model/PartnerInfoVo.java

@@ -14,6 +14,17 @@ public class PartnerInfoVo {
     private String userId;
     private String userId;
     @ApiModelProperty(value = "合伙人Name")
     @ApiModelProperty(value = "合伙人Name")
     private String userName;
     private String userName;
+    /**
+     * 机构id
+     */
+    @ApiModelProperty(value = "机构id")
+    private String deptId;
+    /**
+     * 机构name
+     */
+    @ApiModelProperty(value = "机构name")
+    private String deptName;
+
     @ApiModelProperty(value = "推荐人Name")
     @ApiModelProperty(value = "推荐人Name")
     private String suggestName;
     private String suggestName;
 
 

+ 4 - 0
src/main/java/com/ydtech/modules/admin/model/SysProportionConfig.java

@@ -2,7 +2,9 @@ package com.ydtech.modules.admin.model;
 
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
 
 
@@ -13,6 +15,8 @@ import java.io.Serializable;
  * @since 2024-10-21 10:02:25
  * @since 2024-10-21 10:02:25
  */
  */
 @Data
 @Data
+@NoArgsConstructor
+@AllArgsConstructor
 public class SysProportionConfig implements Serializable {
 public class SysProportionConfig implements Serializable {
     private static final long serialVersionUID = -52994380963075044L;
     private static final long serialVersionUID = -52994380963075044L;
     /**
     /**

+ 7 - 0
src/main/java/com/ydtech/modules/admin/model/report/profitAnalysis/ProfitAnalysisDto.java

@@ -84,6 +84,13 @@ public class ProfitAnalysisDto {
     @ApiModelProperty("类目")
     @ApiModelProperty("类目")
     private String category;
     private String category;
 
 
+    @ApiModelProperty("子类目类目")
+    private String subcategory;
+
+
+    @ApiModelProperty("占比")
+    private String radio;
+
     @ApiModelProperty("子级")
     @ApiModelProperty("子级")
     private List<ProfitAnalysisDto> children;
     private List<ProfitAnalysisDto> children;
 
 

+ 4 - 0
src/main/java/com/ydtech/modules/admin/model/report/profitAnalysis/ProfitAnalysisQueryDto.java

@@ -50,4 +50,8 @@ public class ProfitAnalysisQueryDto {
     @ApiModelProperty("支出ids")
     @ApiModelProperty("支出ids")
     private List<String> expensesIds;
     private List<String> expensesIds;
 
 
+
+    @ApiModelProperty("类目ids")
+    private List<String> ids;
+
 }
 }

+ 1 - 1
src/main/java/com/ydtech/modules/admin/service/SysGeographyPositionService.java

@@ -24,7 +24,7 @@ public interface SysGeographyPositionService extends IService<SysGeographyPositi
     BasePageResult<SysGeographyPositionInfoVo> queryPcAddressInfo(PcAddressInfoDto addressInfoDto);
     BasePageResult<SysGeographyPositionInfoVo> queryPcAddressInfo(PcAddressInfoDto addressInfoDto);
     BasePageResult<SysGeographyPositionInfoVo> queryGeographyRecord(PcAddressInfoDto addressInfoDto);
     BasePageResult<SysGeographyPositionInfoVo> queryGeographyRecord(PcAddressInfoDto addressInfoDto);
 
 
-    AppGeographyHistoryInfoVo getGeographyPosition(String startTime, String endTime, String source);
+    AppGeographyHistoryInfoVo getGeographyPosition(String startTime, String endTime, String source,String queryId,Integer type);
 
 
     List<SysGeographyPosition> getOnlinePeople();
     List<SysGeographyPosition> getOnlinePeople();
 
 

+ 1 - 1
src/main/java/com/ydtech/modules/admin/service/SysPcAddressService.java

@@ -42,7 +42,7 @@ public interface SysPcAddressService extends IService<SysPcAddress> {
 
 
     BasePageResult<SysPcAddress> queryPcAddressInfo(PcAddressInfoDto addressInfoDto);
     BasePageResult<SysPcAddress> queryPcAddressInfo(PcAddressInfoDto addressInfoDto);
 
 
-    PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source);
+    PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source,String queryId,Integer type);
 
 
     List<SysPcAddress> getOnlinePeople();
     List<SysPcAddress> getOnlinePeople();
 
 

+ 160 - 7
src/main/java/com/ydtech/modules/admin/service/impl/ProfitAnalysisServiceImpl.java

@@ -1,23 +1,28 @@
 package com.ydtech.modules.admin.service.impl;
 package com.ydtech.modules.admin.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto;
 import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto;
 import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisQueryDto;
 import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisQueryDto;
 import com.ydtech.modules.admin.service.ProfitAnalysisService;
 import com.ydtech.modules.admin.service.ProfitAnalysisService;
 import com.ydtech.modules.admin.utils.SliceUpDateUtil;
 import com.ydtech.modules.admin.utils.SliceUpDateUtil;
 import com.ydtech.modules.console.dao.ProfitAnalysisMapper;
 import com.ydtech.modules.console.dao.ProfitAnalysisMapper;
 import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
 import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
+import com.ydtech.modules.inv.dao.InvAccountExpensesMapper;
 import com.ydtech.modules.inv.dao.InvAccountMapper;
 import com.ydtech.modules.inv.dao.InvAccountMapper;
 import com.ydtech.modules.inv.model.InvAccount;
 import com.ydtech.modules.inv.model.InvAccount;
 import com.ydtech.modules.inv.model.InvAccountCardVo;
 import com.ydtech.modules.inv.model.InvAccountCardVo;
 import com.ydtech.modules.inv.model.InvAccountExpenses;
 import com.ydtech.modules.inv.model.InvAccountExpenses;
 import com.ydtech.utils.BigDecimalUtils;
 import com.ydtech.utils.BigDecimalUtils;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 
 /**
 /**
  *  @version
  *  @version
@@ -35,6 +40,10 @@ public class ProfitAnalysisServiceImpl implements ProfitAnalysisService {
     @Autowired
     @Autowired
     private ProfitAnalysisMapper profitAnalysisMapper;
     private ProfitAnalysisMapper profitAnalysisMapper;
 
 
+
+    @Autowired
+    private InvAccountExpensesMapper invAccountExpensesMapper;
+
     /**
     /**
      *  @version
      *  @version
      *  @author: hxl
      *  @author: hxl
@@ -87,11 +96,32 @@ public class ProfitAnalysisServiceImpl implements ProfitAnalysisService {
     @Override
     @Override
     public List<ProfitAnalysisDto> getProfitAnalysisQueryDetailsList(ProfitAnalysisQueryDto profitAnalysisQueryDto) {
     public List<ProfitAnalysisDto> getProfitAnalysisQueryDetailsList(ProfitAnalysisQueryDto profitAnalysisQueryDto) {
         List<ProfitAnalysisDto> resultList =new ArrayList<>();
         List<ProfitAnalysisDto> resultList =new ArrayList<>();
-
+//          总支出=人员成本+固定成本+变动成本+税费
+        BigDecimal allExpenditure =this.getAllExpenditure(profitAnalysisQueryDto);
         if (StringUtils.isNotEmpty(profitAnalysisQueryDto.getExpensesType()) && "3".equals(profitAnalysisQueryDto.getExpensesType())) {
         if (StringUtils.isNotEmpty(profitAnalysisQueryDto.getExpensesType()) && "3".equals(profitAnalysisQueryDto.getExpensesType())) {
             List<ProfitAnalysisDto> profitAnalysisDtos =  profitAnalysisMapper.selectAccountExpenses(profitAnalysisQueryDto);
             List<ProfitAnalysisDto> profitAnalysisDtos =  profitAnalysisMapper.selectAccountExpenses(profitAnalysisQueryDto);
-            resultList.addAll(profitAnalysisDtos) ;
-            List<ProfitAnalysisDto> addVariableCost = new ArrayList<>();
+
+            Map<String, ProfitAnalysisDto> map = new HashMap<>();
+            for (ProfitAnalysisDto dto : profitAnalysisDtos) {
+                map.put(dto.getExpensesId(), dto);
+            }
+            ArrayList<ProfitAnalysisDto> parentExpenIdList = new ArrayList<>();
+            // 如果没有parentId为0 的子级 则构建
+            for (ProfitAnalysisDto profitAnalysisDto : profitAnalysisDtos) {
+                if(ObjectUtils.isEmpty(map.get(profitAnalysisDto.getParentId())) && !profitAnalysisDto.getParentId() .equals("0")){
+                    QueryWrapper<InvAccountExpenses> queryWrapper = new QueryWrapper<>();
+                    queryWrapper.eq("expenses_id", profitAnalysisDto.getParentId());
+                    InvAccountExpenses invAccountExpenses = invAccountExpensesMapper.selectOne(queryWrapper);
+                    ProfitAnalysisDto profitAnalysisDto1 = new ProfitAnalysisDto();
+                    profitAnalysisDto1.setExpensesId(invAccountExpenses.getExpensesId());
+                    profitAnalysisDto1.setParentId(invAccountExpenses.getParentId());
+                    profitAnalysisDto1.setCategory(invAccountExpenses.getCategory());
+                    parentExpenIdList.add(profitAnalysisDto1);
+                    map.put(profitAnalysisDto1.getExpensesId(),profitAnalysisDto1);
+                }
+            }
+            profitAnalysisDtos.addAll(parentExpenIdList);
+            List<ProfitAnalysisDto> addVariableCost = new ArrayList<>();  //变动成本金额
             List<ProfitAnalysisDto> profitAnalysisDto1 = insPlyIncomeMapper.changeAmount(profitAnalysisQueryDto);
             List<ProfitAnalysisDto> profitAnalysisDto1 = insPlyIncomeMapper.changeAmount(profitAnalysisQueryDto);
             for (ProfitAnalysisDto analysisDto : profitAnalysisDto1) {
             for (ProfitAnalysisDto analysisDto : profitAnalysisDto1) {
                 String outCardNum = analysisDto.getOutCardNum();
                 String outCardNum = analysisDto.getOutCardNum();
@@ -105,7 +135,6 @@ public class ProfitAnalysisServiceImpl implements ProfitAnalysisService {
                     }
                     }
                 }
                 }
             }
             }
-
             Map<String, BigDecimal> profitAnalysisDtoMap = addVariableCost.stream()
             Map<String, BigDecimal> profitAnalysisDtoMap = addVariableCost.stream()
                     .collect(Collectors.toMap(
                     .collect(Collectors.toMap(
                             ProfitAnalysisDto::getExpensesId,  // keyMapper,用于提取键(expensesId)
                             ProfitAnalysisDto::getExpensesId,  // keyMapper,用于提取键(expensesId)
@@ -113,19 +142,143 @@ public class ProfitAnalysisServiceImpl implements ProfitAnalysisService {
                             BigDecimal::add                    // mergeFunction,用于处理键冲突(相加 applyAmount)
                             BigDecimal::add                    // mergeFunction,用于处理键冲突(相加 applyAmount)
                     ));
                     ));
 
 
-            for (ProfitAnalysisDto profitAnalysisDto : resultList) {
+            for (ProfitAnalysisDto profitAnalysisDto : profitAnalysisDtos) {
                 String expensesId = profitAnalysisDto.getExpensesId();
                 String expensesId = profitAnalysisDto.getExpensesId();
                 if (profitAnalysisDtoMap.containsKey(expensesId)) {
                 if (profitAnalysisDtoMap.containsKey(expensesId)) {
                     BigDecimal bigDecimal = profitAnalysisDtoMap.get(expensesId);
                     BigDecimal bigDecimal = profitAnalysisDtoMap.get(expensesId);
                     profitAnalysisDto.setApplyAmount(bigDecimal);
                     profitAnalysisDto.setApplyAmount(bigDecimal);
                 }
                 }
             }
             }
-        }else {
-            resultList.addAll(profitAnalysisMapper.getAllAccountExpenses(profitAnalysisQueryDto));
+
+            for (ProfitAnalysisDto dto : profitAnalysisDtos) {
+                if (dto.getParentId().equals("0")) {
+                    BigDecimal totalAmount = aggregateChildAmounts(dto.getExpensesId(), map);
+                    dto.setApplyAmount(totalAmount);
+                }
+            }
+
+            for (ProfitAnalysisDto allAccountExpens : profitAnalysisDtos) {
+                BigDecimal applyAmount = allAccountExpens.getApplyAmount() != null ? allAccountExpens.getApplyAmount() : BigDecimal.ZERO;
+                if(applyAmount.compareTo(BigDecimal.ZERO)>0){
+                    allAccountExpens.setRadio(applyAmount.divide(allExpenditure,4,RoundingMode.HALF_UP).multiply(new BigDecimal("100")).toString());
+                }
+            }
+            resultList.addAll(profitAnalysisDtos) ;
+
+
+        } else {
+
+
+            /**
+             *  子类目金额
+             */
+            List<ProfitAnalysisDto> allAccountExpenses = profitAnalysisMapper.getAllAccountExpenses(profitAnalysisQueryDto);
+            //二级类目
+            List<String> collect = allAccountExpenses.stream().filter(item -> !item.getParentId().equals("0")).map(ProfitAnalysisDto::getExpensesId).collect(Collectors.toList());
+            profitAnalysisQueryDto.setIds(collect);
+
+            List<ProfitAnalysisDto> pidAmountList = profitAnalysisMapper.getSumCategory(profitAnalysisQueryDto);
+
+            Map<String, BigDecimal> amountMap = pidAmountList.stream().collect(Collectors.toMap(ProfitAnalysisDto::getParentId, ProfitAnalysisDto::getApplyAmount));
+            Map<String, List<String>> stringListMap = buildTreeMap(allAccountExpenses);
+            stringListMap.forEach((id ,children) ->{
+                profitAnalysisQueryDto.setExpensesIds(children);
+                ProfitAnalysisDto sumCategory = profitAnalysisMapper.getSumByparentAmount(profitAnalysisQueryDto);
+                if(!amountMap.containsKey(id) && ObjectUtils.isNotEmpty(sumCategory)){
+                    amountMap.put(id,sumCategory.getApplyAmount());
+
+                }
+            });
+            for (ProfitAnalysisDto allAccountExpens : allAccountExpenses) {
+                if (amountMap.containsKey(allAccountExpens.getExpensesId())) {
+                    allAccountExpens.setApplyAmount(amountMap.get(allAccountExpens.getExpensesId()));
+                }
+            }
+            for (ProfitAnalysisDto allAccountExpens : allAccountExpenses) {
+                BigDecimal applyAmount = allAccountExpens.getApplyAmount() != null ? allAccountExpens.getApplyAmount() : BigDecimal.ZERO;
+                if(applyAmount.compareTo(BigDecimal.ZERO)>0){
+                    allAccountExpens.setRadio(applyAmount.divide(allExpenditure,4,RoundingMode.HALF_UP).multiply(new BigDecimal("100")).toString());
+                }
+            }
+
+            resultList.addAll(allAccountExpenses);
         }
         }
         return getTree(resultList);
         return getTree(resultList);
     }
     }
 
 
+    private BigDecimal aggregateChildAmounts(String expensesId, Map<String, ProfitAnalysisDto> map) {
+        BigDecimal totalAmount = BigDecimal.ZERO;
+        for (ProfitAnalysisDto dto : map.values()) {
+            if (dto.getParentId() .equals(expensesId) ) {
+                totalAmount = totalAmount.add(dto.getApplyAmount() != null ? dto.getApplyAmount() : BigDecimal.ZERO);
+                totalAmount = totalAmount.add(aggregateChildAmounts(dto.getExpensesId(), map)); // 递归查找子对象
+            }
+        }
+        return totalAmount;
+    }
+
+    private BigDecimal getAllExpenditure(ProfitAnalysisQueryDto profitAnalysisQueryDto) {
+        HashMap<String, BigDecimal> sumExpenditure = profitAnalysisMapper.getTotalExpenditure(profitAnalysisQueryDto);
+//          查询变动成本
+        BigDecimal variableCost = BigDecimal.ZERO;
+        BigDecimal allExpenditure = BigDecimal.ZERO;
+
+
+        String yearAndMonth = profitAnalysisQueryDto.getYearAndMonth();
+        profitAnalysisQueryDto.setYearAndMonth(yearAndMonth);
+        List<ProfitAnalysisDto> profitAnalysisDto1 = insPlyIncomeMapper.changeAmount(profitAnalysisQueryDto);
+        for (ProfitAnalysisDto analysisDto : profitAnalysisDto1) {
+            String outCardNum = analysisDto.getOutCardNum();
+            String enterCardNum = analysisDto.getEnterCardNum();
+            InvAccountCardVo outAccount = invAccountMapper.getByCarNumber(outCardNum);
+            InvAccountCardVo enterAccount  = invAccountMapper.getByCarNumber(enterCardNum);
+            if(StringUtils.isNotEmpty(outAccount.getOuterFlag()) && StringUtils.isNotEmpty(enterAccount.getOuterFlag())){
+                if(!enterAccount.getOuterFlag().equals(outAccount.getOuterFlag())){
+                    variableCost=variableCost.add(analysisDto.getApplyAmount());
+                }
+            }
+        }
+        if(!sumExpenditure.isEmpty()){
+            BigDecimal fixedCost = sumExpenditure.get("fixedCost") != null ? sumExpenditure.get("fixedCost") : BigDecimal.ZERO;
+            BigDecimal laborCost = sumExpenditure.get("laborCost") != null ? sumExpenditure.get("laborCost") : BigDecimal.ZERO;
+            BigDecimal taxation = sumExpenditure.get("taxation") != null ? sumExpenditure.get("taxation") : BigDecimal.ZERO;
+            allExpenditure =allExpenditure.add(fixedCost).add(laborCost).add(taxation).add(variableCost);
+        }
+        return allExpenditure;
+    }
+
+
+    public static Map<String, List<String>> buildTreeMap(List<ProfitAnalysisDto> nodes) {
+        Map<String, ProfitAnalysisDto> nodeMap = new HashMap<>();
+        for (ProfitAnalysisDto node : nodes) {
+            nodeMap.put(node.getExpensesId(), node);
+        }
+
+        Map<String, List<String>> parentChildrenMap = new HashMap<>();
+
+        for (ProfitAnalysisDto node : nodes) {
+            if (node.getParentId().equals("0")) {
+                // Root node, start recursion here
+                List<String> allIds = getAllIds(node, nodeMap, new ArrayList<>());
+                parentChildrenMap.put(String.valueOf(node.getExpensesId()), allIds);
+            }
+        }
+
+        return parentChildrenMap;
+    }
+
+
+    private static List<String> getAllIds(ProfitAnalysisDto node, Map<String, ProfitAnalysisDto> nodeMap, List<String> ids) {
+        ids.add(String.valueOf(node.getExpensesId()));
+
+        for (ProfitAnalysisDto potentialChild : nodeMap.values()) {
+            if (potentialChild.getParentId() .equals(node.getExpensesId())) {
+                getAllIds(potentialChild, nodeMap, ids);
+            }
+        }
+        return ids;
+    }
+
     /**
     /**
      * 组装树形结构结果集方法
      * 组装树形结构结果集方法
      */
      */

+ 190 - 52
src/main/java/com/ydtech/modules/admin/service/impl/SysGeographyPositionServiceImpl.java

@@ -599,7 +599,7 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
     }
     }
 
 
     @Override
     @Override
-    public AppGeographyHistoryInfoVo getGeographyPosition(String startTime, String endTime, String source) {
+    public AppGeographyHistoryInfoVo getGeographyPosition(String startTime, String endTime, String source,String queryId,Integer type) {
         AppGeographyHistoryInfoVo appGeographyHistoryInfoVo = new AppGeographyHistoryInfoVo();
         AppGeographyHistoryInfoVo appGeographyHistoryInfoVo = new AppGeographyHistoryInfoVo();
         //admin 可看所有,其他下只能看下面管理的人员
         //admin 可看所有,其他下只能看下面管理的人员
         String userId = BaseController.getUserId();
         String userId = BaseController.getUserId();
@@ -614,64 +614,202 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
             collect.addAll(idList);
             collect.addAll(idList);
 
 
         }
         }
+        if (type == 1) {
+            //机构
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .likeRight(StringUtils.isNotEmpty(startTime), "create_time", startTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
+                        .likeRight(StringUtils.isNotEmpty(queryId),"user_id",queryId)
+                        .eq(StringUtils.isNotEmpty(source),"source",source);
+                Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                appGeographyHistoryInfoVo.setOnlineNum(total);
+                List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPosition(startTime,source,collect,queryId);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionRecord(startTime,source,collect,queryId);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+
 
 
-        if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+            }else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .between("create_time", startTime, endTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
+                        .eq(StringUtils.isNotEmpty(source),"source",source);
+                Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                appGeographyHistoryInfoVo.setOnlineNum(total);
+
+                List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPositionSection(startTime,endTime,source,collect,queryId);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionHistory(startTime,endTime,source,collect,queryId);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+
+            }
 
 
-            if (StringUtils.isNullOrEmpty(startTime)) {
-                Date date = new Date();
-                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                startTime = simpleDateFormat.format(date);
+        }else if (type == 2) {
+            //人员id
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, queryId).ne(SysUser::getStatus, 0));
+            List<String> collect1 = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size() == 0) {
+                return appGeographyHistoryInfoVo;
             }
             }
-            QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
-            // 指定 COUNT(DISTINCT user_id) 查询
-            queryWrapper.select("COUNT(DISTINCT user_id) AS total")
-                    .likeRight(StringUtils.isNotEmpty(startTime), "create_time", startTime)
-                    .in("source", Arrays.asList(1, 2))
-                    .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
-                    .eq(StringUtils.isNotEmpty(source),"source",source);
-            Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
-            Long total = (Long) result.get("total");
-            appGeographyHistoryInfoVo.setOnlineNum(total);
-            List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPosition(startTime,source,collect);
-            appGeographyHistoryInfoVo.setList(geographyPosition);
-
-            List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionRecord(startTime,source,collect);
-            extracted(sysGeographyPositionRecords);
-            System.out.println("********************" + sysGeographyPositionRecords.size());
-            appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+            List<String> idList = queryList(collect1, ids);
+            collect.addAll(idList);
+            List<String> collect2 = collect.stream().distinct().collect(Collectors.toList());
 
 
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .likeRight(StringUtils.isNotEmpty(startTime), "create_time", startTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect2), "user_id", collect2)
+                        .eq(StringUtils.isNotEmpty(source),"source",source);
+                Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                appGeographyHistoryInfoVo.setOnlineNum(total);
+                List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPosition(startTime,source,collect2,null);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionRecord(startTime,source,collect2,null);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+
+
+            }else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .between("create_time", startTime, endTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect2), "user_id", collect2)
+                        .eq(StringUtils.isNotEmpty(source),"source",source);
+                Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                appGeographyHistoryInfoVo.setOnlineNum(total);
+
+                List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPositionSection(startTime,endTime,source,collect2,null);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionHistory(startTime,endTime,source,collect2,null);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
 
 
-        }else {
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            startTime = startTime + " 00:00:01";
-            endTime = endTime + " 23:59:59";
-            try {
-                Date parse = simpleDateFormat.parse(startTime);
-                Date parse1 = simpleDateFormat.parse(endTime);
-                startTime = simpleDateFormat.format(parse);
-                endTime = simpleDateFormat.format(parse1);
-
-            } catch (ParseException e) {
-                throw new RuntimeException(e);
             }
             }
-            QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
-            queryWrapper.select("COUNT(DISTINCT user_id) AS total")
-                    .between("create_time", startTime, endTime)
-                    .in("source", Arrays.asList(1, 2))
-                    .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
-                    .eq(StringUtils.isNotEmpty(source),"source",source);
-            Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
-            Long total = (Long) result.get("total");
-            appGeographyHistoryInfoVo.setOnlineNum(total);
-
-            List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPositionSection(startTime,endTime,source,collect);
-            appGeographyHistoryInfoVo.setList(geographyPosition);
-
-            List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionHistory(startTime,endTime,source,collect);
-            extracted(sysGeographyPositionRecords);
-            System.out.println("********************" + sysGeographyPositionRecords.size());
-            appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
 
 
+
+
+        }else {
+
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .likeRight(StringUtils.isNotEmpty(startTime), "create_time", startTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
+                        .eq(StringUtils.isNotEmpty(source),"source",source);
+                Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                appGeographyHistoryInfoVo.setOnlineNum(total);
+                List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPosition(startTime,source,collect,null);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionRecord(startTime,source,collect,null);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+
+
+            }else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                QueryWrapper<SysGeographyPositionRecord> queryWrapper = new QueryWrapper<>();
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .between("create_time", startTime, endTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
+                        .eq(StringUtils.isNotEmpty(source),"source",source);
+                Map<String, Object> result = sysGeographyPositionRecordService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                appGeographyHistoryInfoVo.setOnlineNum(total);
+
+                List<PcAddressHistoryTimeVo> geographyPosition = sysGeographyPositionRecordMapper.getGeographyPositionSection(startTime,endTime,source,collect,null);
+                appGeographyHistoryInfoVo.setList(geographyPosition);
+
+                List<SysGeographyPositionRecord> sysGeographyPositionRecords =sysGeographyPositionRecordMapper.getGeographyPositionHistory(startTime,endTime,source,collect,null);
+                extracted(sysGeographyPositionRecords);
+                System.out.println("********************" + sysGeographyPositionRecords.size());
+                appGeographyHistoryInfoVo.setPositionRecordList(sysGeographyPositionRecords);
+
+            }
         }
         }
 
 
         return appGeographyHistoryInfoVo;
         return appGeographyHistoryInfoVo;

+ 111 - 246
src/main/java/com/ydtech/modules/admin/service/impl/SysPartnerServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.aop.exception.DescribeException;
 import com.ydtech.aop.exception.DescribeException;
+import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.dao.*;
 import com.ydtech.modules.admin.dao.*;
 import com.ydtech.modules.admin.model.*;
 import com.ydtech.modules.admin.model.*;
 import com.ydtech.modules.admin.model.dto.*;
 import com.ydtech.modules.admin.model.dto.*;
@@ -16,8 +17,9 @@ import com.ydtech.modules.admin.model.vo.*;
 import com.ydtech.modules.admin.service.SysAgencyLeaderService;
 import com.ydtech.modules.admin.service.SysAgencyLeaderService;
 import com.ydtech.modules.admin.service.SysPartnerService;
 import com.ydtech.modules.admin.service.SysPartnerService;
 import com.ydtech.modules.admin.service.SysPremiumDetailsService;
 import com.ydtech.modules.admin.service.SysPremiumDetailsService;
-import com.ydtech.modules.admin.service.SysUserService;
 import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.base.controller.BaseController;
+import com.ydtech.modules.esm.dao.EsmUserReferrerMapper;
+import com.ydtech.modules.esm.model.EsmUserReferrer;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.utils.StringUtils;
 import com.ydtech.utils.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -26,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.math.RoundingMode;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
@@ -73,6 +76,9 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
 
 
     @Resource
     @Resource
     private SysProportionConfigMapper sysProportionConfigMapper;
     private SysProportionConfigMapper sysProportionConfigMapper;
+    @Resource
+    private EsmUserReferrerMapper esmUserReferrerMapper;
+
 
 
 
 
     @Override
     @Override
@@ -176,6 +182,11 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
         sysPartner.setType(sysPartnerDto.getLevel());
         sysPartner.setType(sysPartnerDto.getLevel());
         boolean b = false;
         boolean b = false;
         b = sysPartnerMapper.insert(sysPartner) > 0;
         b = sysPartnerMapper.insert(sysPartner) > 0;
+        //一级合伙人添加默认比例
+        if (sysPartnerDto.getLevel() == 1) {
+            SysProportionConfig sysProportionConfig = new SysProportionConfig(null,sysPartner.getUserId(),"0.5","0.1","0.1","0.1","0.1","0.1");
+            sysProportionConfigMapper.insert(sysProportionConfig);
+        }
         if (sysPartnerDto.getSuggestId() != null) {
         if (sysPartnerDto.getSuggestId() != null) {
             SysPartner sysPartner1 = sysPartnerMapper.selectOne(new LambdaQueryWrapper<SysPartner>()
             SysPartner sysPartner1 = sysPartnerMapper.selectOne(new LambdaQueryWrapper<SysPartner>()
                     .eq(SysPartner::getDelFlag, 1).eq(SysPartner::getUserId, sysPartnerDto.getSuggestId()));
                     .eq(SysPartner::getDelFlag, 1).eq(SysPartner::getUserId, sysPartnerDto.getSuggestId()));
@@ -668,7 +679,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             }
             }
             appPartnerInfo.setTeamManNum(deptManNum);
             appPartnerInfo.setTeamManNum(deptManNum);
             appPartnerInfo.setUserIds(userIdList);
             appPartnerInfo.setUserIds(userIdList);
-
+            if (CollectionUtil.isEmpty(userIdList)) continue;
             //查团队的保费
             //查团队的保费
             List<SysPremiumDetails> sysPremiumDetails = sysPremiumDetailsMapper.selectList(new LambdaQueryWrapper<SysPremiumDetails>()
             List<SysPremiumDetails> sysPremiumDetails = sysPremiumDetailsMapper.selectList(new LambdaQueryWrapper<SysPremiumDetails>()
                     .in(SysPremiumDetails::getUserId, userIdList)
                     .in(SysPremiumDetails::getUserId, userIdList)
@@ -697,6 +708,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                 ids.addAll(list);
                 ids.addAll(list);
             }
             }
         }
         }
+        if (CollectionUtil.isEmpty(ids)) return appPartnerInfoFreeVo;
 
 
         List<SysPremiumDetails> sysPremiumDetails = sysPremiumDetailsMapper.selectList(new LambdaQueryWrapper<SysPremiumDetails>()
         List<SysPremiumDetails> sysPremiumDetails = sysPremiumDetailsMapper.selectList(new LambdaQueryWrapper<SysPremiumDetails>()
                 .in(SysPremiumDetails::getUserId, ids)
                 .in(SysPremiumDetails::getUserId, ids)
@@ -882,8 +894,8 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                 BigDecimal sumPremium = sysPremiumDetails.stream().map(SysPremiumDetails::getSumpremium).reduce(BigDecimal.ZERO, BigDecimal::add);
                 BigDecimal sumPremium = sysPremiumDetails.stream().map(SysPremiumDetails::getSumpremium).reduce(BigDecimal.ZERO, BigDecimal::add);
                 BigDecimal extractFee = sysPremiumDetails.stream().map(SysPremiumDetails::getExtractFee).reduce(BigDecimal.ZERO, BigDecimal::add);
                 BigDecimal extractFee = sysPremiumDetails.stream().map(SysPremiumDetails::getExtractFee).reduce(BigDecimal.ZERO, BigDecimal::add);
 
 
-//                appSysPartnerVo.setSumPremium(sumPremium);
-//                appSysPartnerVo.setExtractFee(extractFee);
+                appSysPartnerVo.setSumPremium(sumPremium);
+                appSysPartnerVo.setExtractFee(extractFee);
                 //二级以下团队的总人数
                 //二级以下团队的总人数
                 List<SysRelationPerson> sysRelationPersonList = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
                 List<SysRelationPerson> sysRelationPersonList = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
                         .in(CollectionUtil.isNotEmpty(ids), SysRelationPerson::getSuggestId, ids)
                         .in(CollectionUtil.isNotEmpty(ids), SysRelationPerson::getSuggestId, ids)
@@ -912,26 +924,16 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                         }
                         }
                     }
                     }
                 }
                 }
-//                appSysPartnerVo.setTeamManNum(deptManNum);
-
-                List<String> list = new ArrayList<>();
-                if (partnerType == 1) {
-                    //一级获取登陆人的之际工作室
-                    list.add(userId);
-                } else {
-
-                    //获取上一级合伙人,查询工作室数量
-                    List<SysPartner> sysPartners = listMap.get(partnerType - 1);
-                    if (sysPartners != null) {
-                        //上一级直接推荐的工作室数量
-                        List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-                        list.addAll(list1);
-                        extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    } else {
-                        appSysPartnerVo.setTeamManNum(deptManNum);
-
-                        appSysPartnerVo.setNumber(appSysPartnerVo.getPartnerNumber());
-                    }
+                appSysPartnerVo.setTeamManNum(deptManNum);
+                List<SysRelationPerson> sysRelationPersons = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
+                        .in(CollectionUtil.isNotEmpty(ids), SysRelationPerson::getSuggestId, ids)
+                        .eq(SysRelationPerson::getDelFlag, 1)
+                        .eq(SysRelationPerson::getSource, 0)
+                        .eq(SysRelationPerson::getType, 1));
+                appSysPartnerVo.setWorkNumber(sysRelationPersons.size());
+                if (sysRelationPersons.size() > 0) {
+                    List<String> list1 = sysRelationPersons.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
+                    appSysPartnerVo.setLeaderIds(list1);
                 }
                 }
 
 
                 //每一级存入map
                 //每一级存入map
@@ -972,7 +974,8 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                         .eq(SysPremiumDetails::getStatus, 1));
                         .eq(SysPremiumDetails::getStatus, 1));
                 BigDecimal sumPremium = sysPremiumDetails.stream().map(SysPremiumDetails::getSumpremium).reduce(BigDecimal.ZERO, BigDecimal::add);
                 BigDecimal sumPremium = sysPremiumDetails.stream().map(SysPremiumDetails::getSumpremium).reduce(BigDecimal.ZERO, BigDecimal::add);
                 BigDecimal extractFee = sysPremiumDetails.stream().map(SysPremiumDetails::getExtractFee).reduce(BigDecimal.ZERO, BigDecimal::add);
                 BigDecimal extractFee = sysPremiumDetails.stream().map(SysPremiumDetails::getExtractFee).reduce(BigDecimal.ZERO, BigDecimal::add);
-
+                appSysPartnerVo.setSumPremium(sumPremium);
+                appSysPartnerVo.setExtractFee(extractFee);
                 //同等级合伙人团队的总人数:
                 //同等级合伙人团队的总人数:
                 List<SysRelationPerson> sysRelationPersonList = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
                 List<SysRelationPerson> sysRelationPersonList = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
                         .in(CollectionUtil.isNotEmpty(ids), SysRelationPerson::getSuggestId, ids)
                         .in(CollectionUtil.isNotEmpty(ids), SysRelationPerson::getSuggestId, ids)
@@ -1001,197 +1004,25 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                         }
                         }
                     }
                     }
                 }
                 }
+                appSysPartnerVo.setTeamManNum(deptManNum);
 
 
-                List<String> list = new ArrayList<>();
-//                int type = sysPartner.getType();
-                if (type == 1) {
-                    if (i == 2) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    } else {
-                        extractedLeader(partnerInfoDto, listMap, i, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    }
-                } else if (type == 2) {
-                    if (i == 3) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        extractedLeader(partnerInfoDto, listMap, i, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    }
-
-                } else if (type == 3) {
-                    if (i == 4) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    } else {
-
-                        //获取上一级合伙人,查询工作室数量
-                        extractedLeader(partnerInfoDto, listMap, i, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    }
-
-                } else if (type == 4) {
-                    if (i == 5) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        extractedLeader(partnerInfoDto, listMap, i, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-                    }
-
+                List<SysRelationPerson> sysRelationPersons = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
+                        .in(CollectionUtil.isNotEmpty(ids), SysRelationPerson::getSuggestId, ids)
+                        .eq(SysRelationPerson::getDelFlag, 1)
+                        .eq(SysRelationPerson::getSource, 0)
+                        .eq(SysRelationPerson::getType, 1));
+                appSysPartnerVo.setWorkNumber(sysRelationPersons.size());
+                if (sysRelationPersons.size() > 0) {
+                    List<String> list1 = sysRelationPersons.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
+                    appSysPartnerVo.setLeaderIds(list1);
                 }
                 }
                 //每一级存入map
                 //每一级存入map
-                appSysPartnerVos.add(appSysPartnerVo);
-            } else {
-                //无合伙人,查看上一级的直接工作室
-                List<String> list = new ArrayList<>();
-                AppSysPartnerVo appSysPartnerVo = new AppSysPartnerVo();
-                appSysPartnerVo.setPartnerType(i);
-                if (type == 1) {
-                    if (i == 2) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        List<SysPartner> sysPartners = listMap.get(i - 1);
-                        if (sysPartners != null) {
-                            //上一级直接推荐的工作室数量
-                            List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-                            list.addAll(list1);
-                            extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                        }
-                    }
-                } else if (type == 2) {
-                    if (i == 3) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        List<SysPartner> sysPartners = listMap.get(i - 1);
-                        if (sysPartners != null) {
-                            //上一级直接推荐的工作室数量
-                            List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-                            list.addAll(list1);
-                            extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                        }
-                    }
-                } else if (type == 3) {
-                    if (i == 4) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        List<SysPartner> sysPartners = listMap.get(i - 1);
-                        if (sysPartners != null) {
-                            //上一级直接推荐的工作室数量
-                            List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-                            list.addAll(list1);
-                            extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                        }
-                    }
-                } else if (type == 4) {
-                    if (i == 5) {
-                        //一级获取登陆人的之际工作室
-                        list.add(userId);
-                        extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                    } else {
-                        //获取上一级合伙人,查询工作室数量
-                        List<SysPartner> sysPartners = listMap.get(i - 1);
-                        if (sysPartners != null) {
-                            //上一级直接推荐的工作室数量
-                            List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-                            list.addAll(list1);
-                            extracted(partnerInfoDto, appSysPartnerVo, BigDecimal.ZERO, BigDecimal.ZERO, 0, list);
-                        }
-                    }
-                }
-
                 appSysPartnerVos.add(appSysPartnerVo);
                 appSysPartnerVos.add(appSysPartnerVo);
             }
             }
         }
         }
         return appSysPartnerVos;
         return appSysPartnerVos;
     }
     }
 
 
-    private void extractedLeader(PartnerInfoDto partnerInfoDto, Map<Integer, List<SysPartner>> listMap, int i, AppSysPartnerVo appSysPartnerVo, BigDecimal sumPremium, BigDecimal extractFee, int deptManNum, List<String> list) {
-        //获取上一级合伙人,查询工作室数量
-        List<SysPartner> sysPartners = listMap.get(i - 1);
-        if (sysPartners != null) {
-            //上一级直接推荐的工作室数量
-            List<String> list1 = sysPartners.stream().map(SysPartner::getUserId).collect(Collectors.toList());
-            list.addAll(list1);
-            extracted(partnerInfoDto, appSysPartnerVo, sumPremium, extractFee, deptManNum, list);
-        } else {
-            appSysPartnerVo.setTeamManNum(deptManNum);
-            appSysPartnerVo.setNumber(Optional.ofNullable(appSysPartnerVo.getPartnerNumber()).orElse(0));
-        }
-    }
-
-    private void extracted(PartnerInfoDto partnerInfoDto, AppSysPartnerVo appSysPartnerVo, BigDecimal sumPremium, BigDecimal extractFee, int deptManNum, List<String> list) {
-        List<SysRelationPerson> sysRelationPersons = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
-                .in(CollectionUtil.isNotEmpty(list), SysRelationPerson::getSuggestId, list)
-                .eq(SysRelationPerson::getDelFlag, 1)
-                .eq(SysRelationPerson::getSource, 0)
-                .eq(SysRelationPerson::getType, 1));
-        appSysPartnerVo.setWorkNumber(sysRelationPersons.size());
-        if (sysRelationPersons.size() > 0) {
-
-            List<String> list1 = sysRelationPersons.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
-            appSysPartnerVo.setLeaderIds(list1);
-            //直接工作室保费
-            List<SysPremiumDetails> sysPremiumDetails1 = sysPremiumDetailsMapper.selectList(new LambdaQueryWrapper<SysPremiumDetails>()
-                    .in(CollectionUtil.isNotEmpty(list1), SysPremiumDetails::getUserId, list1)
-                    .between(StringUtils.isNotEmpty(partnerInfoDto.getBeginTime()) && StringUtils.isNotEmpty(partnerInfoDto.getEndTime()),
-                            SysPremiumDetails::getCreateTime, partnerInfoDto.getBeginTime(), partnerInfoDto.getEndTime())
-                    .eq(partnerInfoDto.getIndustrySector() != null, SysPremiumDetails::getIndustrySector, partnerInfoDto.getIndustrySector())
-                    .eq(SysPremiumDetails::getStatus, 1));
-            if (sysPremiumDetails1.size() > 0) {
-
-                BigDecimal sumPremium1 = sysPremiumDetails1.stream().map(SysPremiumDetails::getSumpremium).reduce(BigDecimal.ZERO, BigDecimal::add);
-                BigDecimal extractFee1 = sysPremiumDetails1.stream().map(SysPremiumDetails::getExtractFee).reduce(BigDecimal.ZERO, BigDecimal::add);
-
-                appSysPartnerVo.setSumPremium(sumPremium.add(sumPremium1));
-                appSysPartnerVo.setExtractFee(extractFee.add(extractFee1));
-            } else {
-                appSysPartnerVo.setSumPremium(sumPremium);
-                appSysPartnerVo.setExtractFee(extractFee);
-            }
-            int leaderManNum = 0;
-            //直接工作室总
-            List<SysAgencyLeader> leaderList = sysAgencyLeaderMapper.selectList(new LambdaQueryWrapper<SysAgencyLeader>()
-                    .in(CollectionUtil.isNotEmpty(list1), SysAgencyLeader::getUserId, list1).eq(SysAgencyLeader::getDelFlag, 1));
-
-            if (leaderList.size() > 0) {
-                for (SysAgencyLeader sysAgencyLeader : leaderList) {
-                    //获取机构下的团队
-                    List<SysDept> sysDeptList = sysDeptMapper.selectList(new LambdaQueryWrapper<SysDept>()
-                            .likeRight(SysDept::getId, sysAgencyLeader.getDeptId())
-                            .isNull(SysDept::getComlevel).eq(SysDept::getDelFlag, 0)
-                            .eq(SysDept::getManagementSource, sysAgencyLeader.getSource()));
-                    if (sysDeptList.size() > 0) {
-                        for (SysDept sysDept : sysDeptList) {
-                            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
-                                    .likeRight(SysUser::getId, sysDept.getId()).ne(SysUser::getStatus, 0));
-                            leaderManNum = leaderManNum + sysUsers.size();
-
-                        }
-                    }
-                }
-            }
-
-            appSysPartnerVo.setTeamManNum(deptManNum + leaderManNum);
-            Integer partnerNumber = Optional.ofNullable(appSysPartnerVo.getPartnerNumber()).orElse(0);
-            Integer workNumber = Optional.ofNullable(appSysPartnerVo.getWorkNumber()).orElse(0);
-            appSysPartnerVo.setNumber(partnerNumber + workNumber);
-        }
-    }
-
     @Override
     @Override
     public PartnerInfoFreeVo queryPartnerInfo(PartnerGradeInfo partnerGradeInfo) {
     public PartnerInfoFreeVo queryPartnerInfo(PartnerGradeInfo partnerGradeInfo) {
         PartnerInfoFreeVo partnerInfoFreeVo = new PartnerInfoFreeVo();
         PartnerInfoFreeVo partnerInfoFreeVo = new PartnerInfoFreeVo();
@@ -1260,7 +1091,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                     partnerInfoVo.setLeaderIds(collects);
                     partnerInfoVo.setLeaderIds(collects);
                     partnerInfoVo.setWorkNumber(collects.size());
                     partnerInfoVo.setWorkNumber(collects.size());
 
 
-                    //合伙人下所有工作室数
+                    //合伙人下所有工作室数 核算总代理人数
                     List<SysRelationPerson> sysRelationPersonList2 = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
                     List<SysRelationPerson> sysRelationPersonList2 = sysRelationPersonMapper.selectList(new LambdaQueryWrapper<SysRelationPerson>()
                             .eq(SysRelationPerson::getSuggestId, userId)
                             .eq(SysRelationPerson::getSuggestId, userId)
                             .eq(SysRelationPerson::getDelFlag, 1)
                             .eq(SysRelationPerson::getDelFlag, 1)
@@ -1425,10 +1256,10 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             TeamUserInfosVo teamUserInfosVo = new TeamUserInfosVo();
             TeamUserInfosVo teamUserInfosVo = new TeamUserInfosVo();
             teamUserInfosVo.setUserId(sysUser.getId());
             teamUserInfosVo.setUserId(sysUser.getId());
             teamUserInfosVo.setUserName(sysUser.getName());
             teamUserInfosVo.setUserName(sysUser.getName());
-            String leaderId = sysUser.getLeaderId();
-            if (StringUtils.isNotEmpty(leaderId)) {
-                teamUserInfosVo.setLeaderId(sysUser.getLeaderId());
-                SysUser sysUser1 = sysUserMapper.selectById(sysUser.getLeaderId());
+            EsmUserReferrer esmUserReferrer = esmUserReferrerMapper.selectById(sysUser.getId());
+            if (esmUserReferrer != null) {
+                teamUserInfosVo.setLeaderId(esmUserReferrer.getReferrerId());
+                SysUser sysUser1 = sysUserMapper.selectById(esmUserReferrer.getReferrerId());
                 teamUserInfosVo.setLeaderName(sysUser1.getName());
                 teamUserInfosVo.setLeaderName(sysUser1.getName());
             }
             }
 
 
@@ -1613,7 +1444,9 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             partnerInfoVo.setUserName(sysUser.getName());
             partnerInfoVo.setUserName(sysUser.getName());
             SysUser sysUser1 = sysUserMapper.selectById(sysAgencyLeader.getSuggestId());
             SysUser sysUser1 = sysUserMapper.selectById(sysAgencyLeader.getSuggestId());
             partnerInfoVo.setSuggestName(sysUser1.getName());
             partnerInfoVo.setSuggestName(sysUser1.getName());
-
+            partnerInfoVo.setDeptId(sysAgencyLeader.getDeptId());
+            SysDept sysDept1 = sysDeptMapper.selectById(sysAgencyLeader.getDeptId());
+            partnerInfoVo.setDeptName(sysDept1.getName());
             //费用
             //费用
             List<SysPremiumDetails> sysPremiumDetail = sysPremiumDetailsMapper.selectList(new LambdaQueryWrapper<SysPremiumDetails>()
             List<SysPremiumDetails> sysPremiumDetail = sysPremiumDetailsMapper.selectList(new LambdaQueryWrapper<SysPremiumDetails>()
                     .eq(SysPremiumDetails::getUserId, userId)
                     .eq(SysPremiumDetails::getUserId, userId)
@@ -1739,9 +1572,9 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
         String startTime1 = countUserDto.getBeginTime();
         String startTime1 = countUserDto.getBeginTime();
         String endTime1 = countUserDto.getEndTime();
         String endTime1 = countUserDto.getEndTime();
 
 
-        int deptSum=0;
-        int deptManSum=0;
-        List<String> deptIds =new ArrayList<>();
+        int deptSum = 0;
+        int deptManSum = 0;
+        List<String> deptIds = new ArrayList<>();
         //查工作室下的团队
         //查工作室下的团队
         SysAgencyLeader sysAgencyLeader = sysAgencyLeaderMapper.selectOne(new LambdaQueryWrapper<SysAgencyLeader>()
         SysAgencyLeader sysAgencyLeader = sysAgencyLeaderMapper.selectOne(new LambdaQueryWrapper<SysAgencyLeader>()
                 .eq(SysAgencyLeader::getDelFlag, 1).in(SysAgencyLeader::getUserId, userId));
                 .eq(SysAgencyLeader::getDelFlag, 1).in(SysAgencyLeader::getUserId, userId));
@@ -1779,10 +1612,10 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                     if (s.equals(s1)) {
                     if (s.equals(s1)) {
                         //查一天的数据
                         //查一天的数据
                         countUserNumVoList = sysPartnerMapper.queryDeptByTimes(deptIds, countUserDto);
                         countUserNumVoList = sysPartnerMapper.queryDeptByTimes(deptIds, countUserDto);
-                    }else {
+                    } else {
                         countUserNumVoList = sysPartnerMapper.queryDeptByTime(deptIds, countUserDto);
                         countUserNumVoList = sysPartnerMapper.queryDeptByTime(deptIds, countUserDto);
                     }
                     }
-                }else {
+                } else {
                     countUserNumVoList = sysPartnerMapper.queryDeptByTime(deptIds, countUserDto);
                     countUserNumVoList = sysPartnerMapper.queryDeptByTime(deptIds, countUserDto);
                 }
                 }
 
 
@@ -1792,10 +1625,10 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                     String s1 = endTime1.split(" ")[0];
                     String s1 = endTime1.split(" ")[0];
                     if (s.equals(s1)) {
                     if (s.equals(s1)) {
                         countUserNumVoList = sysPartnerMapper.queryUserByTimes(deptIds, countUserDto);
                         countUserNumVoList = sysPartnerMapper.queryUserByTimes(deptIds, countUserDto);
-                    }else {
+                    } else {
                         countUserNumVoList = sysPartnerMapper.queryUserByTime(deptIds, countUserDto);
                         countUserNumVoList = sysPartnerMapper.queryUserByTime(deptIds, countUserDto);
                     }
                     }
-                }else {
+                } else {
                     countUserNumVoList = sysPartnerMapper.queryUserByTime(deptIds, countUserDto);
                     countUserNumVoList = sysPartnerMapper.queryUserByTime(deptIds, countUserDto);
                 }
                 }
 
 
@@ -1814,7 +1647,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
         SysPartner sysPartner = sysPartnerMapper.selectOne(new LambdaQueryWrapper<SysPartner>()
         SysPartner sysPartner = sysPartnerMapper.selectOne(new LambdaQueryWrapper<SysPartner>()
                 .eq(SysPartner::getUserId, userId).eq(SysPartner::getDelFlag, 1));
                 .eq(SysPartner::getUserId, userId).eq(SysPartner::getDelFlag, 1));
         int type = sysPartner.getType();
         int type = sysPartner.getType();
-        partnerCountDto.setType(type+partnerCountDto.getType());
+        partnerCountDto.setType(type + partnerCountDto.getType());
         //查询登陆人下所有合伙人
         //查询登陆人下所有合伙人
         List<SysPartner> sysPartnerList = sysPartnerMapper.queryPartnerById(userId, partnerCountDto);
         List<SysPartner> sysPartnerList = sysPartnerMapper.queryPartnerById(userId, partnerCountDto);
         if (CollectionUtil.isEmpty(sysPartnerList)) return partnerCountVo;
         if (CollectionUtil.isEmpty(sysPartnerList)) return partnerCountVo;
@@ -1835,7 +1668,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             List<SysPartner> fourPartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 4).collect(Collectors.toList());
             List<SysPartner> fourPartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 4).collect(Collectors.toList());
             partnerCountVo.setFourPartnerNum(fourPartners.size());
             partnerCountVo.setFourPartnerNum(fourPartners.size());
 
 
-        }else if (type == 2) {
+        } else if (type == 2) {
             //1
             //1
             List<SysPartner> onePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 1).collect(Collectors.toList());
             List<SysPartner> onePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 1).collect(Collectors.toList());
             partnerCountVo.setOnePartnerNum(onePartners.size());
             partnerCountVo.setOnePartnerNum(onePartners.size());
@@ -1846,7 +1679,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             List<SysPartner> threePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 3).collect(Collectors.toList());
             List<SysPartner> threePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 3).collect(Collectors.toList());
             partnerCountVo.setThreePartnerNum(threePartners.size());
             partnerCountVo.setThreePartnerNum(threePartners.size());
 
 
-        }else if (type == 3) {
+        } else if (type == 3) {
             //1
             //1
             List<SysPartner> onePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 1).collect(Collectors.toList());
             List<SysPartner> onePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 1).collect(Collectors.toList());
             partnerCountVo.setOnePartnerNum(onePartners.size());
             partnerCountVo.setOnePartnerNum(onePartners.size());
@@ -1854,7 +1687,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             List<SysPartner> twoPartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 2).collect(Collectors.toList());
             List<SysPartner> twoPartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 2).collect(Collectors.toList());
             partnerCountVo.setTwoPartnerNum(twoPartners.size());
             partnerCountVo.setTwoPartnerNum(twoPartners.size());
 
 
-        }else if (type == 4) {
+        } else if (type == 4) {
             //1
             //1
             List<SysPartner> onePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 1).collect(Collectors.toList());
             List<SysPartner> onePartners = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == type + 1).collect(Collectors.toList());
             partnerCountVo.setOnePartnerNum(onePartners.size());
             partnerCountVo.setOnePartnerNum(onePartners.size());
@@ -1869,9 +1702,9 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             List<String> collect = sysRelationPersonList.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
             List<String> collect = sysRelationPersonList.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
             //查工作室下的团队
             //查工作室下的团队
             List<SysAgencyLeader> leaderList = sysAgencyLeaderMapper.selectList(new LambdaQueryWrapper<SysAgencyLeader>()
             List<SysAgencyLeader> leaderList = sysAgencyLeaderMapper.selectList(new LambdaQueryWrapper<SysAgencyLeader>()
-                    .eq(SysAgencyLeader::getDelFlag,1).in(SysAgencyLeader::getUserId,collect));
-            int deptSum=0;
-            int deptManSum=0;
+                    .eq(SysAgencyLeader::getDelFlag, 1).in(SysAgencyLeader::getUserId, collect));
+            int deptSum = 0;
+            int deptManSum = 0;
 
 
             for (SysAgencyLeader sysAgencyLeader : leaderList) {
             for (SysAgencyLeader sysAgencyLeader : leaderList) {
                 //根据机构id查下面团队
                 //根据机构id查下面团队
@@ -1909,7 +1742,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
             if (s.equals(s1)) {
             if (s.equals(s1)) {
                 //查一天的数据
                 //查一天的数据
                 countUserNumVoList = sysPartnerMapper.queryPartnerByTimes(userId, partnerCountDto);
                 countUserNumVoList = sysPartnerMapper.queryPartnerByTimes(userId, partnerCountDto);
-            }else {
+            } else {
                 countUserNumVoList = sysPartnerMapper.queryPartnerByTime(userId, partnerCountDto);
                 countUserNumVoList = sysPartnerMapper.queryPartnerByTime(userId, partnerCountDto);
             }
             }
 
 
@@ -1930,28 +1763,60 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                 .eq(SysPartner::getUserId, userId).eq(SysPartner::getDelFlag, 1));
                 .eq(SysPartner::getUserId, userId).eq(SysPartner::getDelFlag, 1));
         int level = sysPartner.getType() + partnerCountDto.getType();
         int level = sysPartner.getType() + partnerCountDto.getType();
         List<SysPartner> sysPartnerList = sysPartnerMapper.queryByLoginId(userId);
         List<SysPartner> sysPartnerList = sysPartnerMapper.queryByLoginId(userId);
+        List<SysPartner> collectNum;
+        List<SysPartner> collectSum;
+        try {
+            if (StringUtils.isNotEmpty(partnerCountDto.getBeginTime())) {
+                SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+                Date parse = simpleDateFormat1.parse(partnerCountDto.getBeginTime());
+                Date parse1 = simpleDateFormat1.parse(partnerCountDto.getEndTime());
+                collectNum = sysPartnerList.stream().filter(SysPartner -> SysPartner.getCreateTime().after(parse)
+                                && SysPartner.getCreateTime().before(parse1) && SysPartner.getType() == level)
+                        .collect(Collectors.toList());
+
+                collectSum = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == level)
+                        .collect(Collectors.toList());
+            } else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                Date date = new Date();
+                String format = simpleDateFormat.format(date);
+                String start = format + " 00:00:01";
+                String end = format + " 23:59:59";
+                SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+                Date parse = simpleDateFormat1.parse(start);
+                Date parse1 = simpleDateFormat1.parse(end);
+                collectNum = sysPartnerList.stream().filter(SysPartner -> SysPartner.getCreateTime().after(parse)
+                                && SysPartner.getCreateTime().before(parse1) && SysPartner.getType() == level)
+                        .collect(Collectors.toList());
+
+                collectSum = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == level)
+                        .collect(Collectors.toList());
 
 
-        List<SysPartner> collectNum = sysPartnerList.stream().filter(SysPartner -> SysPartner.getCreateTime().after(new Date(partnerCountDto.getBeginTime()))
-                        && SysPartner.getCreateTime().before(new Date(partnerCountDto.getEndTime())) && SysPartner.getType()==level)
-                .collect(Collectors.toList());
-
-        List<SysPartner> collectSum = sysPartnerList.stream().filter(SysPartner ->SysPartner.getType()==level)
-                .collect(Collectors.toList());
+            }
+        } catch (Exception e) {
+            throw new SystemException("系统繁忙,请联系管理员");
+        }
 
 
-        partnerProportionVo.setNewNum(collectNum.size());
-        partnerProportionVo.setNumber(collectSum.size());
+        partnerProportionVo.setNewNum(Optional.ofNullable(collectNum.size()).orElse(0));
+        partnerProportionVo.setNumber(Optional.ofNullable(collectSum.size()).orElse(0));
         if (CollectionUtil.isNotEmpty(collectSum)) {
         if (CollectionUtil.isNotEmpty(collectSum)) {
             int i = collectSum.size() - collectNum.size();
             int i = collectSum.size() - collectNum.size();
             partnerProportionVo.setOldNum(i);
             partnerProportionVo.setOldNum(i);
         }
         }
         if (CollectionUtil.isNotEmpty(collectNum)) {
         if (CollectionUtil.isNotEmpty(collectNum)) {
-            double v = (float)collectNum.size() / (float) collectSum.size() * 100;
-            partnerProportionVo.setNewProportion(v);
+            double v = (float) collectNum.size() / (float) collectSum.size() * 100;
+            String format = String.format("%.2f", v);
+            Double aDouble = Double.valueOf(format);
+            partnerProportionVo.setNewProportion(aDouble);
         }
         }
         int oldNum = partnerProportionVo.getOldNum();
         int oldNum = partnerProportionVo.getOldNum();
         if (oldNum != 0) {
         if (oldNum != 0) {
-            double v = (float)oldNum / (float) collectSum.size() * 100;
-            partnerProportionVo.setOldProportion(v);
+            double v = (float) oldNum / (float) collectSum.size() * 100;
+            String format = String.format("%.2f", v);
+            Double aDouble = Double.valueOf(format);
+            partnerProportionVo.setOldProportion(aDouble);
         }
         }
 
 
         return partnerProportionVo;
         return partnerProportionVo;
@@ -1963,11 +1828,11 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
         String userId = BaseController.getUserId();
         String userId = BaseController.getUserId();
         SysPartner sysPartner = sysPartnerMapper.selectOne(new LambdaQueryWrapper<SysPartner>()
         SysPartner sysPartner = sysPartnerMapper.selectOne(new LambdaQueryWrapper<SysPartner>()
                 .eq(SysPartner::getUserId, userId).eq(SysPartner::getDelFlag, 1));
                 .eq(SysPartner::getUserId, userId).eq(SysPartner::getDelFlag, 1));
-        int level = sysPartner.getType() +type;
+        int level = sysPartner.getType() + type;
 
 
         List<SysPartner> sysPartnerList = sysPartnerMapper.queryByLoginId(userId);
         List<SysPartner> sysPartnerList = sysPartnerMapper.queryByLoginId(userId);
 
 
-        List<SysPartner> collect = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType()==level)
+        List<SysPartner> collect = sysPartnerList.stream().filter(SysPartner -> SysPartner.getType() == level)
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
         if (CollectionUtil.isEmpty(collect)) return partnerVoList;
         if (CollectionUtil.isEmpty(collect)) return partnerVoList;
 
 
@@ -1986,9 +1851,9 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
                 List<String> collects = sysRelationPersonList.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
                 List<String> collects = sysRelationPersonList.stream().map(SysRelationPerson::getAgencyLeaderId).collect(Collectors.toList());
                 //查工作室下的团队
                 //查工作室下的团队
                 List<SysAgencyLeader> leaderList = sysAgencyLeaderMapper.selectList(new LambdaQueryWrapper<SysAgencyLeader>()
                 List<SysAgencyLeader> leaderList = sysAgencyLeaderMapper.selectList(new LambdaQueryWrapper<SysAgencyLeader>()
-                        .eq(SysAgencyLeader::getDelFlag,1).in(SysAgencyLeader::getUserId,collects));
-                int deptSum=0;
-                int deptManSum=0;
+                        .eq(SysAgencyLeader::getDelFlag, 1).in(SysAgencyLeader::getUserId, collects));
+                int deptSum = 0;
+                int deptManSum = 0;
                 for (SysAgencyLeader sysAgencyLeader : leaderList) {
                 for (SysAgencyLeader sysAgencyLeader : leaderList) {
                     //根据机构id查下面团队
                     //根据机构id查下面团队
                     List<SysDept> sysDeptList = sysDeptMapper.selectList(new LambdaQueryWrapper<SysDept>()
                     List<SysDept> sysDeptList = sysDeptMapper.selectList(new LambdaQueryWrapper<SysDept>()
@@ -2009,7 +1874,7 @@ public class SysPartnerServiceImpl extends ServiceImpl<SysPartnerMapper, SysPart
 
 
                 levelPartnerVo.setDeptManNum(deptManSum);
                 levelPartnerVo.setDeptManNum(deptManSum);
 
 
-            }else {
+            } else {
                 levelPartnerVo.setDeptManNum(0);
                 levelPartnerVo.setDeptManNum(0);
             }
             }
 
 

+ 189 - 54
src/main/java/com/ydtech/modules/admin/service/impl/SysPcAddressServiceImpl.java

@@ -392,7 +392,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
     }
     }
 
 
     @Override
     @Override
-    public PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source) {
+    public PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source,String queryId,Integer type) {
         PcAddressHistoryInfoVo pcAddressHistoryInfoVo = new PcAddressHistoryInfoVo();
         PcAddressHistoryInfoVo pcAddressHistoryInfoVo = new PcAddressHistoryInfoVo();
         //admin 看所有,其他人看自己下属的人员信息
         //admin 看所有,其他人看自己下属的人员信息
         String userId = BaseController.getUserId();
         String userId = BaseController.getUserId();
@@ -406,65 +406,200 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
             List<String> idList = queryList(collect, ids);
             List<String> idList = queryList(collect, ids);
             collect.addAll(idList);
             collect.addAll(idList);
         }
         }
+        if (type == 1) {
+            //带机构查
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .likeRight(StringUtils.isNotEmpty(startTime), "operation_time", startTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
+                        .likeRight(StringUtils.isNotEmpty(queryId),"user_id",queryId)
+                        .eq(StringUtils.isNotEmpty(source), "source", source);
+                Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                pcAddressHistoryInfoVo.setOnlineNum(total);
+
+                List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddress(startTime, source, collect,queryId);
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime, source, collect,queryId);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
 
 
+            } else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total").between("operation_time", startTime, endTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .eq(StringUtils.isNotEmpty(source), "source", source)
+                        .likeRight(StringUtils.isNotEmpty(queryId),"user_id",queryId)
+                        .in(CollectionUtil.isNotEmpty(collect), "user_id", collect);
+                Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                pcAddressHistoryInfoVo.setOnlineNum(total);
+
+                List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddressSection(startTime, endTime, source, collect,queryId);
+
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime, source, collect,queryId);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
+            }
 
 
-        if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
-            if (StringUtils.isNullOrEmpty(startTime)) {
-                Date date = new Date();
-                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                startTime = simpleDateFormat.format(date);
+        }else if (type == 2) {
+            //带用户查
+            List<String> ids = new ArrayList<>();
+            List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getLeaderId, queryId).ne(SysUser::getStatus, 0));
+            List<String> collect1 = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
+            if (collect.size() == 0) {
+                return pcAddressHistoryInfoVo;
             }
             }
-            QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
-            // 指定 COUNT(DISTINCT user_id) 查询
-            queryWrapper.select("COUNT(DISTINCT user_id) AS total")
-                    .likeRight(StringUtils.isNotEmpty(startTime), "operation_time", startTime)
-                    .in("source", Arrays.asList(1, 2))
-                    .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
-                    .eq(StringUtils.isNotEmpty(source), "source", source);
-            Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
-            Long total = (Long) result.get("total");
-            pcAddressHistoryInfoVo.setOnlineNum(total);
-
-            List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddress(startTime, source, collect);
-            pcAddressHistoryInfoVo.setList(pcAddress);
-
-            List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime, source, collect);
-            extracted(sysPcAddressHistories);
-            System.out.println("********************" + sysPcAddressHistories.size());
-            pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
+            List<String> idList = queryList(collect1, ids);
+            collect.addAll(idList);
+            List<String> collect2 = collect.stream().distinct().collect(Collectors.toList());
 
 
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .likeRight(StringUtils.isNotEmpty(startTime), "operation_time", startTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect2), "user_id", collect2)
+                        .eq(StringUtils.isNotEmpty(source), "source", source);
+                Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                pcAddressHistoryInfoVo.setOnlineNum(total);
+
+                List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddress(startTime, source, collect2,null);
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime, source, collect2,null);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
 
 
-        } else {
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            startTime = startTime + " 00:00:01";
-            endTime = endTime + " 23:59:59";
-            try {
-                Date parse = simpleDateFormat.parse(startTime);
-                Date parse1 = simpleDateFormat.parse(endTime);
-                startTime = simpleDateFormat.format(parse);
-                endTime = simpleDateFormat.format(parse1);
-
-            } catch (ParseException e) {
-                throw new RuntimeException(e);
+            } else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total").between("operation_time", startTime, endTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .eq(StringUtils.isNotEmpty(source), "source", source)
+                        .in(CollectionUtil.isNotEmpty(collect2), "user_id", collect2);
+                Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                pcAddressHistoryInfoVo.setOnlineNum(total);
+
+                List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddressSection(startTime, endTime, source, collect2,null);
+
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime, source, collect2,null);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
+            }
+
+
+        }else {
+            //正常查
+            if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
+                if (StringUtils.isNullOrEmpty(startTime)) {
+                    Date date = new Date();
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                    startTime = simpleDateFormat.format(date);
+                }
+                QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total")
+                        .likeRight(StringUtils.isNotEmpty(startTime), "operation_time", startTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .in(CollectionUtil.isNotEmpty(collect), "user_id", collect)
+                        .eq(StringUtils.isNotEmpty(source), "source", source);
+                Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                pcAddressHistoryInfoVo.setOnlineNum(total);
+
+                List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddress(startTime, source, collect,null);
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime, source, collect,null);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
+
+
+            } else {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                startTime = startTime + " 00:00:01";
+                endTime = endTime + " 23:59:59";
+                try {
+                    Date parse = simpleDateFormat.parse(startTime);
+                    Date parse1 = simpleDateFormat.parse(endTime);
+                    startTime = simpleDateFormat.format(parse);
+                    endTime = simpleDateFormat.format(parse1);
+
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+                QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
+                // 指定 COUNT(DISTINCT user_id) 查询
+                queryWrapper.select("COUNT(DISTINCT user_id) AS total").between("operation_time", startTime, endTime)
+                        .in("source", Arrays.asList(1, 2))
+                        .eq(StringUtils.isNotEmpty(source), "source", source)
+                        .in(CollectionUtil.isNotEmpty(collect), "user_id", collect);
+                Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
+                Long total = (Long) result.get("total");
+                pcAddressHistoryInfoVo.setOnlineNum(total);
+
+                List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddressSection(startTime, endTime, source, collect,null);
+
+                pcAddressHistoryInfoVo.setList(pcAddress);
+
+                List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime, source, collect,null);
+                extracted(sysPcAddressHistories);
+                System.out.println("********************" + sysPcAddressHistories.size());
+                pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
             }
             }
-            QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
-            // 指定 COUNT(DISTINCT user_id) 查询
-            queryWrapper.select("COUNT(DISTINCT user_id) AS total").between("operation_time", startTime, endTime)
-                    .in("source", Arrays.asList(1, 2))
-                    .eq(StringUtils.isNotEmpty(source), "source", source)
-                    .in(CollectionUtil.isNotEmpty(collect), "user_id", collect);
-            Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
-            Long total = (Long) result.get("total");
-            pcAddressHistoryInfoVo.setOnlineNum(total);
-
-            List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddressSection(startTime, endTime, source, collect);
-
-            pcAddressHistoryInfoVo.setList(pcAddress);
-
-            List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime, source, collect);
-            extracted(sysPcAddressHistories);
-            System.out.println("********************" + sysPcAddressHistories.size());
-            pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
         }
         }
 
 
         return pcAddressHistoryInfoVo;
         return pcAddressHistoryInfoVo;

+ 31 - 0
src/main/java/com/ydtech/modules/console/dao/ProfitAnalysisMapper.java

@@ -5,6 +5,7 @@ import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisQueryD
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
+import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 
 
@@ -16,4 +17,34 @@ public interface ProfitAnalysisMapper {
 
 
     List<ProfitAnalysisDto> selectAccountExpenses(@Param("vo") ProfitAnalysisQueryDto profitAnalysisQueryDto);
     List<ProfitAnalysisDto> selectAccountExpenses(@Param("vo") ProfitAnalysisQueryDto profitAnalysisQueryDto);
 
 
+    /**
+     *
+     *
+     * @param profitAnalysisQueryDto
+     * @return  类目总金额
+     */
+    List<ProfitAnalysisDto> getSumCategory(@Param("vo") ProfitAnalysisQueryDto profitAnalysisQueryDto);
+
+    /**
+     *
+     *
+     * @param parentId
+     * @return  通过父id获取子集合
+     */
+    List<ProfitAnalysisDto> getByparentId(String parentId);
+
+    /**
+     *
+     * @param profitAnalysisQueryDto
+     * @return  通过父id获取金额
+     */
+    ProfitAnalysisDto getSumByparentAmount(@Param("vo") ProfitAnalysisQueryDto profitAnalysisQueryDto);
+
+    /**
+     *
+     * @param profitAnalysisQueryDto
+     * @return  获取公司总支出
+     */
+    HashMap<String, BigDecimal> getTotalExpenditure( @Param("vo") ProfitAnalysisQueryDto profitAnalysisQueryDto);
+
 }
 }

+ 3 - 0
src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceNewImpl.java

@@ -1845,8 +1845,11 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 noReCalcuLateProportion.getProxyProportion());
                 noReCalcuLateProportion.getProxyProportion());
 
 
         externalOrderFeeVo.setJqExportPremium(jqExportFee.getTotalAmount());
         externalOrderFeeVo.setJqExportPremium(jqExportFee.getTotalAmount());
+        externalOrderFeeVo.setJqExportRadio(jqExportFee.getTotalProportion());
         externalOrderFeeVo.setSyExportPremium(syExportFee.getTotalAmount());
         externalOrderFeeVo.setSyExportPremium(syExportFee.getTotalAmount());
+        externalOrderFeeVo.setSyExportRadio(syExportFee.getTotalProportion());
         externalOrderFeeVo.setNoExportPremium(noExportFee.getTotalAmount());
         externalOrderFeeVo.setNoExportPremium(noExportFee.getTotalAmount());
+        externalOrderFeeVo.setNoExportRadio(noExportFee.getTotalProportion());
         //endregion
         //endregion
 
 
         return externalOrderFeeVo;
         return externalOrderFeeVo;

+ 3 - 0
src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java

@@ -228,4 +228,7 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
 
 
     List<ProfitAnalysisDto> changeAmount(@Param("vo") ProfitAnalysisQueryDto profitAnalysisQueryDto);
     List<ProfitAnalysisDto> changeAmount(@Param("vo") ProfitAnalysisQueryDto profitAnalysisQueryDto);
 
 
+    BigDecimal queryDateByNotTypeSumAmount(@Param("vo") FinancialReceivablesQueryVo financialReceivablesQueryVo);
+
+    BigDecimal queryDateByTypeNotSumAmount(@Param("vo") FinancialReceivablesQueryVo financialReceivablesQueryVo);
 }
 }

+ 8 - 6
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -3408,10 +3408,12 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         financialReceivablesQueryVo.setEndDate(SliceUpDateUtil.getYearEndDateStr(year)+" 23:59:59");
         financialReceivablesQueryVo.setEndDate(SliceUpDateUtil.getYearEndDateStr(year)+" 23:59:59");
         //总应收
         //总应收
         financialReceivablesQueryVo.setType("1");
         financialReceivablesQueryVo.setType("1");
-        BigDecimal ptSumAmount =  baseMapper.queryDateByTypeSumAmount(financialReceivablesQueryVo);
+
+        BigDecimal ptSumAmount =  baseMapper.queryDateByTypeNotSumAmount(financialReceivablesQueryVo);
+
         financialReceivablesQueryVo.setType("2");
         financialReceivablesQueryVo.setType("2");
         //总应收
         //总应收
-        BigDecimal sySumAmount =  baseMapper.queryDateByTypeSumAmount(financialReceivablesQueryVo);
+        BigDecimal sySumAmount =  baseMapper.queryDateByNotTypeSumAmount(financialReceivablesQueryVo);
 
 
 
 
         return new FinancialReceivablesAllVo(ptSumAmount !=null? ptSumAmount.toString(): "0",sySumAmount !=null  ? sySumAmount.toString() : "0",year+"",list);
         return new FinancialReceivablesAllVo(ptSumAmount !=null? ptSumAmount.toString(): "0",sySumAmount !=null  ? sySumAmount.toString() : "0",year+"",list);
@@ -3464,11 +3466,11 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             throw new SystemException("月份不能为空");
             throw new SystemException("月份不能为空");
         }
         }
         String yearAndMonth = financialReceivablesQueryVo.getYearAndMonth();
         String yearAndMonth = financialReceivablesQueryVo.getYearAndMonth();
-        int year = Integer.parseInt(yearAndMonth.split("-")[0]);
-        int month = Integer.parseInt(yearAndMonth.split("-")[1]);
+//        int year = Integer.parseInt(yearAndMonth.split("-")[0]);
+//        int month = Integer.parseInt(yearAndMonth.split("-")[1]);
 
 
-        financialReceivablesQueryVo.setBeginDate(SliceUpDateUtil.getStartOfMonth(year, month));
-        financialReceivablesQueryVo.setEndDate(SliceUpDateUtil.getEndOfMonth(year, month));
+//        financialReceivablesQueryVo.setBeginDate(SliceUpDateUtil.getStartOfMonth(year, month));
+//        financialReceivablesQueryVo.setEndDate(SliceUpDateUtil.getEndOfMonth(year, month));
         //查询总数
         //查询总数
         FinancialReceivablesAllMonthVo vo = baseMapper.queryDateByTypeByMonth(financialReceivablesQueryVo);
         FinancialReceivablesAllMonthVo vo = baseMapper.queryDateByTypeByMonth(financialReceivablesQueryVo);
         if(vo!= null){
         if(vo!= null){

+ 3 - 1
src/main/java/com/ydtech/modules/order/controller/QuoteController.java

@@ -123,6 +123,8 @@ public class QuoteController extends BaseController {
 
 
         BaseQuoteInfoVo quoteInfo = insOrdersComponents.getQuoteInfo(quoteVo.getOrderNo(), quoteVo.getAgreementId(),quoteVo.getKinds());
         BaseQuoteInfoVo quoteInfo = insOrdersComponents.getQuoteInfo(quoteVo.getOrderNo(), quoteVo.getAgreementId(),quoteVo.getKinds());
         quoteInfo.setKindList(kinds);
         quoteInfo.setKindList(kinds);
+        //设置座位数 驾意险需要传
+        quoteVo.setSeatNum(quoteInfo.getCarInfo().getSeatCount());
 
 
         HttpResult<QuoteRespVo> respVo = null;
         HttpResult<QuoteRespVo> respVo = null;
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@@ -186,7 +188,7 @@ public class QuoteController extends BaseController {
             QuoteAccidentalDrivingVo javaObject = jsonObject.toJavaObject(QuoteAccidentalDrivingVo.class);
             QuoteAccidentalDrivingVo javaObject = jsonObject.toJavaObject(QuoteAccidentalDrivingVo.class);
             BeanUtils.copyProperties(quoteVo, quoteVo1);
             BeanUtils.copyProperties(quoteVo, quoteVo1);
             quoteVo1.setAccidentalDrivingVo(javaObject);
             quoteVo1.setAccidentalDrivingVo(javaObject);
-
+//            quoteVo1.setSeatNum();
             BaseQuoteVo<GuorenAccidentalDrivingVo> baseQuoteVo = insOrdersService.convertDriving(quoteVo1);
             BaseQuoteVo<GuorenAccidentalDrivingVo> baseQuoteVo = insOrdersService.convertDriving(quoteVo1);
             GuoRenQuoteVo guoRenQuoteVo = new GuoRenQuoteVo();
             GuoRenQuoteVo guoRenQuoteVo = new GuoRenQuoteVo();
             BeanUtils.copyProperties(baseQuoteVo, guoRenQuoteVo);
             BeanUtils.copyProperties(baseQuoteVo, guoRenQuoteVo);

+ 11 - 1
src/main/java/com/ydtech/modules/order/service/impl/InsOrdersServiceImpl.java

@@ -1676,7 +1676,7 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
             guoRenBaseQuoteVo.getAccidentalDrivingVo().setProdCode(baseQuoteVo.getAccidentalDrivingVo().getProjectCode());
             guoRenBaseQuoteVo.getAccidentalDrivingVo().setProdCode(baseQuoteVo.getAccidentalDrivingVo().getProjectCode());
             guoRenBaseQuoteVo.getAccidentalDrivingVo().setGoodsCode(baseQuoteVo.getAccidentalDrivingVo().getParentCode());
             guoRenBaseQuoteVo.getAccidentalDrivingVo().setGoodsCode(baseQuoteVo.getAccidentalDrivingVo().getParentCode());
             guoRenBaseQuoteVo.getAccidentalDrivingVo().setGoodsName(baseQuoteVo.getAccidentalDrivingVo().getParentName());
             guoRenBaseQuoteVo.getAccidentalDrivingVo().setGoodsName(baseQuoteVo.getAccidentalDrivingVo().getParentName());
-            InsDrivingIntentionInsurance byProjectCode = insDrivingIntentionInsuranceService.getByProjectCode(baseQuoteVo.getCompanyId(), baseQuoteVo.getAccidentalDrivingVo().getProjectCode());
+            InsDrivingIntentionInsurance byProjectCode = insDrivingIntentionInsuranceService.getByProjectCode(baseQuoteVo.getCompanyId(), baseQuoteVo.getAccidentalDrivingVo().getProjectCode(),baseQuoteVo.getSeatNum());
             guoRenBaseQuoteVo.getAccidentalDrivingVo().setRiskCode(byProjectCode.getRiskCode());
             guoRenBaseQuoteVo.getAccidentalDrivingVo().setRiskCode(byProjectCode.getRiskCode());
             guoRenBaseQuoteVo.getAccidentalDrivingVo().setQuantity(baseQuoteVo.getAccidentalDrivingVo().getQuantity());
             guoRenBaseQuoteVo.getAccidentalDrivingVo().setQuantity(baseQuoteVo.getAccidentalDrivingVo().getQuantity());
             return guoRenBaseQuoteVo;
             return guoRenBaseQuoteVo;
@@ -1808,6 +1808,16 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
             InsDrivingIntentionInsurance byProjectCode = insDrivingIntentionInsuranceService.getByProjectCode(baseQuoteVo.getCompanyId(), baseQuoteVo.getAccidentalDrivingVo().getProjectCode(), baseQuoteVo.getSeatNum());
             InsDrivingIntentionInsurance byProjectCode = insDrivingIntentionInsuranceService.getByProjectCode(baseQuoteVo.getCompanyId(), baseQuoteVo.getAccidentalDrivingVo().getProjectCode(), baseQuoteVo.getSeatNum());
             chengtaiBaseQuoteVo.setAccidentalDrivingVo(JSONObject.parseObject(byProjectCode.getRequestData()));
             chengtaiBaseQuoteVo.setAccidentalDrivingVo(JSONObject.parseObject(byProjectCode.getRequestData()));
             return chengtaiBaseQuoteVo;
             return chengtaiBaseQuoteVo;
+        } else if(baseQuoteVo.getCompanyId().equals("CPIC1000000")){
+            // 太平洋财险
+            BaseQuoteVo<Object> taiPingYangBaseQuoteVo = new BaseQuoteVo<>();
+            BeanUtils.copyProperties(baseQuoteVo, taiPingYangBaseQuoteVo);
+            JSONObject accidentObject = JSONObject.parseObject(JSONObject.toJSONString(taiPingYangBaseQuoteVo.getAccidentalDrivingVo()));
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("productCode", accidentObject.getString("projectCode"));
+            jsonObject.put("planCode", accidentObject.getString("riskCode"));
+            taiPingYangBaseQuoteVo.setAccidentalDrivingVo(jsonObject);
+            return taiPingYangBaseQuoteVo;
         }
         }
 
 
         return null;
         return null;

+ 6 - 0
src/main/resources/mapper/modules/admin/SysGeographyPositionRecordMapper.xml

@@ -34,6 +34,9 @@
                     #{item}
                     #{item}
                 </foreach>
                 </foreach>
             </if>
             </if>
+            <if test="queryId != null and queryId != ''">
+                and user_id like concat(#{dto.queryId},'%')
+            </if>
             <if test="dates != null and dates != ''">
             <if test="dates != null and dates != ''">
                 and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
                 and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
             </if>
             </if>
@@ -62,6 +65,9 @@
                     #{item}
                     #{item}
                 </foreach>
                 </foreach>
             </if>
             </if>
+            <if test="queryId != null and queryId != ''">
+                and user_id like concat(#{dto.queryId},'%')
+            </if>
             <if test="dates != null and dates != ''">
             <if test="dates != null and dates != ''">
                 and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
                 and DATE_FORMAT(s.create_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
             </if>
             </if>

+ 12 - 0
src/main/resources/mapper/modules/admin/SysPcAddressHistoryMapper.xml

@@ -41,6 +41,9 @@
                          #{item}
                          #{item}
                      </foreach>
                      </foreach>
                  </if>
                  </if>
+                 <if test="queryId != null and queryId != ''">
+                     and user_id like concat(#{dto.queryId},'%')
+                 </if>
                  <if test="dates != null and dates != ''">
                  <if test="dates != null and dates != ''">
                      and DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
                      and DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
                  </if>
                  </if>
@@ -73,6 +76,9 @@
                     #{item}
                     #{item}
                 </foreach>
                 </foreach>
             </if>
             </if>
+            <if test="queryId != null and queryId != ''">
+                and user_id like concat(#{dto.queryId},'%')
+            </if>
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                 and (DATE_FORMAT(s.operation_time, '%Y-%m-%d') between DATE_FORMAT( #{startTime}, '%Y-%m-%d') and DATE_FORMAT( #{endTime}, '%Y-%m-%d'))
                 and (DATE_FORMAT(s.operation_time, '%Y-%m-%d') between DATE_FORMAT( #{startTime}, '%Y-%m-%d') and DATE_FORMAT( #{endTime}, '%Y-%m-%d'))
             </if>
             </if>
@@ -103,6 +109,9 @@
                     #{item}
                     #{item}
                 </foreach>
                 </foreach>
             </if>
             </if>
+            <if test="queryId != null and queryId != ''">
+                and user_id like concat(#{dto.queryId},'%')
+            </if>
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                 and (DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) between DATE_FORMAT( #{startTime}, '%Y-%m-%d' ) and DATE_FORMAT( #{endTime}, '%Y-%m-%d' ))
                 and (DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) between DATE_FORMAT( #{startTime}, '%Y-%m-%d' ) and DATE_FORMAT( #{endTime}, '%Y-%m-%d' ))
             </if>
             </if>
@@ -131,6 +140,9 @@
                         #{item}
                         #{item}
                     </foreach>
                     </foreach>
                 </if>
                 </if>
+                <if test="queryId != null and queryId != ''">
+                    and user_id like concat(#{dto.queryId},'%')
+                </if>
                 <if test="dates != null and dates != ''">
                 <if test="dates != null and dates != ''">
                     and DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
                     and DATE_FORMAT(s.operation_time, '%Y-%m-%d' ) = DATE_FORMAT( #{dates}, '%Y-%m-%d' )
                 </if>
                 </if>

+ 199 - 7
src/main/resources/mapper/modules/console/ProfitAnalysisMapper.xml

@@ -9,12 +9,15 @@
 
 
         select iae.expenses_id as "expensesId",
         select iae.expenses_id as "expensesId",
                iae.parent_id as "parentId",
                iae.parent_id as "parentId",
-               iae.category as "category",
-               a.applyAmount as "applyAmount"
+                case when iae.parent_id ='0' then iae.category  end as "category",
+                case when iae.parent_id !='0' then iae.category   end as "subcategory",
+               a.applyAmount as "applyAmount",
+               a.parentId as "parentId"
         from inv_account_expenses iae
         from inv_account_expenses iae
         left  join  (
         left  join  (
             SELECT
             SELECT
                 b.expensesId,
                 b.expensesId,
+                b.parentId,
                 sum( CAST(a.apply_amount AS DECIMAL ( 10, 2 )) ) AS "applyAmount"
                 sum( CAST(a.apply_amount AS DECIMAL ( 10, 2 )) ) AS "applyAmount"
             FROM
             FROM
                 inv_account_operate a
                 inv_account_operate a
@@ -23,12 +26,16 @@
                         a.category AS "aCategory",
                         a.category AS "aCategory",
                         b.category AS "bCategory",
                         b.category AS "bCategory",
                         a.expenditure_details AS "expenditureDetails",
                         a.expenditure_details AS "expenditureDetails",
-                        a.expenses_id AS "expensesId"
+                        a.expenses_id AS "expensesId",
+                        a.parent_id as "parentId"
                     FROM
                     FROM
                         inv_account_expenses a
                         inv_account_expenses a
                             LEFT JOIN inv_account_expenses b ON a.parent_id = b.expenses_id
                             LEFT JOIN inv_account_expenses b ON a.parent_id = b.expenses_id
                     WHERE
                     WHERE
                         b.category IS NOT NULL
                         b.category IS NOT NULL
+                    <if test="vo.expensesType !=null  and  vo.expensesType !='' ">
+                        AND a.expenditure_details  =#{vo.expensesType}
+                    </if>
                 ) b ON a.fund_use = b.bCategory
                 ) b ON a.fund_use = b.bCategory
                     AND a.fund_fen = b.aCategory
                     AND a.fund_fen = b.aCategory
             WHERE
             WHERE
@@ -44,9 +51,6 @@
                 )
                 )
               AND a.revenue_outlay = '1'
               AND a.revenue_outlay = '1'
               AND a.del_flag = '0'
               AND a.del_flag = '0'
-              <if test="vo.expensesType !=null  and  vo.expensesType !='' ">
-                  AND b.expenditureDetails  =#{vo.expensesType}
-              </if>
 
 
               <if test="vo.yearAndMonth !=null and vo.yearAndMonth !=''">
               <if test="vo.yearAndMonth !=null and vo.yearAndMonth !=''">
                   AND DATE_FORMAT( a.create_time, '%Y-%m' )=#{vo.yearAndMonth}
                   AND DATE_FORMAT( a.create_time, '%Y-%m' )=#{vo.yearAndMonth}
@@ -60,9 +64,81 @@
             GROUP BY
             GROUP BY
                 b.expensesId
                 b.expensesId
         ) a  on a.expensesId  =iae.expenses_id
         ) a  on a.expensesId  =iae.expenses_id
+        <where>
+            <if test="vo.expensesType !=null  and  vo.expensesType !='' ">
+                AND iae.expenditure_details  =#{vo.expensesType}
+            </if>
+
+        </where>
     </select>
     </select>
 
 
 
 
+    <select id="getSumCategory" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
+
+        select   a.parentId as "parentId",
+                 sum(a.applyAmount) as "applyAmount"
+        from  (
+        SELECT
+        b.parentId,
+        sum( CAST(a.apply_amount AS DECIMAL ( 10, 2 )) ) AS "applyAmount"
+        FROM
+        inv_account_operate a
+        LEFT JOIN (
+        SELECT
+        a.category AS "aCategory",
+        b.category AS "bCategory",
+        a.expenditure_details AS "expenditureDetails",
+        a.expenses_id AS "expensesId",
+        a.parent_id as "parentId"
+        FROM
+        inv_account_expenses a
+        LEFT JOIN inv_account_expenses b ON a.parent_id = b.expenses_id
+        WHERE
+        b.category IS NOT NULL
+        <if test="vo.expensesType !=null  and  vo.expensesType !='' ">
+            AND a.expenditure_details  =#{vo.expensesType}
+        </if>
+        ) b ON a.fund_use = b.bCategory
+        AND a.fund_fen = b.aCategory
+        WHERE
+        a.out_card_num IN (
+        SELECT
+        bank_card_num
+        FROM
+        inv_account_card iac
+        LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
+        WHERE
+        ia.del_flag = '0'
+        AND ia.outer_flag LIKE concat( '%', '0', '%' )
+        )
+        AND a.revenue_outlay = '1'
+        AND a.del_flag = '0'
+
+        <if test="vo.yearAndMonth !=null and vo.yearAndMonth !=''">
+            AND DATE_FORMAT( a.create_time, '%Y-%m' )=#{vo.yearAndMonth}
+        </if>
+        <if test="vo.expensesIds !=null  and  vo.expensesIds !='' and vo.expensesIds.size()>0 ">
+            and b.expensesId in
+            <foreach collection="vo.expensesIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="vo.ids !=null  and  vo.ids !='' and vo.ids.size()>0 ">
+            and b.parentId in
+            <foreach collection="vo.ids" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY
+        b.expensesId
+       ) a
+        group by   a.parentId
+    </select>
+
+
+
+
+
     <select id="getAllAccountExpensesId" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
     <select id="getAllAccountExpensesId" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
         SELECT
         SELECT
         b.expensesId,
         b.expensesId,
@@ -122,9 +198,125 @@
     <select id="selectAccountExpenses" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
     <select id="selectAccountExpenses" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
         select iae.expenses_id as "expensesId",
         select iae.expenses_id as "expensesId",
         iae.parent_id as "parentId",
         iae.parent_id as "parentId",
-        iae.category as "category"
+        case when iae.parent_id ='0' then iae.category  end as "category",
+        case when iae.parent_id !='0' then iae.category   end as "subcategory"
         from inv_account_expenses iae
         from inv_account_expenses iae
+        <where>
+            1=1
+            <if test="vo.expensesType !=null  and  vo.expensesType !='' ">
+                AND iae.expenditure_details  =#{vo.expensesType}
+            </if>
+        </where>
+
     </select>
     </select>
 
 
 
 
+    <select id="getByparentId" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
+        select
+        a.expenses_id as "expensesId",
+        a.category as "category",
+        a.parent_id as "parentId"
+        from  inv_account_expenses  a
+        <where>
+            <if test="parentId !=null  and  parentId !=''">
+                a.parent_id =#{parentId}
+            </if>
+        </where>
+    </select>
+
+    <select id="getSumByparentAmount" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
+        select  IFNULL(sum(a.applyAmount),0) as "applyAmount" from  (
+        SELECT
+        sum( CAST(a.apply_amount AS DECIMAL ( 10, 2 )) ) AS "applyAmount"
+        FROM
+        inv_account_operate a
+        LEFT JOIN (
+        SELECT
+        a.category AS "aCategory",
+        b.category AS "bCategory",
+        a.expenditure_details AS "expenditureDetails",
+        a.expenses_id AS "expensesId"
+        FROM
+        inv_account_expenses a
+        LEFT JOIN inv_account_expenses b ON a.parent_id = b.expenses_id
+        WHERE
+        b.category IS NOT NULL
+        ) b ON a.fund_use = b.bCategory
+        AND a.fund_fen = b.aCategory
+        WHERE
+        a.out_card_num IN (
+        SELECT
+        bank_card_num
+        FROM
+        inv_account_card iac
+        LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
+        WHERE
+        ia.del_flag = '0'
+        AND ia.outer_flag LIKE concat( '%', '0', '%' )
+        )
+        AND a.revenue_outlay = '1'
+        AND a.del_flag = '0'
+        <if test="vo.expensesType !=null  and  vo.expensesType !='' ">
+            <choose>
+                <when test="vo.expensesType !=3 ">
+                    AND b.expenditureDetails = #{vo.expensesType}
+                </when>
+                <when test="vo.expensesType = 3 ">
+                    AND b.expenditureDetails !=  #{vo.expensesType}
+                </when>
+            </choose>
+        </if>
+        <if test="vo.expensesIds !=null  and  vo.expensesIds !='' and vo.expensesIds.size()>0 ">
+            and b.expensesId in
+            <foreach collection="vo.expensesIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="vo.yearAndMonth !=null and vo.yearAndMonth !=''">
+            AND DATE_FORMAT( a.create_time, '%Y-%m' )=#{vo.yearAndMonth}
+        </if>
+        GROUP BY
+        b.expensesId) a
+    </select>
+
+
+    <select id="getTotalExpenditure" resultType="java.util.HashMap">
+     select sum(a.fixedCost)  as "fixedCost",
+            sum(a.laborCost)  as "laborCost",
+            sum(a.taxation)  as "taxation"
+     from  (
+            SELECT
+            CAST(sum(case when b.expenditureDetails = '1' then a.apply_amount else 0 end) as  DECIMAL(10, 2) ) as "laborCost",
+            CAST(sum(case when b.expenditureDetails = '2' then a.apply_amount else 0 end) as  DECIMAL(10, 2) ) as "fixedCost",
+            CAST(sum(case when b.expenditureDetails = '4' then a.apply_amount else 0 end) as  DECIMAL(10, 2) ) as "taxation",
+            b.expenditureDetails
+            FROM
+            inv_account_operate a
+            left  join  (
+            select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from  inv_account_expenses a
+            left  join  inv_account_expenses  b  on a.parent_id =b.expenses_id
+            where   b.category  is  not  null
+            )  b on a.fund_use  = b.bCategory  and  a.fund_fen  = b.aCategory
+            <where>
+                a.out_card_num IN (
+                SELECT
+                bank_card_num
+                FROM
+                inv_account_card iac
+                LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
+                WHERE
+                ia.del_flag = '0'
+                AND ia.outer_flag LIKE concat( '%', '0', '%' )
+                )
+                AND a.revenue_outlay = '1'
+                AND a.del_flag = '0'
+                <if test="vo.yearAndMonth  !=null  and vo.yearAndMonth !=''">
+                   and  DATE_FORMAT( a.create_time, '%Y-%m' ) =#{vo.yearAndMonth}
+                </if>
+            </where>
+            GROUP BY  DATE_FORMAT( a.create_time, '%Y-%m' )  , b.expenditureDetails
+             )  a
+
+    </select>
+
 </mapper>
 </mapper>

+ 127 - 16
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -2454,23 +2454,58 @@
     </select>
     </select>
 
 
     <select id="queryDateByTypeSumAmount" resultType="java.math.BigDecimal">
     <select id="queryDateByTypeSumAmount" resultType="java.math.BigDecimal">
+          select
+             IFNULL( sum(a.readyCommissionFeevalue),0) as "noSettlementAmount"
+          from  (
         SELECT
         SELECT
-          SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
+        a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
+        FROM
+        (
+        SELECT
+        DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
+        IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
         FROM
         FROM
         ins_ply_income a
         ins_ply_income a
-        LEFT JOIN
-        ptl_agreement pa ON pa.id = a.agreement_id
+        LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
         <where>
         <where>
-            <if test="vo.type !=null  and  vo.type  !=''">
-                and pa.agreement_type =#{vo.type}
-            </if>
+            pa.agreement_type = '2'
             <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
             <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
                 and a.is_not_car =#{vo.isNotCar}
                 and a.is_not_car =#{vo.isNotCar}
             </if>
             </if>
-            <if test="vo.year !=null  and  vo.year !=''">
-                and  DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
+        </where>
+        GROUP BY
+        DATE_FORMAT( a.signdate, '%Y-%m' )
+        ) a
+        LEFT JOIN (
+        SELECT
+        DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
+        sum( a.settlement_amount ) AS "settCommAmount",
+        sum(a.remaining_amount) as "remainingAmount",
+        sum(a.total_amount) as "invoicComm"
+        FROM
+        sys_insurance_handling_settlement_month a
+        <where>
+            1=1
+            <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
+                and a.is_not_car =#{vo.isNotCar}
             </if>
             </if>
         </where>
         </where>
+        GROUP BY
+        DATE_FORMAT( a.signing_time, '%Y-%m' )
+        ) b ON a.subSigndate = b.subSigndate
+        left  join  (
+        select DATE_FORMAT( a.signing_time, '%Y-%m' ) as "subSigndate" ,  sum(settlement_amount) as "otherInvoic", sum(invoiced_settled_amount) as "settAmountOther", sum(Invoiced_not_settled_amount) as "invoicNotOther"
+        from
+        settlement_documentary_fees  a
+        where a.settlement_status='1'
+        and handling_fees_status ='1'
+        <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
+            and a.is_not_car =#{vo.isNotCar}
+        </if>
+        GROUP BY 	DATE_FORMAT( a.signing_time, '%Y-%m' )
+        )  c  on c.subSigndate=a.subSigndate
+        order by    a.subSigndate
+                           ) a
     </select>
     </select>
 
 
     <select id="queryDateByType"
     <select id="queryDateByType"
@@ -2562,8 +2597,8 @@
             <if test="vo.type !=null  and  vo.type  !=''">
             <if test="vo.type !=null  and  vo.type  !=''">
                 and pa.agreement_type =#{vo.type}
                 and pa.agreement_type =#{vo.type}
             </if>
             </if>
-            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
-                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+            <if test="vo.yearAndMonth  != null  and  vo.yearAndMonth!=''  ">
+                AND   DATE_FORMAT(a.signdate, '%Y-%m' )  =#{vo.yearAndMonth}
             </if>
             </if>
            <if test="vo.yearAndMonth  != null  and  vo.yearAndMonth!=''">
            <if test="vo.yearAndMonth  != null  and  vo.yearAndMonth!=''">
                 AND   DATE_FORMAT(a.signdate, '%Y-%m') =#{vo.yearAndMonth}
                 AND   DATE_FORMAT(a.signdate, '%Y-%m') =#{vo.yearAndMonth}
@@ -2714,8 +2749,8 @@
                 LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
                 LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
         <where>
         <where>
             pa.agreement_type = '1'
             pa.agreement_type = '1'
-            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
-                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+            <if test="vo.yearAndMonth  != null  and  vo.yearAndMonth!=''  ">
+                AND   DATE_FORMAT(a.signdate, '%Y-%m' )  =#{vo.yearAndMonth}
             </if>
             </if>
             <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
             <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
                 and a.is_not_car =#{vo.isNoCar}
                 and a.is_not_car =#{vo.isNoCar}
@@ -2744,8 +2779,8 @@
                 LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
                 LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
         <where>
         <where>
             pa.agreement_type = '1'
             pa.agreement_type = '1'
-            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
-                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+            <if test="vo.yearAndMonth  != null  and  vo.yearAndMonth!=''  ">
+                AND   DATE_FORMAT(a.signdate, '%Y-%m' )  =#{vo.yearAndMonth}
             </if>
             </if>
             <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
             <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
                 and a.is_not_car =#{vo.isNoCar}
                 and a.is_not_car =#{vo.isNoCar}
@@ -2772,8 +2807,8 @@
                 LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
                 LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
         <where>
         <where>
             pa.agreement_type = '1'
             pa.agreement_type = '1'
-            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
-                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+            <if test="vo.yearAndMonth  != null  and  vo.yearAndMonth!=''  ">
+                AND   DATE_FORMAT(a.signdate, '%Y-%m' )  =#{vo.yearAndMonth}
             </if>
             </if>
             <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
             <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
                 and a.is_not_car =#{vo.isNoCar}
                 and a.is_not_car =#{vo.isNoCar}
@@ -3459,4 +3494,80 @@
         pa.docking_person
         pa.docking_person
         order by  sum( a.all_fee_value ) - sum(case when a.handling_fees_status =1 then a.all_fee_value else 0 end) desc
         order by  sum( a.all_fee_value ) - sum(case when a.handling_fees_status =1 then a.all_fee_value else 0 end) desc
     </select>
     </select>
+
+
+    <select id="queryDateByNotTypeSumAmount" resultType="java.math.BigDecimal">
+        select  IFNULL(sum(a.noSettlementAmount),0) as "sySumAmount"
+        from  (
+        SELECT
+        (a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0)))  as "noSettlementAmount"
+        FROM
+        (
+        SELECT
+        DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
+        IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
+        FROM
+        ins_ply_income a
+        LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
+        <where>
+            pa.agreement_type = '2'
+            <if test="vo.year !=null  and  vo.year !=''">
+                and  DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
+            </if>
+        </where>
+        GROUP BY
+        DATE_FORMAT( a.signdate, '%Y-%m' )
+        ) a
+        LEFT JOIN (
+        SELECT
+        DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
+        sum( a.settlement_amount ) AS "settCommAmount",
+        sum(a.remaining_amount) as "remainingAmount",
+        sum(a.total_amount) as "invoicComm"
+        FROM
+        sys_insurance_handling_settlement_month a
+        <where>
+            <if test="vo.year !=null  and  vo.year !=''">
+                DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
+            </if>
+        </where>
+        GROUP BY
+        DATE_FORMAT( a.signing_time, '%Y-%m' )
+        ) b ON a.subSigndate = b.subSigndate
+        left  join  (
+        select DATE_FORMAT( a.signing_time, '%Y-%m' ) as "subSigndate" ,  sum(settlement_amount) as "otherInvoic", sum(invoiced_settled_amount) as "settAmountOther", sum(Invoiced_not_settled_amount) as "invoicNotOther"
+        from
+        settlement_documentary_fees  a
+        <where>
+            a.settlement_status='1'
+            and handling_fees_status ='1'
+            <if test="vo.year !=null  and  vo.year !=''">
+                and    DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
+            </if>
+        </where>
+        GROUP BY 	DATE_FORMAT( a.signing_time, '%Y-%m' )
+        )  c  on c.subSigndate=a.subSigndate
+        ORDER BY   a.subSigndate
+    ) a
+    </select>
+
+
+    <select id="queryDateByTypeNotSumAmount" resultType="java.math.BigDecimal">
+        SELECT
+        IFNULL(a.notInvoicAmount, 0) as "noSettlementAmount"
+        FROM (
+        SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "notInvoicAmount"
+        FROM ins_ply_income a
+        LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
+        <where>
+            pa.agreement_type = '1'
+            and a.handling_fees_status = '0'
+            <if test="vo.year !=null  and  vo.year !=''">
+                and   DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
+            </if>
+        </where>
+        ) a
+
+
+    </select>
 </mapper>
 </mapper>