Browse Source

Merge branch 'feat-20221102-bi'

shc 2 năm trước cách đây
mục cha
commit
600195042b
18 tập tin đã thay đổi với 690 bổ sung122 xóa
  1. 36 0
      db/v2.1/4sys_tenant_rel.sql
  2. 32 0
      hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/constant/UpmsLevel.java
  3. 32 1
      hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/constant/UpmsType.java
  4. 62 0
      hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/dto/SysEnterpriseRelationDTO.java
  5. 68 0
      hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/entity/SysEnterpriseRelation.java
  6. 32 0
      hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/vo/SysEnterpriseRelationVO.java
  7. 24 0
      hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/vo/SysEnterpriseServiceChargeVO.java
  8. 59 0
      hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/SysEnterpriseRelationController.java
  9. 2 0
      hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/entity/SysDeptSub.java
  10. 13 2
      hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/mapper/SysDeptMapper.java
  11. 3 0
      hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/mapper/SysDeptSubMapper.java
  12. 16 0
      hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/mapper/SysEnterpriseRelationMapper.java
  13. 11 1
      hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/SysDeptService.java
  14. 35 0
      hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/SysEnterpriseRelationService.java
  15. 16 2
      hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysDeptServiceImpl.java
  16. 97 0
      hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysEnterpriseRelationServiceImpl.java
  17. 137 116
      hnqz-upms/hnqz-upms-biz/src/main/resources/mapper/SysDeptMapper.xml
  18. 15 0
      hnqz-upms/hnqz-upms-biz/src/main/resources/mapper/SysDeptSubMapper.xml

+ 36 - 0
db/v2.1/4sys_tenant_rel.sql

@@ -0,0 +1,36 @@
+USE hnqzx;
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for sys_ent_rel
+-- ----------------------------
+DROP TABLE IF EXISTS `sys_ent_rel`;
+CREATE TABLE `sys_ent_rel`
+(
+    `rel_id`      INT(20) AUTO_INCREMENT COMMENT 'id',
+    `ent_id`      INT(20)    NOT NULL COMMENT '企业id',
+    `e_type`      VARCHAR(8) NOT NULL COMMENT '租户类型',
+    `pro_line`    VARCHAR(8) NOT NULL COMMENT '产品线',
+    `e_level`     VARCHAR(8) NOT NULL COMMENT '租户层级',
+    `parent_id`   INT(20)    NOT NULL COMMENT '父级id',
+    `root_id`     INT(20)    NOT NULL COMMENT '顶层id',
+    `create_time` DATETIME   NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    `update_time` DATETIME   NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+    PRIMARY KEY `pk_id` (`rel_id`) USING BTREE,
+    INDEX `idx_type` (`e_type`) USING BTREE,
+    INDEX `idx_pro_line` (`pro_line`) USING BTREE,
+    INDEX `idx_pid` (`parent_id`) USING BTREE,
+    INDEX `idx_level` (`e_level`) USING BTREE,
+    INDEX `idx_rid` (`root_id`) USING BTREE
+) ENGINE = InnoDB
+  DEFAULT CHARSET = utf8mb4 COMMENT ='企业层级关系表';
+
+-- ----------------------------
+-- Records of sys_tenant_rel
+-- ----------------------------
+BEGIN;
+COMMIT;
+
+SET FOREIGN_KEY_CHECKS = 1;

+ 32 - 0
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/constant/UpmsLevel.java

@@ -0,0 +1,32 @@
+package com.qunzhixinxi.hnqz.admin.api.constant;
+
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 层级标签
+ *
+ * @author jimmy
+ * @version 1.0.0
+ * @date 2022-11-02 10:53
+ */
+public final class UpmsLevel {
+
+	private UpmsLevel() {
+	}
+
+	// 企业等级
+	@Getter
+	@AllArgsConstructor
+	public enum EnterpriseLevel {
+
+		L1("L1", "一级"),
+		L2("L2", "二级");
+
+		@EnumValue
+		private final String level;
+		private final String description;
+
+	}
+}

+ 32 - 1
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/constant/UpmsType.java

@@ -11,7 +11,10 @@ import lombok.Getter;
  * @version 1.0.0
  * @date 2022-08-15 15:24
  */
