Qchen 1 год назад
Родитель
Сommit
93258abbae

+ 30 - 0
commons/src/main/java/com/jzg/commons/entity/agreement/po/PtlAgreementAttributionDept.java

@@ -0,0 +1,30 @@
+package com.jzg.commons.entity.agreement.po;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author quchen
+ * @date 2025/3/17 10:16
+ */
+
+@Data
+@Schema(description = "保险公司归属信息账号授权部门")
+@NoArgsConstructor
+@EqualsAndHashCode
+@AllArgsConstructor
+@TableName(value = "ptl_agreement_attribution_dept", autoResultMap = true)
+public class PtlAgreementAttributionDept {
+    @Schema(description = "保司账号id")
+    @TableField(value = "agreement_attribution_id")
+    private String agreementAttributionId;
+
+    @Schema(description = "部门id")
+    @TableField(value = "dept_id")
+    private String deptId;
+}

+ 17 - 0
commons/src/main/java/com/jzg/commons/entity/agreement/vo/PtlAgreementAttributionDeptListVo.java

@@ -0,0 +1,17 @@
+package com.jzg.commons.entity.agreement.vo;
+
+import com.jzg.commons.entity.vo.SysDeptVo;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author quchen
+ * @date 2025/3/17 17:34
+ */
+
+@Data
+public class PtlAgreementAttributionDeptListVo {
+    private List<SysDeptVo> deptList;
+    private List<String> deptIds;
+}

+ 25 - 0
commons/src/main/java/com/jzg/commons/entity/agreement/vo/PtlAgreementAttributionDeptVo.java

@@ -0,0 +1,25 @@
+package com.jzg.commons.entity.agreement.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author quchen
+ * @date 2025/3/17 11:12
+ */
+
+@Data
+public class PtlAgreementAttributionDeptVo {
+
+    @NotNull(message = "保司账号id不能为空")
+    @Schema(description = "保司账号id")
+    private String id;
+
+    @NotEmpty(message = "机构id不能为空")
+    @Schema(description = "机构id数组")
+    private List<String> deptIds;
+}

+ 21 - 4
platform/src/main/java/com/jzg/controller/AgreementAttributionController.java

@@ -2,17 +2,18 @@ package com.jzg.controller;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.agreement.vo.PtlAgreementAttributionDeptVo;
 import com.jzg.commons.entity.agreement.vo.PtlAgreementAttributionQueryVo;
 import com.jzg.commons.entity.agreement.vo.PtlAgreementAttributionSaveVo;
+import com.jzg.commons.entity.dto.AgreementAuthParam;
 import com.jzg.commons.request.RequestSingleParam;
