Просмотр исходного кода

Merge branch 'master' of http://git_xt.jsxt.jsjtyxt.com/wenhongquan/VisualInspection

minitiger 8 лет назад
Родитель
Сommit
a112019e2d

+ 3 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/bean/StatisticsBean.java

@@ -80,4 +80,7 @@ public class StatisticsBean {
     
     // 月份
     private String mth ;
+    
+    // 收费站名称
+    private String feeStationName ;
 }

+ 36 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/controller/StatisticsController.java

@@ -64,5 +64,41 @@ public class StatisticsController extends BaseController {
     	return super.returnSuccessResult(lists);
     }
     
+    /**
+     * 收费站
+     */
+    @RequestMapping(value = "/score/tollgate/info")
+    public String selectTollgateScoreChange(@RequestBody StatisticsBean obj){
+    	List<StatisticsBean> lists=  statisticsService.getFeeStationScoreInfo(obj);
+    	return super.returnSuccessResult(lists);
+    }
+    
+    /**
+     * 道管中心3
+     */
+    @RequestMapping(value = "/score/center/manage/info")
+    public String selectCentermanageScoreChange(@RequestBody StatisticsBean obj){
+    	List<StatisticsBean> lists=  statisticsService.getCenterManageScoreInfo(obj);
+    	return super.returnSuccessResult(lists);
+    }
+    
+    /**
+     * 道管下收费站
+     */
+    @RequestMapping(value = "/score/manage/tollgate/info")
+    public String selectCentermanageTollgateScoreChange(@RequestBody StatisticsBean obj){
+    	List<StatisticsBean> lists=  statisticsService.getSingleFeeStationScoreInfo(obj);
+    	return super.returnSuccessResult(lists);
+    }
+    
+    
+    /**
+     * 考核粘粉情况比
+     */
+    @RequestMapping(value = "/lost/score/rate")
+    public String getCheckedInfoRate(@RequestBody StatisticsBean obj){
+    	StatisticsBean returnObj=  statisticsService.getCheckedScoreInfo(obj);
+    	return super.returnSuccessResult(returnObj);
+    }
     
 }

+ 3 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/dao/cluster/UserInfoDao.java

@@ -1,5 +1,6 @@
 package com.xintong.visualinspection.dao.cluster;
 
+import com.xintong.visualinspection.bean.StatisticsBean;
 import com.xintong.visualinspection.bean.User;
 import org.apache.ibatis.annotations.Mapper;
 
@@ -19,4 +20,6 @@ public interface UserInfoDao {
     public void delete(Integer id);
     public User findByUserName(String username);
     public List<User> getAllCheckmans();
+    public List<StatisticsBean> getUsersCountList();
+    public Integer getUsersCenterManageCount(StatisticsBean obj);
 }

+ 4 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/dao/master/StatisticsDao.java

@@ -24,4 +24,8 @@ public interface StatisticsDao  {
 	public List<StatisticsBean> selectFeeStationCheckedPersonScoreDetail(StatisticsBean obj);
 	
 	public List<StatisticsBean> selectYearScoreInfo(StatisticsBean obj);
+	
+	public List<StatisticsBean> selectFeeStationScoreInfo(StatisticsBean obj);
+	
+	public List<StatisticsBean> selectCheckedScoreList(StatisticsBean obj);
 }

+ 12 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/cluster/UserInfoMapper.xml

@@ -87,6 +87,18 @@
         where username= #{username}
     </select>
     