-public class UpmsType {
+public final class UpmsType {
+
+	private UpmsType() {
+	}
 
 	/**
 	 * 任务大类
@@ -60,4 +63,32 @@ public class UpmsType {
 		private final String description;
 
 	}
+
+	// 企业类型
+	@Getter
+	@AllArgsConstructor
+	public enum EnterpriseType {
+
+		CMO("CMO", "药企"),
+		CSO("CSO", "CSO"),
+		NET_MED("NET_MED", "互联网医疗"),
+		MED_MED("MED_MED", "医学传媒"),
+		MEETING("MEETING", "科室会");
+
+		@EnumValue
+		private final String type;
+		private final String description;
+	}
+
+	// 产品线
+	@Getter
+	@AllArgsConstructor
+	public enum ProductLine {
+
+		CSO1("CSO1", "CSO1");
+
+		@EnumValue
+		private final String type;
+		private final String description;
+	}
 }

+ 62 - 0
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/dto/SysEnterpriseRelationDTO.java

@@ -0,0 +1,62 @@
+package com.qunzhixinxi.hnqz.admin.api.dto;
+
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsLevel;
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 企业关系Dto
+ *
+ * @author jimmy
+ * @version 1.0.0
+ * @date 2022-11-02 14:45
+ */
+@Data
+@ToString
+public class SysEnterpriseRelationDTO implements Serializable {
+	private static final long serialVersionUID = 1318703734982431471L;
+
+
+	/**
+	 * id
+	 */
+	private Integer relId;
+
+	/**
+	 * 企业id
+	 */
+	private Integer enterpriseId;
+
+	/**
+	 * 企业类型
+	 */
+	private UpmsType.EnterpriseType enterpriseType;
+
+	/**
+	 * 产品线
+	 */
+	private UpmsType.ProductLine productLine;
+
+	/**
+	 * 企业等级
+	 */
+	private UpmsLevel.EnterpriseLevel enterpriseLevel;
+
+	/**
+	 * 父级id
+	 */
+	private Integer parentId;
+
+	/**
+	 * 服务费
+	 */
+	private List<Map<String, Object>> serviceCharges;
+
+
+}

+ 68 - 0
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/entity/SysEnterpriseRelation.java

@@ -0,0 +1,68 @@
+package com.qunzhixinxi.hnqz.admin.api.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsLevel;
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+
+/**
+ * 企业关系表
+ *
+ * @author jimmy
+ * @version 1.0.0
+ * @date 2022-11-02 10:45
+ */
+@Data
+@ToString
+@TableName(value = "sys_ent_rel")
+public class SysEnterpriseRelation implements Serializable {
+	private static final long serialVersionUID = 6584285982757215110L;
+
+	/**
+	 * id
+	 */
+	@TableId(value = "rel_id", type = IdType.AUTO)
+	private Integer relId;
+
+	/**
+	 * 企业id
+	 */
+	@TableField(value = "ent_id")
+	private Integer enterpriseId;
+
+	/**
+	 * 企业类型
+	 */
+	@TableField(value = "e_type")
+	private UpmsType.EnterpriseType enterpriseType;
+
+	/**
+	 * 产品线
+	 */
+	@TableField(value = "pro_line")
+	private UpmsType.ProductLine productLine;
+
+	/**
+	 * 企业等级
+	 */
+	@TableField(value = "e_level")
+	private UpmsLevel.EnterpriseLevel enterpriseLevel;
+
+	/**
+	 * 父级id
+	 */
+	private Integer parentId;
+
+	/**
+	 * 根id
+	 */
+	private Integer rootId;
+
+
+}

+ 32 - 0
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/vo/SysEnterpriseRelationVO.java

@@ -0,0 +1,32 @@
+package com.qunzhixinxi.hnqz.admin.api.vo;
+
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsLevel;
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+
+/**
+ * 企业关系vo
+ *
+ * @author jimmy
+ * @version 1.0.0
+ * @date 2022-11-02 14:45
+ */
+@Data
+@ToString
+public class SysEnterpriseRelationVO implements Serializable {
+	private static final long serialVersionUID = 1318703734982431471L;
+
+	private Long relId;
+	private Long entId;
+	private String entName;
+	private Long rootId;
+	private String rootName;
+	private UpmsType.EnterpriseType entType;
+	private UpmsType.ProductLine productLine;
+	private UpmsLevel.EnterpriseLevel entLevel;
+
+
+}

+ 24 - 0
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/vo/SysEnterpriseServiceChargeVO.java

@@ -0,0 +1,24 @@
+package com.qunzhixinxi.hnqz.admin.api.vo;
+
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 企业服务费率
+ *
+ * @author jimmy
+ * @version 1.0.0
+ * @date 2022-11-02 15:53
+ */
+@Data
+@ToString
+public class SysEnterpriseServiceChargeVO implements Serializable {
+	private static final long serialVersionUID = 6688063328094811017L;
+
+	private Integer entId;
+	private String subjectLocation;
+	private BigDecimal serviceCharge;
+}

+ 59 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/SysEnterpriseRelationController.java

@@ -0,0 +1,59 @@
+package com.qunzhixinxi.hnqz.admin.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qunzhixinxi.hnqz.admin.api.dto.SysEnterpriseRelationDTO;
+import com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseRelationVO;
+import com.qunzhixinxi.hnqz.admin.service.SysEnterpriseRelationService;
+import com.qunzhixinxi.hnqz.common.core.util.R;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+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.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 企业关系控制层
+ *
+ * @author jimmy
+ * @version 1.0.0
+ * @date 2022-11-02 11:12
+ */
+@Slf4j
+@RestController
+@AllArgsConstructor
+@RequestMapping(value = "/ent/rel")
+public class SysEnterpriseRelationController {
+
+
+	private final SysEnterpriseRelationService enterpriseRelationService;
+
+
+	/**
+	 * 获取企业分页
+	 *
+	 * @param page 分页参数
+	 * @return 分页
+	 */
+	@GetMapping(value = "/page")
+	public R<Page<SysEnterpriseRelationVO>> pageEntRels(Page<SysEnterpriseRelationVO> page,
+														@RequestParam(value = "entName", required = false) String entName) {
+		return R.ok(enterpriseRelationService.pageEntRels(page, entName));
+	}
+
+	/**
+	 * 更新企业关系
+	 *
+	 * @param relationDTO 关系内容
+	 * @return 更新结果
+	 */
+	@PostMapping
+	public R<Boolean> updateEntRel(@RequestBody SysEnterpriseRelationDTO relationDTO) {
+
+		return R.ok(enterpriseRelationService.updateEntRel(relationDTO));
+
+
+	}
+}

+ 2 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/entity/SysDeptSub.java

@@ -74,4 +74,6 @@ public class SysDeptSub extends Model<SysDeptSub> {
 
 	@ApiModelProperty(value = "更新时间")
 	private LocalDateTime updateTime;
+
+	private BigDecimal serviceCharge;
 }

+ 13 - 2
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/mapper/SysDeptMapper.java

@@ -19,8 +19,10 @@
 
 package com.qunzhixinxi.hnqz.admin.mapper;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
+import com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseRelationVO;
 import com.qunzhixinxi.hnqz.common.data.datascope.DataScopeMapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -48,9 +50,9 @@ public interface SysDeptMapper extends DataScopeMapper<SysDept> {
 
 	SysDept selectDistinctDeptId(@Param("query") SysDept sysDept);
 
-	List<SysDept> selectDeptByName(@Param("query")SysDept sysDept);
+	List<SysDept> selectDeptByName(@Param("query") SysDept sysDept);
 
-	List<Map<String,Object>> selectDeptById(@Param("query") SysDept sysDept);
+	List<Map<String, Object>> selectDeptById(@Param("query") SysDept sysDept);
 
 	List<SysDept> selectByName(String entname);
 
@@ -85,4 +87,13 @@ public interface SysDeptMapper extends DataScopeMapper<SysDept> {
 	 * @return
 	 */
 	List<SysDept> selectByIds(@Param("ids") List<Integer> ids);
+
+	/**
+	 * 获取企业关系分页
+	 *
+	 * @param entName 企业名称
+	 * @param page    分页信息
+	 * @return 分页结果
+	 */
+	Page<SysEnterpriseRelationVO> pageEntRels(Page<SysEnterpriseRelationVO> page, @Param("entName") String entName);
 }

+ 3 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/mapper/SysDeptSubMapper.java

@@ -18,6 +18,7 @@
 package com.qunzhixinxi.hnqz.admin.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseServiceChargeVO;
 import com.qunzhixinxi.hnqz.admin.entity.SysDeptSub;
 import com.qunzhixinxi.hnqz.admin.entity.input.SettleAmountMonitorInput;
 import com.qunzhixinxi.hnqz.admin.entity.output.SettleAmountMonitorOutput;
@@ -40,4 +41,6 @@ public interface SysDeptSubMapper extends BaseMapper<SysDeptSub> {
 	List<SettleAmountMonitorOutput> getDeptAmountMonitor(@Param("query") SettleAmountMonitorInput input);
 
 	List<SettleAmountMonitorOutput> getYaoyiAmountMonitor(@Param("query") SettleAmountMonitorInput yaoyiMonitorInput);
+
+	List<SysEnterpriseServiceChargeVO> listSysEnterpriseServiceCharge(@Param("deptId") Integer deptId);
 }

+ 16 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/mapper/SysEnterpriseRelationMapper.java

@@ -0,0 +1,16 @@
+package com.qunzhixinxi.hnqz.admin.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qunzhixinxi.hnqz.admin.api.entity.SysEnterpriseRelation;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 企业关系mapper
+ *
+ * @author jimmy
+ * @version 1.0.0
+ * @date 2022-11-02 11:04
+ */
+@Mapper
+public interface SysEnterpriseRelationMapper extends BaseMapper<SysEnterpriseRelation> {
+}

+ 11 - 1
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/SysDeptService.java

@@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qunzhixinxi.hnqz.admin.api.dto.DeptTree;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
+import com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseRelationVO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -105,9 +106,18 @@ public interface SysDeptService extends IService<SysDept> {
 	/**
 	 * 分页查询药企和CSO代理商
 	 *
-	 * @param page 分页参数
+	 * @param page     分页参数
 	 * @param deptName 部门名称
 	 * @return
 	 */
 	Map<String, Object> listEntAndAgent(Page page, String deptName);
+
+	/**
+	 * 获取分页
+	 *
+	 * @param entName 企业名称
+	 * @param page    分页参数
+	 * @return 翻页结果
+	 */
+	Page<SysEnterpriseRelationVO> pageEntRels(Page<SysEnterpriseRelationVO> page, String entName);
 }

+ 35 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/SysEnterpriseRelationService.java

@@ -0,0 +1,35 @@
+package com.qunzhixinxi.hnqz.admin.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qunzhixinxi.hnqz.admin.api.dto.SysEnterpriseRelationDTO;
+import com.qunzhixinxi.hnqz.admin.api.entity.SysEnterpriseRelation;
+import com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseRelationVO;
+
+/**
+ * 企业关系服务
+ *
+ * @author jimmy
+ * @version 1.0.0
+ * @date 2022-11-02 11:08
+ */
+public interface SysEnterpriseRelationService extends IService<SysEnterpriseRelation> {
+
+
+	/**
+	 * 获取分页
+	 *
+	 * @param entName 企业名称
+	 * @param page    分页参数
+	 * @return 翻页结果
+	 */
+	Page<SysEnterpriseRelationVO> pageEntRels(Page<SysEnterpriseRelationVO> page, String entName);
+
+	/**
+	 * 更新企业关系信息
+	 *
+	 * @param relationDTO 更新内容
+	 * @return 更新结果
+	 */
+	Boolean updateEntRel(SysEnterpriseRelationDTO relationDTO);
+}

+ 16 - 2
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysDeptServiceImpl.java

@@ -29,6 +29,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qunzhixinxi.hnqz.admin.api.dto.DeptTree;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysDeptRelation;
+import com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseRelationVO;
 import com.qunzhixinxi.hnqz.admin.api.vo.TreeUtil;
 import com.qunzhixinxi.hnqz.admin.entity.base.HnqzPage;
 import com.qunzhixinxi.hnqz.admin.enums.DelEnum;
@@ -463,7 +464,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 	/**
 	 * 分页查询药企和CSO代理商
 	 *
-	 * @param page 分页参数
+	 * @param page     分页参数
 	 * @param deptName 部门名称
 	 * @return
 	 */
@@ -493,7 +494,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 		if (StringUtils.isNotBlank(deptName)) {
 			csoWrapper.like(SysDept::getName, deptName);
 		}
-		Page<SysDept> csoPage = this.page(page, csoWrapper);List<Map<String, Object>> csoMapList = csoPage.getRecords().stream().map(sysDept -> {
+		Page<SysDept> csoPage = this.page(page, csoWrapper);
+		List<Map<String, Object>> csoMapList = csoPage.getRecords().stream().map(sysDept -> {
 			Map<String, Object> deptMap = MapUtil.newHashMap(2);
 			deptMap.put("deptId", sysDept.getDeptId());
 			deptMap.put("name", sysDept.getName());
@@ -507,4 +509,16 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 		resultMap.put("csoPage", new HnqzPage<>(csoHnqzPage));
 		return resultMap;
 	}
+
+	/**
+	 * 获取分页
+	 *
+	 * @param entName 企业名称
+	 * @param page    分页参数
+	 * @return 翻页结果
+	 */
+	@Override
+	public Page<SysEnterpriseRelationVO> pageEntRels(Page<SysEnterpriseRelationVO> page, String entName) {
+		return this.baseMapper.pageEntRels(page, entName);
+	}
 }

+ 97 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysEnterpriseRelationServiceImpl.java

@@ -0,0 +1,97 @@
+package com.qunzhixinxi.hnqz.admin.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qunzhixinxi.hnqz.admin.api.dto.SysEnterpriseRelationDTO;
+import com.qunzhixinxi.hnqz.admin.api.entity.SysEnterpriseRelation;
+import com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseRelationVO;
+import com.qunzhixinxi.hnqz.admin.entity.SysDeptSub;
+import com.qunzhixinxi.hnqz.admin.enums.SubjectLocation;
+import com.qunzhixinxi.hnqz.admin.mapper.SysEnterpriseRelationMapper;
+import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
+import com.qunzhixinxi.hnqz.admin.service.SysDeptSubService;
+import com.qunzhixinxi.hnqz.admin.service.SysEnterpriseRelationService;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * 企业关系实现
+ *
+ * @author jimmy
+ * @version 1.0.0
+ * @date 2022-11-02 11:09
+ */
+@Slf4j
+@Service
+@AllArgsConstructor
+public class SysEnterpriseRelationServiceImpl extends ServiceImpl<SysEnterpriseRelationMapper, SysEnterpriseRelation> implements SysEnterpriseRelationService {
+
+	private final SysDeptService deptService;
+	private final SysDeptSubService deptSubService;
+
+	/**
+	 * 获取分页
+	 *
+	 * @param page 分页参数
+	 * @return 翻页结果
+	 */
+	@Override
+	public Page<SysEnterpriseRelationVO> pageEntRels(Page<SysEnterpriseRelationVO> page, String entName) {
+		return deptService.pageEntRels(page, entName);
+	}
+
+	/**
+	 * 更新企业关系信息
+	 *
+	 * @param relationDTO 更新内容
+	 * @return 更新结果
+	 */
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public Boolean updateEntRel(SysEnterpriseRelationDTO relationDTO) {
+
+		SysEnterpriseRelation relation = BeanUtil.copyProperties(relationDTO, SysEnterpriseRelation.class);
+		relation.setRootId(relation.getParentId());
+
+		this.saveOrUpdate(relation);
+
+
+		List<Map<String, Object>> serviceCharges = relationDTO.getServiceCharges();
+
+		if (CollUtil.isNotEmpty(serviceCharges)) {
+
+			List<SysDeptSub> deptSubs = deptSubService.list(Wrappers.<SysDeptSub>lambdaQuery().eq(SysDeptSub::getDeptId, relation.getEnterpriseId()));
+
+			if (CollUtil.isNotEmpty(deptSubs)) {
+				Map<SubjectLocation, Integer> subMap = deptSubs.stream().collect(Collectors.toMap(SysDeptSub::getSubjectLocation, SysDeptSub::getSubId));
+
+				List<SysDeptSub> subs = serviceCharges.stream().map(m -> {
+					SysDeptSub sub = new SysDeptSub();
+					sub.setDeptId(relation.getEnterpriseId());
+					SubjectLocation location = Enum.valueOf(SubjectLocation.class, (String) m.get("subjectLocation"));
+					Integer subId = subMap.get(location);
+					sub.setSubId(subId);
+					sub.setSubjectLocation(location);
+					sub.setServiceCharge(new BigDecimal(m.get("serviceCharge").toString()));
+					return sub;
+				}).collect(Collectors.toList());
+
+				deptSubService.updateBatchById(subs);
+			}
+
+		}
+
+
+		return Boolean.TRUE;
+	}
+}

+ 137 - 116
hnqz-upms/hnqz-upms-biz/src/main/resources/mapper/SysDeptMapper.xml

@@ -46,105 +46,102 @@
 		<result property="taxCode" column="tax_code"/>
 	</resultMap>
 
+	<resultMap id="sysEntRelMap" type="com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseRelationVO">
+		<id property="relId" column="rel_id"/>
+		<result property="entId" column="ent_id"/>
+		<result property="entName" column="ent_name"/>
+		<result property="rootId" column="root_id"/>
+		<result property="rootName" column="root_name"/>
+		<result property="entType" column="ent_type"/>
+		<result property="productLine" column="product_line"/>
+		<result property="entLevel" column="ent_level"/>
+		<collection property="serviceCharges" ofType="com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseServiceChargeVO"
+					select="com.qunzhixinxi.hnqz.admin.mapper.SysDeptSubMapper.listSysEnterpriseServiceCharge"
+					column="ent_id"/>
+	</resultMap>
+
 	<select id="selectDistinctDeptId" resultMap="sysDeptMap">
-		select
-		DISTINCT dept_id,
-		level
-		from
-		sys_dept
-		where
-		dept_id = #{query.deptId,jdbcType=INTEGER}
-		order by level
-		limit 1
+		SELECT DISTINCT dept_id,
+						level
+		FROM sys_dept
+		WHERE dept_id = #{query.deptId,jdbcType=INTEGER}
+		ORDER BY level
+		LIMIT 1
 	</select>
 
 	<select id="selectDeptList" resultMap="sysDeptMap">
-		select
-		dept_id,
-		sort,
-		name
-		from
-		sys_dept
+		SELECT dept_id,
+			   sort,
+			   name
+		FROM sys_dept
 	</select>
 
 	<select id="selectDeptByIds" resultMap="sysDeptMap">
-  		select
-  		*
-   		from
-   		sys_dept
-   		where
-   		dept_id = #{query.deptId,jdbcType=INTEGER}
+		SELECT *
+		FROM sys_dept
+		WHERE dept_id = #{query.deptId,jdbcType=INTEGER}
 	</select>
 
 	<select id="selectDeptByName" resultMap="sysDeptMap">
-  		select
-  		dept_id,name
-   		from
-   		sys_dept
-   		where
-   		dept_id = #{query.deptId,jdbcType=INTEGER}
+		SELECT dept_id,
+			   name
+		FROM sys_dept
+		WHERE dept_id = #{query.deptId,jdbcType=INTEGER}
 	</select>
 
 	<select id="selectDept" resultMap="sysDeptMap">
-  		select
-  		*
-   		from
-   		sys_dept
-   		where
-   		dept_id = #{deptId,jdbcType=INTEGER}
+		SELECT *
+		FROM sys_dept
+		WHERE dept_id = #{deptId,jdbcType=INTEGER}
 	</select>
 
 	<select id="selectListByDept" resultMap="sysDeptMap">
-		select
-		dept_id,
-		name
-		from
-		sys_dept
-		where del_flag = 0
+		SELECT dept_id,
+			   name
+		FROM sys_dept
+		WHERE del_flag = 0
 	</select>
 
 	<select id="selectDeptById" resultType="java.util.HashMap">
-  		SELECT
-		d.dept_id as deptId,d.name,d.level,
-		CASE WHEN a.zj_number IS NULL THEN e.entcode ELSE a.zj_number END entcode
-		FROM
-		sys_dept d
-		LEFT JOIN wm_da_agent a ON d.dept_id = a.dept_id
-		LEFT JOIN wm_da_drug_ent e ON d.dept_id = e.dept_id
-		WHERE
-		d.dept_id = #{query.deptId,jdbcType=INTEGER}
+		SELECT d.dept_id AS                                                      deptid,
+			   d.name,
+			   d.level,
+			   CASE WHEN a.zj_number IS NULL THEN e.entcode ELSE a.zj_number END entcode
+		FROM sys_dept d
+				 LEFT JOIN wm_da_agent a ON d.dept_id = a.dept_id
+				 LEFT JOIN wm_da_drug_ent e ON d.dept_id = e.dept_id
+		WHERE d.dept_id = #{query.deptId,jdbcType=INTEGER}
 	</select>
 
 	<select id="getAllParentDept" resultMap="sysDeptMap">
-		select DISTINCT
-		dept_id,
-		`name`,
-		`level`
-		from sys_dept
-		where dept_id IN
-		(select d.dept_id  from sys_dept d
-		where d.dept_id=#{query.deptId}
-		union
-		select r.up_id from sys_dept d
-		left join wm_relation r on d.dept_id=r.down_id
-		where d.dept_id=#{query.deptId}
-		union
-		select r2.up_id from sys_dept d
-		left join wm_relation r on d.dept_id=r.down_id
-		left join wm_relation r2 on r.up_id=r2.down_id
-		where d.dept_id=#{query.deptId}
-				)
-		and del_flag=0
-		AND dept_id NOT in(1)
+		SELECT DISTINCT dept_id,
+						`name`,
+						`level`
+		FROM sys_dept
+		WHERE dept_id IN
+			  (SELECT d.dept_id
+			   FROM sys_dept d
+			   WHERE d.dept_id = #{query.deptId}
+			   UNION
+			   SELECT r.up_id
+			   FROM sys_dept d
+						LEFT JOIN wm_relation r ON d.dept_id = r.down_id
+			   WHERE d.dept_id = #{query.deptId}
+			   UNION
+			   SELECT r2.up_id
+			   FROM sys_dept d
+						LEFT JOIN wm_relation r ON d.dept_id = r.down_id
+						LEFT JOIN wm_relation r2 ON r.up_id = r2.down_id
+			   WHERE d.dept_id = #{query.deptId}
+			  )
+		  AND del_flag = 0
+		  AND dept_id NOT IN (1)
 	</select>
 
 	<select id="selectByName" resultMap="sysDeptMap">
-		select
-		*
-		from
-		sys_dept
-		where
-		name = #{name,jdbcType=VARCHAR}
+		SELECT *
+		FROM sys_dept
+		WHERE name = #{name,jdbcType=VARCHAR}
 	</select>
 	<select id="selectEntCodeByLevelId" resultType="string">
 		<choose>
@@ -158,19 +155,19 @@
 		WHERE `id` = #{levelId}
 	</select>
 
-	<update id="updateByPrimaryKeySelective" parameterType="com.qunzhixinxi.hnqz.admin.api.entity.SysDept" >
+	<update id="updateByPrimaryKeySelective" parameterType="com.qunzhixinxi.hnqz.admin.api.entity.SysDept">
 		update sys_dept
-		<set >
-			<if test="delFlag != null" >
+		<set>
+			<if test="delFlag != null">
 				del_flag = #{delFlag,jdbcType=VARCHAR},
 			</if>
-			<if test="name != null" >
+			<if test="name != null">
 				name = #{name,jdbcType=VARCHAR},
 			</if>
-			<if test="subjectType != null" >
+			<if test="subjectType != null">
 				subject_type = #{subjectType,jdbcType=VARCHAR},
 			</if>
-			<if test="taxCode != null" >
+			<if test="taxCode != null">
 				tax_code = #{taxCode,jdbcType=VARCHAR},
 			</if>
 			<if test="deptPermissions != null and deptPermissions != ''">
@@ -181,52 +178,56 @@
 	</update>
 
 	<select id="getParentDept" resultType="map">
-		select DISTINCT
-		dept_id  deptId,
-		`name`
-		from sys_dept
-		where dept_id IN
-		(
-		select r.up_id from sys_dept d
-		left join wm_relation r on d.dept_id=r.down_id
-		where d.dept_id=#{query.deptId}
-		union
-		select r2.up_id from sys_dept d
-		left join wm_relation r on d.dept_id=r.down_id
-		left join wm_relation r2 on r.up_id=r2.down_id
-		where d.dept_id=#{query.deptId}
-				)
-		and del_flag=0
-		AND dept_id NOT in(1)
+		SELECT DISTINCT dept_id deptid,
+						`name`
+		FROM sys_dept
+		WHERE dept_id IN
+			  (
+				  SELECT r.up_id
+				  FROM sys_dept d
+						   LEFT JOIN wm_relation r ON d.dept_id = r.down_id
+				  WHERE d.dept_id = #{query.deptId}
+				  UNION
+				  SELECT r2.up_id
+				  FROM sys_dept d
+						   LEFT JOIN wm_relation r ON d.dept_id = r.down_id
+						   LEFT JOIN wm_relation r2 ON r.up_id = r2.down_id
+				  WHERE d.dept_id = #{query.deptId}
+			  )
+		  AND del_flag = 0
+		  AND dept_id NOT IN (1)
 	</select>
 
 	<select id="getChildDept" resultType="map">
-		select DISTINCT
-		dept_id  deptId,
-		`name`
-		from sys_dept
-		where dept_id IN
-		(
-		select r.down_id from sys_dept d
-		left join wm_relation r on d.dept_id=r.up_id
-		where d.dept_id=#{query.deptId}
-		union
-		select r2.down_id from sys_dept d
-		left join wm_relation r on d.dept_id=r.up_id
-		left join wm_relation r2 on r.down_id=r2.up_id
-		where d.dept_id=#{query.deptId}
-				)
-		and del_flag=0
-		AND dept_id NOT in(1)
+		SELECT DISTINCT dept_id deptid,
+						`name`
+		FROM sys_dept
+		WHERE dept_id IN
+			  (
+				  SELECT r.down_id
+				  FROM sys_dept d
+						   LEFT JOIN wm_relation r ON d.dept_id = r.up_id
+				  WHERE d.dept_id = #{query.deptId}
+				  UNION
+				  SELECT r2.down_id
+				  FROM sys_dept d
+						   LEFT JOIN wm_relation r ON d.dept_id = r.up_id
+						   LEFT JOIN wm_relation r2 ON r.down_id = r2.up_id
+				  WHERE d.dept_id = #{query.deptId}
+			  )
+		  AND del_flag = 0
+		  AND dept_id NOT IN (1)
 	</select>
 
 	<select id="getDeptConvertToName" resultType="map">
-		select  dept_id  deptId, `name` from sys_dept
+		SELECT dept_id deptid, `name`
+		FROM sys_dept
 	</select>
 
 	<!-- 查询所有dept -->
 	<select id="listAllDept" resultMap="sysDeptMap">
-		select * from sys_dept
+		SELECT *
+		FROM sys_dept
 	</select>
 
 	<!-- 根据id批量查询 -->
@@ -236,4 +237,24 @@
 			#{item}
 		</foreach>
 	</select>
+
+	<select id="pageEntRels" resultMap="sysEntRelMap">
+		SELECT el.rel_id,
+		d.dept_id AS `ent_id`,
+		d.name AS `ent_name`,
+		d1.dept_id AS `root_id`,
+		d1.name AS `root_name`,
+		el.e_type AS `ent_type`,
+		el.pro_line AS `product_line`,
+		el.e_level AS `ent_level`
+		FROM sys_dept d
+		LEFT JOIN sys_ent_rel el ON el.ent_id = d.dept_id
+		LEFT JOIN sys_dept d1 ON el.root_id = d1.dept_id
+		<where>
+			d.del_flag = 0
+			<if test="entName != null and entName != ''">
+				AND d.name like CONCAT('%', #{entName},'%')
+			</if>
+		</where>
+	</select>
 </mapper>

+ 15 - 0
hnqz-upms/hnqz-upms-biz/src/main/resources/mapper/SysDeptSubMapper.xml

@@ -15,6 +15,12 @@
 		<result property="enableFlag" column="enable_flag"/>
 	</resultMap>
 
+	<resultMap id="serviceChargeMap" type="com.qunzhixinxi.hnqz.admin.api.vo.SysEnterpriseServiceChargeVO">
+		<id property="entId" column="ent_id"/>
+		<result property="subjectLocation" column="app_id"/>
+		<result property="serviceCharge" column="app_secret"/>
+	</resultMap>
+
 	<select id="getSettleAmountMonitor" resultType="com.qunzhixinxi.hnqz.admin.entity.output.SettleAmountMonitorOutput">
 		SELECT
 		t.id_card_number,
@@ -76,4 +82,13 @@
 		GROUP BY t.id_card_number
 	</select>
 
+	<select id="listSysEnterpriseServiceCharge" resultMap="serviceChargeMap">
+		SELECT ds.dept_id AS `ent_id`,
+			   ds.subject_location ,
+			   ds.service_charge
+		FROM  sys_dept_sub ds
+		WHERE ds.dept_id = #{deptId}
+	</select>
+
+
 </mapper>