+import com.jzg.service.PtlAgreementAttributionDeptService;
 import com.jzg.service.PtlAgreementAttributionService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.annotation.Resource;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -29,6 +30,9 @@ public class AgreementAttributionController {
     @Resource
     private PtlAgreementAttributionService agreementAttributionService;
 
+    @Resource
+    private PtlAgreementAttributionDeptService agreementAttributionDeptService;
+
     @Operation(summary = "添加保险公司账号接口", description = "添加保险公司账号接口")
     @PostMapping(value = "/addAgreementAttribution")
     public HttpResult<Object> addAgreementAttribution(@RequestBody PtlAgreementAttributionSaveVo agreementAttributionSaveVo){
@@ -78,4 +82,17 @@ public class AgreementAttributionController {
         return agreementAttributionService.disableAgreementAttribution(ids) ? HttpResult.ok("禁用成功") : HttpResult.error("禁用失败");
     }
 
+    @GetMapping(value = { "/deptTree"})
+    @Operation(summary = "保司账号授权机构查询")
+    public HttpResult deptTree(String id, String deptName) {
+        return HttpResult.ok(agreementAttributionDeptService.deptTree(id, deptName));
+    }
+
+    @Operation(summary = "保司账号授权保存")
+    @PostMapping("/authorization")
+    public HttpResult authorization(@Validated @RequestBody PtlAgreementAttributionDeptVo ptlAgreementAttributionDeptVo) {
+        agreementAttributionDeptService.authorization(ptlAgreementAttributionDeptVo);
+        return HttpResult.ok("授权成功");
+    }
+
 }

+ 9 - 0
platform/src/main/java/com/jzg/mapper/PtlAgreementAttributionDeptMapper.java

@@ -0,0 +1,9 @@
+package com.jzg.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jzg.commons.entity.agreement.po.PtlAgreementAttributionDept;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface PtlAgreementAttributionDeptMapper extends BaseMapper<PtlAgreementAttributionDept> {
+}

+ 29 - 0
platform/src/main/java/com/jzg/service/PtlAgreementAttributionDeptService.java

@@ -0,0 +1,29 @@
+package com.jzg.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jzg.commons.entity.agreement.po.PtlAgreementAttributionDept;
+import com.jzg.commons.entity.agreement.vo.PtlAgreementAttributionDeptListVo;
+import com.jzg.commons.entity.agreement.vo.PtlAgreementAttributionDeptVo;
+import com.jzg.commons.entity.dto.AgreementAuthParam;
+import com.jzg.commons.entity.vo.SysDeptVo;
+
+import java.util.List;
+
+
+public interface PtlAgreementAttributionDeptService extends IService<PtlAgreementAttributionDept> {
+    /**
+     * 获取保司账号授权机构树
+     *
+     * @param id
+     * @param deptName
+     * @return
+     */
+    PtlAgreementAttributionDeptListVo deptTree(String id, String deptName);
+
+
+    /**
+     * 保司账号授权保存
+     * @param ptlAgreementAttributionDeptVo
+     */
+    void authorization(PtlAgreementAttributionDeptVo ptlAgreementAttributionDeptVo);
+}

+ 109 - 0
platform/src/main/java/com/jzg/service/impl/PtlAgreementAttributionDeptServiceImpl.java

@@ -0,0 +1,109 @@
+package com.jzg.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jzg.commons.core.base.BaseController;
+import com.jzg.commons.entity.agreement.po.PtlAgreementAttributionDept;
+import com.jzg.commons.entity.agreement.vo.PtlAgreementAttributionDeptListVo;
+import com.jzg.commons.entity.agreement.vo.PtlAgreementAttributionDeptVo;
+import com.jzg.commons.entity.dto.AgreementAuthParam;
+import com.jzg.commons.entity.po.PtlAgreementDept;
+import com.jzg.commons.entity.po.SysDept;
+import com.jzg.commons.entity.vo.SysDeptVo;
+import com.jzg.commons.util.StringUtils;
+import com.jzg.mapper.PtlAgreementAttributionDeptMapper;
+import com.jzg.mapper.SysDeptMapper;
+import com.jzg.service.PtlAgreementAttributionDeptService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * @author quchen
+ * @date 2025/3/17 10:30
+ */
+
+@Service
+public class PtlAgreementAttributionDeptServiceImpl extends ServiceImpl<PtlAgreementAttributionDeptMapper, PtlAgreementAttributionDept> implements PtlAgreementAttributionDeptService {
+    @Autowired
+    private BaseController baseController;
+
+    @Autowired
+    private SysDeptMapper deptMapper;
+
+    @Override
+    public PtlAgreementAttributionDeptListVo deptTree(String id, String deptName) {
+        // 获取所有协议选中的机构id
+        LambdaQueryWrapper<PtlAgreementAttributionDept> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(PtlAgreementAttributionDept::getAgreementAttributionId, id);
+        List<PtlAgreementAttributionDept> agreementDepts = list(wrapper);
+        Map<String, PtlAgreementAttributionDept> deptMap = agreementDepts.stream().collect(Collectors.toMap(PtlAgreementAttributionDept::getDeptId, dept -> dept));
+        String deptId = baseController.getUserDeptId();
+        List<SysDeptVo> sysDepts = new ArrayList<>();
+        SysDept sysDept = deptMapper.selectById(deptId);
+        SysDeptVo sysDeptVo = new SysDeptVo(sysDept);
+        SysDept nameDept = null;
+        if(StringUtils.isNotEmpty(deptName)){
+            LambdaQueryWrapper<SysDept> deptWrapper = new LambdaQueryWrapper<>();
+            deptWrapper.eq(SysDept :: getName, deptName);
+            nameDept = deptMapper.selectOne(deptWrapper);
+        }
+
+        LambdaQueryWrapper<SysDept> allWrapper = new LambdaQueryWrapper<>();
+        allWrapper.like(SysDept :: getRoute, deptId)
+                .eq(SysDept :: getIsDelete, 0);
+        if (Objects.nonNull(nameDept)){
+            allWrapper.like(Objects.isNull(nameDept), SysDept :: getRoute, nameDept.getId());
+        }
+        List<SysDept> depts = deptMapper.selectList(allWrapper);
+        List<String> deptIds = new ArrayList<>();
+        List<SysDeptVo> voDept = new ArrayList<>();
+        depts.forEach(item->{
+            SysDeptVo sysDeptv = new SysDeptVo(item);
+            if(deptMap.containsKey(sysDeptv.getId())){
+                sysDeptv.setIsCheck(1);
+                deptIds.add(sysDeptv.getId());
+            }else{
+                sysDeptv.setIsCheck(0);
+            }
+            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<>())));
+        if (!Objects.isNull(nameDept)){
+            sysDepts = map.get(nameDept.getParentId());
+        } else if(!Objects.isNull(sysDept)) {
+            sysDepts = map.get(sysDeptVo.getParentId());
+        }
+        List<SysDeptVo> newResultDept = new ArrayList<>();
+        newResultDept.addAll(sysDepts);
+        PtlAgreementAttributionDeptListVo resultDept = new PtlAgreementAttributionDeptListVo();
+        resultDept.setDeptList(newResultDept);
+        resultDept.setDeptIds(deptIds);
+        return resultDept;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void authorization(PtlAgreementAttributionDeptVo ptlAgreementAttributionDeptVo) {
+        // 删除之前所有的授权id
+        LambdaQueryWrapper<PtlAgreementAttributionDept> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(PtlAgreementAttributionDept::getAgreementAttributionId, ptlAgreementAttributionDeptVo.getId());
+        this.remove(wrapper);
+
+        // 新增保存授权数据
+        List<String> deptIds = ptlAgreementAttributionDeptVo.getDeptIds();
+        List<PtlAgreementAttributionDept> agreementDepts = new ArrayList<>();
+        deptIds.forEach(deptId->{
+            PtlAgreementAttributionDept dept = new PtlAgreementAttributionDept(ptlAgreementAttributionDeptVo.getId(),deptId);
+            agreementDepts.add(dept);
+        });
+        this.saveBatch(agreementDepts);
+    }
+}

+ 2 - 4
platform/src/main/java/com/jzg/service/impl/PtlInsAttributionTemplateServiceImpl.java

@@ -100,11 +100,9 @@ public class PtlInsAttributionTemplateServiceImpl extends ServiceImpl<PtlInsAttr
 
     @Override
     public HttpResult<PtlInsAttributionTemplate> getPtlInsAttributionTemplate(PtlInsAttributionTemplateVo ptlInsAttributionTemplateVo) {
-        String code = "000000";
-        String substring = ptlInsAttributionTemplateVo.getInsCompanyId().substring(0, 5);
-        String companyId = substring + code;
-
+        String companyId = ptlInsAttributionTemplateVo.getInsCompanyId();
         PtlInsAttributionTemplate ptlInsAttributionTemplate = lambdaQuery().eq(PtlInsAttributionTemplate::getInsCompanyId, companyId)
+                .eq(PtlInsAttributionTemplate::getApiType, ptlInsAttributionTemplateVo.getApiType())
                 .one();
         AssertionUtils.isEmpty(ptlInsAttributionTemplate, "保险公司归属信息模板查询失败");
         return HttpResult.ok(ptlInsAttributionTemplate);

+ 1 - 0
platform/src/main/resources/application.yml

@@ -48,6 +48,7 @@ tenant:
     - jyx_blame
     - jyx_config
     - jyx_setting
+    - ptl_agreement_attribution_dept
   ignoreLoginNames:
 
   ignoreFunction:

+ 1 - 1
tenant/organization/src/main/java/com/jzg/organization/service/impl/SysActivityServiceImpl.java

@@ -266,7 +266,7 @@ public class SysActivityServiceImpl extends ServiceImpl<SysActivityMapper, SysAc
 
     @Override
     public Page<SysActivity> getActivityList(Page page,SysActivityVo sysActivityVo) {
-        Page<SysActivity> pages =  baseMapper.getSysActivityList(page,sysActivityVo);
+        Page<SysActivity> pages = baseMapper.getSysActivityList(page,sysActivityVo);
         pages.getRecords().forEach(activity -> {
             SysDept sysDept = sysDeptService.getById(activity.getActDept());
             List<SysActivityDept> sysActivityDeptList = sysActivityDeptService.list(new LambdaQueryWrapper<SysActivityDept>()