Przeglądaj źródła

[task-2627]双击切换主部门后,仅展示主部门的设备维护和设施环境相关信息

Li Yuan 1 rok temu
rodzic
commit
d9e520c040

+ 34 - 21
ibps-provider-root/modules/provider-bpmn/src/main/java/com/lc/ibps/office/provider/BpmInitiatedProvider.java

@@ -1470,6 +1470,14 @@ public class BpmInitiatedProvider extends GenericProvider implements IBpmInitiat
 					(List<Map<String, Object>>) commonDao.query(" SELECT entity.parent_id_ as id_ FROM ibps_party_entity entity, ibps_party_employee em " +
 							" WHERE entity.party_type_='position' AND entity.depth_=3 AND em.id_=#{p0} AND FIND_IN_SET(entity.id_,em.positions_)" , new String[]{currentUserId});
 
+			// 获取当前用户主部门
+			String mainPosition = "";
+			String sql3 = "select p.id_ from IBPS_PARTY_POSITION p INNER JOIN ibps_party_rel r on p.id_=r.MAIN_PID_ " +
+					"where r.sub_pid_='%s' and r.BIZ_='mainPost' ORDER BY p.CREATE_TIME_ DESC";
+			Map<String, Object> data = commonDao.queryOne(String.format(sql3,currentUserId));
+			if (BeanUtils.isNotEmpty(data)){
+				mainPosition = data.get("id_").toString();
+			}
 			try {
 //				final Infobox infobox = new Infobox();
 //				myCompleted(multiTaskType, name, executor, workerWrappers, list, infobox);
@@ -1519,18 +1527,22 @@ public class BpmInitiatedProvider extends GenericProvider implements IBpmInitiat
 				infobox2.setAlias("myDevices");
 				infobox2.setDataText("-1");
 				infobox2.setAccessToken(ContextUtil.getCurrentAccessToken());
-				if(Collections.isEmpty(object3)) {
-					List<Map<String, Object>> object4 =
-							(List<Map<String, Object>>) commonDao.query("SELECT COUNT(1) AS total FROM  t_mjsbwhbyjlby v,ibps_party_employee u " +
-									"	WHERE FIND_IN_SET(v.bian_zhi_bu_men_, u.positions_) AND u.id_=#{p0} " +
-									"	AND DATE(v.create_time_)=CURDATE() AND shi_fou_guo_shen_='待处理'", new String[]{currentUserId});
-					infobox2.setDataText(object4.get(0).get("total").toString());
+				String sql;
+				if (BeanUtils.isNotEmpty(mainPosition)){
+					sql = "SELECT COUNT(1) AS total FROM  t_mjsbwhbyjlby v,ibps_party_employee u " +
+							"	WHERE FIND_IN_SET(v.bian_zhi_bu_men_, '%s') AND u.id_='%s' " +
+							"	AND DATE(v.create_time_)=CURDATE() AND shi_fou_guo_shen_='待处理'";
+					sql = String.format(sql,mainPosition,currentUserId);
+				}else if(Collections.isEmpty(object3)) {
+					sql = "SELECT COUNT(1) AS total FROM  t_mjsbwhbyjlby v,ibps_party_employee u " +
+							"	WHERE FIND_IN_SET(v.bian_zhi_bu_men_, u.positions_) AND u.id_='%s' " +
+							"	AND DATE(v.create_time_)=CURDATE() AND shi_fou_guo_shen_='待处理'";
+					sql = String.format(sql,currentUserId);
 				}else{
-					List<Map<String, Object>> object4 =
-							(List<Map<String, Object>>) commonDao.query("SELECT COUNT(1) AS total FROM  t_mjsbwhbyjlby " +
-									"	WHERE di_dian_=#{p0} AND DATE(create_time_)=CURDATE() AND shi_fou_guo_shen_='待处理'", new String[]{(String)object3.get(0).get("id_")});
-					infobox2.setDataText(object4.get(0).get("total").toString());
+					sql ="SELECT COUNT(1) AS total FROM  t_mjsbwhbyjlby WHERE di_dian_='%s' AND DATE(create_time_)=CURDATE() AND shi_fou_guo_shen_='待处理'";
+					sql = String.format(sql,object3.get(0).get("id_"));
 				}
+				infobox2.setDataText(commonDao.queryOne(sql).get("total").toString());
 				list.add(infobox2);
 			} catch (Exception e) {
 				logger.error(e.getMessage(), e);
@@ -1548,19 +1560,20 @@ public class BpmInitiatedProvider extends GenericProvider implements IBpmInitiat
 				infobox2.setAlias("myFacility");
 				infobox2.setDataText("-1");
 				infobox2.setAccessToken(ContextUtil.getCurrentAccessToken());
-				if(Collections.isEmpty(object3)) {
-					List<Map<String, Object>> object4 =
-							(List<Map<String, Object>>) commonDao.query("SELECT COUNT(1) AS total" +
-									"	FROM v_facs_summary_daily facs, ibps_party_employee emp" +
-									"	WHERE shi_fou_guo_shen_='待处理' and FIND_IN_SET(bian_zhi_bu_men_,emp.positions_) AND emp.id_=#{p0}", new String[]{currentUserId});
-					infobox2.setDataText(object4.get(0).get("total").toString());
+				String sql;
+				if (BeanUtils.isNotEmpty(mainPosition)){
+					sql = "SELECT COUNT(1) AS total FROM v_facs_summary_daily facs, ibps_party_employee emp " +
+							"WHERE shi_fou_guo_shen_='待处理' and FIND_IN_SET(bian_zhi_bu_men_,'%s') AND emp.id_='%s'";
+					sql = String.format(sql,mainPosition,currentUserId);
+				}else if(Collections.isEmpty(object3)) {
+					sql = "SELECT COUNT(1) AS total FROM v_facs_summary_daily facs, ibps_party_employee emp " +
+							"WHERE shi_fou_guo_shen_='待处理' and FIND_IN_SET(bian_zhi_bu_men_,emp.positions_) AND emp.id_='%s'";
+					sql = String.format(sql,currentUserId);
 				}else{
-					List<Map<String, Object>> object4 =
-							(List<Map<String, Object>>) commonDao.query("SELECT COUNT(1) AS total" +
-									"	FROM v_facs_summary_daily " +
-									"	WHERE shi_fou_guo_shen_='待处理' and  di_dian_=#{p0}", new String[]{(String)object3.get(0).get("id_")});
-					infobox2.setDataText(object4.get(0).get("total").toString());
+					sql = "SELECT COUNT(1) AS total FROM v_facs_summary_daily WHERE shi_fou_guo_shen_='待处理' and  di_dian_='%s'";
+					sql = String.format(sql,object3.get(0).get("id_"));
 				}
+				infobox2.setDataText(commonDao.queryOne(sql).get("total").toString());
 				list.add(infobox2);
 			} catch (Exception e) {
 				logger.error(e.getMessage(), e);

+ 13 - 2
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/business/service/impl/FacilityEnvironmentServiceImpl.java

@@ -2,6 +2,7 @@ package com.lc.ibps.business.service.impl;
 
 import com.lc.ibps.base.core.constants.StringPool;
 import com.lc.ibps.base.core.util.AppUtil;
+import com.lc.ibps.base.core.util.BeanUtils;
 import com.lc.ibps.base.core.util.Collections;
 import com.lc.ibps.base.framework.table.ICommonDao;
 import com.lc.ibps.base.web.context.ContextUtil;
@@ -23,8 +24,8 @@ public class FacilityEnvironmentServiceImpl implements FacilityEnvironmentServic
     private ICommonDao<?> commonDao;
     @Override
     public List<Map<String, Object>> getDailySummary(String buMen) {
+        String userId = ContextUtil.getCurrentUserId();
         if(StringUtils.isEmpty(buMen)){
-            String userId = ContextUtil.getCurrentUserId();
             String sql = "SELECT pos.path_ as path  " +
                     "FROM ibps_party_employee em,ibps_party_entity pos  " +
                     "WHERE  FIND_IN_SET(pos.id_,em.positions_)  " +
@@ -52,7 +53,17 @@ public class FacilityEnvironmentServiceImpl implements FacilityEnvironmentServic
         String sql = " SELECT parent_id_ as id_ FROM ibps_party_entity  WHERE party_type_='position' AND depth_=3 AND FIND_IN_SET(id_,'%s')";
         List<Map<String,Object>> object3 =
                 (List<Map<String, Object>>) commonDao.query(String.format(sql,buMen));
-        if(Collections.isEmpty(object3)) {
+        String sql3 = "select p.id_ from IBPS_PARTY_POSITION p INNER JOIN ibps_party_rel r on p.id_=r.MAIN_PID_ " +
+                "where r.sub_pid_='%s' and r.BIZ_='mainPost' ORDER BY p.CREATE_TIME_ DESC";
+        Map<String, Object> data = commonDao.queryOne(String.format(sql3,userId));
+        if (BeanUtils.isNotEmpty(data)){
+            buMen = data.get("id_").toString();
+            String fetchSql =  "SELECT jian_ce_zhou_qi_,facs_type,pos.name_,COUNT(shi_fou_guo_shen_<>'已完成'  OR NULL ) AS todo,COUNT(shi_fou_guo_shen_='已完成'  OR NULL) AS done ,MAX(facs.pagePath) AS pagePath" +
+                    "   FROM v_facs_summary_daily, ibps_party_position pos,(SELECT DISTINCT pagePath,`type` FROM v_facs WHERE pagePath <>'') facs" +
+                    "   WHERE FIND_IN_SET(bian_zhi_bu_men_,'%s') AND bian_zhi_bu_men_=pos.id_ AND facs_type = facs.type" +
+                    "   GROUP BY jian_ce_zhou_qi_,facs_type,bian_zhi_bu_men_ ORDER BY facs_type;";
+            return (List<Map<String, Object>>)commonDao.query(String.format(fetchSql,buMen));
+        }else if(Collections.isEmpty(object3)) {
             String fetchSql =  "SELECT jian_ce_zhou_qi_,facs_type,pos.name_,COUNT(shi_fou_guo_shen_<>'已完成'  OR NULL ) AS todo,COUNT(shi_fou_guo_shen_='已完成'  OR NULL) AS done ,MAX(facs.pagePath) AS pagePath" +
                     "   FROM v_facs_summary_daily, ibps_party_position pos,(SELECT DISTINCT pagePath,`type` FROM v_facs WHERE pagePath <>'') facs" +
                     "   WHERE FIND_IN_SET(bian_zhi_bu_men_,'%s') AND bian_zhi_bu_men_=pos.id_ AND facs_type = facs.type" +

+ 1 - 1
ibps-provider-root/modules/provider-platform/src/main/resources/conf/dataSource-dev.xml

@@ -7,7 +7,7 @@
     <!-- dev下使用该链接 -->
     <dbType>mysql</dbType>
     <driver>com.mysql.jdbc.Driver</driver>
-    <driverUrl>jdbc:mysql://192.168.2.161:3306/klims-ibps3?useUnicode=true&amp;characterEncoding=utf-8</driverUrl>
+    <driverUrl>jdbc:mysql://dev2.local:3306/klims-ibps3?useUnicode=true&amp;characterEncoding=utf-8</driverUrl>
     <user>root</user>
     <password>test001</password>