|
|
@@ -0,0 +1,171 @@
|
|
|
+package com.jzg.console.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.jzg.commons.constants.report.enums.SearchKeyCodeEnum;
|
|
|
+import com.jzg.commons.entity.po.SysArea;
|
|
|
+import com.jzg.commons.entity.po.SysDept;
|
|
|
+import com.jzg.commons.entity.report.dto.ReportDictDto;
|
|
|
+import com.jzg.commons.entity.report.dto.ReportSearchConfigurationDto;
|
|
|
+import com.jzg.commons.entity.report.po.ReportSearchConfiguration;
|
|
|
+import com.jzg.commons.entity.vo.SysAreaVo;
|
|
|
+import com.jzg.commons.entity.vo.SysDeptVo;
|
|
|
+import com.jzg.console.mapper.ReportSearchConfigurationMapper;
|
|
|
+import com.jzg.console.service.ReportSearchConfigurationService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+* @author Administrator
|
|
|
+* @description 针对表【report_search_configuration(报表查询配置)】的数据库操作Service实现
|
|
|
+* @createDate 2025-09-16 16:57:57
|
|
|
+*/
|
|
|
+@Service
|
|
|
+public class ReportSearchConfigurationServiceImpl extends ServiceImpl<ReportSearchConfigurationMapper, ReportSearchConfiguration>
|
|
|
+ implements ReportSearchConfigurationService {
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2025/9/16 18:05
|
|
|
+ * @Description: 查询公共参数列表
|
|
|
+ * common 时公共参数 ,后期如果单独配置也是靠 routerPath 区分
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ReportSearchConfigurationDto> getSearchConfigurationList(String userId,String routerKey) {
|
|
|
+ List<ReportSearchConfigurationDto> list = this.getBaseMapper().getSearchConfigurationList(routerKey);
|
|
|
+ if(list!=null && !list.isEmpty()){
|
|
|
+ for (ReportSearchConfigurationDto reportSearchConfigurationDto : list) {
|
|
|
+ if(StringUtils.isNotBlank(reportSearchConfigurationDto.getSearchSql())){
|
|
|
+ //通过配置的sql查询具体的对象
|
|
|
+ List<?> searchConfigurationList = getSearchConfigurationList(userId, reportSearchConfigurationDto.getSearchSql(), reportSearchConfigurationDto.getSearchKey(), reportSearchConfigurationDto.getShowType());
|
|
|
+ reportSearchConfigurationDto.setList(searchConfigurationList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2025/9/17 9:01
|
|
|
+ * @Description:
|
|
|
+ */
|
|
|
+ public List<?> getSearchConfigurationList(String userId,String sqlType,String searchKey,String showType) {
|
|
|
+ // 查询字典列表
|
|
|
+ if("select".equals(showType) && SearchKeyCodeEnum.getSearchKeyCode(searchKey)!=null && StringUtils.isNotBlank(SearchKeyCodeEnum.getSearchKeyCode(searchKey).getDistCode()) && "dictSql".equals(sqlType) ){
|
|
|
+ String distCode = SearchKeyCodeEnum.getSearchKeyCode(searchKey).getDistCode();
|
|
|
+ return this.getBaseMapper().selectDictListByCode(distCode);
|
|
|
+ }
|
|
|
+ //查询用户配置的查询保险公司
|
|
|
+ if("select".equals(showType) && searchKey.equals(SearchKeyCodeEnum.SEARCHKEY_COMPANYID.getCode())){
|
|
|
+ return queryCompanyListByUserId(userId);
|
|
|
+ }
|
|
|
+ //查询用户配置的出单机构
|
|
|
+ if("tree".equals(showType) && searchKey.equals(SearchKeyCodeEnum.SEARCHKEY_ORGIDS.getCode())){
|
|
|
+ return getDeptTree(userId);
|
|
|
+ }
|
|
|
+ //查询所有的省
|
|
|
+ if("areaSelect".equals(showType) && searchKey.equals(SearchKeyCodeEnum.SEARCHKEY_AREACODES.getCode())){
|
|
|
+ return querySysAreaList();
|
|
|
+ }
|
|
|
+ //查询 合作保险公司 单独写
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2025/9/17 11:46
|
|
|
+ * @Description: 查询 省、市
|
|
|
+ */
|
|
|
+ public List<SysAreaVo> querySysAreaList() {
|
|
|
+ List<SysArea> list = this.getBaseMapper().getSecondLevelAreaList();
|
|
|
+ List<SysAreaVo> collect = list.stream().map(SysAreaVo::new).collect(Collectors.toList());
|
|
|
+ Map<String, List<SysAreaVo>> map = collect.stream().collect(Collectors.groupingBy(SysAreaVo::getUpperCode));
|
|
|
+ collect.forEach(i -> i.setChild(map.getOrDefault(i.getAreaCode(), new ArrayList<>())));
|
|
|
+ return map.get("0");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2025/9/17 14:16
|
|
|
+ * @Description: 查询租户下的出单机构
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<SysDeptVo> getDeptTree(String userId) {
|
|
|
+ List<SysDept> sysDeptList = this.getBaseMapper().getDeptListByUserId(userId);
|
|
|
+ List<SysDeptVo> voDept = new ArrayList<>();
|
|
|
+ sysDeptList.forEach(item->{
|
|
|
+ SysDeptVo sysDeptv = new SysDeptVo(item);
|
|
|
+ voDept.add(sysDeptv);
|
|
|
+ });
|
|
|
+ Map<String, List<SysDeptVo>> map = voDept.stream().collect(Collectors.groupingBy(SysDeptVo::getParentId));
|
|
|
+ voDept.forEach(i -> i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>())));
|
|
|
+ List<SysDeptVo> sysDeptVos = map.get("0");
|
|
|
+ List<SysDeptVo> newResultDept = new ArrayList<>();
|
|
|
+ newResultDept.addAll(sysDeptVos);
|
|
|
+ return newResultDept;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2025/9/17 14:37
|
|
|
+ * @Description: 查询用户所在的保险公司
|
|
|
+ */
|
|
|
+ public List<ReportDictDto> queryCompanyListByUserId(String userId) {
|
|
|
+ return this.getBaseMapper().queryCompanyListByUserId(userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2025/9/17 14:43
|
|
|
+ * @Description: 通过保险公司id查询合作公司的第三级
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ReportDictDto> getPartnerCompanyListByCompanyId(String companyId) {
|
|
|
+ return this.getBaseMapper().getPartnerCompanyListByCompanyId(companyId);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2025/9/17 17:37
|
|
|
+ * @Description: 查询管理员树 暂时不知道如何处理暂放
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ReportDictDto> getUserManageListByUserId(String userId) {
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ReportSearchConfigurationDto> getSearchDefaultList(String userId, String routerKey) {
|
|
|
+ List<ReportSearchConfigurationDto> list = this.getBaseMapper().getSearchDefaultList(routerKey);
|
|
|
+ if(list!=null && !list.isEmpty()){
|
|
|
+ for (ReportSearchConfigurationDto reportSearchConfigurationDto : list) {
|
|
|
+ if(StringUtils.isNotBlank(reportSearchConfigurationDto.getSearchSql())){
|
|
|
+ //通过配置的sql查询具体的对象
|
|
|
+ List<?> searchConfigurationList = getSearchConfigurationList(userId, reportSearchConfigurationDto.getSearchSql(), reportSearchConfigurationDto.getSearchKey(), reportSearchConfigurationDto.getShowType());
|
|
|
+ reportSearchConfigurationDto.setList(searchConfigurationList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|