minitiger 8 gadi atpakaļ
vecāks
revīzija
f817e7f84d

+ 4 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/controller/ConstantController.java

@@ -17,6 +17,7 @@ import com.xintong.system.err.BusinessException;
 import com.xintong.visualinspection.bean.Constant;
 import com.xintong.visualinspection.bean.Constant;
 import com.xintong.visualinspection.bean.User;
 import com.xintong.visualinspection.bean.User;
 import com.xintong.visualinspection.service.ConstantService;
 import com.xintong.visualinspection.service.ConstantService;
+import com.xintong.visualinspection.util.CacheUtil;
 
 
 /**
 /**
  * 文件名:TestController
  * 文件名:TestController
@@ -41,6 +42,7 @@ public class ConstantController extends BaseController {
     public String add(@Valid @RequestBody Constant constant){
     public String add(@Valid @RequestBody Constant constant){
     	if(constant.getValid()==1) constant.setValid(1);
     	if(constant.getValid()==1) constant.setValid(1);
     	constantService.insert(constant);
     	constantService.insert(constant);
+    	CacheUtil.refreshCodeMap(constantService);
     	return super.returnSuccessResult("添加成功");
     	return super.returnSuccessResult("添加成功");
     }
     }
     
     
@@ -57,6 +59,7 @@ public class ConstantController extends BaseController {
     		throw new BusinessException(20002);
     		throw new BusinessException(20002);
     	}
     	}
     	constantService.update(constant);
     	constantService.update(constant);
+    	CacheUtil.refreshCodeMap(constantService);
     	return super.returnSuccessResult("修改成功");
     	return super.returnSuccessResult("修改成功");
     }
     }
     
     
@@ -73,6 +76,7 @@ public class ConstantController extends BaseController {
     		throw new BusinessException(20002);
     		throw new BusinessException(20002);
     	}
     	}
     	constantService.delete(constant.getId());
     	constantService.delete(constant.getId());
+    	CacheUtil.refreshCodeMap(constantService);
     	return super.returnSuccessResult("删除成功");
     	return super.returnSuccessResult("删除成功");
     }
     }
     
     

+ 5 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/controller/DepartmentController.java

@@ -16,6 +16,7 @@ import com.xintong.visualinspection.bean.FeeStation;
 import com.xintong.visualinspection.bean.Organ;
 import com.xintong.visualinspection.bean.Organ;
 import com.xintong.visualinspection.bean.User;
 import com.xintong.visualinspection.bean.User;
 import com.xintong.visualinspection.service.DepartmentService;
 import com.xintong.visualinspection.service.DepartmentService;
+import com.xintong.visualinspection.util.CacheUtil;
 
 
 /**
 /**
  * 文件名:TestController
  * 文件名:TestController
@@ -43,6 +44,8 @@ public class DepartmentController extends BaseController {
     public String addDept(@RequestBody Organ organ) throws Exception{
     public String addDept(@RequestBody Organ organ) throws Exception{
         
         
     	departmentService.insert(organ);
     	departmentService.insert(organ);
+    	
+    	CacheUtil.refreshDeptMap(departmentService);
     	return returnResult(0, "添加成功", null);
     	return returnResult(0, "添加成功", null);
     }
     }
     
     
@@ -58,6 +61,7 @@ public class DepartmentController extends BaseController {
         try{
         try{
         	organ.setId(organid);
         	organ.setId(organid);
         	departmentService.update(organ);
         	departmentService.update(organ);
+        	CacheUtil.refreshDeptMap(departmentService);
         	return super.returnResult(0, "修改成功", null);
         	return super.returnResult(0, "修改成功", null);
         }catch(Exception e){
         }catch(Exception e){
         	throw new BusinessException(20003);
         	throw new BusinessException(20003);
@@ -75,6 +79,7 @@ public class DepartmentController extends BaseController {
     public String deleteDept(@PathVariable Integer organid){
     public String deleteDept(@PathVariable Integer organid){
         try{
         try{
         	departmentService.delete((organid));
         	departmentService.delete((organid));
+        	CacheUtil.refreshDeptMap(departmentService);
         	return returnResult(0, "删除成功", null);
         	return returnResult(0, "删除成功", null);
         }catch(Exception e){
         }catch(Exception e){
         	throw new BusinessException(20002);
         	throw new BusinessException(20002);

+ 3 - 1
VisualInspection_server/src/main/java/com/xintong/visualinspection/controller/UserController.java

@@ -94,7 +94,7 @@ public class UserController extends BaseController {
         		}
         		}
         	}
         	}
     	}
     	}
-    	
+    	CacheUtil.refreshUserMap(userService);
     	return returnResult(0, "添加成功", null);
     	return returnResult(0, "添加成功", null);
     }
     }
     
     
@@ -121,6 +121,7 @@ public class UserController extends BaseController {
         		}
         		}
         	}
         	}
         	userService.update(user);
         	userService.update(user);
+        	CacheUtil.refreshUserMap(userService);
         	return super.returnResult(0, "修改成功", null);
         	return super.returnResult(0, "修改成功", null);
         }catch(Exception e){
         }catch(Exception e){
         	throw new BusinessException(20003);
         	throw new BusinessException(20003);
@@ -138,6 +139,7 @@ public class UserController extends BaseController {
     public String deleteUser(@PathVariable Integer userid){
     public String deleteUser(@PathVariable Integer userid){
         try{
         try{
         	userService.delete((userid));
         	userService.delete((userid));
+        	CacheUtil.refreshUserMap(userService);
         	return returnResult(0, "删除成功", null);
         	return returnResult(0, "删除成功", null);
         }catch(Exception e){
         }catch(Exception e){
         	throw new BusinessException(20002);
         	throw new BusinessException(20002);

+ 13 - 4
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/cluster/UserInfoMapper.xml

@@ -7,13 +7,22 @@
         <result column="password" property="password" jdbcType="VARCHAR" />
         <result column="password" property="password" jdbcType="VARCHAR" />
         <result column="organid" property="organid" jdbcType="INTEGER" />
         <result column="organid" property="organid" jdbcType="INTEGER" />
         <result column="workno" property="workno" jdbcType="VARCHAR" />
         <result column="workno" property="workno" jdbcType="VARCHAR" />
+        <result property="truename" column="truename" jdbcType="VARCHAR"/>
+        <result property="positionid" column="positionid" jdbcType="INTEGER"/>
+        <result property="idno" column="idno" jdbcType="VARCHAR"/>
+        <result property="pic" column="pic" jdbcType="VARCHAR"/>
+        <result column="workno" property="workno" jdbcType="VARCHAR" />
     </resultMap>
     </resultMap>
     <resultMap id="userMap" type="com.xintong.visualinspection.bean.User">
     <resultMap id="userMap" type="com.xintong.visualinspection.bean.User">
         <id property="id" column="ID"/>
         <id property="id" column="ID"/>
-        <result property="username" column="username"/>
-        <result property="password" column="PASSWORD"/>
-        <result property="truename" column="truename"/>
+        <result property="username" column="username" jdbcType="VARCHAR"/>
+        <result property="password" column="PASSWORD" jdbcType="VARCHAR"/>
         <result column="organid" property="organid" jdbcType="INTEGER" />
         <result column="organid" property="organid" jdbcType="INTEGER" />
+        <result property="truename" column="truename" jdbcType="VARCHAR"/>
+        <result property="positionid" column="positionid" jdbcType="INTEGER"/>
+        <result property="idno" column="idno" jdbcType="VARCHAR"/>
+        <result property="pic" column="pic" jdbcType="VARCHAR"/>
+        <result column="workno" property="workno" jdbcType="VARCHAR" />
         <collection property="roles" ofType="com.xintong.visualinspection.bean.Role">
         <collection property="roles" ofType="com.xintong.visualinspection.bean.Role">
             <result column="name" property="name"/>
             <result column="name" property="name"/>
         </collection>
         </collection>
@@ -85,7 +94,7 @@
         <if test="positionid != null and positionid != 0">and t.positionid = #{positionid} </if>
         <if test="positionid != null and positionid != 0">and t.positionid = #{positionid} </if>
         <if test="classid != null and classid != 0">and t.classid = #{classid} </if>
         <if test="classid != null and classid != 0">and t.classid = #{classid} </if>
         <if test="teamid != null and teamid != 0">and t.teamid = #{teamid} </if>
         <if test="teamid != null and teamid != 0">and t.teamid = #{teamid} </if>
-        order by work_no
+        order by workno
     </select>
     </select>
     <select id="getAllCheckmans" parameterType="com.xintong.visualinspection.bean.User" resultMap="BaseResultMap"  >
     <select id="getAllCheckmans" parameterType="com.xintong.visualinspection.bean.User" resultMap="BaseResultMap"  >
         SELECT *
         SELECT *

+ 36 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/util/CacheUtil.java

@@ -1,11 +1,18 @@
 package com.xintong.visualinspection.util;
 package com.xintong.visualinspection.util;
 
 
 import java.util.HashMap;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
+import org.slf4j.LoggerFactory;
+
+import com.xintong.SystemInit;
 import com.xintong.visualinspection.bean.Constant;
 import com.xintong.visualinspection.bean.Constant;
 import com.xintong.visualinspection.bean.Organ;
 import com.xintong.visualinspection.bean.Organ;
 import com.xintong.visualinspection.bean.User;
 import com.xintong.visualinspection.bean.User;
+import com.xintong.visualinspection.service.ConstantService;
+import com.xintong.visualinspection.service.DepartmentService;
+import com.xintong.visualinspection.service.UserService;
 
 
 public class CacheUtil {
 public class CacheUtil {
 	
 	
@@ -15,6 +22,35 @@ public class CacheUtil {
 	
 	
 	public static Map<String,Constant> codeMap = new HashMap<String,Constant>();
 	public static Map<String,Constant> codeMap = new HashMap<String,Constant>();
 	
 	
+	private static final org.slf4j.Logger logger = LoggerFactory.getLogger(CacheUtil.class);
+	
+	public static void refreshCodeMap(ConstantService constantService){
+		//加载用户信息
+		List<Constant> constantList = constantService.getAll();
+		for(Constant c:constantList){
+			CacheUtil.codeMap.put(c.getCode_flag()+"_"+c.getCode_value(), c);
+		}
+		logger.info("加载用户信息成功,数据数:"+CacheUtil.userMap.size());
+	}
+	
+	public static void refreshUserMap(UserService userService){
+		//加载用户信息
+		List<User> userList = userService.getAll();
+		for(User user:userList){
+			CacheUtil.userMap.put(new Long(user.getId()), user);
+		}
+		logger.info("加载用户信息成功,数据数:"+CacheUtil.userMap.size());
+	}
+	
+	public static void refreshDeptMap(DepartmentService deptService){
+		//加载部门信息
+		List<Organ> deptList = deptService.getAll();
+		for(Organ organ:deptList){
+			CacheUtil.deptMap.put(new Long(organ.getId()), organ);
+		}
+		logger.info("加载部门信息成功,数据数:"+CacheUtil.deptMap.size());
+	}
+	
 	public static User getUserFromMap(Long key){
 	public static User getUserFromMap(Long key){
 		if(key == null) return null;
 		if(key == null) return null;
 		return  CacheUtil.userMap.get(key);
 		return  CacheUtil.userMap.get(key);