Browse Source

fix 新增首页统计数据

Administrator 3 years ago
parent
commit
a8eca260ce

+ 27 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/BmProjectController.java

@@ -247,4 +247,31 @@ public class BmProjectController extends BaseController {
         Map<String, Object> stringObjectMap = bmProjectService.selectProjectContractEharts(year);
         return AjaxResult.success(stringObjectMap);
     }
+
+    /**
+     * 首页-统计数字(只根据当前登录人的部门)
+     */
+    @PostMapping("/indexInfo")
+    public AjaxResult  indexInfo (BmProject bmProject) {
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        Long deptId = -1L;
+        if (ObjectUtil.isNotNull(loginUser)) {
+            List<SysRole> roles = loginUser.getUser().getRoles();
+            boolean flag = false;
+            if (roles.size() > 0) {
+                for (SysRole role : roles) {
+                    String roleKey = role.getRoleKey();
+                    if (StringUtils.isNotBlank(roleKey) && ("manage".equals(roleKey) || "admin".equals(roleKey))) {
+                        flag = true;
+                        break;
+                    }
+                }
+            }
+            if (!flag) {
+                deptId = loginUser.getUser().getDeptId();
+            }
+        }
+        bmProject.setDeptId(deptId);
+      return   bmProjectService.indexInfo(bmProject);
+    }
 }

+ 1 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -44,7 +44,7 @@ spring:
     # 国际化资源文件路径
     basename: i18n/messages
   profiles:
-    active: prod
+    active: druid
   # 文件上传
   servlet:
      multipart:

+ 13 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/project/BmProject.java

@@ -72,6 +72,19 @@ public class BmProject extends BaseEntity
     @Excel(name = "填报单位")
     private String deptName;
 
+    /**
+     * 首页统计数据用
+     */
+    private String num;
+
+    public String getNum() {
+        return num;
+    }
+
+    public void setNum(String num) {
+        this.num = num;
+    }
+
     public String getDictLabel() {
         return dictLabel;
     }

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/project/BmProjectMapper.java

@@ -99,4 +99,11 @@ public interface BmProjectMapper
      * @return
      */
     public List<BmProject> selectBmProjectInProjectStatus();
+
+    /**
+     * 首页-统计数字(只根据当前登录人的部门)
+     * @param bmProject
+     * @return
+     */
+    public List<BmProject> indexInfo(BmProject bmProject);
 }

+ 37 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/project/BmProjectServiceImpl.java

@@ -428,4 +428,41 @@ public class BmProjectServiceImpl implements IBmProjectService {
             }
         }
     }
+
+    /**
+     * 首页-统计数字(只根据当前登录人的部门)
+     * @param bmProject
+     * @return
+     */
+    @Override
+    public AjaxResult indexInfo(BmProject bmProject) {
+        int zt = 0;
+        int qy = 0;
+        int zj = 0;
+        int tc = 0;
+        List<BmProject> bmProjects = bmProjectMapper.indexInfo(bmProject);
+        if (bmProjects.size()>0){
+            for (BmProject project : bmProjects) {
+                Long projectStatus = project.getProjectStatus();
+                if (projectStatus == 1 || projectStatus == 2 || projectStatus == 3){
+                    zt = zt + 1;
+                }
+                if (projectStatus == 5){
+                    qy = qy + 1;
+                }
+                if (projectStatus == 7){
+                    zj = zj + 1;
+                }
+                if (projectStatus == 9){
+                    tc = tc + 1;
+                }
+            }
+        }
+        Map<String,Object> map  = new HashMap<>();
+        map.put("zt",zt);
+        map.put("qy",qy);
+        map.put("zj",zj);
+        map.put("tc",tc);
+        return AjaxResult.success(map);
+    }
 }

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/project/IBmProjectService.java

@@ -104,4 +104,11 @@ public interface IBmProjectService
      * 每周三下午14点给未添加线索信息的用户发送短信
      */
     void selectBmProjectInProjectStatus();
+
+    /**
+     * 首页-统计数字(只根据当前登录人的部门)
+     * @param bmProject
+     * @return
+     */
+    AjaxResult indexInfo(BmProject bmProject);
 }

+ 5 - 0
ruoyi-system/src/main/resources/mapper/system/project/BmProjectMapper.xml

@@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="remark"    column="remark"    />
         <result property="deptName"    column="dept_name"    />
         <result property="dictLabel"    column="dict_label"    />
+        <result property="num"    column="num"    />
     </resultMap>
 
     <sql id="selectBmProjectVo">
@@ -260,4 +261,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectBmProjectVo"></include>
         where project_status = 1 and is_del = 0 group by dept_id
     </select>
+
+    <select id="indexInfo"  resultMap="BmProjectResult">
+    select count(id) as num,project_status from bm_project where is_del = '0' group by project_status
+    </select>
 </mapper>