ソースを参照

指标排行区分责任部门和下达部门

丁治程 1 年間 前
コミット
ff6916881e

+ 17 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysDepartMapper.java

@@ -111,4 +111,21 @@ public interface SysDepartMapper extends BaseMapper<SysDepart> {
 	 */
 	@Select("SELECT depart_name FROM sys_depart where id=#{id}")
 	String getDepNameById(String id);
+
+
+	/**
+	*   author: dzc
+	*   version: 1.0
+	*   des: 查询责任部门的集合
+	*   date: 2023/11/22
+	*/
+	public List<String> getZrbmDepartList();
+
+	/**
+	*   author: dzc
+	*   version: 1.0
+	*   des: 查询下达部门的集合
+	*   date: 2023/11/22
+	*/
+	public List<String> getXdbmDepartList();
 }

+ 16 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysDepartService.java

@@ -181,4 +181,20 @@ public interface ISysDepartService extends IService<SysDepart>{
      * @return
      */
     String getDepNameById(String id);
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 查询责任部门的集合
+     *   date: 2023/11/22
+     */
+    public List<String> getZrbmDepartList();
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 查询下达部门的集合
+     *   date: 2023/11/22
+     */
+    public List<String> getXdbmDepartList();
 }

+ 9 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java

@@ -830,4 +830,13 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
 		return sysDepartMapper.getDepNameById(id);
 	}
 
+	@Override
+	public List<String> getZrbmDepartList() {
+		return sysDepartMapper.getZrbmDepartList();
+	}
+
+	@Override
+	public List<String> getXdbmDepartList() {
+		return sysDepartMapper.getXdbmDepartList();
+	}
 }

+ 47 - 19
module_kzks/src/main/java/org/jeecg/modules/Index/service/impl/IndexKpiServiceImpl.java

@@ -13,6 +13,7 @@ import org.jeecg.modules.Index.service.IndexKpiService;
 import org.jeecg.modules.Index.util.AuthMark;
 import org.jeecg.modules.Index.util.CommonMethod;
 import org.jeecg.modules.dataSourceSwitch.annotation.TargetDataSource;
