فهرست منبع

1.控制台业务数据调整

wuhp 1 سال پیش
والد
کامیت
ff7e9e9422

+ 2 - 0
src/main/java/com/ydtech/modules/admin/dao/SysUserMapper.java

@@ -509,6 +509,8 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
      *  @Description:  通过机构id查询后线用户数据
      */
     List<SysUser> getLeadListDeptId(@Param("deptId") String deptId);
+
+    List<SysUser> selectByLeadId(String userId);
 }
 
 

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

@@ -56,4 +56,10 @@ public class BusinessAgentData {
     @ApiModelProperty(value = "总人数")
     private String totalNumber;
 
+    @ApiModelProperty(value = "部门名称")
+    private String deptName;
+
+    @ApiModelProperty(value = "部门id")
+    private String deptId;
+
 }

+ 43 - 2
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptServiceImpl.java

@@ -771,7 +771,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
     public KztUserDeptTreeDto  getUserDeptTree(SysDeptVo sysDeptVo) {
         KztUserDeptTreeDto kztUserDeptTreeDto = new KztUserDeptTreeDto();
         String userId = BaseController.getUserId();
-        if (userId.contains("M")) {
+        QueryWrapper<SysDept> queryWrapper = new QueryWrapper<>();
+        QueryWrapper<SysDept> leaderId = queryWrapper.eq("leader_id", userId);
+        List<SysDept> sysDepts = sysDeptMapper.selectList(leaderId);
+        if (!sysDepts.isEmpty()) {
             kztUserDeptTreeDto.setType("1"); //前线
         } else {
             kztUserDeptTreeDto.setType("2"); //代理
@@ -796,7 +799,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
 
         List<SysUser> users = sysUserMapper.selectByParams(params);
 
-        if (users == null || users.size() == 0) {
+        for (SysUser user : users) {
+            this.appendName(user);
+        }
+        if (users == null || users.isEmpty()) {
             return new ArrayList<>();
         }
         List<SysUser> topUsers = new ArrayList<>(); //存放1级用户,即没有直接上级的用户
@@ -804,6 +810,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         if("admin".equals(sysUser.getName())){
             topUsers.add(sysUserMapper.selectById("99D1501"));
         }else {
+            this.appendName(sysUser);
             topUsers.add(sysUser);
         }
         // 递归构建用户树结构
@@ -811,6 +818,40 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         return topUsers;
     }
 
+    /**
+     * 拼接机构来源
+     * @param users
+     */
+    private void appendName(SysUser user) {
+        StringBuilder stringBuilder = new StringBuilder();
+        String deptId = user.getDeptId();
+        if (StringUtils.isNotEmpty(deptId)) {
+            int length = deptId.length();
+            if (length > 0) {
+                if (length <= 5) {
+                    String dept = deptId.replaceAll("[^\\d]*(\\d+).*", "$1");
+                    SysDept cityName = baseMapper.selectById(dept);
+                    String name = cityName.getName();
+                    stringBuilder.append("(").append(name).append(")");
+                } else if (length > 5) {
+                    String dept = deptId.replaceAll("[^\\d]*(\\d+).*", "$1");
+                    if (dept.length() < 5) {
+                        SysDept dept1 = baseMapper.selectById(dept);
+                        SysDept cityName = baseMapper.selectById(deptId);
+                        stringBuilder.append("(").append(dept1.getName()).append(cityName.getName()).append(")");
+                    } else {
+                        String deptIdTwo = dept.substring(0, 4);
+
+                        SysDept dept1 = baseMapper.selectById(deptIdTwo);
+                        SysDept dept2 = baseMapper.selectById(dept);
+                        stringBuilder.append("(").append(dept1.getName()).append(dept2.getName()).append(")");
+                    }
+                }
+                user.setName(user.getName()+stringBuilder.toString());
+            }
+        }
+    }
+
     private List<SysDeptTreeVo> getFiveLevelDeptKzt(SysUser byUserId) {
         SysDept sysDept = getById("9");
         SysDeptVo sysDeptVo = new SysDeptVo();

+ 40 - 1
src/main/java/com/ydtech/modules/admin/service/impl/TaskStatisticsServiceImpl.java

@@ -11,6 +11,7 @@ import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageRequest;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.dao.SysAmountAuditingMapper;
+import com.ydtech.modules.admin.dao.SysDeptMapper;
 import com.ydtech.modules.admin.dao.SysUserMapper;
 import com.ydtech.modules.admin.dao.TaskStatisticsMapper;
 import com.ydtech.modules.admin.model.SysDept;
@@ -23,6 +24,7 @@ import com.ydtech.modules.admin.model.vo.TaskStatisticsVo;
 import com.ydtech.modules.admin.service.SysDeptService;
 import com.ydtech.modules.admin.service.TaskStatisticsService;
 import com.ydtech.modules.admin.utils.SliceUpDateUtil;
+import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.base.model.vo.PageVo;
 import com.ydtech.modules.inv.utils.EasyExcelUtils;
 import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
@@ -70,6 +72,8 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
     private SysDeptService sysDeptService;
     @Autowired
     private SysUserMapper sysUserMapper;
+    @Autowired
+    private SysDeptMapper sysDeptMapper;
 
 
     @Value("${upload.file.path}")
@@ -373,6 +377,7 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
             }else if ("1".equals(taskStatisticsVo.getTreeType())){
                 taskStatisticsVo.setDeptId(taskStatisticsVo.getTreeUserId());
                 taskStatisticsVo.setTreeUserId(null);
+                taskStatisticsVo.setUserIds(new ArrayList<>());
             }
         }
         PageVo<TaskStatisticsVo> pageVo = new PageVo<>();
@@ -387,6 +392,10 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
         taskStatisticsVo.setCreatetimeEnd(dateMapByType.get("endDate"));
 
         IPage<BusinessAgentData> list = this.taskStatisticsMapper.getBusinessAgentData(page,taskStatisticsVo);
+        List<BusinessAgentData> records = list.getRecords();
+        for (BusinessAgentData record : records) {
+            this.appendName(record);
+        }
         Long  total = this.taskStatisticsMapper.getBusinessAgentDataTotal(taskStatisticsVo);
         list.setTotal(total);
         return list;
@@ -537,10 +546,11 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
             }else if ("1".equals(taskStatisticsVo.getTreeType())){
                 taskStatisticsVo.setDeptId(taskStatisticsVo.getTreeUserId());
                 taskStatisticsVo.setTreeUserId(null);
+                taskStatisticsVo.setUserIds(new ArrayList<>());
             }
         }
 
