Prechádzať zdrojové kódy

APP 机构负责人

helixiao 2 rokov pred
rodič
commit
fbae8edf26

+ 0 - 2
src/main/java/com/ydtech/modules/admin/model/dto/TeamInformationDto.java

@@ -9,8 +9,6 @@ import org.springframework.format.annotation.DateTimeFormat;
 @ApiModel(value = "查询机构下团队信息")
 public class TeamInformationDto {
 
-    @ApiModelProperty(value = "机构负责人id")
-    private String userId;
 
     @ApiModelProperty(value = "团队name")
     private String deptName;

+ 6 - 0
src/main/java/com/ydtech/modules/admin/model/vo/TeamInformation.java

@@ -12,6 +12,12 @@ import java.util.Date;
 @ApiModel(value = "机构下团队的信息实体")
 public class TeamInformation {
 
+
+    /**
+     * 团队名称
+     */
+    @ApiModelProperty(value = "负责人")
+    private String userName;
     /**
      * 团队id
      */

+ 20 - 18
src/main/java/com/ydtech/modules/admin/service/impl/SysAgencyLeaderServiceImpl.java

@@ -636,10 +636,7 @@ public class SysAgencyLeaderServiceImpl extends ServiceImpl<SysAgencyLeaderMappe
 
     @Override
     public BasePageResult<TeamInformation> queryTeamInfoPage(TeamInformationDto teamInformationDto) {
-        String userId = teamInformationDto.getUserId();
-        if (userId == null) {
-            userId = BaseController.getUserId();
-        }
+        String userId = BaseController.getUserId();
         List<TeamInformation> informationList = new ArrayList<>();
         //机构负责人查询机构下的团队
         SysAgencyLeader sysAgencyLeaders = sysAgencyLeaderMapper.selectOne(new LambdaQueryWrapper<SysAgencyLeader>().eq(SysAgencyLeader::getUserId, userId)
@@ -663,9 +660,11 @@ public class SysAgencyLeaderServiceImpl extends ServiceImpl<SysAgencyLeaderMappe
             BigDecimal bigDecimal = new BigDecimal("0.00");
             for (SysDept sysDept : sysDeptList) {
                 TeamInformation teamInformation = new TeamInformation();
+                teamInformation.setUserName(sysAgencyLeaders.getUserName());
                 teamInformation.setDeptId(sysDept.getId());
                 teamInformation.setDeptName(sysDept.getName());
-                List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().likeRight(SysUser::getId, sysDept.getId()).eq(SysUser::getStatus, 1));
+                List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
+                        .likeRight(SysUser::getId, sysDept.getId()).eq(SysUser::getStatus, 1));
                 teamInformation.setDeptManNum(sysUsers.size());
                 List<InsOrders> insOrderList;
                 //筛选订单,选择时间
@@ -689,36 +688,39 @@ public class SysAgencyLeaderServiceImpl extends ServiceImpl<SysAgencyLeaderMappe
                 }
 
                 if (insOrderList.size() > 0) {
-                    for (InsOrders insOrders : insOrderList) {
+                        List<String> collect = insOrderList.stream().map(InsOrders::getOrderno).collect(Collectors.toList());
                         //查询订单下的所有子订单
-                        List<InsAreaCompany> insAreaCompanies = insAreaCompanyMapper.selectList(new LambdaQueryWrapper<InsAreaCompany>().eq(InsAreaCompany::getOrderno, insOrders.getOrderno())
+                        List<InsAreaCompany> insAreaCompanies = insAreaCompanyMapper.selectList(new LambdaQueryWrapper<InsAreaCompany>()
+                                .in(InsAreaCompany::getOrderno, collect)
                                 .eq(InsAreaCompany::getOrderstatus, 3));
                         if (insAreaCompanies.size() > 0) {
-                            for (InsAreaCompany insAreaCompany : insAreaCompanies) {
                                 //累加每一个子订单的交强险费用+商业险费用+驾意险费用
-                                bigDecimal = bigDecimal.add(insAreaCompany.getJqpremium()).add(insAreaCompany.getSypremium()).add(insAreaCompany.getJypremium());
+                                BigDecimal jqpremium = insAreaCompanies.stream().map(InsAreaCompany::getJqpremium).reduce(BigDecimal.ZERO, BigDecimal::add);
+                                BigDecimal sypremium = insAreaCompanies.stream().map(InsAreaCompany::getSypremium).reduce(BigDecimal.ZERO, BigDecimal::add);
+                                BigDecimal jypremium = insAreaCompanies.stream().map(InsAreaCompany::getJypremium).reduce(BigDecimal.ZERO, BigDecimal::add);
 
-                            }
+                                bigDecimal = jqpremium.add(sypremium).add(jypremium);
                         }
-                    }
+
                 }
                 teamInformation.setSumpremium(bigDecimal);
-                int num = 0;
+//                int num = 0;
                 // 查团队有几人出单 :订单表中userid相等同时在 子订单表中状态为3已承保才为出单
                 List<String> userIdList = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
                 for (String s : userIdList) {
                     List<InsOrders> collect = insOrderList.stream().filter(InsOrders -> InsOrders.getUserid().equals(s)).collect(Collectors.toList());
                     if (collect.size() > 0) {
-                        InsOrders insOrders = collect.get(0);
-                        List<InsAreaCompany> insAreaCompanies1 = insAreaCompanyMapper.selectList(new LambdaQueryWrapper<InsAreaCompany>().eq(InsAreaCompany::getOrderno, insOrders.getOrderno())
+                        List<String> insOrders = collect.stream().map(InsOrders::getOrderno).collect(Collectors.toList());
+                        List<InsAreaCompany> insAreaCompanies1 = insAreaCompanyMapper.selectList(new LambdaQueryWrapper<InsAreaCompany>()
+                                .in(InsAreaCompany::getOrderno, insOrders)
                                 .eq(InsAreaCompany::getOrderstatus, 3));
-                        if (insAreaCompanies1.size() > 0) {
-                            num++;
-                        }
+//                        if (insAreaCompanies1.size() > 0) {
+//                            num++;
+//                        }
 
+                        teamInformation.setOrderManNum(insAreaCompanies1.size());
                     }
                 }
-                teamInformation.setOrderManNum(num);
                 informationList.add(teamInformation);
 
             }