|
|
@@ -1,6 +1,8 @@
|
|
|
package com.fs.his.controller;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
@@ -117,6 +119,33 @@ public class FsCompanyController extends BaseController {
|
|
|
List<OptionsVO> list = companyService.selectAllCompanyList(depId);
|
|
|
return R.ok().put("data",list);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询当前租户员工账户使用统计
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('his:company:list')")
|
|
|
+ @GetMapping("/accountStats")
|
|
|
+ public AjaxResult accountStats(HttpServletRequest request) {
|
|
|
+ // 1. 汇总所有公司的限制用户数量
|
|
|
+ Integer usedCount = companyService.selectSumLimitUserCount();
|
|
|
+
|
|
|
+ // 2. 切主库,查租户购买的员工账户配额
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.MASTER.name());
|
|
|
+ String code = request.getHeader("tenant-code");
|
|
|
+ TenantInfo tenantInfo = tenantInfoMapper.getTenByCode(code);
|
|
|
+
|
|
|
+ // 3. 计算剩余
|
|
|
+ int purchased = tenantInfo != null ? tenantInfo.getAccountNum() : 0;
|
|
|
+ int used = usedCount != null ? usedCount : 0;
|
|
|
+ int remaining = Math.max(purchased - used, 0);
|
|
|
+
|
|
|
+ Map<String, Integer> result = new HashMap<>();
|
|
|
+ result.put("purchasedCount", purchased);
|
|
|
+ result.put("usedCount", used);
|
|
|
+ result.put("remainingCount", remaining);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导出诊所管理列表
|
|
|
*/
|