+import org.jeecg.modules.system.service.ISysDepartService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -47,6 +48,10 @@ public class IndexKpiServiceImpl implements IndexKpiService {
     @Autowired
     private DepartKpiMapper departKpiMapper;
 
+    @Autowired
+    @SuppressWarnings("all")
+    private ISysDepartService sysDepartService;
+
     /**
      * 工具类
      * 根据日期字符串求上一个月的字符串
@@ -356,12 +361,12 @@ public class IndexKpiServiceImpl implements IndexKpiService {
             try{
                 if(timeType.equals("year")){
                     isCurrentDate = dateString.equals(String.valueOf(currentDateYear));
-                    dateYm = String.format("%s-%d", currentDateYear, 12);
+                    dateYm = String.format("%s-%d", Integer.parseInt(dateString), 12);
                     dateLastYm = String.format("%d-%d", Integer.parseInt(dateString)-1, 12);
                 }else if(timeType.equals("month")){
                     isCurrentDate = dateString.equals(currentYm);
                     dateYm = dateString;
-                    dateLastYm = getLastMonthString(currentYm);
+                    dateLastYm = getLastMonthString(dateString);
                 }
             }catch (ParseException e){
                 System.out.println("部门指标排行传送的日期字符串错误!!!");
@@ -375,56 +380,78 @@ public class IndexKpiServiceImpl implements IndexKpiService {
             //获取部门指标数据  kpi
 //            Map<String, IndexKpiCompletByDate> kpiMap = new TreeMap<>();//用来保存部门指标表中的部门和指标,根据部门查找对应数据
             List<String> departList = new ArrayList<>();//用来存放需要进行排行的部门
+            List<String> zrbmList = new ArrayList<>();//用来存放需要进行排行的部门 (责任部门)
+            List<String> xdbmList = new ArrayList<>();//用来存放需要进行排行的部门 (下达部门)
             List<IndexKpiCompletByDate> kpiList;
             if(timeType.equals("year")){
                 kpiList =  departKpiMapper.getKpiYear(Integer.parseInt(dateString));
             }else{
                 kpiList = departKpiMapper.getKpiMonth(dateString);
             }
+            // 根据部门表的数据,分别查询出 责任部门跟下达部门的list集合
+            List<String> zrbmDepartList = sysDepartService.getZrbmDepartList();
+            List<String> xdbmDepartList = sysDepartService.getXdbmDepartList();
             //根据年指标导入表中的部门进行指标完成度排行 将合同额和已收款赋以及完成度都置为0
             for(IndexKpiCompletByDate kpiData:kpiList){
-                kpiData.setContractAmount(initDecimalNum);
-                kpiData.setReceived(initDecimalNum);
-                kpiData.setKpiCompletRate(initDecimalNum);
-                kpiDataZrbmList.add(kpiData);
-                kpiDataJycsList.add((IndexKpiCompletByDate) kpiData.clone());
-                departList.add(kpiData.getDepart());
+                if (zrbmDepartList.contains(kpiData.getDepart())){
+                    kpiData.setContractAmount(initDecimalNum);
+                    kpiData.setReceived(initDecimalNum);
+                    kpiData.setKpiCompletRate(initDecimalNum);
+                    kpiDataZrbmList.add(kpiData);
+                    zrbmList.add(kpiData.getDepart());
+                }
+                if (xdbmDepartList.contains(kpiData.getDepart())){
+                    kpiData.setContractAmount(initDecimalNum);
+                    kpiData.setReceived(initDecimalNum);
+                    kpiData.setKpiCompletRate(initDecimalNum);
+                    kpiDataJycsList.add(kpiData);
+                    xdbmList.add(kpiData.getDepart());
+                }
+                //kpiData.setContractAmount(initDecimalNum);
+                //kpiData.setReceived(initDecimalNum);
+                //kpiData.setKpiCompletRate(initDecimalNum);
+                //kpiDataZrbmList.add(kpiData);
+                //kpiDataJycsList.add((IndexKpiCompletByDate) kpiData.clone());
+                //departList.add(kpiData.getDepart());
             }
-            if(departList.isEmpty()) return indexKpiDataDepart;
+            if(zrbmList.isEmpty() && xdbmList.isEmpty()) return indexKpiDataDepart;
 
-            //获取选择年月的数据  合同额、已收款
+            //责任部门 获取选择年月的数据  合同额、已收款
             CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedZrbmMapFuture = CompletableFuture.supplyAsync(() -> {
                 Map<String, IndexKpiCompletByDate> htereceivedZrbmMap = new TreeMap<>();//用来保存部门该月合计的合同额、已收款以及责任部门
                 List<IndexKpiCompletByDate> htereceivedZrbmList;
                 //如果选择的日期是当年当月,则从项目成本表里取数据,否则从每月月底项目进度考核表中取
                 if(finalIsCurrentDate){
-                    htereceivedZrbmList = indexKpiMapper.getHteReceivedZrbmCost(departList);
+                    //htereceivedZrbmList = indexKpiMapper.getHteReceivedZrbmCost(departList);
+                    htereceivedZrbmList = indexKpiMapper.getHteReceivedZrbmCost(zrbmList);
                 }else{
-                    htereceivedZrbmList = indexKpiMapper.getHteReceivedZrbmYm(finalDateYm, departList);
+                    htereceivedZrbmList = indexKpiMapper.getHteReceivedZrbmYm(finalDateYm, zrbmList);
                 }
                 for(IndexKpiCompletByDate htereceivedZrbm:htereceivedZrbmList){
                     htereceivedZrbmMap.put(htereceivedZrbm.getDepart(), htereceivedZrbm);
                 }
                 return htereceivedZrbmMap;
             });
-            //获取选择年月上月的数据  合同额、已收款
+            //责任部门 获取选择年月上月的数据  合同额、已收款
             CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedZrbmLastMapFuture = CompletableFuture.supplyAsync(() -> {
                 Map<String, IndexKpiCompletByDate> htereceivedZrbmLastMap = new TreeMap<>();//用来保存部门上月合计的合同额、已收款以及责任部门
-                List<IndexKpiCompletByDate> htereceivedZrbmLastList = indexKpiMapper.getHteReceivedZrbmYm(finalDateLastYm, departList);
+                //List<IndexKpiCompletByDate> htereceivedZrbmLastList = indexKpiMapper.getHteReceivedZrbmYm(finalDateLastYm, departList);
+                List<IndexKpiCompletByDate> htereceivedZrbmLastList = indexKpiMapper.getHteReceivedZrbmYm(finalDateLastYm, zrbmList);
                 for(IndexKpiCompletByDate htereceivedZrbmLast:htereceivedZrbmLastList){
                     htereceivedZrbmLastMap.put(htereceivedZrbmLast.getDepart(), htereceivedZrbmLast);
                 }
                 return htereceivedZrbmLastMap;
             });
-            //获取选择年月的数据  合同额、已收款
+            //下达部门 获取选择年月的数据  合同额、已收款
             CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedJycsMapFuture = CompletableFuture.supplyAsync(() -> {
                 Map<String, IndexKpiCompletByDate> htereceivedJycsMap = new TreeMap<>();//用来保存部门该月合计的合同额、已收款以及下达部门
                 List<IndexKpiCompletByDate> htereceivedJycsList;
                 //如果选择的日期是当年当月,则从项目成本表里取数据,否则从每月月底项目进度考核表中取
                 if(finalIsCurrentDate){
-                    htereceivedJycsList = indexKpiMapper.getHteReceivedJycsCost(departList);
+                    //htereceivedJycsList = indexKpiMapper.getHteReceivedJycsCost(departList);
+                    htereceivedJycsList = indexKpiMapper.getHteReceivedJycsCost(xdbmList);
                 }else{
-                    htereceivedJycsList = indexKpiMapper.getHteReceivedJycsYm(finalDateYm, departList);
+                    htereceivedJycsList = indexKpiMapper.getHteReceivedJycsYm(finalDateYm, xdbmList);
                 }
 
                 for(IndexKpiCompletByDate htereceivedJycs:htereceivedJycsList){
@@ -432,10 +459,11 @@ public class IndexKpiServiceImpl implements IndexKpiService {
                 }
                 return htereceivedJycsMap;
             });
-            //获取选择年月上月的数据  合同额、已收款
+            //下达部门 获取选择年月上月的数据  合同额、已收款
             CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedJycsLastMapFuture = CompletableFuture.supplyAsync(() -> {
                 Map<String, IndexKpiCompletByDate> htereceivedJycsLastMap = new TreeMap<>();//用来保存部门上月合计的合同额、已收款以及下达部门
-                List<IndexKpiCompletByDate> htereceivedJycsLastList = indexKpiMapper.getHteReceivedJycsYm(finalDateLastYm, departList);
+                //List<IndexKpiCompletByDate> htereceivedJycsLastList = indexKpiMapper.getHteReceivedJycsYm(finalDateLastYm, departList);
+                List<IndexKpiCompletByDate> htereceivedJycsLastList = indexKpiMapper.getHteReceivedJycsYm(finalDateLastYm, xdbmList);
                 for(IndexKpiCompletByDate htereceivedJycsLast:htereceivedJycsLastList){
                     htereceivedJycsLastMap.put(htereceivedJycsLast.getDepart(), htereceivedJycsLast);
                 }