minitiger 9 лет назад
Родитель
Сommit
87eac498e4

+ 10 - 8
VisualInspection_server/src/main/java/com/xintong/visualinspection/bean/CheckRule.java

@@ -1,23 +1,25 @@
 package com.xintong.visualinspection.bean;
 
+import java.util.List;
+
 import lombok.Data;
 
 /**
- * 文件名:AssessmentMethod
+ * 文件名:CheckRule
  * 版本信息:日期:2017/4/18 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
  */
 @Data
 public class CheckRule {
     //编号
-    private Integer id;
+    private Long id;
     //名称
     private String name;
-    //类型
-    private Integer type;
-    //被考核人员类型
-    private String assessment_personnel_type;
+    //名称
+    private List<CheckItem> check_items;
+    //被考核人员
+    private String checked_person_type;
     //被考核职位
-    private Integer assessment_occupation_id;
+    private Long checked_position_id;
     //被考核部门id
-    private Integer assessment_department_id;
+    private Long checked_dept_id;
 }

+ 57 - 16
VisualInspection_server/src/main/java/com/xintong/visualinspection/controller/CheckRuleController.java

@@ -1,15 +1,18 @@
 package com.xintong.visualinspection.controller;
 
+import java.util.List;
+
 import javax.validation.Valid;
 
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import com.xintong.visualinspection.bean.Constant;
-import com.xintong.visualinspection.service.ConstantService;
+import com.mysql.jdbc.StringUtils;
+import com.xintong.visualinspection.bean.CheckRule;
+import com.xintong.visualinspection.err.BusinessException;
+import com.xintong.visualinspection.service.CheckRuleService;
 
 /**
  * 文件名:TestController
@@ -20,45 +23,83 @@ import com.xintong.visualinspection.service.ConstantService;
 public class CheckRuleController extends BaseController {
 
     @Autowired
-    private ConstantService constantService;
+    private CheckRuleService checkRuleService;
 
    
     /**
-     * 添加常量
+     * 添加考核办法
      * @return
      * String
      * @exception
      * @since  1.0.0
      */