+    <select id="getUsersCenterManageCount" parameterType="com.xintong.visualinspection.bean.StatisticsBean"  resultType="java.lang.Integer">
+    	SELECT  count(1)  FROM t_sys_users t 
+    			INNER JOIN t_br_layer_fee_station tf ON t.organid = tf.organ_id  
+    			WHERE t.status >0  AND t.positionid  in (1,6)  AND t.organid in ( SELECT id FROM t_sys_organ where parentid=#{dept_id} )  
+    </select>
+    
+    <select id="getUsersCountList"  resultType="com.xintong.visualinspection.bean.StatisticsBean">
+    	SELECT t.organid AS dept_id , count(1) AS people_num,tf.name FROM t_sys_users t 
+    			INNER JOIN t_br_layer_fee_station tf ON t.organid = tf.organ_id  
+    			WHERE t.status >0  AND t.positionid  in (1,6) GROUP BY t.organid
+			ORDER BY t.organid 
+    </select>
     
     <select id="getUsers" parameterType="com.xintong.visualinspection.bean.User" resultMap="BaseResultMap"  >
         SELECT

+ 39 - 3
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/master/StatisticsMapper.xml

@@ -85,6 +85,9 @@
 				<if test="end_date !=null">
 					AND t.end_time &lt;= #{end_date}
 				</if>
+				<if test="mth!=null and mth!=''">
+					AND monthfunc (t.start_time) =#{mth}
+				</if>
 				GROUP BY
 					mth,
 					t.checked_person
@@ -106,6 +109,9 @@
 			<if test="end_date !=null">
 				AND t.end_time &lt;= #{end_date}
 			</if>
+			<if test="mth!=null and mth!=''">
+				AND monthfunc (t.start_time) =#{mth}
+			</if>
 			GROUP BY
 				t.checked_person,
 				mth
@@ -116,17 +122,47 @@
     <select id="selectYearScoreInfo" parameterType="com.xintong.visualinspection.bean.StatisticsBean" resultType="com.xintong.visualinspection.bean.StatisticsBean">
     	SELECT sum(tab.checkd_all_score) AS all_check_score  , sum(tab.checked_num) AS checked_num  , tab.mth FROM ( <include refid="selectAllCheckedInfo" />  ) tab 
     	WHERE 1=1 
-    	<if test="dept_list!=null and queryType == 2 ">
+    	<if test="dept_list!=null and queryType == 1 and dept_list.size()>0 ">
     		AND	tab.checked_dept IN
 		    	<foreach item="obj"  collection="dept_list" open="("
 		            separator="," close=")">
 		            #{obj.id}  
 		         </foreach>
     	</if>
-    	<if test="dept_id!=null and queryType ==3">
+    	<if test="dept_id!=null and queryType ==2">
     		AND tab.checked_dept=#{dept_id}
     	</if>
     	GROUP BY tab.mth
     </select>
-      
+     
+    <select id="selectFeeStationScoreInfo" parameterType="com.xintong.visualinspection.bean.StatisticsBean" resultType="com.xintong.visualinspection.bean.StatisticsBean">
+    	SELECT sum(tab.checkd_all_score) AS all_check_score , sum(tab.checked_num) AS checked_num ,tab.checked_dept AS dept_id FROM ( <include refid="selectAllCheckedInfo" />  ) tab
+    	WHERE 1=1 
+    	GROUP BY tab.checked_dept
+    </select>
+     
+     
+     <sql id="selectEveryCheckedInfo">
+     	SELECT  SUM(sc.check_item_score) AS checkd_all_score , t.checked_person ,t.checked_dept FROM check_task t 
+			INNER JOIN check_score sc ON sc.task_id = t.id 
+			WHERE monthfunc( t.start_time ) = #{mth}
+			GROUP BY t.checked_person
+     </sql>
+     
+     <select id="selectCheckedScoreList" parameterType="com.xintong.visualinspection.bean.StatisticsBean" resultType="com.xintong.visualinspection.bean.StatisticsBean">
+     	SELECT tab.checkd_all_score AS all_check_score,tab.checked_person AS user_id , tab.checked_dept AS dept_id   FROM (  <include refid="selectEveryCheckedInfo"/> ) tab 
+     	WHERE 1=1 
+     	<if test="dept_list!=null and queryType == 1 and dept_list.size()>0 ">
+    		AND	tab.checked_dept IN
+		    	<foreach item="obj"  collection="dept_list" open="("
+		            separator="," close=")">
+		            #{obj.id}  
+		         </foreach>
+    	</if>
+    	<if test="dept_id!=null and queryType ==2">
+    		AND tab.checked_dept=#{dept_id}
+    	</if>
+     	
+     </select>
+     
 </mapper>

+ 8 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/StatisticsService.java

@@ -36,4 +36,12 @@ public interface StatisticsService {
 	
 	public List<StatisticsBean> getYearScoreChange(StatisticsBean obj);
 	
+	public List<StatisticsBean> getFeeStationScoreInfo(StatisticsBean obj);
+	
+	public List<StatisticsBean> getCenterManageScoreInfo(StatisticsBean obj);
+	
+	public List<StatisticsBean> getSingleFeeStationScoreInfo(StatisticsBean obj);
+	
+	// 考核扣分情况占比
+	public StatisticsBean getCheckedScoreInfo(StatisticsBean obj);
 }

+ 231 - 1
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/impl/StatisticsServiceImpl.java

@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.xintong.visualinspection.bean.FeeStation;
 import com.xintong.visualinspection.bean.Organ;
 import com.xintong.visualinspection.bean.StatisticsBean;
 import com.xintong.visualinspection.bean.StatisticsBo;
@@ -412,10 +413,11 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 		}
 	}
 