-
+        String deptId = BaseController.getDeptId();
         BusinessAgentData result = this.taskStatisticsMapper.getBusinessAgentDataTotalAdd(taskStatisticsVo);
         Long  total = this.taskStatisticsMapper.getBusinessAgentDataTotal(taskStatisticsVo);
         result.setTotalNumber(total.toString());
@@ -629,4 +639,33 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
         IPage<TaskStatisticsDto> list = this.taskStatisticsMapper.channelAgentDetails(page,taskStatisticsVo);
         return list;
     }
+    private void appendName(BusinessAgentData user) {
+        StringBuilder stringBuilder = new StringBuilder();
+        String deptId = user.getDeptId();
+        if (com.ydtech.utils.StringUtils.isNotEmpty(deptId)) {
+            int length = deptId.length();
+            if (length > 0) {
+                if (length <= 5) {
+                    String dept = deptId.replaceAll("[^\\d]*(\\d+).*", "$1");
+                    SysDept cityName = sysDeptMapper.selectById(dept);
+                    String name = cityName.getName();
+                    stringBuilder.append("(").append(name).append(")");
+                } else if (length > 5) {
+                    String dept = deptId.replaceAll("[^\\d]*(\\d+).*", "$1");
+                    if (dept.length() < 5) {
+                        SysDept dept1 = sysDeptMapper.selectById(dept);
+                        SysDept cityName = sysDeptMapper.selectById(deptId);
+                        stringBuilder.append(dept1.getName()).append(cityName.getName());
+                    } else {
+                        String deptIdTwo = dept.substring(0, 4);
+
+                        SysDept dept1 = sysDeptMapper.selectById(deptIdTwo);
+                        SysDept dept2 = sysDeptMapper.selectById(dept);
+                        stringBuilder.append(dept1.getName()).append(dept2.getName());
+                    }
+                }
+                user.setDeptName(stringBuilder.toString());
+            }
+        }
+    }
 }

+ 2 - 3
src/main/java/com/ydtech/modules/admin/utils/KztGetDeptUtils.java

@@ -100,9 +100,8 @@ public class KztGetDeptUtils {
         ApplicationContext applicationContext = SpringContextUtil.getApplicationContext();
         SysUserMapper sysUserMapper = applicationContext.getBean(SysUserMapper.class);
         sysUserMapper.selectUserById(userId);
-        HashMap<String, Object> params = new HashMap<>();
-        params.put("leaderId", userId);
-        List<SysUser> sysUsers = sysUserMapper.selectByParams(params);
+
+        List<SysUser> sysUsers = sysUserMapper.selectByLeadId(userId);
         if (!sysUsers.isEmpty()) {
             ids.addAll(sysUsers.stream().map(SysUser::getId).collect(Collectors.toList()));
         }

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

@@ -1434,7 +1434,7 @@
     </select>
 
     <select id="getByUserId" resultType="com.ydtech.modules.admin.model.SysUser">
-        select t.id id, t.name name, t.mobile mobile, t2.management_source managementSource,t.operatorCode
+        select t.id id, t.name name, t.mobile mobile, t2.management_source managementSource,t.operatorCode,t2.id  deptId
         from sys_user t
                  left join sys_dept t2 on t.dept_id = t2.id
         where t.id = #{id}
@@ -1763,6 +1763,7 @@
         left join sys_dept sd on sd.id =su.dept_id
         <where>
             su.leader_id is not null
+            AND su.id not LIKE '%M%'
              <if test="leaderId !=null and  leaderId !=''">
                and  su.leader_id =#{leaderId}
              </if>
@@ -1783,4 +1784,14 @@
             t1.`status` = 1
           AND t1.id NOT LIKE '%M%'
     </select>
+
+
+    <select id="selectByLeadId" resultType="com.ydtech.modules.admin.model.SysUser">
+        select *
+        from sys_user su
+        where su.status = 1
+        and  su.leader_id =#{userId}
+    </select>
+
+
 </mapper>

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

@@ -8,6 +8,7 @@
         select
         io.userid as "userId",
         su.name as "userName",
+        sd.id as "deptId",
         sum(IFNULL(jqpremium, 0) + IFNULL(sypremium, 0)+ IFNULL(jypremium, 0)) as "sumpremium",
         IFNULL(sum(jqpremium),0) as "jqpremium",
         IFNULL(sum(sypremium),0) as "sypremium",
@@ -54,7 +55,7 @@
                 and su.name=#{vo.userName}
             </if>
         </where>
-        group by io.userid,su.name,sd.management_source
+        group by io.userid,su.name,sd.management_source,sd.id
     </select>
 
     <select id="getBusinessAgentDataTotal" resultType="java.lang.Long">