Quellcode durchsuchen

feat: 派工企业管理-权限调整

lixuesong vor 1 Jahr
Ursprung
Commit
9139a52d18

+ 13 - 1
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/WmDaAgentController.java

@@ -898,7 +898,19 @@ public class WmDaAgentController {
 		Integer mahSettleDeptId = null;
 		if (Boolean.TRUE.equals(wmDaAgent.getMahSettleFlag())) {
 			// 如果是允许结算,则保存当前药企deptId
-			mahSettleDeptId = SecurityUtils.getUser().getDeptId();
+			if (SecurityUtils.getUser().getDeptId().equals(1)) {
+				// 如果当前企业是平台,则查询上级药企
+				WmDaAgent agent = wmDaAgentMapper.selectById(wmDaAgent.getId());
+				List<SysDeptRelation> relations = sysDeptRelationMapper.selectList(Wrappers.<SysDeptRelation>lambdaQuery()
+						.eq(SysDeptRelation::getDescendant, agent.getDeptId())
+						.notIn(SysDeptRelation::getAncestor, 1, agent.getDeptId()));
+				if (CollUtil.isNotEmpty(relations)) {
+					mahSettleDeptId = relations.get(0).getAncestor();
+				}
+			} else {
+				// 如果当前企业是药企, 则取当前企业deptId
+				mahSettleDeptId = SecurityUtils.getUser().getDeptId();
+			}
 		}
 
 		return R.ok(wmDaAgentService.update(Wrappers.<WmDaAgent>lambdaUpdate()