+
 	@Override
 	public List<StatisticsBean> getYearScoreChange(StatisticsBean obj) {
 		// 导管中心
-		if(obj.getQueryType()!=null && obj.getQueryType() == 2){
+		if(obj.getQueryType()!=null && obj.getQueryType() == 1){
 			// 检索当前导管中心下的deptid
 			Organ organ =new Organ();
 			organ.setParentid(obj.getDept_id().intValue());
@@ -424,7 +426,235 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 			obj.setDept_list(list);
 		}
 		
+		// 这边把总人数计算出来
+		List<StatisticsBean> feeStationList ;
+		int people_num = 0 ;
+		if(obj.getQueryType()!=null && obj.getQueryType() == 1 ){
+			// 道管中心
+			people_num = userInfoDao.getUsersCenterManageCount(obj);
+			
+		}else if(obj.getQueryType()!=null && obj.getQueryType() == 2){
+			// 收费站
+			feeStationList = userInfoDao.getUsersCountList();
+			if(feeStationList!=null && feeStationList.size()>0){
+				for(StatisticsBean sta : feeStationList){
+					if(obj.getDept_id()+0L == sta.getDept_id()){
+						people_num = sta.getPeople_num();
+					}
+				}
+			}
+		}else{
+			// 总公司
+			feeStationList = userInfoDao.getUsersCountList();
+			if(feeStationList!=null && feeStationList.size()>0){
+				for(StatisticsBean sta : feeStationList){
+					people_num += sta.getPeople_num();
+				}
+			}
+		}
+		
+		
 		List<StatisticsBean> lists = statisticsDao.selectYearScoreInfo(obj);
+		for(StatisticsBean sta:lists){
+			sta.setPeople_num(people_num);
+		}
 		return lists;
 	}
+
+	private List<StatisticsBean> reFeeStationScoreInfo(StatisticsBean obj){
+		List<StatisticsBean> scoreList = statisticsDao.selectFeeStationScoreInfo(obj);
+		Map<Long,StatisticsBean> feeStationMap = new HashMap<>();
+		// 获取所有的收费站
+		List<StatisticsBean> feeStationList = userInfoDao.getUsersCountList();
+		for(StatisticsBean feeObj :  scoreList){
+			if(!feeStationMap.containsKey(feeObj.getDept_id() )){
+				feeStationMap.put(feeObj.getDept_id() , feeObj);
+			}
+		}
+		// 需要补充的
+		List<StatisticsBean> reList = new ArrayList<>();
+		
+		for(StatisticsBean sta:feeStationList){
+			if(feeStationMap.containsKey(sta.getDept_id())){
+				feeStationMap.get(sta.getDept_id()).setFeeStationName(sta.getName());
+				feeStationMap.get(sta.getDept_id()).setPeople_num(sta.getPeople_num());
+			}else{
+				sta.setAll_check_score(0);
+				sta.setChecked_num(0);
+				sta.setFeeStationName(sta.getName());
+				reList.add(sta);
+			}
+		}
+		scoreList.addAll(reList);
+		return scoreList;
+	}
+	
+	/**
+	 * 检索公司收费站的排名
+	 */
+	@Override
+	public List<StatisticsBean> getFeeStationScoreInfo(StatisticsBean obj) {
+		List<StatisticsBean> scoreList = reFeeStationScoreInfo(obj);
+		
+		scoreList.sort(new Comparator<StatisticsBean>() {
+			@Override
+			public int compare(StatisticsBean o1, StatisticsBean o2) {
+				if(o1.getChecked_num()!=0 && o2.getChecked_num()!=0){
+					if (o1.getAll_check_score()/(o1.getChecked_num()+0.0) > o2.getAll_check_score()/(o2.getChecked_num()+0.0) ) {
+						return 1;
+					} else if (o1.getAll_check_score()/(o1.getChecked_num()+0.0) < o2.getAll_check_score()/(o2.getChecked_num()+0.0)) {
+						return -1;
+					} else {
+						return 0;
+					}
+				}else{
+					if(o1.getChecked_num() == 0){
+						return -1 ;
+					}else if(o2.getChecked_num() ==0){
+						return 1;
+					}else{
+						return 0;
+					}
+				}
+			}
+		});
+		
+		return scoreList;
+	}
+	
+	/**
+	 * 检索某个导管中心下的收费站排名
+	 */
+	@Override
+	public List<StatisticsBean> getSingleFeeStationScoreInfo(StatisticsBean obj) {
+		List<StatisticsBean> resultList = new ArrayList<>();
+		
+		List<StatisticsBean> scoreList = reFeeStationScoreInfo(obj);
+		Map<Long,StatisticsBean> centerManageMap = new HashMap<>();
+		for(StatisticsBean sta : scoreList){
+			if(! centerManageMap.containsKey(sta.getDept_id())){
+				centerManageMap.put(sta.getDept_id(), sta);
+			}
+		}
+		Organ organ =new Organ();
+		organ.setParentid(obj.getDept_id().intValue());
+		List<Organ> list = departmentDao.getOrgan(organ);
+		
+		for(Organ org : list){
+			if(centerManageMap.containsKey( org.getId()+0L)){
+				resultList.add(centerManageMap.get(org.getId()+0L));
+			}
+		}
+		
+		return resultList;
+	}
+	
+	/**
+	 * 检索导管中心排名和数据
+	 */
+	@Override
+	public List<StatisticsBean> getCenterManageScoreInfo(StatisticsBean obj) {
+		
+		// 导管中心
+		List<StatisticsBean> centerManageList = new ArrayList<>();
+		for(int i=0;i<3;i++){
+			StatisticsBean e =new StatisticsBean();
+			centerManageList.add(e);
+		}
+		
+		List<StatisticsBean> scoreList = reFeeStationScoreInfo(obj);
+		Map<Long,StatisticsBean> centerManageMap = new HashMap<>();
+		for(StatisticsBean sta : scoreList){
+			if(! centerManageMap.containsKey(sta.getDept_id())){
+				centerManageMap.put(sta.getDept_id(), sta);
+			}
+		}
+		
+		List<StatisticsBean> lists = departmentDao.selectFeeStationGroup(obj);
+		int i = 0;
+		for (StatisticsBean sta : lists) {
+			if (i < 7) {
+				centerManageList.get(0).setAll_check_score(centerManageList.get(0).getAll_check_score()+ 
+							centerManageMap.get(sta.getDept_id()).getAll_check_score());
+				centerManageList.get(0).setChecked_num(centerManageList.get(0).getChecked_num() + 
+						centerManageMap.get(sta.getDept_id()).getChecked_num());
+				centerManageList.get(0).setPeople_num(centerManageList.get(0).getPeople_num() + 
+						centerManageMap.get(sta.getDept_id()).getPeople_num());
+				
+				centerManageList.get(0).setFeeStationName("连云港");
+			} else if (i < 13) {
+				centerManageList.get(1).setAll_check_score(centerManageList.get(1).getAll_check_score()+ 
+						centerManageMap.get(sta.getDept_id()).getAll_check_score());
+				centerManageList.get(1).setChecked_num(centerManageList.get(1).getChecked_num() + 
+						centerManageMap.get(sta.getDept_id()).getChecked_num());
+				centerManageList.get(1).setPeople_num(centerManageList.get(1).getPeople_num() + 
+						centerManageMap.get(sta.getDept_id()).getPeople_num());
+				centerManageList.get(1).setFeeStationName("盐城");
+			} else {
+				centerManageList.get(2).setAll_check_score(centerManageList.get(2).getAll_check_score()+ 
+						centerManageMap.get(sta.getDept_id()).getAll_check_score());
+				centerManageList.get(2).setChecked_num(centerManageList.get(2).getChecked_num() + 
+						centerManageMap.get(sta.getDept_id()).getChecked_num());
+				centerManageList.get(2).setPeople_num(centerManageList.get(2).getPeople_num() + 
+						centerManageMap.get(sta.getDept_id()).getPeople_num());
+				centerManageList.get(2).setFeeStationName("南通");
+			}
+			i++ ;
+		}
+		
+		return centerManageList;
+	}
+	
+	/**
+	 * 考核情况占比
+	 */
+	@Override
+	public StatisticsBean getCheckedScoreInfo(StatisticsBean obj) {
+		int people_num = 0 ;
+		StatisticsBean returnObj =  new StatisticsBean();
+		if(obj.getQueryType() ==0){
+			// 公司
+			// 公司总人数
+			List<StatisticsBean> feeStationList = userInfoDao.getUsersCountList();
+			if(feeStationList!=null && feeStationList.size()>0){
+				for(StatisticsBean sta : feeStationList){
+					people_num += sta.getPeople_num();
+				}
+			}
+		}else if(obj.getQueryType() == 1){
+			// 道管中心
+			Organ organ =new Organ();
+			organ.setParentid(obj.getDept_id().intValue());
+			List<Organ> list = departmentDao.getOrgan(organ);
+			// 将导管中心下的收费站部门id 列表放入到list中
+			obj.setDept_list(list);
+			
+			people_num = userInfoDao.getUsersCenterManageCount(obj);
+		}else if(obj.getQueryType() == 2){
+			// 收费站
+			List<StatisticsBean> feeStationList = userInfoDao.getUsersCountList();
+			if(feeStationList!=null && feeStationList.size()>0){
+				for(StatisticsBean sta : feeStationList){
+					if(obj.getDept_id()+0L == sta.getDept_id()){
+						people_num = sta.getPeople_num();
+					}
+				}
+			}
+		}
+		
+		List<StatisticsBean> userLostScoreInfoList = statisticsDao.selectCheckedScoreList(obj);
+		
+		for (StatisticsBean sta : userLostScoreInfoList) {
+			if (sta.getAll_check_score()  <= 15) {
+				returnObj.setScore_fifteen(returnObj.getScore_fifteen() + 1);
+			} else if (sta.getAll_check_score() <= 50) {
+				returnObj.setScore_fifty(returnObj.getScore_fifty() + 1);
+			} else {
+				returnObj.setScore_over_fifty(returnObj.getScore_over_fifty() + 1);
+			}
+		}
+		returnObj.setPeople_num(people_num);
+		
+		return returnObj;
+	}
 }