helixiao 1 tahun lalu
induk
melakukan
d6b789dcd7

+ 211 - 211
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/xxxt/system/service/impl/DictServiceImpl.java

@@ -88,107 +88,147 @@ public class DictServiceImpl implements DictService {
             dto.setDfComcode(dto.getComcode().length() > 2 ? dto.getComcode().substring(0, 2) : dto.getComcode());
         }
         List<DictVo> dictList = qwSysDictMapper.select(dto);
-        if (CollectionUtils.isEmpty(dictList)) {
-            switch (dto.getDicttype().toUpperCase()) {
-                case "QW_BY_DEPTID_GET_CHILD_USERID":
-                    if (sysUser.getUserId().equals(UserConstant.USERID)) {
-                        dictList = sysUserMapper.selectByDeptIdGetIdNameChildList(Lists.newArrayList(sysUser.getDeptId()+""), Lists.newArrayList(UserConstant.ROLE_14 + "", UserConstant.ROLE_10+ "", UserConstant.ROLE_9+ ""));
-                    }else {
-                        List<SysRole> roles = sysUser.getRoles();
-                        if (!CollectionUtils.isEmpty(roles)) {
-                            List<Long> collect = roles.stream().map(role -> role.getRoleId()).collect(Collectors.toList());
-                            List<String> allDeptId = sysUserService.getAllDeptId(true, true, true, false);
-
-                            // 查询当前登录人的角色,如果是二级续保管理员,查询当前机构下的所有
-                            if (collect.contains(UserConstant.ROLE_14)) {
-                                //获取token的deptid
-                                List<String> list = Lists.newArrayList(UserConstant.ROLE_14 + "", UserConstant.ROLE_10+ "");
-                                dictList = sysUserMapper.selectByDeptIdGetIdNameChildList(allDeptId, list);
-                            }else if (collect.contains(UserConstant.ROLE_9)){
-                                //获取token的deptid
-                                List<String> list = Lists.newArrayList(UserConstant.ROLE_14 + "", UserConstant.ROLE_10+ "", UserConstant.ROLE_9+ "");
-                                dictList = sysUserMapper.selectByDeptIdGetIdNameChildList(allDeptId, list);
-                            }else if (collect.contains(UserConstant.ROLE_10)){
-                                //获取token的deptid
-                                DictVo dictVo = new DictVo();
-                                dictVo.setDicttype("QW_BY_DEPTID_GET_CHILD_USERID");
-                                dictVo.setDictcode(sysUser.getUserId()+"");
-                                dictVo.setDictvalue(sysUser.getUserName());
-                                dictList = new ArrayList<>();
-                                dictList.add(dictVo);
-                            }
-                        }
-                    }
-
-
-                    System.out.println("-------转换输出json结果-------");
-                    System.out.println(JSON.toJSON(dictList));
-                    break;
-                case "DEPT":
-//                    4	    公司总部        取第3层或第4层
-//                    3007	个人代理        取第3层或第4层
-//                    3026	业务员          取第3层或第4层
-//                    3104	专业代理        取第3层或第4层
-                    dictList = getDictVos(sysUser.getDept());
-                    // 最终的集合
-                    List<String> finalList = new ArrayList<>();
-
-                    String deptIds = sysUser.getDeptIds();
-                    List<String> list = Arrays.asList(deptIds.split(","));
-                    finalList.addAll(list);
-                    for (String deptId : list) {
-                        List<String> list3 = sysDeptMapper.selectByDeptId(deptId);
-                        finalList.addAll(list3);
-                    }
-
-                    // 已经映射机构的
-                    if (!CollectionUtils.isEmpty(finalList)) {
-                        one:
-                        for (String deptId : finalList) {
-                            if ((sysUser.getDeptId() + "").equals(deptId)) {
-                                continue;
-                            }
-                            SysDept sysDept = sysDeptService.selectBydeptId(deptId);
-                            if (!Objects.isNull(sysDept)) {
-                                List<DictVo> dictList1 = getDictVos(sysDept);
-                                if (CollectionUtils.isEmpty(dictList)) {
-                                    dictList = new ArrayList<>();
-                                }
-                                dictList.addAll(dictList1);
-                            }
-                        }
-                    }
-
-                    Set<String> seenCodes = new HashSet<>();
-
-                    deduplicateChildLists(dictList, seenCodes);
-
-
-                    System.out.println("-------转换输出json结果-------");
-                    System.out.println(JSON.toJSON(dictList));
-                    break;
-                case "COMCODE":
-//                    DictVo vo = null;
+//        if (CollectionUtils.isEmpty(dictList)) {
+//            switch (dto.getDicttype().toUpperCase()) {
+//                case "QW_BY_DEPTID_GET_CHILD_USERID":
+//                    if (sysUser.getUserId().equals(UserConstant.USERID)) {
+//                        dictList = sysUserMapper.selectByDeptIdGetIdNameChildList(Lists.newArrayList(sysUser.getDeptId()+""), Lists.newArrayList(UserConstant.ROLE_14 + "", UserConstant.ROLE_10+ "", UserConstant.ROLE_9+ ""));
+//                    }else {
+//                        List<SysRole> roles = sysUser.getRoles();
+//                        if (!CollectionUtils.isEmpty(roles)) {
+//                            List<Long> collect = roles.stream().map(role -> role.getRoleId()).collect(Collectors.toList());
+//                            List<String> allDeptId = sysUserService.getAllDeptId(true, true, true, false);
+//
+//                            // 查询当前登录人的角色,如果是二级续保管理员,查询当前机构下的所有
+//                            if (collect.contains(UserConstant.ROLE_14)) {
+//                                //获取token的deptid
+//                                List<String> list = Lists.newArrayList(UserConstant.ROLE_14 + "", UserConstant.ROLE_10+ "");
+//                                dictList = sysUserMapper.selectByDeptIdGetIdNameChildList(allDeptId, list);
+//                            }else if (collect.contains(UserConstant.ROLE_9)){
+//                                //获取token的deptid
+//                                List<String> list = Lists.newArrayList(UserConstant.ROLE_14 + "", UserConstant.ROLE_10+ "", UserConstant.ROLE_9+ "");
+//                                dictList = sysUserMapper.selectByDeptIdGetIdNameChildList(allDeptId, list);
+//                            }else if (collect.contains(UserConstant.ROLE_10)){
+//                                //获取token的deptid
+//                                DictVo dictVo = new DictVo();
+//                                dictVo.setDicttype("QW_BY_DEPTID_GET_CHILD_USERID");
+//                                dictVo.setDictcode(sysUser.getUserId()+"");
+//                                dictVo.setDictvalue(sysUser.getUserName());
+//                                dictList = new ArrayList<>();
+//                                dictList.add(dictVo);
+//                            }
+//                        }
+//                    }
+//
+//
+//                    System.out.println("-------转换输出json结果-------");
+//                    System.out.println(JSON.toJSON(dictList));
+//                    break;
+//                case "DEPT":
+////                    4	    公司总部        取第3层或第4层
+////                    3007	个人代理        取第3层或第4层
+////                    3026	业务员          取第3层或第4层
+////                    3104	专业代理        取第3层或第4层
+//                    dictList = getDictVos(sysUser.getDept());
+//                    // 最终的集合
+//                    List<String> finalList = new ArrayList<>();
+//
+//                    String deptIds = sysUser.getDeptIds();
+//                    List<String> list = Arrays.asList(deptIds.split(","));
+//                    finalList.addAll(list);
+//                    for (String deptId : list) {
+//                        List<String> list3 = sysDeptMapper.selectByDeptId(deptId);
+//                        finalList.addAll(list3);
+//                    }
+//
+//                    // 已经映射机构的
+//                    if (!CollectionUtils.isEmpty(finalList)) {
+//                        one:
+//                        for (String deptId : finalList) {
+//                            if ((sysUser.getDeptId() + "").equals(deptId)) {
+//                                continue;
+//                            }
+//                            SysDept sysDept = sysDeptService.selectBydeptId(deptId);
+//                            if (!Objects.isNull(sysDept)) {
+//                                List<DictVo> dictList1 = getDictVos(sysDept);
+//                                if (CollectionUtils.isEmpty(dictList)) {
+//                                    dictList = new ArrayList<>();
+//                                }
+//                                dictList.addAll(dictList1);
+//                            }
+//                        }
+//                    }
+//
+//                    Set<String> seenCodes = new HashSet<>();
+//
+//                    deduplicateChildLists(dictList, seenCodes);
+//
+//
+//                    System.out.println("-------转换输出json结果-------");
+//                    System.out.println(JSON.toJSON(dictList));
+//                    break;
+//                case "COMCODE":
+////                    DictVo vo = null;
+////                    if (StringUtils.isNotBlank(comcode)) {
+////                        dto.setDictcode(comcode);
+////                        // 查询父节点
+////                        DictDto dto1 = new DictDto();
+////                        dto1.setComcode(comcode);
+////                        dto1.setDicttype(dto.getDicttype());
+////                        vo = dictMapper.selectParentcomcode(dto1);
+////                    } else {
+////                        throw new SystemException("该用户未配置归属机构!");
+////                    }
+////
+////                    if (StringUtils.isNotBlank(userDept.getComcodeNotin())) {
+////                        List<String> collect = Arrays.stream(userDept.getComcodeNotin().split(",")).collect(Collectors.toList());
+////                        dto.setComcodeNotin(collect);
+////                    }
+////                    List<DictVo> sacompanies = dictMapper.selectSacompany(dto);
+////                    if (vo != null) {
+////                        sacompanies.add(vo);
+////                        // 设置父节点
+////                        dto.setDictcode(vo.getDictcode());
+////                    } else {
+////                        if (StringUtils.isNotBlank(comcode)) {
+////                            if (DeptConstant.COMCODE_00.equals(comcode)) {
+////                                // 总公司时设置父节点
+////                                dto.setDictcode(DeptConstant.COMCODE_1);
+////                            }
+////                        }
+////                    }
+////                    //获取父节点数据
+////                    dictList = sacompanies.stream().filter(m -> m.getParentId().equals(StringUtils.isEmpty(dto.getDictcode()) ? DeptConstant.COMCODE_1 : dto.getDictcode())).map(
+////                            (m) -> {
+////                                m.setChildList(getChildrens(m, sacompanies));
+////                                return m;
+////                            }
+////                    ).collect(Collectors.toList());
+////                    System.out.println("-------转换输出json结果-------");
+////                    System.out.println(JSON.toJSON(dictList));
+//                    break;
+//                case "COM3CODE":
+//                    DictVo vo3 = null;
 //                    if (StringUtils.isNotBlank(comcode)) {
 //                        dto.setDictcode(comcode);
 //                        // 查询父节点
 //                        DictDto dto1 = new DictDto();
 //                        dto1.setComcode(comcode);
 //                        dto1.setDicttype(dto.getDicttype());
-//                        vo = dictMapper.selectParentcomcode(dto1);
+//                        vo3 = dictMapper.selectParentcomcode(dto1);
 //                    } else {
 //                        throw new SystemException("该用户未配置归属机构!");
 //                    }
-//
 //                    if (StringUtils.isNotBlank(userDept.getComcodeNotin())) {
 //                        List<String> collect = Arrays.stream(userDept.getComcodeNotin().split(",")).collect(Collectors.toList());
 //                        dto.setComcodeNotin(collect);
 //                    }
-//                    List<DictVo> sacompanies = dictMapper.selectSacompany(dto);
-//                    if (vo != null) {
-//                        sacompanies.add(vo);
+//
+//                    List<DictVo> sacompanies3 = dictMapper.selectSacompanyLength3Level(dto);
+//                    if (vo3 != null) {
+//                        sacompanies3.add(vo3);
 //                        // 设置父节点
-//                        dto.setDictcode(vo.getDictcode());
+//                        dto.setDictcode(vo3.getDictcode());
 //                    } else {
 //                        if (StringUtils.isNotBlank(comcode)) {
 //                            if (DeptConstant.COMCODE_00.equals(comcode)) {
@@ -198,136 +238,96 @@ public class DictServiceImpl implements DictService {
 //                        }
 //                    }
 //                    //获取父节点数据
-//                    dictList = sacompanies.stream().filter(m -> m.getParentId().equals(StringUtils.isEmpty(dto.getDictcode()) ? DeptConstant.COMCODE_1 : dto.getDictcode())).map(
+//                    dictList = sacompanies3.stream().filter(m -> m.getParentId().equals(StringUtils.isEmpty(dto.getDictcode()) ? DeptConstant.COMCODE_1 : dto.getDictcode())).map(
 //                            (m) -> {
-//                                m.setChildList(getChildrens(m, sacompanies));
+//                                m.setChildList(getChildrens(m, sacompanies3));
 //                                return m;
 //                            }
 //                    ).collect(Collectors.toList());
 //                    System.out.println("-------转换输出json结果-------");
 //                    System.out.println(JSON.toJSON(dictList));
-                    break;
-                case "COM3CODE":
-                    DictVo vo3 = null;
-                    if (StringUtils.isNotBlank(comcode)) {
-                        dto.setDictcode(comcode);
-                        // 查询父节点
-                        DictDto dto1 = new DictDto();
-                        dto1.setComcode(comcode);
-                        dto1.setDicttype(dto.getDicttype());
-                        vo3 = dictMapper.selectParentcomcode(dto1);
-                    } else {
-                        throw new SystemException("该用户未配置归属机构!");
-                    }
-                    if (StringUtils.isNotBlank(userDept.getComcodeNotin())) {
-                        List<String> collect = Arrays.stream(userDept.getComcodeNotin().split(",")).collect(Collectors.toList());
-                        dto.setComcodeNotin(collect);
-                    }
-
-                    List<DictVo> sacompanies3 = dictMapper.selectSacompanyLength3Level(dto);
-                    if (vo3 != null) {
-                        sacompanies3.add(vo3);
-                        // 设置父节点
-                        dto.setDictcode(vo3.getDictcode());
-                    } else {
-                        if (StringUtils.isNotBlank(comcode)) {
-                            if (DeptConstant.COMCODE_00.equals(comcode)) {
-                                // 总公司时设置父节点
-                                dto.setDictcode(DeptConstant.COMCODE_1);
-                            }
-                        }
-                    }
-                    //获取父节点数据
-                    dictList = sacompanies3.stream().filter(m -> m.getParentId().equals(StringUtils.isEmpty(dto.getDictcode()) ? DeptConstant.COMCODE_1 : dto.getDictcode())).map(
-                            (m) -> {
-                                m.setChildList(getChildrens(m, sacompanies3));
-                                return m;
-                            }
-                    ).collect(Collectors.toList());
-                    System.out.println("-------转换输出json结果-------");
-                    System.out.println(JSON.toJSON(dictList));
-                    break;
-                case "RISKCODE":
-                    // 查询的是销管表中的险种编码
-                    dictList = dictMapper.selectPrpdrisk(dto);
-                    break;
-                case "AGENT":
-                    if (StringUtils.isEmpty(dto.getComcode())) {
-                        throw new SystemException("查询中介时,请先选择机构!");
-                    }
-                    dictList = dictMapper.selectPrpdagentNew(dto);
-                    break;
-                case "POINT":
-                    if (StringUtils.isEmpty(dto.getComcode())) {
-                        throw new SystemException("查询网点时,请先选择机构!");
-                    }
-                    dictList = dictMapper.selectPrpdnetpointNew(dto);
-                    break;
-                case "AGENTSALES":
-                    // 查询的是销管的中介表
-                    if (StringUtils.isEmpty(dto.getComcode())) {
-                        throw new SystemException("查询代理时,请先选择机构!");
-                    }
-                    dictList = dictMapper.selectPrpdagentSales(dto);
-                    break;
-                case "POINTSALES":
-                    // 查询的是销管的网点表
-                    if (StringUtils.isEmpty(dto.getComcode())) {
-                        throw new SystemException("查询网点时,请先选择机构!");
-                    }
-                    dictList = dictMapper.selectPrpdnetpointSales(dto);
-
-                    break;
-                case "USERCODE":
-                    if (StringUtils.isEmpty(dto.getComcode())) {
-                        throw new SystemException("查询业务员时,请先选择机构!");
-                    }
-                    if (dto.getComcode().length() != 8) {
-                        throw new SystemException("查询业务员时,机构编码必须为8位机构");
-                    }
-                    if (StringUtils.isNotBlank(userDept.getComcodeNotin())) {
-                        List<String> collect = Arrays.stream(userDept.getComcodeNotin().split(",")).collect(Collectors.toList());
-                        dto.setComcodeNotin(collect);
-                    }
-                    dictList = dictMapper.selectSauser(dto);
-                    break;
-                case "USERANDPOINT":
-                    if (StringUtils.isEmpty(dto.getComcode())) {
-                        throw new SystemException("请先选择机构!");
-                    }
-                    if (StringUtils.isNotBlank(userDept.getComcodeNotin())) {
-                        List<String> collect = Arrays.stream(userDept.getComcodeNotin().split(",")).collect(Collectors.toList());
-                        dto.setComcodeNotin(collect);
-                    }
-                    dictList = dictMapper.selectSauser(dto);
-                    dictList.addAll(dictMapper.selectPrpdnetpoint(dto));
-                    break;
-                case "NEWCARUSETYPE":  // 车辆用途
-                    dictList = dictMapper.cxDblinkDict("CarUseTypeNew", "NEWCARUSETYPE");
-                    break;
-                case "NEWCARKIND":  // 车辆大类
-                    dictList = dictMapper.cxDblinkDict("MotorTypeNew", "NEWCARKIND");
-                    break;
-                case "NEWCARKINDSUB":  // 车辆细类
-                    dictList = dictMapper.cxDblinkDict("CarkindSub", "NEWCARKINDSUB");
-                    break;
-                case "POLICYYEAR2":
-                    // 保单年度
-                    // 查询当前时间年的前5年和后5年
-                    int nowYear = DateUtils.getNowYear();
-                    for (int i = nowYear - 5; i <= nowYear + 5; i++) {
-                        DictVo dictVo = new DictVo();
-                        dictVo.setDicttype("POLICYYEAR2");
-                        dictVo.setDictcode(i+"");
-                        dictVo.setDictvalue(i+"");
-                        dictVo.setIsDefault( i == nowYear ? "Y" : "N");
-                        dictList.add(dictVo);
-                    }
-                    break;
-                default:
-                    throw new SystemException("不被支持的字典类型!");
-            }
-        }
+//                    break;
+//                case "RISKCODE":
+//                    // 查询的是销管表中的险种编码
+//                    dictList = dictMapper.selectPrpdrisk(dto);
+//                    break;
+//                case "AGENT":
+//                    if (StringUtils.isEmpty(dto.getComcode())) {
+//                        throw new SystemException("查询中介时,请先选择机构!");
+//                    }
+//                    dictList = dictMapper.selectPrpdagentNew(dto);
+//                    break;
+//                case "POINT":
+//                    if (StringUtils.isEmpty(dto.getComcode())) {
+//                        throw new SystemException("查询网点时,请先选择机构!");
+//                    }
+//                    dictList = dictMapper.selectPrpdnetpointNew(dto);
+//                    break;
+//                case "AGENTSALES":
+//                    // 查询的是销管的中介表
+//                    if (StringUtils.isEmpty(dto.getComcode())) {
+//                        throw new SystemException("查询代理时,请先选择机构!");
+//                    }
+//                    dictList = dictMapper.selectPrpdagentSales(dto);
+//                    break;
+//                case "POINTSALES":
+//                    // 查询的是销管的网点表
+//                    if (StringUtils.isEmpty(dto.getComcode())) {
+//                        throw new SystemException("查询网点时,请先选择机构!");
+//                    }
+//                    dictList = dictMapper.selectPrpdnetpointSales(dto);
+//
+//                    break;
+//                case "USERCODE":
+//                    if (StringUtils.isEmpty(dto.getComcode())) {
+//                        throw new SystemException("查询业务员时,请先选择机构!");
+//                    }
+//                    if (dto.getComcode().length() != 8) {
+//                        throw new SystemException("查询业务员时,机构编码必须为8位机构");
+//                    }
+//                    if (StringUtils.isNotBlank(userDept.getComcodeNotin())) {
+//                        List<String> collect = Arrays.stream(userDept.getComcodeNotin().split(",")).collect(Collectors.toList());
+//                        dto.setComcodeNotin(collect);
+//                    }
+//                    dictList = dictMapper.selectSauser(dto);
+//                    break;
+//                case "USERANDPOINT":
+//                    if (StringUtils.isEmpty(dto.getComcode())) {
+//                        throw new SystemException("请先选择机构!");
+//                    }
+//                    if (StringUtils.isNotBlank(userDept.getComcodeNotin())) {
+//                        List<String> collect = Arrays.stream(userDept.getComcodeNotin().split(",")).collect(Collectors.toList());
+//                        dto.setComcodeNotin(collect);
+//                    }
+//                    dictList = dictMapper.selectSauser(dto);
+//                    dictList.addAll(dictMapper.selectPrpdnetpoint(dto));
+//                    break;
+//                case "NEWCARUSETYPE":  // 车辆用途
+//                    dictList = dictMapper.cxDblinkDict("CarUseTypeNew", "NEWCARUSETYPE");
+//                    break;
+//                case "NEWCARKIND":  // 车辆大类
+//                    dictList = dictMapper.cxDblinkDict("MotorTypeNew", "NEWCARKIND");
+//                    break;
+//                case "NEWCARKINDSUB":  // 车辆细类
+//                    dictList = dictMapper.cxDblinkDict("CarkindSub", "NEWCARKINDSUB");
+//                    break;
+//                case "POLICYYEAR2":
+//                    // 保单年度
+//                    // 查询当前时间年的前5年和后5年
+//                    int nowYear = DateUtils.getNowYear();
+//                    for (int i = nowYear - 5; i <= nowYear + 5; i++) {
+//                        DictVo dictVo = new DictVo();
+//                        dictVo.setDicttype("POLICYYEAR2");
+//                        dictVo.setDictcode(i+"");
+//                        dictVo.setDictvalue(i+"");
+//                        dictVo.setIsDefault( i == nowYear ? "Y" : "N");
+//                        dictList.add(dictVo);
+//                    }
+//                    break;
+//                default:
+//                    throw new SystemException("不被支持的字典类型!");
+//            }
+//        }
 
 
         return AjaxResult.success(dictList);