-    @RequestMapping(value = "/addConstant")
-    public String addConstant(@Valid @RequestBody Constant constant, BindingResult result){
-    	constantService.insert(constant);
+    @RequestMapping(value = "/add")
+    public String add(@Valid @RequestBody CheckRule checkRule){
+    	checkRuleService.insert(checkRule);
     	return super.returnSuccessResult("添加成功");
     }
     
     /**
-     * 修改常量
+     * 修改考核办法
      * @return
      * String
      * @exception
      * @since  1.0.0
      */
-    @RequestMapping(value = "/updateConstant")
-    public String updateConstant(@RequestBody Constant constant){
-    	constantService.update(constant);
+    @RequestMapping(value = "/update")
+    public String update(@Valid @RequestBody CheckRule checkRule){
+    	if(checkRule.getId()==null){
+    		throw new BusinessException(20002);
+    	}
+    	checkRuleService.update(checkRule);
     	return super.returnSuccessResult("修改成功");
     }
     
     /**
-     * 删除常量
+     * 删除考核办法
      * @return
      * String
      * @exception
      * @since  1.0.0
      */
-    @RequestMapping(value = "/deleteConstant")
-    public String deleteConstant(@RequestBody String id){
-    	constantService.delete(Long.parseLong(id));
+    @RequestMapping(value = "/delete")
+    public String delete(@RequestBody CheckRule checkRule){
+    	if(checkRule.getId()==null){
+    		throw new BusinessException(20002);
+    	}
+    	checkRuleService.delete(checkRule.getId());
     	return super.returnSuccessResult("删除成功");
     }
+    
+    /**
+     * 通过id获取考核办法
+     * @return
+     * String
+     * @exception
+     * @since  1.0.0
+     */
+    @RequestMapping(value = "/getById")
+    public String getById(@RequestBody CheckRule checkRule){
+    	if(checkRule.getId()==null){
+    		throw new BusinessException(20002);
+    	}
+    	CheckRule cr = checkRuleService.getById(checkRule.getId());
+    	return super.returnSuccessResult(cr);
+    }
+    
+    /**
+     * 通过名称获取考核办法
+     * @return
+     * String
+     * @exception
+     * @since  1.0.0
+     */
+    @RequestMapping(value = "/getByName")
+    public String getByName(@RequestBody CheckRule checkRule){
+    	if(StringUtils.isNullOrEmpty(checkRule.getName())){
+    		throw new BusinessException(21101);
+    	}
+    	List<CheckRule> crList = checkRuleService.getByName(checkRule.getName());
+    	return super.returnSuccessResult(crList);
+    }
 }

+ 13 - 9
VisualInspection_server/src/main/java/com/xintong/visualinspection/dao/master/CheckRuleDao.java

@@ -1,21 +1,25 @@
 package com.xintong.visualinspection.dao.master;
 
-import com.xintong.visualinspection.bean.User;
+import java.util.List;
+
 import org.apache.ibatis.annotations.Mapper;
-import org.springframework.stereotype.Repository;
 
-import java.util.List;
+import com.xintong.visualinspection.bean.CheckItem;
+import com.xintong.visualinspection.bean.CheckRule;
 
 /**
- * 文件名:UserInfoDao
+ * 文件名:CheckRuleDao
  * 版本信息:日期:2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
  */
 @Mapper
 public interface CheckRuleDao  {
-    public List<User> getAll();
-    public User getOne(Long id);
-    public void insert(User user);
-    public void update(User user);
+    public List<CheckRule> getAll();
+    public CheckRule getOne(Long id);
+    public List<CheckRule> getByName(String name);
+    public void insert(CheckRule checkRule);
+    public void insertRuleItem(List<CheckItem> checkItems);
+    public void update(CheckRule checkRule);
     public void delete(Long id);
-    public User findByUserName(String username);
+    public void deleteRuleItem(Long id);
+    public Long getLastId();
 }

+ 57 - 40
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/master/CheckRuleMapper.xml

@@ -1,68 +1,85 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.xintong.visualinspection.dao.master.CheckRuleDao" >
-    <resultMap id="BaseResultMap" type="com.xintong.visualinspection.bean.User" >
+    <resultMap id="BaseResultMap" type="com.xintong.visualinspection.bean.CheckRule" >
         <id column="id" property="id" jdbcType="INTEGER" />
-        <result column="username" property="username" jdbcType="VARCHAR" />
-        <result column="age" property="age" jdbcType="INTEGER" />
-        <result column="password" property="password" jdbcType="VARCHAR" />
-    </resultMap>
-    <resultMap id="userMap" type="com.xintong.visualinspection.bean.User">
-        <id property="id" column="ID"/>
-        <result property="username" column="username"/>
-        <result property="password" column="PASSWORD"/>
-        <collection property="roles" ofType="com.xintong.visualinspection.bean.Role">
-            <result column="name" property="name"/>
+        <result column="name" property="name" jdbcType="VARCHAR" />
+        <result column="checked_person_type" property="checked_person_type" jdbcType="INTEGER" />
+        <result column="checked_position_id" property="checked_position_id" jdbcType="INTEGER" />
+        <result column="checked_dept_id" property="checked_dept_id" jdbcType="INTEGER" />
+        <collection property="check_items" ofType="com.xintong.visualinspection.bean.CheckItem"  
+        	javaType="ArrayList">
+        	<id property="id"  column="id"/>   
+    		<result property="name"  column="name"/>  
         </collection>
     </resultMap>
 
+	<select id="selectItems" resultType="com.xintong.visualinspection.bean.CheckItem" parameterType="Long">  
+    	SELECT a.*,b.*
+        FROM check_rule a left join check_rule_item b on a.id=b.rule_id
+        WHERE id = #{id}
+  	</select>  
     <select id="getAll" resultMap="BaseResultMap"  >
-        SELECT
-        id,username,age,password
-        FROM sys_user
+        SELECT *
+        FROM check_rule
     </select>
 
     <select id="getOne" parameterType="java.lang.Long" resultMap="BaseResultMap" >
-        SELECT
-        id,username,age,password
-        FROM sys_user
+        SELECT a.*,b.*
+        FROM check_rule a left join check_rule_item b on a.id=b.rule_id
         WHERE id = #{id}
     </select>
+    
+    <select id="getByName"  parameterType="java.lang.String" resultMap="BaseResultMap"  >
+        SELECT *
+        FROM check_rule
+        WHERE name like CONCAT('%',#{name},'%') 
+    </select>
 
-    <insert id="insert" parameterType="com.xintong.visualinspection.bean.User" >
+    <insert id="insert" parameterType="com.xintong.visualinspection.bean.CheckRule" >
         INSERT INTO
-        sys_user
-        (username,age,password,TRUENAME,ORGANID,BIRTH,AGE,MOBILE,POSITIONID,SEX,WORKNO,IDNO)
+        check_rule
+        (name,checked_person_type,checked_position_id,checked_dept_id)
         VALUES
-        (#{username}, #{age},#{password},#{truename},#{deptId},#{birth},#{age},#{mobile},#{positionId},#{sex},#{workno},#{idno})
+        (#{name}, #{checked_person_type},#{checked_position_id},#{checked_dept_id})
     </insert>
-
-    <update id="update" parameterType="com.xintong.visualinspection.bean.User" >
+	
+	<insert id="insertRuleItem" parameterType="List" >
+        INSERT INTO check_rule_item
+        	(rule_id,item_id)
+        VALUES
+         <foreach collection ="list" item="item" index= "index" separator =",">
+        	(#{item.rule_id}, #{item.id})
+         </foreach >
+    </insert>
+    
+    <select id="getLastId" resultType="Long">
+    	select last_insert_id()
+    </select>
+    
+    <update id="update" parameterType="com.xintong.visualinspection.bean.CheckRule" >
         UPDATE
-        sys_user
+        check_rule
         SET
-        <if test="username != null">userName = #{username},</if>
-        <if test="age != null">age = #{age},</if>
-        <if test="password != null">password = #{password},</if>
-        id = #{id}
+        <if test="name != null">name = #{name},</if>
+        <if test="checked_person_type != null">checked_person_type = #{checked_person_type},</if>
+        <if test="checked_position_id != null">checked_position_id = #{checked_position_id},</if>
+        <if test="checked_dept_id != null">checked_dept_id = #{checked_dept_id}</if>
         WHERE
         id = #{id}
     </update>
-
+    
+    <delete id="deleteRuleItem" parameterType="java.lang.Long" >
+        DELETE FROM
+        	check_rule_item
+        WHERE
+        	rule_id = #{id}
+    </delete>
+    
     <delete id="delete" parameterType="java.lang.Long" >
         DELETE FROM
-        sys_user
+        check_rule
         WHERE
         id =#{id}
     </delete>
-
-
-    <select id="findByUserName" parameterType="String" resultMap="userMap">
-        select u.*
-        ,r.name
-        from sys_user u
-        LEFT JOIN sys_role_user sru on u.id= sru.Sys_User_id
-        LEFT JOIN sys_role r on sru.sys_role_id=r.id
-        where username= #{username}
-    </select>
 </mapper>

+ 2 - 3
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/CheckRuleService.java

@@ -19,9 +19,8 @@ import com.xintong.visualinspection.bean.Constant;
  */
 public interface CheckRuleService {
     public List<CheckRule> getAll();
-    public Constant getById(Long id);
-    public List<CheckRule> getByFlag();
-    public Constant getByFlagAndValue(String flag, int value);
+    public CheckRule getById(Long id);
+    public List<CheckRule> getByName(String name);
     public void insert(CheckRule checkRule);
     public void update(CheckRule checkRule);
     public void delete(Long id);

+ 31 - 25
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/impl/CheckRuleServiceImpl.java

@@ -6,8 +6,8 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.xintong.visualinspection.bean.CheckItem;
 import com.xintong.visualinspection.bean.CheckRule;
-import com.xintong.visualinspection.bean.Constant;
 import com.xintong.visualinspection.dao.master.CheckRuleDao;
 import com.xintong.visualinspection.service.BaseService;
 import com.xintong.visualinspection.service.CheckRuleService;
@@ -25,48 +25,54 @@ public class CheckRuleServiceImpl extends BaseService implements CheckRuleServic
     @Autowired
     private CheckRuleDao checkRuleDao;
 
-
-	public List getAll() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-
-	public Constant getById(Long id) {
+	@Override
+	public List<CheckRule> getAll() {
 		// TODO Auto-generated method stub
-		return null;
+		return checkRuleDao.getAll();
 	}
 
-
-	public List getByFlag() {
+	@Override
+	public CheckRule getById(Long id) {
 		// TODO Auto-generated method stub
-		return null;
+		return checkRuleDao.getOne(id);
 	}
 
-
-	public Constant getByFlagAndValue(String flag, int value) {
+	@Override
+	public List<CheckRule> getByName(String name) {
 		// TODO Auto-generated method stub
-		return null;
+		return checkRuleDao.getByName(name);
 	}
 
-
+	@Override
 	public void insert(CheckRule checkRule) {
 		// TODO Auto-generated method stub
-		
+		checkRuleDao.insert(checkRule);
+		if(checkRule.getCheck_items()!=null && checkRule.getCheck_items().size()>0) {
+			Long id = checkRuleDao.getLastId();
+			for(CheckItem item:checkRule.getCheck_items()){
+				item.setRule_id(id);
+			}
+			checkRuleDao.insertRuleItem(checkRule.getCheck_items());
+		}
 	}
 
-
+	@Override
 	public void update(CheckRule checkRule) {
 		// TODO Auto-generated method stub
-		
+		checkRuleDao.update(checkRule);
+		checkRuleDao.deleteRuleItem(checkRule.getId());
+		if(checkRule.getCheck_items()!=null && checkRule.getCheck_items().size()>0) {
+			Long id = checkRule.getId();
+			for(CheckItem item:checkRule.getCheck_items()){
+				item.setRule_id(id);
+			}
+			checkRuleDao.insertRuleItem(checkRule.getCheck_items());
+		}
 	}
 
-
+	@Override
 	public void delete(Long id) {
 		// TODO Auto-generated method stub
-		
+		checkRuleDao.delete(id);
 	}
-
-
-    
 }

+ 1 - 1
VisualInspection_server/src/main/resources/errcode.properties

@@ -37,7 +37,7 @@
 #\u8003\u6838\u9879\u7ba1\u7406\u9519\u8bef
 21001=
 #\u8003\u6838\u529e\u6cd5\u7ba1\u7406\u9519\u8bef
-21101=
+21101=\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a
 #\u4efb\u52a1\u7ba1\u7406\u9519\u8bef
 21201=
 #\u6263\u5206\u7ba1\u7406\u9519\u8bef